@codeyam/codeyam-cli 0.1.0-staging.b8b17a5 → 0.1.0-staging.ba3f279

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 (331) 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 +2 -2
  4. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +135 -0
  5. package/analyzer-template/packages/ai/src/lib/astScopes/nodeToSource.ts +19 -0
  6. package/analyzer-template/packages/ai/src/lib/astScopes/paths.ts +11 -4
  7. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +36 -9
  8. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.ts +10 -3
  9. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +16 -6
  10. package/analyzer-template/packages/analyze/index.ts +4 -1
  11. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +28 -2
  12. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +5 -36
  13. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +10 -6
  14. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +9 -12
  15. package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts +21 -0
  16. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +82 -10
  17. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +4 -0
  18. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +4 -0
  19. package/analyzer-template/packages/analyze/src/lib/files/analyzeNextRoute.ts +8 -3
  20. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +239 -58
  21. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1684 -1462
  22. package/analyzer-template/packages/aws/package.json +1 -1
  23. package/analyzer-template/packages/database/package.json +1 -1
  24. package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +25 -15
  25. package/analyzer-template/packages/database/src/lib/loadEntity.ts +19 -8
  26. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
  27. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +7 -1
  28. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
  29. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts +4 -1
  30. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts.map +1 -1
  31. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js +5 -5
  32. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js.map +1 -1
  33. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts +3 -1
  34. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
  35. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +22 -1
  36. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  37. package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +27 -0
  38. package/analyzer-template/project/analyzeFileEntities.ts +26 -0
  39. package/analyzer-template/project/runMultiScenarioServer.ts +26 -3
  40. package/background/src/lib/virtualized/project/analyzeFileEntities.js +22 -0
  41. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  42. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +23 -3
  43. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  44. package/codeyam-cli/src/cli.js +15 -0
  45. package/codeyam-cli/src/cli.js.map +1 -1
  46. package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js +47 -0
  47. package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js.map +1 -0
  48. package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js +71 -0
  49. package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js.map +1 -0
  50. package/codeyam-cli/src/commands/__tests__/editor.designSystem.test.js +30 -0
  51. package/codeyam-cli/src/commands/__tests__/editor.designSystem.test.js.map +1 -0
  52. package/codeyam-cli/src/commands/__tests__/editor.statePersistence.test.js +55 -0
  53. package/codeyam-cli/src/commands/__tests__/editor.statePersistence.test.js.map +1 -0
  54. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +9 -9
  55. package/codeyam-cli/src/commands/editor.js +1906 -468
  56. package/codeyam-cli/src/commands/editor.js.map +1 -1
  57. package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js +23 -0
  58. package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js.map +1 -0
  59. package/codeyam-cli/src/commands/init.js +1 -0
  60. package/codeyam-cli/src/commands/init.js.map +1 -1
  61. package/codeyam-cli/src/data/designSystems.js +27 -0
  62. package/codeyam-cli/src/data/designSystems.js.map +1 -0
  63. package/codeyam-cli/src/data/techStacks.js +1 -1
  64. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +44 -0
  65. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -1
  66. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +2114 -70
  67. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  68. package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js +137 -0
  69. package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js.map +1 -0
  70. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +66 -0
  71. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -1
  72. package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js +67 -0
  73. package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js.map +1 -0
  74. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +11 -3
  75. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
  76. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +190 -0
  77. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -1
  78. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +249 -1
  79. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
  80. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +134 -1
  81. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -1
  82. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +266 -2
  83. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
  84. package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js +177 -0
  85. package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js.map +1 -0
  86. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +16 -1
  87. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -1
  88. package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js +302 -0
  89. package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js.map +1 -0
  90. package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js +127 -0
  91. package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js.map +1 -0
  92. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +57 -0
  93. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -1
  94. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +180 -1
  95. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -1
  96. package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js +84 -0
  97. package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js.map +1 -0
  98. package/codeyam-cli/src/utils/__tests__/testRunner.test.js +216 -0
  99. package/codeyam-cli/src/utils/__tests__/testRunner.test.js.map +1 -0
  100. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +6 -0
  101. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -1
  102. package/codeyam-cli/src/utils/analysisRunner.js +36 -7
  103. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  104. package/codeyam-cli/src/utils/analyzer.js +11 -1
  105. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  106. package/codeyam-cli/src/utils/backgroundServer.js +1 -1
  107. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  108. package/codeyam-cli/src/utils/editorApi.js +16 -0
  109. package/codeyam-cli/src/utils/editorApi.js.map +1 -1
  110. package/codeyam-cli/src/utils/editorAudit.js +499 -43
  111. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  112. package/codeyam-cli/src/utils/editorGuard.js +36 -0
  113. package/codeyam-cli/src/utils/editorGuard.js.map +1 -0
  114. package/codeyam-cli/src/utils/editorPreview.js +5 -3
  115. package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
  116. package/codeyam-cli/src/utils/editorRecapture.js +109 -0
  117. package/codeyam-cli/src/utils/editorRecapture.js.map +1 -0
  118. package/codeyam-cli/src/utils/editorScenarioSwitch.js +39 -2
  119. package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -1
  120. package/codeyam-cli/src/utils/editorScenarios.js +131 -7
  121. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
  122. package/codeyam-cli/src/utils/editorSeedAdapter.js +69 -16
  123. package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -1
  124. package/codeyam-cli/src/utils/entityChangeStatus.js +31 -3
  125. package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -1
  126. package/codeyam-cli/src/utils/entityChangeStatus.server.js +31 -0
  127. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
  128. package/codeyam-cli/src/utils/glossaryAdd.js +74 -0
  129. package/codeyam-cli/src/utils/glossaryAdd.js.map +1 -0
  130. package/codeyam-cli/src/utils/install-skills.js +5 -0
  131. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  132. package/codeyam-cli/src/utils/manualEntityAnalysis.js +196 -0
  133. package/codeyam-cli/src/utils/manualEntityAnalysis.js.map +1 -0
  134. package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js +159 -0
  135. package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js.map +1 -0
  136. package/codeyam-cli/src/utils/queue/job.js +35 -6
  137. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  138. package/codeyam-cli/src/utils/registerScenarioResult.js +52 -0
  139. package/codeyam-cli/src/utils/registerScenarioResult.js.map +1 -0
  140. package/codeyam-cli/src/utils/scenarioCoverage.js +4 -1
  141. package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -1
  142. package/codeyam-cli/src/utils/scenariosManifest.js +66 -2
  143. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -1
  144. package/codeyam-cli/src/utils/screenshotHash.js +26 -0
  145. package/codeyam-cli/src/utils/screenshotHash.js.map +1 -0
  146. package/codeyam-cli/src/utils/simulationGateMiddleware.js +9 -0
  147. package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
  148. package/codeyam-cli/src/utils/testResultCache.js +53 -0
  149. package/codeyam-cli/src/utils/testResultCache.js.map +1 -0
  150. package/codeyam-cli/src/utils/testResultCache.server.js +81 -0
  151. package/codeyam-cli/src/utils/testResultCache.server.js.map +1 -0
  152. package/codeyam-cli/src/utils/testResultCache.server.test.js +187 -0
  153. package/codeyam-cli/src/utils/testResultCache.server.test.js.map +1 -0
  154. package/codeyam-cli/src/utils/testResultCache.test.js +230 -0
  155. package/codeyam-cli/src/utils/testResultCache.test.js.map +1 -0
  156. package/codeyam-cli/src/utils/testRunner.js +193 -1
  157. package/codeyam-cli/src/utils/testRunner.js.map +1 -1
  158. package/codeyam-cli/src/utils/webappDetection.js +4 -2
  159. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  160. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js +98 -0
  161. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js.map +1 -0
  162. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +68 -1
  163. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -1
  164. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +30 -11
  165. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
  166. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +190 -21
  167. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -1
  168. package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js +135 -0
  169. package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js.map +1 -0
  170. package/codeyam-cli/src/webserver/app/lib/clientErrors.js +22 -1
  171. package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -1
  172. package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js +34 -0
  173. package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js.map +1 -0
  174. package/codeyam-cli/src/webserver/backgroundServer.js +42 -57
  175. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  176. package/codeyam-cli/src/webserver/build/client/assets/{CopyButton-CzTDWkF2.js → CopyButton-CLe80MMu.js} +1 -1
  177. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-BFbq6iFk.js → EntityItem-Crt_KN_U.js} +1 -1
  178. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-B6OMi58N.js → EntityTypeIcon-CD7lGABo.js} +1 -1
  179. package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-DuYodzo1.js → InlineSpinner-CgTNOhnu.js} +1 -1
  180. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CXo9EeCl.js → InteractivePreview-DtYTSPL2.js} +2 -2
  181. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-DYCNb2It.js → LibraryFunctionPreview-D3s1MFkb.js} +1 -1
  182. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CZgY3sxX.js → LogViewer-CM5zg40N.js} +1 -1
  183. package/codeyam-cli/src/webserver/build/client/assets/MiniClaudeChat-CQENLSrF.js +36 -0
  184. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-CnYYwRDw.js → ReportIssueModal-C2PLkej3.js} +1 -1
  185. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-CDoF7ZpU.js → SafeScreenshot-DanvyBPb.js} +1 -1
  186. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DrnfvaLL.js → ScenarioViewer-CefgqbCr.js} +1 -1
  187. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bc8BG-Lw.js +34 -0
  188. package/codeyam-cli/src/webserver/build/client/assets/{ViewportInspectBar-DRKR9T0U.js → ViewportInspectBar-BA_Ry-rs.js} +1 -1
  189. package/codeyam-cli/src/webserver/build/client/assets/{_index-ClR-g3tY.js → _index-C1YkzTAV.js} +1 -1
  190. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-DTH6ydEA.js → activity.(_tab)-yH46LLUz.js} +1 -1
  191. package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-74hnHF59.js → addon-web-links-CHx25PAe.js} +1 -1
  192. package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-B8CYhCO9.js → agent-transcripts-Bg3e7q4S.js} +1 -1
  193. package/codeyam-cli/src/webserver/build/client/assets/api.editor-recapture-stale-l0sNRNKZ.js +1 -0
  194. package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-scenario-data-l0sNRNKZ.js +1 -0
  195. package/codeyam-cli/src/webserver/build/client/assets/api.editor-schema-l0sNRNKZ.js +1 -0
  196. package/codeyam-cli/src/webserver/build/client/assets/api.editor-verify-routes-l0sNRNKZ.js +1 -0
  197. package/codeyam-cli/src/webserver/build/client/assets/api.interactive-switch-scenario-l0sNRNKZ.js +1 -0
  198. package/codeyam-cli/src/webserver/build/client/assets/{book-open-CLaoh4ac.js → book-open-CL-lMgHh.js} +1 -1
  199. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BZ2DZxbW.js → chevron-down-GmAjGS9-.js} +1 -1
  200. package/codeyam-cli/src/webserver/build/client/assets/{chunk-JZWAC4HX-BBXArFPl.js → chunk-JZWAC4HX-BAdwhyCx.js} +11 -11
  201. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CT4unAk-.js → circle-check-DFcQkN5j.js} +1 -1
  202. package/codeyam-cli/src/webserver/build/client/assets/{copy-zK0B6Nu-.js → copy-C6iF61Xs.js} +1 -1
  203. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-DJB0YQJL.js → createLucideIcon-4ImjHTVC.js} +1 -1
  204. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-Coe5NhbS.js +1 -0
  205. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-CCKUIm0S.svg → cy-logo-cli-DoA97ML3.svg} +2 -2
  206. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-CkXFP_i-.js → dev.empty-CRepiabR.js} +1 -1
  207. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-Gbk_i5Js.js +1 -0
  208. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-CRxPi2BB.js +96 -0
  209. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-CluPkvXJ.js +41 -0
  210. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BqAN7hyG.js → entity._sha._-DYJRGiDI.js} +13 -12
  211. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-D1eikpe1.js → entity._sha.scenarios._scenarioId.dev-wdiwx5-Z.js} +1 -1
  212. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-Dg1NhIms.js → entity._sha.scenarios._scenarioId.fullscreen-BrkN-40Y.js} +1 -1
  213. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-CJX6kkkV.js → entity._sha_.create-scenario-DxfhekTZ.js} +1 -1
  214. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BhVjZhKg.js → entity._sha_.edit._scenarioId-CRXJWmpB.js} +1 -1
  215. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-_gzKltPN.js → entry.client-SuW9syRS.js} +1 -1
  216. package/codeyam-cli/src/webserver/build/client/assets/{files-CV_17tZS.js → files-D-xGrg29.js} +1 -1
  217. package/codeyam-cli/src/webserver/build/client/assets/{git-D-YXmMbR.js → git-Bq_fbXP5.js} +1 -1
  218. package/codeyam-cli/src/webserver/build/client/assets/globals-BsGHu8WX.css +1 -0
  219. package/codeyam-cli/src/webserver/build/client/assets/{index-CCrgCshv.js → index-Bp1l4hSv.js} +1 -1
  220. package/codeyam-cli/src/webserver/build/client/assets/{index-BsX0F-9C.js → index-CWV9XZiG.js} +1 -1
  221. package/codeyam-cli/src/webserver/build/client/assets/{index-Blo6EK8G.js → index-DE3jI_dv.js} +1 -1
  222. package/codeyam-cli/src/webserver/build/client/assets/{labs-Byazq8Pv.js → labs-B_IX45ih.js} +1 -1
  223. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-DVQ0oHR7.js → loader-circle-De-7qQ2u.js} +1 -1
  224. package/codeyam-cli/src/webserver/build/client/assets/manifest-9032538f.js +1 -0
  225. package/codeyam-cli/src/webserver/build/client/assets/{memory-b-VmA2Vj.js → memory-Cx2xEx7s.js} +1 -1
  226. package/codeyam-cli/src/webserver/build/client/assets/{pause-DGcndCAa.js → pause-CFxEKL1u.js} +1 -1
  227. package/codeyam-cli/src/webserver/build/client/assets/root-dKFRTYcy.js +80 -0
  228. package/codeyam-cli/src/webserver/build/client/assets/{search-C0Uw0bcK.js → search-BdBb5aqc.js} +1 -1
  229. package/codeyam-cli/src/webserver/build/client/assets/{settings-OoNgHIfW.js → settings-DdE-Untf.js} +1 -1
  230. package/codeyam-cli/src/webserver/build/client/assets/{simulations-Bcemfu8a.js → simulations-DSCdE99u.js} +1 -1
  231. package/codeyam-cli/src/webserver/build/client/assets/{terminal-BgMmG7R9.js → terminal-CrplD4b1.js} +1 -1
  232. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-Cs87hJYK.js → triangle-alert-DqJ0j69l.js} +1 -1
  233. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-BR3Rs7JY.js → useCustomSizes-DhXHbEjP.js} +1 -1
  234. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-D9QZKaLJ.js +2 -0
  235. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-BermyNU5.js → useReportContext-Cy5Qg_UR.js} +1 -1
  236. package/codeyam-cli/src/webserver/build/client/assets/{useToast-a_QN_W9_.js → useToast-5HR2j9ZE.js} +1 -1
  237. package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-OLsM110H.js +16 -0
  238. package/codeyam-cli/src/webserver/build/server/assets/{index-CHymws6l.js → index-WHdB6WTN.js} +1 -1
  239. package/codeyam-cli/src/webserver/build/server/assets/{init-D3HkMDbI.js → init-DbSiZoE6.js} +2 -2
  240. package/codeyam-cli/src/webserver/build/server/assets/server-build-DZbLY6O_.js +690 -0
  241. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  242. package/codeyam-cli/src/webserver/build-info.json +5 -5
  243. package/codeyam-cli/src/webserver/editorProxy.js +55 -3
  244. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
  245. package/codeyam-cli/src/webserver/idleDetector.js +65 -8
  246. package/codeyam-cli/src/webserver/idleDetector.js.map +1 -1
  247. package/codeyam-cli/src/webserver/scripts/journalCapture.ts +53 -0
  248. package/codeyam-cli/src/webserver/server.js +52 -14
  249. package/codeyam-cli/src/webserver/server.js.map +1 -1
  250. package/codeyam-cli/src/webserver/terminalServer.js +153 -32
  251. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  252. package/codeyam-cli/templates/__tests__/editor-step-hook.prompt-capture.test.ts +118 -0
  253. package/codeyam-cli/templates/codeyam-editor-claude.md +2 -0
  254. package/codeyam-cli/templates/codeyam-editor-reference.md +216 -0
  255. package/codeyam-cli/templates/design-systems/clean-dashboard-design-system.md +255 -0
  256. package/codeyam-cli/templates/design-systems/editorial-design-system.md +267 -0
  257. package/codeyam-cli/templates/design-systems/mono-brutalist-design-system.md +256 -0
  258. package/codeyam-cli/templates/design-systems/neo-brutalist-design-system.md +294 -0
  259. package/codeyam-cli/templates/editor-step-hook.py +93 -46
  260. package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +204 -5
  261. package/codeyam-cli/templates/expo-react-native/__tests__/.gitkeep +0 -0
  262. package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +6 -3
  263. package/codeyam-cli/templates/expo-react-native/app/index.tsx +36 -0
  264. package/codeyam-cli/templates/expo-react-native/app.json +11 -0
  265. package/codeyam-cli/templates/expo-react-native/babel.config.js +1 -0
  266. package/codeyam-cli/templates/expo-react-native/gitignore +2 -0
  267. package/codeyam-cli/templates/expo-react-native/global.css +7 -0
  268. package/codeyam-cli/templates/expo-react-native/lib/theme.ts +73 -0
  269. package/codeyam-cli/templates/expo-react-native/package.json +32 -16
  270. package/codeyam-cli/templates/expo-react-native/patches/expo-modules-autolinking+3.0.24.patch +29 -0
  271. package/codeyam-cli/templates/isolation-route/expo-router.tsx.template +54 -0
  272. package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +47 -34
  273. package/codeyam-cli/templates/seed-adapters/supabase.ts +101 -9
  274. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +34 -1
  275. package/package.json +1 -1
  276. package/packages/ai/src/lib/astScopes/methodSemantics.js +99 -0
  277. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  278. package/packages/ai/src/lib/astScopes/nodeToSource.js +16 -0
  279. package/packages/ai/src/lib/astScopes/nodeToSource.js.map +1 -1
  280. package/packages/ai/src/lib/astScopes/paths.js +12 -3
  281. package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
  282. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +27 -10
  283. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  284. package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js +9 -2
  285. package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js.map +1 -1
  286. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +14 -4
  287. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  288. package/packages/analyze/index.js +1 -1
  289. package/packages/analyze/index.js.map +1 -1
  290. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +16 -2
  291. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  292. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +6 -26
  293. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  294. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +3 -2
  295. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  296. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +9 -7
  297. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  298. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +14 -0
  299. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
  300. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +44 -11
  301. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  302. package/packages/analyze/src/lib/files/analyzeChange.js +1 -0
  303. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  304. package/packages/analyze/src/lib/files/analyzeInitial.js +1 -0
  305. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  306. package/packages/analyze/src/lib/files/analyzeNextRoute.js +5 -1
  307. package/packages/analyze/src/lib/files/analyzeNextRoute.js.map +1 -1
  308. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +120 -28
  309. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  310. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +1368 -1193
  311. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  312. package/packages/database/src/lib/loadAnalysis.js +7 -1
  313. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  314. package/packages/database/src/lib/loadEntity.js +5 -5
  315. package/packages/database/src/lib/loadEntity.js.map +1 -1
  316. package/packages/utils/src/lib/fs/rsyncCopy.js +22 -1
  317. package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  318. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Df3UCi8k.js +0 -34
  319. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +0 -1
  320. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-DPw7NZHc.js +0 -1
  321. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DYqG1D_d.js +0 -58
  322. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-DggyRwOr.js +0 -41
  323. package/codeyam-cli/src/webserver/build/client/assets/globals-DRvOjyO3.css +0 -1
  324. package/codeyam-cli/src/webserver/build/client/assets/manifest-f4212c17.js +0 -1
  325. package/codeyam-cli/src/webserver/build/client/assets/root-F-k2uYj5.js +0 -67
  326. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-BxxP_XF9.js +0 -2
  327. package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-if8kM_1Q.js +0 -13
  328. package/codeyam-cli/src/webserver/build/server/assets/server-build-DTCzJQiH.js +0 -551
  329. package/codeyam-cli/templates/expo-react-native/app/(tabs)/_layout.tsx +0 -33
  330. package/codeyam-cli/templates/expo-react-native/app/(tabs)/index.tsx +0 -12
  331. package/codeyam-cli/templates/expo-react-native/app/(tabs)/settings.tsx +0 -12
@@ -4,16 +4,34 @@
4
4
  * Cross-references glossary entries against registered scenarios (components)
5
5
  * and test files (functions) to detect gaps Claude may have missed.
6
6
  */
7
+ import { isIsolationUrl, scenarioEntityName, } from "./entityChangeStatus.js";
7
8
  // ─── Logic ───────────────────────────────────────────────────────────
8
9
  const COMPONENT_RETURN_PATTERNS = ['JSX', 'React', 'Element', 'ReactNode'];
10
+ /** File names that indicate page/route files — these are visual components
11
+ * verified via screenshots, not functions that need unit tests. */
12
+ const PAGE_FILE_NAMES = new Set([
13
+ 'page.tsx',
14
+ 'page.ts',
15
+ 'index.tsx',
16
+ 'index.ts',
17
+ ]);
9
18
  /**
10
- * Returns true when the entry's returnType indicates a React component
11
- * (contains "JSX", "React", "Element", or "ReactNode").
19
+ * Returns true when the entry represents a visual component (needs scenarios,
20
+ * not unit tests). Matches on returnType containing JSX/React patterns, OR
21
+ * on file path patterns for page/route files.
12
22
  */
13
23
  export function isComponent(entry) {
14
- if (!entry.returnType)
15
- return false;
16
- return COMPONENT_RETURN_PATTERNS.some((pat) => entry.returnType.includes(pat));
24
+ if (entry.returnType &&
25
+ COMPONENT_RETURN_PATTERNS.some((pat) => entry.returnType.includes(pat))) {
26
+ return true;
27
+ }
28
+ // Page/route files are visual components — verified via app scenarios, not tests
29
+ if (entry.filePath) {
30
+ const fileName = entry.filePath.split('/').pop() || '';
31
+ if (PAGE_FILE_NAMES.has(fileName))
32
+ return true;
33
+ }
34
+ return false;
17
35
  }
18
36
  /**
19
37
  * Split glossary entries into components (JSX-returning) and functions (everything else).
@@ -39,14 +57,28 @@ export function classifyGlossaryEntries(entries) {
39
57
  * @param scenarioCounts - Map of component_name → number of registered scenarios
40
58
  * @param testFileExistence - Map of testFile path → whether the file exists on disk
41
59
  */
42
- export function computeAudit({ components, functions, scenarioCounts, testFileExistence, testResults, clientErrors, }) {
60
+ export function computeAudit({ components, functions, scenarioCounts, testFileExistence, testResults, clientErrors, totalScenarioCounts, entityChangeStatus, analysisFailedEntities, }) {
43
61
  const componentResults = components.map((c) => {
44
62
  const count = scenarioCounts[c.name] || 0;
63
+ const totalCount = totalScenarioCounts?.[c.name] || 0;
64
+ const changeStatus = entityChangeStatus?.[c.name];
45
65
  const errors = clientErrors?.[c.name];
46
66
  const hasErrors = count > 0 && errors && errors.length > 0;
47
67
  let status;
48
- if (count === 0) {
49
- status = 'missing';
68
+ if (analysisFailedEntities?.has(c.name)) {
69
+ status = 'analysis_failed';
70
+ }
71
+ else if (count === 0) {
72
+ // Entities with existing scenarios from prior sessions don't need
73
+ // new scenarios — they need recapture. This applies to both "edited"
74
+ // and "impacted" entities: an edited page may not have been re-registered
75
+ // this session, and an impacted page's dependency changed.
76
+ if (changeStatus && totalCount > 0) {
77
+ status = 'needs_recapture';
78
+ }
79
+ else {
80
+ status = 'missing';
81
+ }
50
82
  }
51
83
  else if (hasErrors) {
52
84
  status = 'has_errors';
@@ -54,12 +86,33 @@ export function computeAudit({ components, functions, scenarioCounts, testFileEx
54
86
  else {
55
87
  status = 'ok';
56
88
  }
89
+ // Generate actionable hint for missing or needs_recapture components
90
+ let hint;
91
+ if (status === 'missing') {
92
+ const fileName = c.filePath.split('/').pop() || '';
93
+ if (fileName === 'layout.tsx' || fileName === 'layout.ts') {
94
+ hint = `This is a layout file — register an app-level scenario with pageFilePath instead of componentName: codeyam editor register '{"name":"${c.name} - Default","pageFilePath":"${c.filePath}","url":"/<route>","dimensions":["Desktop"]}'`;
95
+ }
96
+ else if (fileName === 'page.tsx' || fileName === 'page.ts') {
97
+ hint = `This is a page file — register an app-level scenario with pageFilePath: codeyam editor register '{"name":"${c.name} - Default","pageFilePath":"${c.filePath}","url":"/<route>","dimensions":["Desktop"]}'`;
98
+ }
99
+ else {
100
+ hint = `Register a component scenario via an isolation route: codeyam editor isolate ${c.name} then codeyam editor register '{"name":"${c.name} - Default","componentName":"${c.name}","url":"/isolated-components/${c.name}?s=Default","dimensions":["Desktop"]}'`;
101
+ }
102
+ }
103
+ else if (status === 'needs_recapture') {
104
+ hint = `This component's code or dependencies changed — recapture existing scenarios to update screenshots: codeyam editor recapture ${c.name}`;
105
+ }
106
+ else if (status === 'analysis_failed') {
107
+ hint = `Analysis failed for this component (likely timed out due to complex dependencies). The component has partial data but may be missing some dependency schemas. Try re-analyzing: codeyam editor analyze-imports`;
108
+ }
57
109
  return {
58
110
  name: c.name,
59
111
  filePath: c.filePath,
60
- scenarioCount: count,
112
+ scenarioCount: status === 'needs_recapture' ? totalCount : count,
61
113
  status,
62
114
  ...(hasErrors ? { clientErrors: errors } : {}),
115
+ ...(hint ? { hint } : {}),
63
116
  };
64
117
  });
65
118
  const functionResults = functions.map((f) => {
@@ -67,12 +120,17 @@ export function computeAudit({ components, functions, scenarioCounts, testFileEx
67
120
  ? (testFileExistence[f.testFile] ?? false)
68
121
  : false;
69
122
  if (!exists) {
123
+ // Suggest conventional test file path when testFile isn't in the glossary
124
+ const suggestedTestFile = !f.testFile
125
+ ? f.filePath.replace(/\.tsx?$/, '.test.ts')
126
+ : undefined;
70
127
  return {
71
128
  name: f.name,
72
129
  filePath: f.filePath,
73
130
  testFile: f.testFile,
74
131
  testFileExists: false,
75
132
  status: 'missing',
133
+ ...(suggestedTestFile ? { suggestedTestFile } : {}),
76
134
  };
77
135
  }
78
136
  // If we have test results for this file, use them for deeper status
@@ -100,6 +158,14 @@ export function computeAudit({ components, functions, scenarioCounts, testFileEx
100
158
  else {
101
159
  status = 'ok';
102
160
  }
161
+ // Generate actionable hint for non-ok functions
162
+ let hint;
163
+ if (status === 'name_mismatch') {
164
+ hint = `Tests pass but won't show in the CodeYam UI. Add a top-level describe("${f.name}", ...) block in ${f.testFile}`;
165
+ }
166
+ else if (status === 'runner_error' && tr.errorMessage) {
167
+ hint = `Test runner crashed (not a test failure): ${tr.errorMessage}`;
168
+ }
103
169
  return {
104
170
  name: f.name,
105
171
  filePath: f.filePath,
@@ -109,11 +175,14 @@ export function computeAudit({ components, functions, scenarioCounts, testFileEx
109
175
  testsVisibleInUi: tr.hasEntityNameDescribe,
110
176
  status,
111
177
  ...(tr.errorMessage ? { errorMessage: tr.errorMessage } : {}),
178
+ ...(hint ? { hint } : {}),
112
179
  };
113
180
  });
114
181
  const componentsOk = componentResults.filter((c) => c.status === 'ok').length;
115
182
  const componentsWithErrors = componentResults.filter((c) => c.status === 'has_errors').length;
116
183
  const componentsMissing = componentResults.filter((c) => c.status === 'missing').length;
184
+ const componentsNeedingRecapture = componentResults.filter((c) => c.status === 'needs_recapture').length;
185
+ const componentsAnalysisFailed = componentResults.filter((c) => c.status === 'analysis_failed').length;
117
186
  const functionsOk = functionResults.filter((f) => f.status === 'ok').length;
118
187
  const functionsFailing = functionResults.filter((f) => f.status === 'failing').length;
119
188
  const functionsRunnerError = functionResults.filter((f) => f.status === 'runner_error').length;
@@ -127,6 +196,8 @@ export function computeAudit({ components, functions, scenarioCounts, testFileEx
127
196
  componentsOk,
128
197
  componentsMissing,
129
198
  componentsWithErrors,
199
+ componentsNeedingRecapture,
200
+ componentsAnalysisFailed,
130
201
  totalFunctions: functionResults.length,
131
202
  functionsOk,
132
203
  functionsMissing,
@@ -135,6 +206,7 @@ export function computeAudit({ components, functions, scenarioCounts, testFileEx
135
206
  functionsNameMismatch,
136
207
  allPassing: componentsMissing === 0 &&
137
208
  componentsWithErrors === 0 &&
209
+ componentsAnalysisFailed === 0 &&
138
210
  functionsFailing === 0 &&
139
211
  functionsRunnerError === 0 &&
140
212
  functionsNameMismatch === 0 &&
@@ -143,30 +215,166 @@ export function computeAudit({ components, functions, scenarioCounts, testFileEx
143
215
  };
144
216
  }
145
217
  /**
146
- * Returns true when the audit failure can be auto-fixed by running
147
- * analyze-imports: incomplete entities are the only issue AND we haven't
148
- * already tried (to prevent infinite retry loops when analysis has errors).
218
+ * Returns true when the audit failure can be auto-fixed inline.
219
+ *
220
+ * Always returns false full analyze-imports takes minutes on large projects
221
+ * and must never run as part of the audit. The audit only does lightweight
222
+ * entity SHA backfill. Users should run `codeyam editor analyze-imports`
223
+ * separately if incomplete entities persist.
149
224
  */
150
- export function isAutoRemediable(summary, alreadyAttempted) {
151
- if (alreadyAttempted)
152
- return false;
153
- if (!summary.incompleteEntities || summary.incompleteEntities === 0)
154
- return false;
155
- return isOnlyIncompleteEntities(summary);
225
+ export function isAutoRemediable(_summary, _alreadyAttempted) {
226
+ return false;
227
+ }
228
+ /**
229
+ * Determine whether the audit should auto-recapture stale scenarios.
230
+ * Returns true when the `--fix` flag is set AND there are stale scenarios.
231
+ */
232
+ export function shouldAutoRecapture(params) {
233
+ return params.fix && params.scenariosNeedingRecapture.length > 0;
234
+ }
235
+ /**
236
+ * Extract unique file paths that need targeted analysis from audit results.
237
+ *
238
+ * After a DB-only backfill attempt fails, these are the files that need
239
+ * `analyze-imports` to create entity records. Unlike full analyze-imports
240
+ * (which scans ALL glossary + page files), this returns only the specific
241
+ * files that have unresolved associations — typically 1-3 files.
242
+ */
243
+ export function determineTargetedAnalysisPaths(auditData) {
244
+ const paths = new Set();
245
+ for (const u of auditData.unassociatedScenarios) {
246
+ if (u.filePath)
247
+ paths.add(u.filePath);
248
+ }
249
+ for (const e of auditData.incompleteEntities) {
250
+ if (e.filePath)
251
+ paths.add(e.filePath);
252
+ }
253
+ return [...paths];
254
+ }
255
+ /**
256
+ * Generate clear, actionable guidance for an incomplete entity.
257
+ *
258
+ * Tells Claude exactly what's wrong, whether it's pre-existing, and
259
+ * the exact command to fix it — no guessing required.
260
+ */
261
+ export function formatIncompleteEntityGuidance(entity) {
262
+ const parts = [];
263
+ if (entity.preExisting) {
264
+ parts.push(`${entity.name}: ${entity.scenarioCount} scenario(s) without import graph (pre-existing issue, not from this session).`);
265
+ parts.push(`This is non-blocking — the entity had scenarios before this session but analyze-imports was never run for it.`);
266
+ }
267
+ else {
268
+ parts.push(`${entity.name}: ${entity.scenarioCount} scenario(s) without import graph — analyze-imports has not been run for this entity.`);
269
+ parts.push(`The entity has scenarios registered but its import graph is not built, so the editor cannot track its dependencies.`);
270
+ }
271
+ parts.push(`Fix: Run \`codeyam editor analyze-imports\` to build the import graph for all entities.`);
272
+ return parts.join(' ');
273
+ }
274
+ /**
275
+ * Generate step-by-step manual analysis instructions for an entity
276
+ * whose automated analysis has persistently failed.
277
+ *
278
+ * Used by the audit when analysis-failures.json contains the entity.
279
+ * Tells Claude exactly how to read the source, gather imports/types,
280
+ * and run `codeyam editor manual-entity` to unblock the audit.
281
+ */
282
+ export function formatManualAnalysisGuidance(entity) {
283
+ const lines = [];
284
+ lines.push(`${entity.name}: ${entity.scenarioCount} scenario(s) — automated analysis failed`);
285
+ lines.push(`Error: ${entity.error}`);
286
+ lines.push('');
287
+ lines.push('MANUAL ANALYSIS REQUIRED — follow these steps:');
288
+ lines.push(`1. Read ${entity.filePath}`);
289
+ lines.push('2. Identify which glossary entities it imports (check .codeyam/glossary.json)');
290
+ lines.push('3. Determine entity type: "visual" if it returns JSX, "library" otherwise');
291
+ lines.push('4. Identify the type structure:');
292
+ lines.push(' - For components: props interface and hook return types');
293
+ lines.push(' - For functions: parameter types and return type');
294
+ lines.push(`5. Write the JSON to .codeyam/tmp/manual-entity.json then run: codeyam editor manual-entity @.codeyam/tmp/manual-entity.json`);
295
+ return lines.join('\n');
296
+ }
297
+ /**
298
+ * Resolve incomplete entity SHAs to their source file paths.
299
+ *
300
+ * Used by the audit to run targeted analysis on just the files that need it,
301
+ * instead of scanning all 117+ project files. Returns deduplicated file paths.
302
+ */
303
+ export async function getIncompleteEntityFilePaths(db, incompleteEntities) {
304
+ if (incompleteEntities.length === 0)
305
+ return [];
306
+ const shas = incompleteEntities.map((e) => e.entitySha);
307
+ const rows = await db
308
+ .selectFrom('entities')
309
+ .select('file_path')
310
+ .where('sha', 'in', shas)
311
+ .execute();
312
+ const paths = new Set();
313
+ for (const row of rows) {
314
+ if (row.file_path)
315
+ paths.add(row.file_path);
316
+ }
317
+ return [...paths];
156
318
  }
157
319
  /**
158
- * Returns true when incompleteEntities is the ONLY audit failure
159
- * all other failure counts are zero. Used to decide whether auto-running
160
- * analyze-imports can fix the audit without manual intervention.
320
+ * Returns true when the only audit failures are auto-fixable entity issues
321
+ * (incompleteEntities and/or unassociatedScenarios) all other failure
322
+ * counts are zero. Used to decide whether auto-running analyze-imports +
323
+ * entity SHA sync can fix the audit without manual intervention.
161
324
  */
162
325
  export function isOnlyIncompleteEntities(summary) {
163
326
  return ((summary.componentsMissing ?? 0) === 0 &&
164
327
  (summary.componentsWithErrors ?? 0) === 0 &&
165
328
  (summary.functionsFailing ?? 0) === 0 &&
329
+ (summary.functionsRunnerError ?? 0) === 0 &&
166
330
  (summary.functionsNameMismatch ?? 0) === 0 &&
167
331
  (summary.functionsMissing ?? 0) === 0 &&
168
332
  (summary.missingFromGlossary ?? 0) === 0 &&
169
- (summary.miscategorizedScenarios ?? 0) === 0);
333
+ (summary.miscategorizedScenarios ?? 0) === 0 &&
334
+ (summary.scenariosNeedingRecapture ?? 0) === 0);
335
+ }
336
+ /**
337
+ * Returns true when the only audit failures are incomplete entities that ALL
338
+ * existed before the current session. Used by the step gate to avoid blocking
339
+ * progress on pre-existing issues the user didn't cause.
340
+ *
341
+ * Requires both the summary (to confirm no other failure types) and the
342
+ * incompleteEntities array (to verify every entry is pre-existing).
343
+ */
344
+ export function isOnlyPreExistingIncomplete(summary, incompleteEntities) {
345
+ // Must have at least one incomplete entity to be relevant
346
+ if (!incompleteEntities || incompleteEntities.length === 0)
347
+ return false;
348
+ // All other failure types must be zero
349
+ if (!isOnlyIncompleteEntities(summary))
350
+ return false;
351
+ // Every incomplete entity must be pre-existing
352
+ return incompleteEntities.every((e) => e.preExisting);
353
+ }
354
+ /**
355
+ * Filter a list of file paths to only those that need analysis.
356
+ *
357
+ * A file is excluded if ANY entity at that file path has an analysis
358
+ * record (direct or inherited from a sibling version with the same
359
+ * name+filePath). Everything else passes through.
360
+ *
361
+ * Used by handleAnalyzeImports to avoid re-analyzing ~120 files when
362
+ * only a few need it.
363
+ */
364
+ export async function filterToIncompleteFilePaths(db, _projectId, allFilePaths) {
365
+ if (allFilePaths.length === 0)
366
+ return [];
367
+ // Single query: find all file paths that have at least one entity
368
+ // with an analysis record. These are already analyzed and can be skipped.
369
+ const analyzedRows = await db
370
+ .selectFrom('entities')
371
+ .innerJoin('analyses', 'analyses.entity_sha', 'entities.sha')
372
+ .select('entities.file_path')
373
+ .where('entities.file_path', 'in', allFilePaths)
374
+ .groupBy('entities.file_path')
375
+ .execute();
376
+ const analyzedFilePaths = new Set(analyzedRows.map((r) => r.file_path));
377
+ return allFilePaths.filter((fp) => !analyzedFilePaths.has(fp));
170
378
  }
171
379
  /**
172
380
  * Ensures the two audit filters — glossary scoping and scenario-count scoping —
@@ -214,22 +422,15 @@ export function filterGlossaryByChangeStatus(entries, entityChangeStatus) {
214
422
  */
215
423
  export async function queryIncompleteEntities(db, projectId, featureStartedAt) {
216
424
  // Step 1: Get distinct entity SHAs from scenarios (with counts)
217
- let scenarioQuery = db
425
+ // No time filter — we check ALL scenarios to catch entities whose
426
+ // scenario SHAs were updated mid-session without touching updated_at.
427
+ const scenarioQuery = db
218
428
  .selectFrom('editor_scenarios')
219
429
  .select(['entity_sha'])
220
430
  .select(db.fn.count('id').as('count'))
221
431
  .where('project_id', '=', projectId)
222
432
  .where('entity_sha', 'is not', null)
223
433
  .groupBy('entity_sha');
224
- if (featureStartedAt) {
225
- const sqliteTimestamp = featureStartedAt
226
- .replace('T', ' ')
227
- .replace(/\.\d{3}Z$/, '');
228
- scenarioQuery = scenarioQuery.where((eb) => eb.or([
229
- eb('created_at', '>=', sqliteTimestamp),
230
- eb('updated_at', '>=', sqliteTimestamp),
231
- ]));
232
- }
233
434
  const scenarioRows = await scenarioQuery.execute();
234
435
  if (scenarioRows.length === 0)
235
436
  return [];
@@ -258,24 +459,41 @@ export async function queryIncompleteEntities(db, projectId, featureStartedAt) {
258
459
  // A new entity version (created by the file watcher) may not have direct
259
460
  // analyses, but an older version (same name+filePath) might. This matches
260
461
  // getAllEntities() behavior which inherits analyses across versions.
261
- const entityNames = [
262
- ...new Set(entityRows.map((r) => r.name).filter(Boolean)),
462
+ // IMPORTANT: Must match by name+filePath, not name alone. When a component
463
+ // is extracted to a new file, the old version (different filePath) may have
464
+ // analyses but getAllEntities() won't inherit across different file paths.
465
+ const entityFilePathMap = new Map(entityRows.map((r) => [r.sha, r.file_path]));
466
+ const entityKeys = [
467
+ ...new Set(entityRows
468
+ .map((r) => `${r.name}::${r.file_path}`)
469
+ .filter((k) => !k.startsWith('::') && !k.endsWith('::'))),
263
470
  ];
264
- let namesWithInheritedAnalyses = new Set();
265
- if (entityNames.length > 0) {
471
+ let keysWithInheritedAnalyses = new Set();
472
+ if (entityKeys.length > 0) {
473
+ // We need to find entities that share name+filePath AND have analyses.
474
+ // Since Kysely doesn't support WHERE (name || '::' || file_path) IN (...),
475
+ // query by the entity names and filter by filePath in JS.
476
+ const entityNames = [
477
+ ...new Set(entityRows.map((r) => r.name).filter(Boolean)),
478
+ ];
266
479
  const siblingRows = await db
267
480
  .selectFrom('entities')
268
481
  .innerJoin('analyses', 'analyses.entity_sha', 'entities.sha')
269
- .select('entities.name')
482
+ .select(['entities.name', 'entities.file_path'])
270
483
  .where('entities.name', 'in', entityNames)
271
- .groupBy('entities.name')
484
+ .groupBy(['entities.name', 'entities.file_path'])
272
485
  .execute();
273
- namesWithInheritedAnalyses = new Set(siblingRows.map((r) => r.name));
486
+ keysWithInheritedAnalyses = new Set(siblingRows.map((r) => `${r.name}::${r.file_path}`));
274
487
  }
275
- // Filter out entities that have inherited analyses
488
+ // Filter out entities that have inherited analyses (same name+filePath)
276
489
  const trulyIncompleteShas = incompleteShas.filter((r) => {
277
- const name = entityNameMap.get(r.entity_sha);
278
- return !name || !namesWithInheritedAnalyses.has(name);
490
+ const sha = r.entity_sha;
491
+ const name = entityNameMap.get(sha);
492
+ const filePath = entityFilePathMap.get(sha);
493
+ if (!name)
494
+ return false; // No entity record (phantom SHA) — skip, not fixable by analysis
495
+ const key = `${name}::${filePath}`;
496
+ return !keysWithInheritedAnalyses.has(key);
279
497
  });
280
498
  if (trulyIncompleteShas.length === 0)
281
499
  return [];
@@ -293,12 +511,34 @@ export async function queryIncompleteEntities(db, projectId, featureStartedAt) {
293
511
  r.entity_sha,
294
512
  r.component_name,
295
513
  ]));
514
+ // Step 6: Determine preExisting flag — if featureStartedAt is provided,
515
+ // check which entity SHAs have at least one scenario created/updated
516
+ // during the session. Those without any are pre-existing issues.
517
+ let sessionShas = new Set();
518
+ if (featureStartedAt) {
519
+ const sqliteTimestamp = featureStartedAt
520
+ .replace('T', ' ')
521
+ .replace(/\.\d{3}Z$/, '');
522
+ const sessionRows = await db
523
+ .selectFrom('editor_scenarios')
524
+ .select('entity_sha')
525
+ .where('project_id', '=', projectId)
526
+ .where('entity_sha', 'in', trulyIncompleteShalist)
527
+ .where((eb) => eb.or([
528
+ eb('created_at', '>=', sqliteTimestamp),
529
+ eb('updated_at', '>=', sqliteTimestamp),
530
+ ]))
531
+ .groupBy('entity_sha')
532
+ .execute();
533
+ sessionShas = new Set(sessionRows.map((r) => r.entity_sha));
534
+ }
296
535
  return trulyIncompleteShas.map((r) => {
297
536
  const sha = r.entity_sha;
298
537
  return {
299
538
  entitySha: sha,
300
539
  name: entityNameMap.get(sha) || scenarioNameMap.get(sha) || 'Unknown',
301
540
  scenarioCount: Number(r.count),
541
+ preExisting: featureStartedAt ? !sessionShas.has(sha) : false,
302
542
  };
303
543
  });
304
544
  }
@@ -330,7 +570,7 @@ export async function queryMiscategorizedScenarios(db, projectId, featureStarted
330
570
  }
331
571
  const rows = await query.execute();
332
572
  // Filter to only rows where URL is NOT an isolation route
333
- const miscategorized = rows.filter((r) => r.url && !r.url.includes('/isolated-components'));
573
+ const miscategorized = rows.filter((r) => r.url && !isIsolationUrl(r.url));
334
574
  if (miscategorized.length === 0)
335
575
  return [];
336
576
  // Group by (component_name, url)
@@ -385,4 +625,220 @@ export async function queryScenarioCounts(db, projectId, featureStartedAt) {
385
625
  }
386
626
  return counts;
387
627
  }
628
+ /**
629
+ * Query scenario counts per page file path for app-level scenarios.
630
+ *
631
+ * App-level scenarios have `component_name = null` and are linked to pages
632
+ * via `page_file_path`. This mirrors `queryScenarioCounts` but groups by
633
+ * `page_file_path` instead of `component_name`.
634
+ */
635
+ export async function queryPageScenarioCounts(db, projectId, featureStartedAt) {
636
+ let query = db
637
+ .selectFrom('editor_scenarios')
638
+ .select(['page_file_path'])
639
+ .select(db.fn.count('id').as('count'))
640
+ .where('project_id', '=', projectId)
641
+ .where('component_name', 'is', null)
642
+ .where('page_file_path', 'is not', null)
643
+ .groupBy('page_file_path');
644
+ if (featureStartedAt) {
645
+ const sqliteTimestamp = featureStartedAt
646
+ .replace('T', ' ')
647
+ .replace(/\.\d{3}Z$/, '');
648
+ query = query.where((eb) => eb.or([
649
+ eb('created_at', '>=', sqliteTimestamp),
650
+ eb('updated_at', '>=', sqliteTimestamp),
651
+ ]));
652
+ }
653
+ const rows = await query.execute();
654
+ const counts = {};
655
+ for (const row of rows) {
656
+ if (row.page_file_path) {
657
+ counts[row.page_file_path] = Number(row.count);
658
+ }
659
+ }
660
+ return counts;
661
+ }
662
+ // ─── Unassociated Scenarios ───────────────────────────────────────────
663
+ /**
664
+ * Find scenarios with NULL entity_sha that have a file path
665
+ * (component_path or page_file_path). These scenarios were registered
666
+ * before entity records existed in the DB — typically because a subagent
667
+ * registered scenarios without running analyze-imports first.
668
+ *
669
+ * Fix: run `codeyam editor analyze-imports` to create entity records,
670
+ * then entity_sha backfill will associate them automatically.
671
+ *
672
+ * Optionally scoped to the current feature session via featureStartedAt.
673
+ */
674
+ export async function queryUnassociatedScenarios(db, projectId, featureStartedAt) {
675
+ let query = db
676
+ .selectFrom('editor_scenarios')
677
+ .select(['component_name', 'component_path', 'page_file_path', 'name'])
678
+ .where('project_id', '=', projectId)
679
+ .where('entity_sha', 'is', null)
680
+ .where((eb) => eb.or([
681
+ eb('component_path', 'is not', null),
682
+ eb('page_file_path', 'is not', null),
683
+ ]));
684
+ if (featureStartedAt) {
685
+ const sqliteTimestamp = featureStartedAt
686
+ .replace('T', ' ')
687
+ .replace(/\.\d{3}Z$/, '');
688
+ query = query.where((eb) => eb.or([
689
+ eb('created_at', '>=', sqliteTimestamp),
690
+ eb('updated_at', '>=', sqliteTimestamp),
691
+ ]));
692
+ }
693
+ const rows = await query.execute();
694
+ if (rows.length === 0)
695
+ return [];
696
+ // Group by file path (component_path or page_file_path)
697
+ const groups = new Map();
698
+ for (const row of rows) {
699
+ const r = row;
700
+ const filePath = r.component_path || r.page_file_path;
701
+ const existing = groups.get(filePath);
702
+ if (existing) {
703
+ existing.scenarioNames.push(r.name);
704
+ }
705
+ else {
706
+ // Derive a display name: use component_name if available,
707
+ // otherwise extract from file path (e.g., "src/lib/LibraryApp.tsx" → "LibraryApp")
708
+ const displayName = r.component_name ||
709
+ filePath
710
+ .split('/')
711
+ .pop()
712
+ ?.replace(/\.\w+$/, '') ||
713
+ filePath;
714
+ groups.set(filePath, {
715
+ name: displayName,
716
+ filePath,
717
+ scenarioNames: [r.name],
718
+ });
719
+ }
720
+ }
721
+ return [...groups.values()].map((g) => ({
722
+ name: g.name,
723
+ filePath: g.filePath,
724
+ scenarioCount: g.scenarioNames.length,
725
+ scenarioNames: g.scenarioNames,
726
+ }));
727
+ }
728
+ // ─── Duplicate Name Detection ─────────────────────────────────────────
729
+ /**
730
+ * Detect glossary entries that share the same `name`.
731
+ *
732
+ * Returns a Map of name → entries[] for names that appear more than once.
733
+ * Single-occurrence names are excluded. Used to warn Claude that ambiguous
734
+ * names will make audit output confusing (e.g., three entries all named "Page").
735
+ */
736
+ export function detectDuplicateNames(entries) {
737
+ const groups = new Map();
738
+ for (const entry of entries) {
739
+ const existing = groups.get(entry.name);
740
+ if (existing)
741
+ existing.push(entry);
742
+ else
743
+ groups.set(entry.name, [entry]);
744
+ }
745
+ // Only return groups with duplicates
746
+ for (const [name, group] of groups) {
747
+ if (group.length <= 1)
748
+ groups.delete(name);
749
+ }
750
+ return groups;
751
+ }
752
+ /**
753
+ * Identify scenarios that need recapture because their entity (or an entity
754
+ * in their dependency tree) has changed.
755
+ *
756
+ * Each scenario's entity name is resolved from its entity_sha (which points
757
+ * to the default export for app-level scenarios). The caller joins
758
+ * editor_scenarios.entity_sha → entities.name before calling this function.
759
+ *
760
+ * A scenario needs recapture when its entity has status 'edited' or 'impacted'
761
+ * AND the scenario was NOT re-registered in the current feature session.
762
+ */
763
+ export function identifyScenariosNeedingRecapture(params) {
764
+ const { scenarios, entityChangeStatus } = params;
765
+ if (!entityChangeStatus || Object.keys(entityChangeStatus).length === 0) {
766
+ return [];
767
+ }
768
+ const result = [];
769
+ for (const scenario of scenarios) {
770
+ if (scenario.updatedInSession)
771
+ continue;
772
+ if (!scenario.entityName)
773
+ continue;
774
+ const changeStatus = entityChangeStatus[scenario.entityName];
775
+ if (!changeStatus)
776
+ continue;
777
+ // "new" entities need initial scenario creation, not recapture.
778
+ // Only "edited" and "impacted" entities have stale screenshots.
779
+ if (changeStatus.status === 'new')
780
+ continue;
781
+ result.push({
782
+ scenarioName: scenario.name,
783
+ entityName: scenario.entityName,
784
+ status: changeStatus,
785
+ });
786
+ }
787
+ return result;
788
+ }
789
+ // ─── Client Error Aggregation ─────────────────────────────────────────
790
+ /**
791
+ * Aggregate client errors by component name using scenario metadata.
792
+ *
793
+ * Given a map of scenario ID → { scenarioName, errors } and a list of
794
+ * scenario metadata (with componentName from the DB), group errors by
795
+ * the component they belong to.
796
+ *
797
+ * For component scenarios: use the `componentName` field directly.
798
+ * For app-level scenarios (no componentName): derive the entity name
799
+ * using `scenarioEntityName()` — the same canonical function used by
800
+ * recapture detection and entity change status. This ensures the keys
801
+ * match what `computeAudit` checks against glossary entry names.
802
+ *
803
+ * This replaces the fragile "parse component name from scenario name"
804
+ * approach which fails for app-level scenarios like "Full Page with Library".
805
+ */
806
+ export function aggregateClientErrorsByComponent(clientErrors, scenarioMetadata) {
807
+ const result = {};
808
+ // Build a lookup from scenario name → component/entity name.
809
+ // Uses scenarioEntityName() for consistency with the rest of the system
810
+ // (recapture detection, entity change status, journal filtering).
811
+ const scenarioToComponent = new Map();
812
+ for (const meta of scenarioMetadata) {
813
+ const entityName = scenarioEntityName({
814
+ componentName: meta.componentName,
815
+ pageFilePath: meta.pageFilePath,
816
+ url: meta.url,
817
+ });
818
+ if (entityName) {
819
+ scenarioToComponent.set(meta.name, entityName);
820
+ }
821
+ }
822
+ for (const [, data] of Object.entries(clientErrors)) {
823
+ if (data.errors.length === 0)
824
+ continue;
825
+ // First try: look up via scenario metadata (authoritative)
826
+ let componentName = scenarioToComponent.get(data.scenarioName);
827
+ // Fallback: parse from scenario name convention "ComponentName - Variant"
828
+ if (!componentName) {
829
+ const dashIndex = data.scenarioName.indexOf(' - ');
830
+ componentName =
831
+ dashIndex >= 0
832
+ ? data.scenarioName.slice(0, dashIndex)
833
+ : data.scenarioName;
834
+ }
835
+ if (componentName) {
836
+ if (!result[componentName]) {
837
+ result[componentName] = [];
838
+ }
839
+ result[componentName].push(...data.errors);
840
+ }
841
+ }
842
+ return result;
843
+ }
388
844
  //# sourceMappingURL=editorAudit.js.map