@codeyam/codeyam-cli 0.1.0-staging.483fdc2 → 0.1.0-staging.4c0c3c9

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 (374) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +4 -4
  4. package/analyzer-template/packages/ai/index.ts +1 -0
  5. package/analyzer-template/packages/ai/package.json +2 -2
  6. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +23 -1
  7. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
  8. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +101 -0
  9. package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +6 -0
  11. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +330 -9
  12. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +11 -2
  14. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +2 -2
  15. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
  16. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +140 -14
  17. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +20 -1
  18. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +84 -19
  19. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +33 -15
  20. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
  21. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +46 -5
  22. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +38 -2
  23. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +359 -142
  24. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
  25. package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
  26. package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
  27. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +24 -4
  28. package/analyzer-template/packages/analyze/index.ts +2 -0
  29. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +69 -3
  30. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +5 -0
  31. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
  32. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +4 -0
  33. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +59 -26
  34. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +194 -15
  35. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +372 -57
  36. package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
  37. package/analyzer-template/packages/database/package.json +1 -1
  38. package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
  39. package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
  40. package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
  41. package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
  42. package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
  43. package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
  44. package/analyzer-template/packages/database/src/lib/kysely/db.ts +6 -0
  45. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +1 -1
  46. package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
  47. package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
  48. package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
  49. package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
  50. package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
  51. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
  52. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
  53. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
  54. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
  55. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
  56. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
  57. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
  58. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
  59. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
  60. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
  61. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
  62. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
  63. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -0
  64. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  65. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +3 -0
  66. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  67. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +1 -1
  68. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
  69. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
  70. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  71. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  72. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
  73. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
  74. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
  75. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
  76. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
  77. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
  78. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
  79. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  80. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
  81. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
  82. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  83. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
  84. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +93 -2
  85. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  86. package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +108 -2
  87. package/analyzer-template/project/constructMockCode.ts +38 -3
  88. package/analyzer-template/project/writeMockDataTsx.ts +119 -17
  89. package/analyzer-template/project/writeScenarioComponents.ts +60 -12
  90. package/analyzer-template/project/writeSimpleRoot.ts +21 -11
  91. package/background/src/lib/local/createLocalAnalyzer.js +1 -1
  92. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  93. package/background/src/lib/virtualized/project/constructMockCode.js +32 -3
  94. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  95. package/background/src/lib/virtualized/project/writeMockDataTsx.js +102 -13
  96. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  97. package/background/src/lib/virtualized/project/writeScenarioComponents.js +60 -15
  98. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  99. package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
  100. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  101. package/codeyam-cli/scripts/apply-setup.js +44 -10
  102. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  103. package/codeyam-cli/src/cli.js +2 -0
  104. package/codeyam-cli/src/cli.js.map +1 -1
  105. package/codeyam-cli/src/codeyam-cli.js +18 -2
  106. package/codeyam-cli/src/codeyam-cli.js.map +1 -1
  107. package/codeyam-cli/src/commands/analyze.js +4 -2
  108. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  109. package/codeyam-cli/src/commands/baseline.js +2 -0
  110. package/codeyam-cli/src/commands/baseline.js.map +1 -1
  111. package/codeyam-cli/src/commands/debug.js +2 -0
  112. package/codeyam-cli/src/commands/debug.js.map +1 -1
  113. package/codeyam-cli/src/commands/default.js +31 -20
  114. package/codeyam-cli/src/commands/default.js.map +1 -1
  115. package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
  116. package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
  117. package/codeyam-cli/src/commands/init.js +49 -257
  118. package/codeyam-cli/src/commands/init.js.map +1 -1
  119. package/codeyam-cli/src/commands/memory.js +17 -26
  120. package/codeyam-cli/src/commands/memory.js.map +1 -1
  121. package/codeyam-cli/src/commands/recapture.js +2 -0
  122. package/codeyam-cli/src/commands/recapture.js.map +1 -1
  123. package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
  124. package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
  125. package/codeyam-cli/src/commands/setup-simulations.js +284 -0
  126. package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
  127. package/codeyam-cli/src/commands/test-startup.js +2 -0
  128. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  129. package/codeyam-cli/src/commands/verify.js +14 -2
  130. package/codeyam-cli/src/commands/verify.js.map +1 -1
  131. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +179 -0
  132. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
  133. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -86
  134. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  135. package/codeyam-cli/src/utils/analyzer.js +7 -0
  136. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  137. package/codeyam-cli/src/utils/backgroundServer.js +90 -19
  138. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  139. package/codeyam-cli/src/utils/generateReport.js +2 -2
  140. package/codeyam-cli/src/utils/install-skills.js +57 -54
  141. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  142. package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
  143. package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
  144. package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
  145. package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
  146. package/codeyam-cli/src/utils/progress.js +7 -0
  147. package/codeyam-cli/src/utils/progress.js.map +1 -1
  148. package/codeyam-cli/src/utils/queue/job.js +4 -0
  149. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  150. package/codeyam-cli/src/utils/requireSimulations.js +10 -0
  151. package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
  152. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
  153. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
  154. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
  155. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
  156. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
  157. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
  158. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
  159. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
  160. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
  161. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
  162. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
  163. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
  164. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
  165. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
  166. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +378 -0
  167. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
  168. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +115 -0
  169. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
  170. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
  171. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
  172. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
  173. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
  174. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
  175. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
  176. package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
  177. package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
  178. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
  179. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
  180. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
  181. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
  182. package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
  183. package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
  184. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
  185. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
  186. package/codeyam-cli/src/utils/rules/index.js +1 -0
  187. package/codeyam-cli/src/utils/rules/index.js.map +1 -1
  188. package/codeyam-cli/src/utils/rules/parser.js +2 -25
  189. package/codeyam-cli/src/utils/rules/parser.js.map +1 -1
  190. package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
  191. package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
  192. package/codeyam-cli/src/utils/rules/staleness.js +16 -11
  193. package/codeyam-cli/src/utils/rules/staleness.js.map +1 -1
  194. package/codeyam-cli/src/utils/serverState.js +37 -10
  195. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  196. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -44
  197. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  198. package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js +66 -0
  199. package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
  200. package/codeyam-cli/src/webserver/app/lib/database.js +15 -3
  201. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  202. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  203. package/codeyam-cli/src/webserver/backgroundServer.js +50 -0
  204. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  205. package/codeyam-cli/src/webserver/bootstrap.js +11 -0
  206. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
  207. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-jNYXRRNI.js +1 -0
  208. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-DsN1wKrm.js → EntityItem-bwuHPyTa.js} +1 -1
  209. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DLqD3qNt.js → EntityTypeBadge-CvzqMxcu.js} +1 -1
  210. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-Ba2JVPzP.js → EntityTypeIcon-BH0XDim7.js} +1 -1
  211. package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-C8lyxW9k.js → InlineSpinner-EhOseatT.js} +1 -1
  212. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-aht4aafF.js → InteractivePreview-yjIHlOGa.js} +2 -2
  213. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CVtiBnY5.js → LibraryFunctionPreview-Cq5o8jL4.js} +1 -1
  214. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-B0GLXMsr.js → LoadingDots-BvMu2i-g.js} +1 -1
  215. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-xgeCVgSM.js → LogViewer-kgBTLoJD.js} +1 -1
  216. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-OApQuNyq.js → ReportIssueModal-BzPgx-xO.js} +3 -8
  217. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DuDvi0jm.js → SafeScreenshot-CwZrv-Ok.js} +1 -1
  218. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DzccYyI8.js → ScenarioViewer-BX2Ny2Qj.js} +2 -2
  219. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-DyFZkK0l.js → TruncatedFilePath-CDpEprKa.js} +1 -1
  220. package/codeyam-cli/src/webserver/build/client/assets/{_index-BwqWJOgH.js → _index-BRx8ZGZo.js} +1 -1
  221. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BwavGCpm.js → activity.(_tab)-4S4yPfFw.js} +6 -11
  222. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DHKuQSmR.js +17 -0
  223. package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
  224. package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
  225. package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
  226. package/codeyam-cli/src/webserver/build/client/assets/book-open-D4IPYH_y.js +6 -0
  227. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-Cx24_aWc.js → chevron-down-CG65viiV.js} +1 -1
  228. package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-CXRTFQ3F.js → chunk-JZWAC4HX-DB3aFuEO.js} +12 -12
  229. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BOARzkeR.js → circle-check-igfMr5DY.js} +1 -1
  230. package/codeyam-cli/src/webserver/build/client/assets/copy-Coc4o_8c.js +11 -0
  231. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-BdhJEx6B.js → createLucideIcon-D1zB-pYc.js} +1 -1
  232. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BBnGWYga.js → dev.empty-JTAjQ54M.js} +1 -1
  233. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BJUiQqZF.js → entity._sha._-B0h9AqE6.js} +10 -10
  234. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js → entity._sha.scenarios._scenarioId.fullscreen-DjLxr2JB.js} +1 -1
  235. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D1T4TGjf.js → entity._sha_.create-scenario-CtYowLOt.js} +1 -1
  236. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CTBG2mmz.js → entity._sha_.edit._scenarioId-PePWg17F.js} +1 -1
  237. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CS2cb_eZ.js → entry.client-I-Wo99C_.js} +1 -1
  238. package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DMJ7zii9.js → fileTableUtils-9sMMAiWJ.js} +1 -1
  239. package/codeyam-cli/src/webserver/build/client/assets/{files-CJ6lTdTA.js → files-Co65J0s3.js} +1 -1
  240. package/codeyam-cli/src/webserver/build/client/assets/{git-CPTZZ-JZ.js → git-BdHOxVfg.js} +1 -1
  241. package/codeyam-cli/src/webserver/build/client/assets/globals-CCgBKWy4.css +1 -0
  242. package/codeyam-cli/src/webserver/build/client/assets/{index-B1h680n5.js → index-CUM5iXwc.js} +1 -1
  243. package/codeyam-cli/src/webserver/build/client/assets/{index-lzqtyFU8.js → index-_417gcQW.js} +1 -1
  244. package/codeyam-cli/src/webserver/build/client/assets/labs-BK0C1H1T.js +1 -0
  245. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-B7B9V-bu.js → loader-circle-TzRHMVog.js} +1 -1
  246. package/codeyam-cli/src/webserver/build/client/assets/manifest-390cb8fa.js +1 -0
  247. package/codeyam-cli/src/webserver/build/client/assets/memory-CzZySbBE.js +78 -0
  248. package/codeyam-cli/src/webserver/build/client/assets/pause-hjzB7t2z.js +11 -0
  249. package/codeyam-cli/src/webserver/build/client/assets/root-DnbDhvTU.js +62 -0
  250. package/codeyam-cli/src/webserver/build/client/assets/{search-CxXUmBSd.js → search-DcAwD_Ln.js} +1 -1
  251. package/codeyam-cli/src/webserver/build/client/assets/settings-CclxrcPK.js +1 -0
  252. package/codeyam-cli/src/webserver/build/client/assets/{simulations-DwFIBT09.js → simulations-DVNJVQgD.js} +1 -1
  253. package/codeyam-cli/src/webserver/build/client/assets/terminal-DbEAHMbA.js +11 -0
  254. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-B6LgvRJg.js → triangle-alert-CAD5b1o_.js} +1 -1
  255. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-C1v1PQzo.js → useCustomSizes-BqgrAzs3.js} +1 -1
  256. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-aSv48UbS.js → useLastLogLine-DAFqfEDH.js} +1 -1
  257. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DYxHZQuP.js → useReportContext-DZlYx2c4.js} +1 -1
  258. package/codeyam-cli/src/webserver/build/client/assets/{useToast-mBRpZPiu.js → useToast-ihdMtlf6.js} +1 -1
  259. package/codeyam-cli/src/webserver/build/server/assets/{index-TD1f-DHV.js → index-CxaRxKVt.js} +1 -1
  260. package/codeyam-cli/src/webserver/build/server/assets/server-build-D4DT0nM_.js +259 -0
  261. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  262. package/codeyam-cli/src/webserver/build-info.json +5 -5
  263. package/codeyam-cli/templates/{codeyam:debug.md → codeyam-debug.md} +1 -1
  264. package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
  265. package/codeyam-cli/templates/codeyam-memory-hook.sh +19 -20
  266. package/codeyam-cli/templates/{codeyam:memory.md → codeyam-memory.md} +26 -33
  267. package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
  268. package/codeyam-cli/templates/{codeyam:setup.md → codeyam-setup.md} +13 -1
  269. package/codeyam-cli/templates/{codeyam:sim.md → codeyam-sim.md} +1 -1
  270. package/codeyam-cli/templates/{codeyam:test.md → codeyam-test.md} +1 -1
  271. package/codeyam-cli/templates/{codeyam:verify.md → codeyam-verify.md} +1 -1
  272. package/codeyam-cli/templates/rule-notification-hook.py +56 -0
  273. package/codeyam-cli/templates/rule-reflection-hook.py +554 -88
  274. package/codeyam-cli/templates/rules-instructions.md +54 -48
  275. package/package.json +9 -9
  276. package/packages/ai/index.js +1 -1
  277. package/packages/ai/index.js.map +1 -1
  278. package/packages/ai/src/lib/analyzeScope.js +21 -1
  279. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  280. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
  281. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
  282. package/packages/ai/src/lib/astScopes/processExpression.js +78 -1
  283. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  284. package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
  285. package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
  286. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +262 -8
  287. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  288. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
  289. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  290. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +11 -2
  291. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  292. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +2 -2
  293. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  294. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
  295. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
  296. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +122 -12
  297. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  298. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +15 -1
  299. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -1
  300. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +78 -17
  301. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  302. package/packages/ai/src/lib/dataStructureChunking.js +26 -11
  303. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -1
  304. package/packages/ai/src/lib/generateEntityDataStructure.js +46 -2
  305. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  306. package/packages/ai/src/lib/generateEntityScenarioData.js +32 -3
  307. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  308. package/packages/ai/src/lib/generateExecutionFlows.js +16 -2
  309. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
  310. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +242 -81
  311. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
  312. package/packages/ai/src/lib/isolateScopes.js +39 -3
  313. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  314. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
  315. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
  316. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
  317. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
  318. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +17 -2
  319. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  320. package/packages/analyze/index.js +1 -0
  321. package/packages/analyze/index.js.map +1 -1
  322. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +52 -2
  323. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  324. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +3 -0
  325. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  326. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
  327. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
  328. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +5 -1
  329. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
  330. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +51 -14
  331. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  332. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +116 -13
  333. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  334. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +310 -45
  335. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  336. package/packages/analyze/src/lib/index.js +1 -0
  337. package/packages/analyze/src/lib/index.js.map +1 -1
  338. package/packages/database/src/lib/analysisBranchToDb.js +1 -1
  339. package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
  340. package/packages/database/src/lib/analysisToDb.js +1 -1
  341. package/packages/database/src/lib/analysisToDb.js.map +1 -1
  342. package/packages/database/src/lib/branchToDb.js +1 -1
  343. package/packages/database/src/lib/branchToDb.js.map +1 -1
  344. package/packages/database/src/lib/commitBranchToDb.js +1 -1
  345. package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
  346. package/packages/database/src/lib/commitToDb.js +1 -1
  347. package/packages/database/src/lib/commitToDb.js.map +1 -1
  348. package/packages/database/src/lib/fileToDb.js +1 -1
  349. package/packages/database/src/lib/fileToDb.js.map +1 -1
  350. package/packages/database/src/lib/kysely/db.js +3 -0
  351. package/packages/database/src/lib/kysely/db.js.map +1 -1
  352. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  353. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  354. package/packages/database/src/lib/projectToDb.js +1 -1
  355. package/packages/database/src/lib/projectToDb.js.map +1 -1
  356. package/packages/database/src/lib/saveFiles.js +1 -1
  357. package/packages/database/src/lib/saveFiles.js.map +1 -1
  358. package/packages/database/src/lib/scenarioToDb.js +1 -1
  359. package/packages/database/src/lib/scenarioToDb.js.map +1 -1
  360. package/packages/utils/src/lib/fs/rsyncCopy.js +93 -2
  361. package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  362. package/scripts/finalize-analyzer.cjs +8 -76
  363. package/codeyam-cli/src/utils/reviewedRules.js +0 -92
  364. package/codeyam-cli/src/utils/reviewedRules.js.map +0 -1
  365. package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +0 -6
  366. package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +0 -6
  367. package/codeyam-cli/src/webserver/build/client/assets/globals-CX9f-5xM.css +0 -1
  368. package/codeyam-cli/src/webserver/build/client/assets/manifest-bba56ec1.js +0 -1
  369. package/codeyam-cli/src/webserver/build/client/assets/memory-DuTFSyJ2.js +0 -92
  370. package/codeyam-cli/src/webserver/build/client/assets/root-DTfSQARG.js +0 -62
  371. package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +0 -1
  372. package/codeyam-cli/src/webserver/build/server/assets/server-build-BQ-1XyEa.js +0 -258
  373. package/codeyam-cli/templates/codeyam:diagnose.md +0 -803
  374. package/codeyam-cli/templates/codeyam:new-rule.md +0 -52
@@ -181,6 +181,7 @@ const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
181
181
  'transformed non-object function equivalency - implicit parent equivalency - rerouted via useCallback',
182
182
  'transformed non-object function equivalency - Array.from() equivalency',
183
183
  'Spread operator equivalency key update: Explicit array deconstruction equivalency value',
184
+ // 'transformed non-object function equivalency - Explicit array deconstruction equivalency value',
184
185
  ]);
185
186
  export class ScopeDataStructure {
186
187
  // Getter for backward compatibility - returns the tree structure
@@ -475,6 +476,10 @@ export class ScopeDataStructure {
475
476
  }
476
477
  return;
477
478
  }
479
+ // PERF: Early exit for paths with repeated function-call signature patterns
480
+ if (this.hasExcessivePatternRepetition(path)) {
481
+ return;
482
+ }
478
483
  // Update chain metadata for database tracking
479
484
  if (equivalencyValueChain.length > 0) {
480
485
  equivalencyValueChain[equivalencyValueChain.length - 1].addToSchemaId =
@@ -971,6 +976,12 @@ export class ScopeDataStructure {
971
976
  const value1 = scopeNode.schema[schemaPath];
972
977
  const value2 = equivalentScopeNode.schema[equivalentSchemaPath];
973
978
  const bestValue = selectBestValue(value1, value2);
979
+ // PERF: Skip paths with repeated function-call signature patterns
980
+ // to prevent recursive type expansion (e.g., string.localeCompare returns string)
981
+ if (this.hasExcessivePatternRepetition(schemaPath) ||
982
+ this.hasExcessivePatternRepetition(equivalentSchemaPath)) {
983
+ continue;
984
+ }
974
985
  scopeNode.schema[schemaPath] = bestValue;
975
986
  equivalentScopeNode.schema[equivalentSchemaPath] = bestValue;
976
987
  }
@@ -982,6 +993,10 @@ export class ScopeDataStructure {
982
993
  equivalentPath,
983
994
  ...remainingSchemaPathParts,
984
995
  ]);
996
+ // PERF: Skip paths with repeated function-call signature patterns
997
+ if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
998
+ continue;
999
+ }
985
1000
  equivalentScopeNode.schema[newEquivalentPath] =
986
1001
  scopeNode.schema[schemaPath];
987
1002
  }
@@ -1063,6 +1078,23 @@ export class ScopeDataStructure {
1063
1078
  return true;
1064
1079
  }
1065
1080
  }
1081
+ // Check for repeated function calls that indicate recursive type expansion.
1082
+ // E.g., localeCompare(b[])...localeCompare(b[]) means string.localeCompare
1083
+ // returns a type that again has localeCompare, causing infinite expansion.
1084
+ // We extract all function call patterns like "funcName(args)" and check if
1085
+ // the same normalized call appears more than once.
1086
+ const funcCallPattern = /(?:^|\.)[^.([]+\([^)]*\)/g;
1087
+ const funcCallMatches = path.match(funcCallPattern);
1088
+ if (funcCallMatches && funcCallMatches.length > 1) {
1089
+ const seen = new Set();
1090
+ for (const match of funcCallMatches) {
1091
+ // Strip leading dot and normalize array indices
1092
+ const normalized = match.replace(/^\./, '').replace(/\[\d+\]/g, '[]');
1093
+ if (seen.has(normalized))
1094
+ return true;
1095
+ seen.add(normalized);
1096
+ }
1097
+ }
1066
1098
  // For longer paths, detect any repeated multi-part segments we haven't explicitly listed
1067
1099
  const pathParts = this.splitPath(path);
1068
1100
  if (pathParts.length <= 6) {
@@ -1752,6 +1784,7 @@ export class ScopeDataStructure {
1752
1784
  const remainingPath = this.joinPathParts(remainingPathParts);
1753
1785
  if (relevantSubPathParts.every((part, i) => part === schemaPathParts[i]) &&
1754
1786
  equivalentValue.scopeNodeName === scopeNode.name) {
1787
+ // DEBUG
1755
1788
  continue;
1756
1789
  }
1757
1790
  const newEquivalentPath = this.joinPathParts([schemaPath, remainingPath]);
@@ -1893,6 +1926,8 @@ export class ScopeDataStructure {
1893
1926
  return;
1894
1927
  }
1895
1928
  const usageScopeNode = this.getScopeOrFunctionCallInfo(usageEquivalency.scopeNodeName);
1929
+ if (!usageScopeNode)
1930
+ continue;
1896
1931
  // Guard against infinite recursion by tracking which paths we've already
1897
1932
  // added from addComplexSourcePathVariables
1898
1933
  if (this.visitedTracker.checkAndMarkComplexSourceVisited(usageScopeNode.name, newUsageEquivalentPath)) {
@@ -1941,6 +1976,8 @@ export class ScopeDataStructure {
1941
1976
  continue;
1942
1977
  }
1943
1978
  const usageScopeNode = this.getScopeOrFunctionCallInfo(usageEquivalency.scopeNodeName);
1979
+ if (!usageScopeNode)
1980
+ continue;
1944
1981
  // This is put in place to avoid propagating array functions like 'filter' through complex equivalencies
1945
1982
  // but may cause problems if the funtion call is not on a known object (e.g. string or array)
1946
1983
  if (newUsageEquivalentPath.endsWith(')') ||
@@ -2246,6 +2283,13 @@ export class ScopeDataStructure {
2246
2283
  delete scopeNode.schema[key];
2247
2284
  }
2248
2285
  }
2286
+ // Ensure parameter-to-signature equivalencies are fully propagated.
2287
+ // When a parameter variable (e.g., `node`) is equivalenced to `signature[N]`,
2288
+ // all sub-paths of that variable should also appear under `signature[N]`.
2289
+ // This handles cases where the sub-path was added to the schema via a propagation
2290
+ // chain that already included the variable↔signature equivalency, causing the
2291
+ // cycle detection to prevent the reverse mapping.
2292
+ this.propagateParameterToSignaturePaths(scopeNode);
2249
2293
  fillInSchemaGapsAndUnknowns(scopeNode, fillInUnknowns);
2250
2294
  if (final) {
2251
2295
  for (const manager of this.equivalencyManagers) {
@@ -2257,6 +2301,40 @@ export class ScopeDataStructure {
2257
2301
  ensureSchemaConsistency(scopeNode.schema);
2258
2302
  }
2259
2303
  }
2304
+ /**
2305
+ * For each equivalency where a simple variable maps to signature[N],
2306
+ * ensure all sub-paths of that variable are reflected under signature[N].
2307
+ */
2308
+ propagateParameterToSignaturePaths(scopeNode) {
2309
+ // Find variable → signature[N] equivalencies
2310
+ for (const [varName, equivalencies] of Object.entries(scopeNode.equivalencies)) {
2311
+ // Only process simple variable names (no dots, brackets, or parens)
2312
+ if (varName.includes('.') ||
2313
+ varName.includes('[') ||
2314
+ varName.includes('(')) {
2315
+ continue;
2316
+ }
2317
+ for (const equiv of equivalencies) {
2318
+ if (equiv.scopeNodeName === scopeNode.name &&
2319
+ equiv.schemaPath.startsWith('signature[')) {
2320
+ const signaturePath = equiv.schemaPath;
2321
+ const varPrefix = varName + '.';
2322
+ const varBracketPrefix = varName + '[';
2323
+ // Find all schema keys starting with the variable
2324
+ for (const key in scopeNode.schema) {
2325
+ if (key.startsWith(varPrefix) || key.startsWith(varBracketPrefix)) {
2326
+ const suffix = key.slice(varName.length);
2327
+ const sigKey = signaturePath + suffix;
2328
+ // Only add if the signature path doesn't already exist
2329
+ if (!scopeNode.schema[sigKey]) {
2330
+ scopeNode.schema[sigKey] = scopeNode.schema[key];
2331
+ }
2332
+ }
2333
+ }
2334
+ }
2335
+ }
2336
+ }
2337
+ }
2260
2338
  filterAndConvertSchema({ filterPath, newPath, schema, }) {
2261
2339
  const filterPathParts = this.splitPath(filterPath);
2262
2340
  return Object.keys(schema).reduce((acc, key) => {
@@ -2316,6 +2394,10 @@ export class ScopeDataStructure {
2316
2394
  path,
2317
2395
  ...this.splitPath(key).slice(equivalentValueSchemaPathParts.length),
2318
2396
  ]);
2397
+ // PERF: Skip keys with repeated function-call signature patterns
2398
+ // to prevent recursive type expansion (e.g., string.localeCompare returns string)
2399
+ if (this.hasExcessivePatternRepetition(newKey))
2400
+ continue;
2319
2401
  resolvedSchema[newKey] = value;
2320
2402
  }
2321
2403
  }
@@ -2337,6 +2419,9 @@ export class ScopeDataStructure {
2337
2419
  if (!subSchema)
2338
2420
  continue;
2339
2421
  for (const resolvedKey in subSchema) {
2422
+ // PERF: Skip keys with repeated function-call signature patterns
2423
+ if (this.hasExcessivePatternRepetition(resolvedKey))
2424
+ continue;
2340
2425
  if (!resolvedSchema[resolvedKey] ||
2341
2426
  subSchema[resolvedKey] === 'unknown') {
2342
2427
  resolvedSchema[resolvedKey] = subSchema[resolvedKey];
@@ -2623,21 +2708,91 @@ export class ScopeDataStructure {
2623
2708
  }
2624
2709
  return [source];
2625
2710
  };
2626
- return entries.reduce((acc, entry) => {
2711
+ const acc = entries.reduce((result, entry) => {
2627
2712
  var _a;
2628
2713
  if (entry.sourceCandidates.length === 0)
2629
- return acc;
2714
+ return result;
2630
2715
  const usages = entry.usages.filter(usageMatchesScope);
2631
2716
  for (const usage of usages) {
2632
- acc[_a = usage.schemaPath] || (acc[_a] = []);
2717
+ result[_a = usage.schemaPath] || (result[_a] = []);
2633
2718
  // Resolve each source candidate through the equivalency chain
2634
2719
  for (const source of entry.sourceCandidates) {
2635
2720
  const resolvedSources = resolveToSignature(source, new Set());
2636
- acc[usage.schemaPath].push(...resolvedSources);
2721
+ result[usage.schemaPath].push(...resolvedSources);
2637
2722
  }
2638
2723
  }
2639
- return acc;
2724
+ return result;
2640
2725
  }, {});
2726
+ // Post-processing: enrich useState-backed sources with co-located external
2727
+ // function calls. When a useState value resolves to a setter variable that
2728
+ // lives in the same scope as a fetch/API call, that fetch is a data source.
2729
+ this.enrichUseStateSourcesWithCoLocatedCalls(acc);
2730
+ return acc;
2731
+ }
2732
+ /**
2733
+ * For each source that ends at a useState path, check if the setter was called
2734
+ * from a scope that also contains external function calls (like fetch).
2735
+ * If so, add those external calls as additional source candidates.
2736
+ */
2737
+ enrichUseStateSourcesWithCoLocatedCalls(acc) {
2738
+ const rootScopeName = this.scopeTreeManager.getRootName();
2739
+ const rootScope = this.scopeNodes[rootScopeName];
2740
+ if (!rootScope)
2741
+ return;
2742
+ // Collect all descendants for each scope node
2743
+ const getAllDescendants = (node) => {
2744
+ const names = new Set([node.name]);
2745
+ for (const child of node.children) {
2746
+ for (const name of getAllDescendants(child)) {
2747
+ names.add(name);
2748
+ }
2749
+ }
2750
+ return names;
2751
+ };
2752
+ for (const [usagePath, sources] of Object.entries(acc)) {
2753
+ const additionalSources = [];
2754
+ for (const source of sources) {
2755
+ // Check if this source is a useState-related terminal path
2756
+ // (e.g., useState(X).functionCallReturnValue[1] or useState(X).signature[0])
2757
+ if (!source.schemaPath.match(/^useState\([^)]*\)\./))
2758
+ continue;
2759
+ // Find the useState call from the source path
2760
+ const useStateCallMatch = source.schemaPath.match(/^(useState\([^)]*\))\./);
2761
+ if (!useStateCallMatch)
2762
+ continue;
2763
+ const useStateCall = useStateCallMatch[1];
2764
+ // Look in the root scope for the useState value equivalency
2765
+ // which tells us where the setter was called from
2766
+ const valuePath = `${useStateCall}.functionCallReturnValue[0]`;
2767
+ const valueEquivs = rootScope.equivalencies[valuePath];
2768
+ if (!valueEquivs)
2769
+ continue;
2770
+ for (const equiv of valueEquivs) {
2771
+ // Find the scope where the setter was called
2772
+ const setterScopeName = equiv.scopeNodeName;
2773
+ const setterScopeTree = this.scopeTreeManager.findNode(setterScopeName);
2774
+ if (!setterScopeTree)
2775
+ continue;
2776
+ // Get all descendant scope names from the setter scope
2777
+ const relatedScopes = getAllDescendants(setterScopeTree);
2778
+ // Find external function calls in those scopes whose return values
2779
+ // are actually consumed (assigned to a variable). This excludes
2780
+ // fire-and-forget calls like analytics.track() or console.log().
2781
+ const coLocatedCalls = this.externalFunctionCalls.filter((efc) => relatedScopes.has(efc.callScope) &&
2782
+ efc.receivingVariableNames &&
2783
+ efc.receivingVariableNames.length > 0);
2784
+ for (const call of coLocatedCalls) {
2785
+ additionalSources.push({
2786
+ scopeNodeName: call.callScope,
2787
+ schemaPath: `${call.callSignature}.functionCallReturnValue`,
2788
+ });
2789
+ }
2790
+ }
2791
+ }
2792
+ if (additionalSources.length > 0) {
2793
+ acc[usagePath].push(...additionalSources);
2794
+ }
2795
+ }
2641
2796
  }
2642
2797
  getUsageEquivalencies(functionName) {
2643
2798
  const scopeNode = this.getScopeOrFunctionCallInfo(functionName);
@@ -2702,6 +2857,49 @@ export class ScopeDataStructure {
2702
2857
  }
2703
2858
  }
2704
2859
  }
2860
+ // Enrich schema with deeply nested paths from internal function call scopes.
2861
+ // When a function call like traverse(tree) exists, and traverse's scope has
2862
+ // signature[0].children[path][entityName] (from propagateParameterToSignaturePaths),
2863
+ // we need to map those paths back to the argument variable (tree) in this scope.
2864
+ // This handles cases where cycle detection prevented the equivalency chain from
2865
+ // propagating deep paths during Phase 2 batch queue processing.
2866
+ for (const equivalenceKey in equivalencies ?? {}) {
2867
+ // Look for keys matching function call pattern: funcName(...).signature[N]
2868
+ const funcCallMatch = equivalenceKey.match(/^([^(]+)\(.*?\)\.(signature\[\d+\])$/);
2869
+ if (!funcCallMatch)
2870
+ continue;
2871
+ const calledFunctionName = funcCallMatch[1];
2872
+ const signatureParam = funcCallMatch[2]; // e.g., "signature[0]"
2873
+ for (const equivalenceValue of equivalencies[equivalenceKey]) {
2874
+ if (equivalenceValue.scopeNodeName !== scopeName)
2875
+ continue;
2876
+ const targetVariable = equivalenceValue.schemaPath;
2877
+ // Get the called function's schema (includes propagated parameter paths)
2878
+ const childSchema = this.getSchema({
2879
+ scopeName: calledFunctionName,
2880
+ });
2881
+ if (!childSchema)
2882
+ continue;
2883
+ // Map child function's signature paths to parent variable paths
2884
+ const sigPrefix = signatureParam + '.';
2885
+ const sigBracketPrefix = signatureParam + '[';
2886
+ for (const childKey in childSchema) {
2887
+ let suffix = null;
2888
+ if (childKey.startsWith(sigPrefix)) {
2889
+ suffix = childKey.slice(signatureParam.length);
2890
+ }
2891
+ else if (childKey.startsWith(sigBracketPrefix)) {
2892
+ suffix = childKey.slice(signatureParam.length);
2893
+ }
2894
+ if (suffix !== null) {
2895
+ const parentKey = targetVariable + suffix;
2896
+ if (!schema[parentKey]) {
2897
+ schema[parentKey] = childSchema[childKey];
2898
+ }
2899
+ }
2900
+ }
2901
+ }
2902
+ }
2705
2903
  // Propagate nested paths from variables to their signature equivalents
2706
2904
  // e.g., if workouts = signature[0].workouts, then workouts[].title becomes
2707
2905
  // signature[0].workouts[].title
@@ -2991,6 +3189,13 @@ export class ScopeDataStructure {
2991
3189
  !equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
2992
3190
  !equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
2993
3191
  ) {
3192
+ // Skip bare "returnValue" from child scopes — this is the child's return value,
3193
+ // not a meaningful data source path in the parent scope
3194
+ if (equivalentValue.schemaPath === 'returnValue' &&
3195
+ equivalentValue.scopeNodeName !==
3196
+ this.scopeTreeManager.getRootName()) {
3197
+ continue;
3198
+ }
2994
3199
  // Add equivalency (will accumulate if multiple values for OR expressions)
2995
3200
  addEquivalency(path, equivalentValue.schemaPath);
2996
3201
  }
@@ -3550,6 +3755,7 @@ export class ScopeDataStructure {
3550
3755
  */
3551
3756
  getEnrichedConditionalUsages() {
3552
3757
  const enriched = {};
3758
+ console.log(`[getEnrichedConditionalUsages] Processing ${Object.keys(this.rawConditionalUsages).length} conditional paths: [${Object.keys(this.rawConditionalUsages).join(', ')}]`);
3553
3759
  for (const [path, usages] of Object.entries(this.rawConditionalUsages)) {
3554
3760
  // Try to trace this path back to a data source
3555
3761
  // First, try the root scope
@@ -3557,9 +3763,47 @@ export class ScopeDataStructure {
3557
3763
  const explanation = this.explainPath(rootScopeName, path);
3558
3764
  let sourceDataPath;
3559
3765
  if (explanation.source) {
3560
- // Build the full data path: scopeName.path
3561
- sourceDataPath = `${explanation.source.scope}.${explanation.source.path}`;
3766
+ const { scope, path: sourcePath } = explanation.source;
3767
+ // Build initial path — avoid redundant prefix when path already contains the scope call
3768
+ let fullPath;
3769
+ if (sourcePath.startsWith(`${scope}(`)) {
3770
+ fullPath = sourcePath;
3771
+ }
3772
+ else {
3773
+ fullPath = `${scope}.${sourcePath}`;
3774
+ }
3775
+ sourceDataPath = fullPath;
3776
+ console.log(`[getEnrichedConditionalUsages] "${path}" explainPath → scope="${scope}", sourcePath="${sourcePath}" → sourceDataPath="${sourceDataPath}"`);
3562
3777
  }
3778
+ else {
3779
+ console.log(`[getEnrichedConditionalUsages] "${path}" explainPath → no source found`);
3780
+ }
3781
+ // If explainPath didn't find a useful external source (e.g., it traced to
3782
+ // useState or just to the component scope itself), check sourceEquivalencies
3783
+ // for an external function call source like a fetch call
3784
+ const hasExternalSource = sourceDataPath?.includes('.functionCallReturnValue');
3785
+ if (!hasExternalSource) {
3786
+ console.log(`[getEnrichedConditionalUsages] "${path}" no external source (sourceDataPath="${sourceDataPath}"), checking sourceEquivalencies fallback...`);
3787
+ const sourceEquiv = this.getSourceEquivalencies();
3788
+ const returnValueKey = `returnValue.${path}`;
3789
+ const sources = sourceEquiv[returnValueKey];
3790
+ if (sources) {
3791
+ console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] has ${sources.length} sources: [${sources.map((s) => s.schemaPath).join(', ')}]`);
3792
+ const externalSource = sources.find((s) => s.schemaPath.includes('.functionCallReturnValue') &&
3793
+ !s.schemaPath.startsWith('useState('));
3794
+ if (externalSource) {
3795
+ console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found external source: "${externalSource.schemaPath}"`);
3796
+ sourceDataPath = externalSource.schemaPath;
3797
+ }
3798
+ else {
3799
+ console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found no external function call source`);
3800
+ }
3801
+ }
3802
+ else {
3803
+ console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] not found`);
3804
+ }
3805
+ }
3806
+ console.log(`[getEnrichedConditionalUsages] "${path}" FINAL sourceDataPath="${sourceDataPath ?? '(none)'}" (${usages.length} usages)`);
3563
3807
  enriched[path] = usages.map((usage) => ({
3564
3808
  ...usage,
3565
3809
  sourceDataPath,
@@ -3818,11 +4062,21 @@ export class ScopeDataStructure {
3818
4062
  perVariableSchemas = undefined;
3819
4063
  }
3820
4064
  }
4065
+ // Enrich the schema with inferred types by applying fillInSchemaGapsAndUnknowns.
4066
+ // This ensures the serialized schema has the same type inference as getReturnValue().
4067
+ // Without this, evidence like "entities[].analyses: array" becomes "unknown".
4068
+ const enrichedSchema = { ...efc.schema };
4069
+ const tempScopeNode = {
4070
+ name: efc.name,
4071
+ schema: enrichedSchema,
4072
+ equivalencies: efc.equivalencies ?? {},
4073
+ };
4074
+ fillInSchemaGapsAndUnknowns(tempScopeNode, true);
3821
4075
  return {
3822
4076
  name: efc.name,
3823
4077
  callSignature: efc.callSignature,
3824
4078
  callScope: efc.callScope,
3825
- schema: efc.schema,
4079
+ schema: enrichedSchema,
3826
4080
  equivalencies: efc.equivalencies
3827
4081
  ? Object.entries(efc.equivalencies).reduce((acc, [key, vars]) => {
3828
4082
  // Clean cyScope from the key as well as variable properties