@codeyam/codeyam-cli 0.1.0-staging.ae0de75 → 0.1.0-staging.b6c4c78

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 (420) 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 +6 -6
  4. package/analyzer-template/packages/ai/package.json +1 -1
  5. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +0 -33
  6. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +13 -7
  7. package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
  8. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +0 -98
  9. package/analyzer-template/packages/aws/package.json +1 -1
  10. package/analyzer-template/packages/database/package.json +1 -1
  11. package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +92 -0
  12. package/analyzer-template/packages/database/src/lib/loadEntities.ts +0 -6
  13. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +0 -65
  14. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +10 -0
  15. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
  16. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +92 -0
  17. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
  18. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  19. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +0 -6
  20. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  21. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  22. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +0 -25
  23. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  24. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts +2 -0
  25. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
  26. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js +2 -0
  27. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js.map +1 -1
  28. package/analyzer-template/packages/types/src/enums/ProjectFramework.ts +2 -0
  29. package/analyzer-template/packages/ui-components/package.json +1 -1
  30. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts +2 -0
  31. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
  32. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js +2 -0
  33. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js.map +1 -1
  34. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
  35. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
  36. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
  37. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
  38. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
  39. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
  40. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +45 -0
  41. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
  42. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +101 -47
  43. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
  44. package/codeyam-cli/src/commands/default.js +3 -46
  45. package/codeyam-cli/src/commands/default.js.map +1 -1
  46. package/codeyam-cli/src/commands/editor.js +2629 -329
  47. package/codeyam-cli/src/commands/editor.js.map +1 -1
  48. package/codeyam-cli/src/commands/init.js +68 -34
  49. package/codeyam-cli/src/commands/init.js.map +1 -1
  50. package/codeyam-cli/src/data/techStacks.js +77 -0
  51. package/codeyam-cli/src/data/techStacks.js.map +1 -0
  52. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +173 -0
  53. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
  54. package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js +46 -0
  55. package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js.map +1 -0
  56. package/codeyam-cli/src/utils/__tests__/devServerState.test.js +134 -0
  57. package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
  58. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +137 -0
  59. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
  60. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +742 -1
  61. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  62. package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js +76 -0
  63. package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js.map +1 -0
  64. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
  65. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
  66. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +181 -3
  67. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -1
  68. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +124 -0
  69. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
  70. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +223 -0
  71. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -0
  72. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
  73. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
  74. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +249 -2
  75. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -1
  76. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +555 -0
  77. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
  78. package/codeyam-cli/src/utils/__tests__/editorMigration.test.js +430 -0
  79. package/codeyam-cli/src/utils/__tests__/editorMigration.test.js.map +1 -0
  80. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +118 -1
  81. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -1
  82. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +209 -3
  83. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
  84. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +153 -0
  85. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -0
  86. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
  87. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
  88. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +221 -0
  89. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
  90. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +1114 -2
  91. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
  92. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +280 -0
  93. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
  94. package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js +66 -0
  95. package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js.map +1 -0
  96. package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js +53 -0
  97. package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js.map +1 -0
  98. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +1829 -0
  99. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
  100. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +107 -0
  101. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
  102. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +129 -0
  103. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
  104. package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js +118 -0
  105. package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js.map +1 -0
  106. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +227 -0
  107. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
  108. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +454 -0
  109. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -0
  110. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +26 -5
  111. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  112. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +51 -0
  113. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
  114. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +142 -0
  115. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -0
  116. package/codeyam-cli/src/utils/analysisRunner.js +3 -1
  117. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  118. package/codeyam-cli/src/utils/analyzer.js +9 -0
  119. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  120. package/codeyam-cli/src/utils/analyzerFinalization.js +100 -0
  121. package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
  122. package/codeyam-cli/src/utils/backgroundServer.js +94 -18
  123. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  124. package/codeyam-cli/src/utils/database.js +37 -2
  125. package/codeyam-cli/src/utils/database.js.map +1 -1
  126. package/codeyam-cli/src/utils/devServerState.js +71 -0
  127. package/codeyam-cli/src/utils/devServerState.js.map +1 -0
  128. package/codeyam-cli/src/utils/editorApi.js +79 -0
  129. package/codeyam-cli/src/utils/editorApi.js.map +1 -0
  130. package/codeyam-cli/src/utils/editorAudit.js +135 -7
  131. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  132. package/codeyam-cli/src/utils/editorBroadcastViewport.js +26 -0
  133. package/codeyam-cli/src/utils/editorBroadcastViewport.js.map +1 -0
  134. package/codeyam-cli/src/utils/editorCapture.js +102 -0
  135. package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
  136. package/codeyam-cli/src/utils/editorDevServer.js +100 -1
  137. package/codeyam-cli/src/utils/editorDevServer.js.map +1 -1
  138. package/codeyam-cli/src/utils/editorEntityChangeStatus.js +44 -0
  139. package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
  140. package/codeyam-cli/src/utils/editorEntityHelpers.js +129 -0
  141. package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -0
  142. package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
  143. package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
  144. package/codeyam-cli/src/utils/editorJournal.js +92 -4
  145. package/codeyam-cli/src/utils/editorJournal.js.map +1 -1
  146. package/codeyam-cli/src/utils/editorLoaderHelpers.js +140 -0
  147. package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
  148. package/codeyam-cli/src/utils/editorMigration.js +224 -0
  149. package/codeyam-cli/src/utils/editorMigration.js.map +1 -0
  150. package/codeyam-cli/src/utils/editorMockState.js +1 -1
  151. package/codeyam-cli/src/utils/editorPreloadHelpers.js +72 -1
  152. package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -1
  153. package/codeyam-cli/src/utils/editorPreview.js +72 -1
  154. package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
  155. package/codeyam-cli/src/utils/editorScenarioSwitch.js +112 -0
  156. package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
  157. package/codeyam-cli/src/utils/editorScenarios.js +349 -0
  158. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
  159. package/codeyam-cli/src/utils/editorSeedAdapter.js +352 -0
  160. package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
  161. package/codeyam-cli/src/utils/editorShouldRevalidate.js +21 -0
  162. package/codeyam-cli/src/utils/editorShouldRevalidate.js.map +1 -0
  163. package/codeyam-cli/src/utils/entityChangeStatus.js +360 -0
  164. package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
  165. package/codeyam-cli/src/utils/entityChangeStatus.server.js +196 -0
  166. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
  167. package/codeyam-cli/src/utils/install-skills.js +10 -1
  168. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  169. package/codeyam-cli/src/utils/parseRegisterArg.js +31 -0
  170. package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
  171. package/codeyam-cli/src/utils/progress.js +2 -2
  172. package/codeyam-cli/src/utils/progress.js.map +1 -1
  173. package/codeyam-cli/src/utils/routePatternMatching.js +129 -0
  174. package/codeyam-cli/src/utils/routePatternMatching.js.map +1 -0
  175. package/codeyam-cli/src/utils/scenarioCoverage.js +74 -0
  176. package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
  177. package/codeyam-cli/src/utils/scenariosManifest.js +244 -0
  178. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
  179. package/codeyam-cli/src/utils/serverState.js +30 -0
  180. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  181. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +47 -16
  182. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  183. package/codeyam-cli/src/utils/simulationGateMiddleware.js +8 -1
  184. package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
  185. package/codeyam-cli/src/utils/slugUtils.js +25 -0
  186. package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
  187. package/codeyam-cli/src/utils/syncMocksMiddleware.js +2 -2
  188. package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
  189. package/codeyam-cli/src/utils/webappDetection.js +21 -0
  190. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  191. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +40 -0
  192. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -0
  193. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +567 -0
  194. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -0
  195. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +146 -0
  196. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
  197. package/codeyam-cli/src/webserver/app/lib/clientErrors.js +65 -0
  198. package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
  199. package/codeyam-cli/src/webserver/app/lib/git.js +397 -0
  200. package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
  201. package/codeyam-cli/src/webserver/app/types/editor.js +8 -0
  202. package/codeyam-cli/src/webserver/app/types/editor.js.map +1 -0
  203. package/codeyam-cli/src/webserver/backgroundServer.js +18 -4
  204. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  205. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CzTDWkF2.js +1 -0
  206. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-C76mRRiF.js → EntityItem-BFbq6iFk.js} +5 -5
  207. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CQgyEGV-.js +1 -0
  208. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CobE682z.js → EntityTypeIcon-B6OMi58N.js} +9 -9
  209. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-DuYodzo1.js +1 -0
  210. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-CXo9EeCl.js +25 -0
  211. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DYCNb2It.js +3 -0
  212. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-BU_OAEMP.js → LoadingDots-By5zI316.js} +1 -1
  213. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-ceAyBX-H.js → LogViewer-CZgY3sxX.js} +3 -3
  214. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-djPLI-WV.js → ReportIssueModal-CnYYwRDw.js} +4 -4
  215. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CDoF7ZpU.js +1 -0
  216. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-B76aig_2.js → ScenarioViewer-DrnfvaLL.js} +3 -3
  217. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Df3UCi8k.js +34 -0
  218. package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CK7-NaPZ.js +1 -0
  219. package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-DRKR9T0U.js +1 -0
  220. package/codeyam-cli/src/webserver/build/client/assets/{_index-C96V0n15.js → _index-ClR-g3tY.js} +4 -4
  221. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BpKzcsJz.js → activity.(_tab)-DTH6ydEA.js} +8 -8
  222. package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
  223. package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
  224. package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-Duc5hnl7.js → addon-web-links-74hnHF59.js} +1 -1
  225. package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
  226. package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-D9hemwl6.js → agent-transcripts-B8CYhCO9.js} +7 -7
  227. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
  228. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
  229. package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
  230. package/codeyam-cli/src/webserver/build/client/assets/api.editor-rename-scenario-l0sNRNKZ.js +1 -0
  231. package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-seed-state-l0sNRNKZ.js +1 -0
  232. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-l0sNRNKZ.js +1 -0
  233. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-prompt-l0sNRNKZ.js +1 -0
  234. package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
  235. package/codeyam-cli/src/webserver/build/client/assets/{book-open-D_nMCFmP.js → book-open-CLaoh4ac.js} +2 -2
  236. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BH2h1Ea2.js → chevron-down-BZ2DZxbW.js} +2 -2
  237. package/codeyam-cli/src/webserver/build/client/assets/{chunk-JZWAC4HX-C4pqxYJB.js → chunk-JZWAC4HX-BBXArFPl.js} +13 -21
  238. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-DyIKORY6.js → circle-check-CT4unAk-.js} +2 -2
  239. package/codeyam-cli/src/webserver/build/client/assets/{copy-NDbZjXao.js → copy-zK0B6Nu-.js} +3 -3
  240. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-DJB0YQJL.js +41 -0
  241. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CkXFP_i-.js +1 -0
  242. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-DPw7NZHc.js +1 -0
  243. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-y_5LB2iU.js +58 -0
  244. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-DBa7T2FK.js +41 -0
  245. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CrjR3zZW.js → entity._sha._-BqAN7hyG.js} +3 -3
  246. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-BOi8kpwd.js +6 -0
  247. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-Dg1NhIms.js +6 -0
  248. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CJX6kkkV.js +6 -0
  249. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMvVHNXU.js → entity._sha_.edit._scenarioId-BhVjZhKg.js} +2 -2
  250. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DTvKq3TY.js → entry.client-_gzKltPN.js} +6 -6
  251. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-Daa96Fr1.js +1 -0
  252. package/codeyam-cli/src/webserver/build/client/assets/files-CV_17tZS.js +1 -0
  253. package/codeyam-cli/src/webserver/build/client/assets/git-D-YXmMbR.js +1 -0
  254. package/codeyam-cli/src/webserver/build/client/assets/globals-BCTpZEY8.css +1 -0
  255. package/codeyam-cli/src/webserver/build/client/assets/index-Blo6EK8G.js +15 -0
  256. package/codeyam-cli/src/webserver/build/client/assets/{index-10oVnAAH.js → index-BsX0F-9C.js} +1 -1
  257. package/codeyam-cli/src/webserver/build/client/assets/{index-BcvgDzbZ.js → index-CCrgCshv.js} +1 -1
  258. package/codeyam-cli/src/webserver/build/client/assets/jsx-runtime-D_zvdyIk.js +9 -0
  259. package/codeyam-cli/src/webserver/build/client/assets/labs-Byazq8Pv.js +1 -0
  260. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-BAXYRVEO.js → loader-circle-DVQ0oHR7.js} +2 -2
  261. package/codeyam-cli/src/webserver/build/client/assets/manifest-5f1c29f5.js +1 -0
  262. package/codeyam-cli/src/webserver/build/client/assets/memory-b-VmA2Vj.js +101 -0
  263. package/codeyam-cli/src/webserver/build/client/assets/{pause-DTAcYxBt.js → pause-DGcndCAa.js} +3 -3
  264. package/codeyam-cli/src/webserver/build/client/assets/root-BBCQJ_ZM.js +67 -0
  265. package/codeyam-cli/src/webserver/build/client/assets/{search-fKo7v0Zo.js → search-C0Uw0bcK.js} +2 -2
  266. package/codeyam-cli/src/webserver/build/client/assets/settings-OoNgHIfW.js +1 -0
  267. package/codeyam-cli/src/webserver/build/client/assets/simulations-Bcemfu8a.js +1 -0
  268. package/codeyam-cli/src/webserver/build/client/assets/{terminal-BG4heKCG.js → terminal-BgMmG7R9.js} +3 -3
  269. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-DtSmdtM4.js → triangle-alert-Cs87hJYK.js} +2 -2
  270. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BR3Rs7JY.js +1 -0
  271. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-C14nCb1q.js → useLastLogLine-BxxP_XF9.js} +1 -1
  272. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-BermyNU5.js +1 -0
  273. package/codeyam-cli/src/webserver/build/client/assets/useToast-a_QN_W9_.js +1 -0
  274. package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
  275. package/codeyam-cli/src/webserver/build/server/assets/index-BLKsJR3o.js +1 -0
  276. package/codeyam-cli/src/webserver/build/server/assets/init-C2iMAqYu.js +10 -0
  277. package/codeyam-cli/src/webserver/build/server/assets/server-build-DR42Xd5a.js +489 -0
  278. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  279. package/codeyam-cli/src/webserver/build-info.json +5 -5
  280. package/codeyam-cli/src/webserver/editorProxy.js +511 -50
  281. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
  282. package/codeyam-cli/src/webserver/idleDetector.js +73 -0
  283. package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
  284. package/codeyam-cli/src/webserver/mockStateEvents.js +28 -0
  285. package/codeyam-cli/src/webserver/mockStateEvents.js.map +1 -0
  286. package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
  287. package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +242 -3
  288. package/codeyam-cli/src/webserver/scripts/journalCapture.ts +94 -4
  289. package/codeyam-cli/src/webserver/server.js +99 -16
  290. package/codeyam-cli/src/webserver/server.js.map +1 -1
  291. package/codeyam-cli/src/webserver/terminalServer.js +186 -39
  292. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  293. package/codeyam-cli/templates/chrome-extension-react/EXTENSION_SETUP.md +75 -0
  294. package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
  295. package/codeyam-cli/templates/chrome-extension-react/gitignore +15 -0
  296. package/codeyam-cli/templates/chrome-extension-react/index.html +12 -0
  297. package/codeyam-cli/templates/chrome-extension-react/package.json +27 -0
  298. package/codeyam-cli/templates/chrome-extension-react/popup.html +12 -0
  299. package/codeyam-cli/templates/chrome-extension-react/public/manifest.json +15 -0
  300. package/codeyam-cli/templates/chrome-extension-react/src/background/service-worker.ts +7 -0
  301. package/codeyam-cli/templates/chrome-extension-react/src/globals.css +6 -0
  302. package/codeyam-cli/templates/chrome-extension-react/src/lib/storage.ts +37 -0
  303. package/codeyam-cli/templates/chrome-extension-react/src/popup/App.tsx +12 -0
  304. package/codeyam-cli/templates/chrome-extension-react/src/popup/main.tsx +10 -0
  305. package/codeyam-cli/templates/chrome-extension-react/tsconfig.json +24 -0
  306. package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +41 -0
  307. package/codeyam-cli/templates/codeyam-editor-claude.md +84 -5
  308. package/codeyam-cli/templates/editor-step-hook.py +188 -21
  309. package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +89 -0
  310. package/codeyam-cli/templates/expo-react-native/README.md +41 -0
  311. package/codeyam-cli/templates/expo-react-native/app/(tabs)/_layout.tsx +33 -0
  312. package/codeyam-cli/templates/expo-react-native/app/(tabs)/index.tsx +12 -0
  313. package/codeyam-cli/templates/expo-react-native/app/(tabs)/settings.tsx +12 -0
  314. package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +12 -0
  315. package/codeyam-cli/templates/expo-react-native/app.json +18 -0
  316. package/codeyam-cli/templates/expo-react-native/babel.config.js +9 -0
  317. package/codeyam-cli/templates/expo-react-native/gitignore +12 -0
  318. package/codeyam-cli/templates/expo-react-native/global.css +3 -0
  319. package/codeyam-cli/templates/expo-react-native/lib/storage.ts +32 -0
  320. package/codeyam-cli/templates/expo-react-native/metro.config.js +6 -0
  321. package/codeyam-cli/templates/expo-react-native/nativewind-env.d.ts +1 -0
  322. package/codeyam-cli/templates/expo-react-native/package.json +38 -0
  323. package/codeyam-cli/templates/expo-react-native/tailwind.config.js +10 -0
  324. package/codeyam-cli/templates/expo-react-native/tsconfig.json +10 -0
  325. package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_PATTERNS.md +308 -0
  326. package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_UPGRADE.md +304 -0
  327. package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +126 -0
  328. package/codeyam-cli/templates/nextjs-prisma-sqlite/FEATURE_PATTERNS.md +37 -0
  329. package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
  330. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
  331. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +9 -4
  332. package/codeyam-cli/templates/nextjs-prisma-sqlite/env +4 -0
  333. package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +21 -0
  334. package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +5 -1
  335. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +4 -1
  336. package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +127 -0
  337. package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
  338. package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
  339. package/codeyam-cli/templates/{nextjs-prisma-sqlite/PRISMA_SETUP.md → nextjs-prisma-supabase/SUPABASE_SETUP.md} +37 -17
  340. package/codeyam-cli/templates/nextjs-prisma-supabase/app/api/todos/route.ts +17 -0
  341. package/codeyam-cli/templates/nextjs-prisma-supabase/app/globals.css +26 -0
  342. package/codeyam-cli/templates/nextjs-prisma-supabase/app/layout.tsx +34 -0
  343. package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/prisma.ts +20 -0
  344. package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/supabase.ts +12 -0
  345. package/codeyam-cli/templates/nextjs-prisma-supabase/app/page.tsx +10 -0
  346. package/codeyam-cli/templates/nextjs-prisma-supabase/env +9 -0
  347. package/codeyam-cli/templates/nextjs-prisma-supabase/eslint.config.mjs +11 -0
  348. package/codeyam-cli/templates/nextjs-prisma-supabase/gitignore +40 -0
  349. package/codeyam-cli/templates/nextjs-prisma-supabase/next.config.ts +11 -0
  350. package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +37 -0
  351. package/codeyam-cli/templates/nextjs-prisma-supabase/postcss.config.mjs +7 -0
  352. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/schema.prisma +27 -0
  353. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/seed.ts +39 -0
  354. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma.config.ts +12 -0
  355. package/codeyam-cli/templates/nextjs-prisma-supabase/tsconfig.json +34 -0
  356. package/codeyam-cli/templates/seed-adapters/supabase.ts +282 -0
  357. package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +2 -2
  358. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +159 -17
  359. package/codeyam-cli/templates/skills/codeyam-memory/SKILL.md +10 -10
  360. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
  361. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
  362. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
  363. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
  364. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
  365. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
  366. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
  367. package/package.json +15 -10
  368. package/packages/ai/src/lib/generateExecutionFlows.js +0 -11
  369. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
  370. package/packages/analyze/src/lib/ProjectAnalyzer.js +10 -4
  371. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  372. package/packages/analyze/src/lib/asts/index.js +4 -2
  373. package/packages/analyze/src/lib/asts/index.js.map +1 -1
  374. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +0 -40
  375. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
  376. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +92 -0
  377. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
  378. package/packages/database/src/lib/loadEntities.js +0 -6
  379. package/packages/database/src/lib/loadEntities.js.map +1 -1
  380. package/packages/database/src/lib/updateCommitMetadata.js +0 -25
  381. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  382. package/packages/types/src/enums/ProjectFramework.js +2 -0
  383. package/packages/types/src/enums/ProjectFramework.js.map +1 -1
  384. package/scripts/npm-post-install.cjs +22 -0
  385. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-DmJveP3T.js +0 -1
  386. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-g3saevPb.js +0 -1
  387. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +0 -1
  388. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DYFW3lDD.js +0 -25
  389. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DLeucoVX.js +0 -3
  390. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BED4B6sP.js +0 -1
  391. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +0 -34
  392. package/codeyam-cli/src/webserver/build/client/assets/Terminal-wkqC0AQk.js +0 -41
  393. package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-C8OKAR5x.js +0 -1
  394. package/codeyam-cli/src/webserver/build/client/assets/addon-fit-CUXOrorO.js +0 -1
  395. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CMT1jU2q.js +0 -21
  396. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BiM6z3Do.js +0 -1
  397. package/codeyam-cli/src/webserver/build/client/assets/editor-CdjF_fX6.js +0 -8
  398. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-D8ILZMR0.js +0 -6
  399. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-C28BiQzt.js +0 -6
  400. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +0 -6
  401. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-cPo8LiG3.js +0 -1
  402. package/codeyam-cli/src/webserver/build/client/assets/files-DO4CZ16O.js +0 -1
  403. package/codeyam-cli/src/webserver/build/client/assets/git-CFCTYk9I.js +0 -15
  404. package/codeyam-cli/src/webserver/build/client/assets/globals-B17TBSS6.css +0 -1
  405. package/codeyam-cli/src/webserver/build/client/assets/labs-Zk7ryIM1.js +0 -1
  406. package/codeyam-cli/src/webserver/build/client/assets/manifest-b8fd6b07.js +0 -1
  407. package/codeyam-cli/src/webserver/build/client/assets/memory-FweZHj5U.js +0 -93
  408. package/codeyam-cli/src/webserver/build/client/assets/root-DUKqhFlb.js +0 -67
  409. package/codeyam-cli/src/webserver/build/client/assets/settings-DfuTtcJP.js +0 -1
  410. package/codeyam-cli/src/webserver/build/client/assets/simulations-B3aOzpCZ.js +0 -1
  411. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-ByhSyh0W.js +0 -1
  412. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-O-jkvSPx.js +0 -1
  413. package/codeyam-cli/src/webserver/build/client/assets/useToast-9FIWuYfK.js +0 -1
  414. package/codeyam-cli/src/webserver/build/server/assets/index-BLhjL9Xi.js +0 -1
  415. package/codeyam-cli/src/webserver/build/server/assets/server-build-DyMuI5mU.js +0 -363
  416. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.sh +0 -108
  417. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.sh +0 -69
  418. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.sh +0 -12
  419. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter.jq +0 -45
  420. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.sh +0 -139
@@ -0,0 +1,124 @@
1
+ import { computeEntityChangeStatusForEditor } from "../editorEntityChangeStatus.js";
2
+ import * as entityChangeStatusServerModule from "../entityChangeStatus.server/index.js";
3
+ import * as gitModule from "../../webserver/app/lib/git/index.js";
4
+ import * as databaseModule from "../database/index.js";
5
+ import * as codeyamDb from "../../../../packages/database/index.js";
6
+ // Mock external dependencies
7
+ jest.mock('../../webserver/app/lib/git', () => ({
8
+ getGitStatusForProject: jest.fn(),
9
+ }));
10
+ jest.mock('../database', () => ({
11
+ initializeEnvironment: jest.fn(),
12
+ }));
13
+ jest.mock('../../../../packages/database/index.js', () => ({
14
+ loadEntities: jest.fn(),
15
+ }));
16
+ jest.mock('../entityChangeStatus.server', () => ({
17
+ detectFirstFeature: jest.fn(),
18
+ scanPageFilePaths: jest.fn(),
19
+ }));
20
+ describe('computeEntityChangeStatusForEditor', () => {
21
+ const mockGetGitStatus = gitModule.getGitStatusForProject;
22
+ const mockDetectFirstFeature = entityChangeStatusServerModule.detectFirstFeature;
23
+ const mockScanPageFilePaths = entityChangeStatusServerModule.scanPageFilePaths;
24
+ const mockInitEnv = databaseModule.initializeEnvironment;
25
+ const mockLoadEntities = codeyamDb.loadEntities;
26
+ beforeEach(() => {
27
+ jest.clearAllMocks();
28
+ mockDetectFirstFeature.mockReturnValue(false);
29
+ mockScanPageFilePaths.mockReturnValue({ map: {}, allFiles: [] });
30
+ mockGetGitStatus.mockReturnValue([]);
31
+ mockInitEnv.mockResolvedValue(undefined);
32
+ mockLoadEntities.mockResolvedValue([]);
33
+ });
34
+ it('should return empty status when no git changes', async () => {
35
+ mockGetGitStatus.mockReturnValue([]);
36
+ const result = await computeEntityChangeStatusForEditor({
37
+ projectRoot: '/test',
38
+ scenarioInputs: [
39
+ { componentName: 'Button', componentPath: 'src/Button.tsx' },
40
+ ],
41
+ });
42
+ expect(result.entityChangeStatus).toEqual({});
43
+ });
44
+ it('should detect new entities from added files', async () => {
45
+ mockDetectFirstFeature.mockReturnValue(false);
46
+ mockGetGitStatus.mockReturnValue([
47
+ { path: 'src/Button.tsx', status: 'added' },
48
+ ]);
49
+ mockLoadEntities.mockResolvedValue([]);
50
+ const result = await computeEntityChangeStatusForEditor({
51
+ projectRoot: '/test',
52
+ scenarioInputs: [
53
+ { componentName: 'Button', componentPath: 'src/Button.tsx' },
54
+ ],
55
+ });
56
+ expect(result.entityChangeStatus).toEqual({
57
+ Button: { status: 'new' },
58
+ });
59
+ });
60
+ it('should detect edited entities from modified files', async () => {
61
+ mockGetGitStatus.mockReturnValue([
62
+ { path: 'src/Card.tsx', status: 'modified' },
63
+ ]);
64
+ mockLoadEntities.mockResolvedValue([]);
65
+ const result = await computeEntityChangeStatusForEditor({
66
+ projectRoot: '/test',
67
+ scenarioInputs: [
68
+ { componentName: 'Card', componentPath: 'src/Card.tsx' },
69
+ ],
70
+ });
71
+ expect(result.entityChangeStatus).toEqual({
72
+ Card: { status: 'edited' },
73
+ });
74
+ });
75
+ it('should include page entity names from scanned pages', async () => {
76
+ mockScanPageFilePaths.mockReturnValue({
77
+ map: {
78
+ Home: 'app/page.tsx',
79
+ Drinks: 'app/drinks/page.tsx',
80
+ },
81
+ allFiles: ['app/page.tsx', 'app/drinks/page.tsx'],
82
+ });
83
+ mockGetGitStatus.mockReturnValue([
84
+ { path: 'app/page.tsx', status: 'modified' },
85
+ ]);
86
+ mockLoadEntities.mockResolvedValue([]);
87
+ const result = await computeEntityChangeStatusForEditor({
88
+ projectRoot: '/test',
89
+ scenarioInputs: [{ url: '/' }],
90
+ });
91
+ expect(result.pageEntityNames).toContain('Home');
92
+ expect(result.pageEntityNames).toContain('Drinks');
93
+ expect(result.entityChangeStatus['Home']).toEqual({ status: 'edited' });
94
+ });
95
+ it('should treat all files as new for first feature', async () => {
96
+ mockDetectFirstFeature.mockReturnValue(true);
97
+ mockGetGitStatus.mockReturnValue([
98
+ { path: 'src/Nav.tsx', status: 'modified' },
99
+ ]);
100
+ mockLoadEntities.mockResolvedValue([]);
101
+ const result = await computeEntityChangeStatusForEditor({
102
+ projectRoot: '/test',
103
+ scenarioInputs: [{ componentName: 'Nav', componentPath: 'src/Nav.tsx' }],
104
+ });
105
+ expect(result.entityChangeStatus).toEqual({
106
+ Nav: { status: 'new' },
107
+ });
108
+ });
109
+ it('should include glossary inputs in change status', async () => {
110
+ mockGetGitStatus.mockReturnValue([
111
+ { path: 'src/utils.ts', status: 'modified' },
112
+ ]);
113
+ mockLoadEntities.mockResolvedValue([]);
114
+ const result = await computeEntityChangeStatusForEditor({
115
+ projectRoot: '/test',
116
+ scenarioInputs: [],
117
+ glossaryInputs: [{ name: 'formatDate', filePath: 'src/utils.ts' }],
118
+ });
119
+ expect(result.entityChangeStatus).toEqual({
120
+ formatDate: { status: 'edited' },
121
+ });
122
+ });
123
+ });
124
+ //# sourceMappingURL=editorEntityChangeStatus.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorEntityChangeStatus.test.js","sourceRoot":"","sources":["../../../../../src/utils/__tests__/editorEntityChangeStatus.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAA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CAAC;YACxC,UAAU,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;SACjC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,223 @@
1
+ import { groupScenarios, buildEntityShaMap, isEntityComplete, findBrokenEntities, resolveClientFocusedEntity, } from "../editorEntityHelpers.js";
2
+ function makeScenario(overrides) {
3
+ return {
4
+ id: overrides.id || `id-${overrides.name}`,
5
+ name: overrides.name,
6
+ description: '',
7
+ componentName: null,
8
+ componentPath: null,
9
+ screenshotPath: null,
10
+ url: null,
11
+ type: null,
12
+ viewportWidth: null,
13
+ viewportHeight: null,
14
+ dimension: null,
15
+ dimensions: null,
16
+ screenshotPaths: null,
17
+ pageFilePath: null,
18
+ entitySha: null,
19
+ displayName: null,
20
+ updatedAt: null,
21
+ ...overrides,
22
+ };
23
+ }
24
+ describe('groupScenarios', () => {
25
+ it('should group component scenarios by componentName', () => {
26
+ const scenarios = [
27
+ makeScenario({ name: 'NavBar - Active', componentName: 'NavBar' }),
28
+ makeScenario({ name: 'NavBar - Idle', componentName: 'NavBar' }),
29
+ makeScenario({ name: 'Button - Default', componentName: 'Button' }),
30
+ ];
31
+ const { pageGroups, componentGroups } = groupScenarios(scenarios);
32
+ expect(pageGroups.size).toBe(0);
33
+ expect(componentGroups.get('NavBar')?.length).toBe(2);
34
+ expect(componentGroups.get('Button')?.length).toBe(1);
35
+ });
36
+ it('should group page scenarios by displayName from DB', () => {
37
+ const scenarios = [
38
+ makeScenario({
39
+ name: 'Home - Default',
40
+ url: '/',
41
+ displayName: 'Home',
42
+ }),
43
+ makeScenario({
44
+ name: 'Home - Full',
45
+ url: '/',
46
+ displayName: 'Home',
47
+ }),
48
+ ];
49
+ const { pageGroups } = groupScenarios(scenarios);
50
+ expect(pageGroups.get('Home')?.length).toBe(2);
51
+ });
52
+ it('should fall back to pageNameFromUrl when displayName is null', () => {
53
+ const scenarios = [makeScenario({ name: 'Home - Default', url: '/' })];
54
+ const { pageGroups } = groupScenarios(scenarios);
55
+ expect(pageGroups.has('Home')).toBe(true);
56
+ });
57
+ it('should use routeDisplayName for Next.js pageFilePath', () => {
58
+ const scenarios = [
59
+ makeScenario({
60
+ name: 'About',
61
+ url: '/about',
62
+ pageFilePath: 'app/about/page.tsx',
63
+ }),
64
+ ];
65
+ const { pageGroups } = groupScenarios(scenarios);
66
+ expect(pageGroups.has('About')).toBe(true);
67
+ });
68
+ it('should not use pageFilePath for non-app/ files', () => {
69
+ const scenarios = [
70
+ makeScenario({
71
+ name: 'Home - Default',
72
+ url: '/',
73
+ pageFilePath: 'src/App.tsx',
74
+ }),
75
+ ];
76
+ const { pageGroups } = groupScenarios(scenarios);
77
+ // Should use pageNameFromUrl('/') = 'Home', not buildRoutePattern('src/App.tsx')
78
+ expect(pageGroups.has('Home')).toBe(true);
79
+ });
80
+ it('should sort component groups alphabetically', () => {
81
+ const scenarios = [
82
+ makeScenario({ name: 'Z - Default', componentName: 'Zebra' }),
83
+ makeScenario({ name: 'A - Default', componentName: 'Apple' }),
84
+ ];
85
+ const { componentGroups } = groupScenarios(scenarios);
86
+ const keys = [...componentGroups.keys()];
87
+ expect(keys).toEqual(['Apple', 'Zebra']);
88
+ });
89
+ });
90
+ describe('buildEntityShaMap', () => {
91
+ it('should map group names to entity SHAs from scenarios', () => {
92
+ const pageGroups = new Map([
93
+ [
94
+ 'Home',
95
+ [makeScenario({ name: 'Home - Default', entitySha: 'sha-home' })],
96
+ ],
97
+ ]);
98
+ const componentGroups = new Map([
99
+ [
100
+ 'NavBar',
101
+ [makeScenario({ name: 'NavBar - Default', entitySha: 'sha-nav' })],
102
+ ],
103
+ ]);
104
+ const map = buildEntityShaMap(pageGroups, componentGroups);
105
+ expect(map.get('Home')).toBe('sha-home');
106
+ expect(map.get('NavBar')).toBe('sha-nav');
107
+ });
108
+ it('should skip groups where no scenario has entitySha', () => {
109
+ const pageGroups = new Map([
110
+ ['Home', [makeScenario({ name: 'Home - Default' })]],
111
+ ]);
112
+ const map = buildEntityShaMap(pageGroups, new Map());
113
+ expect(map.has('Home')).toBe(false);
114
+ });
115
+ });
116
+ describe('isEntityComplete', () => {
117
+ const allEntities = [
118
+ {
119
+ sha: 'sha-a',
120
+ name: 'App',
121
+ entityType: 'visual',
122
+ filePath: 'src/App.tsx',
123
+ },
124
+ {
125
+ sha: 'sha-b',
126
+ name: 'Lib',
127
+ entityType: 'visual',
128
+ filePath: 'src/Lib.tsx',
129
+ },
130
+ ];
131
+ it('should return true if SHA is in analyzedShas', () => {
132
+ const analyzedShas = new Set(['sha-a']);
133
+ const namesWithImports = new Set();
134
+ expect(isEntityComplete('sha-a', analyzedShas, allEntities, namesWithImports)).toBe(true);
135
+ });
136
+ it('should return true if entity name has imports', () => {
137
+ const analyzedShas = new Set();
138
+ const namesWithImports = new Set(['App']);
139
+ expect(isEntityComplete('sha-a', analyzedShas, allEntities, namesWithImports)).toBe(true);
140
+ });
141
+ it('should return false if entity has no analysis and no imports', () => {
142
+ const analyzedShas = new Set();
143
+ const namesWithImports = new Set();
144
+ expect(isEntityComplete('sha-b', analyzedShas, allEntities, namesWithImports)).toBe(false);
145
+ });
146
+ it('should return false for unknown SHA', () => {
147
+ expect(isEntityComplete('unknown', new Set(), allEntities, new Set())).toBe(false);
148
+ });
149
+ });
150
+ describe('findBrokenEntities', () => {
151
+ it('should flag groups without entitySha as missing', () => {
152
+ const pageGroups = new Map([
153
+ ['Home', [makeScenario({ name: 'Home - Default' })]],
154
+ ]);
155
+ const entityShaMap = new Map();
156
+ const broken = findBrokenEntities(pageGroups, new Map(), entityShaMap, () => true);
157
+ expect(broken).toEqual([
158
+ { name: 'Home', scenarios: expect.any(Array), reason: 'missing' },
159
+ ]);
160
+ });
161
+ it('should flag groups with SHA but incomplete entity as incomplete', () => {
162
+ const scenarios = [
163
+ makeScenario({ name: 'Home - Default', entitySha: 'sha-a' }),
164
+ ];
165
+ const pageGroups = new Map([['Home', scenarios]]);
166
+ const entityShaMap = new Map([['Home', 'sha-a']]);
167
+ const broken = findBrokenEntities(pageGroups, new Map(), entityShaMap, () => false);
168
+ expect(broken).toEqual([{ name: 'Home', scenarios, reason: 'incomplete' }]);
169
+ });
170
+ it('should return empty for complete entities', () => {
171
+ const scenarios = [
172
+ makeScenario({ name: 'Home - Default', entitySha: 'sha-a' }),
173
+ ];
174
+ const pageGroups = new Map([['Home', scenarios]]);
175
+ const entityShaMap = new Map([['Home', 'sha-a']]);
176
+ const broken = findBrokenEntities(pageGroups, new Map(), entityShaMap, () => true);
177
+ expect(broken).toEqual([]);
178
+ });
179
+ });
180
+ describe('resolveClientFocusedEntity', () => {
181
+ const allEntities = [
182
+ {
183
+ sha: 'sha-app',
184
+ name: 'App',
185
+ entityType: 'visual',
186
+ filePath: 'src/App.tsx',
187
+ },
188
+ {
189
+ sha: 'sha-lib',
190
+ name: 'LibraryPage',
191
+ entityType: 'visual',
192
+ filePath: 'src/library/LibraryPage.tsx',
193
+ },
194
+ ];
195
+ it('should return null for null SHA', () => {
196
+ expect(resolveClientFocusedEntity(null, allEntities, [])).toBeNull();
197
+ });
198
+ it('should resolve entity by SHA', () => {
199
+ const result = resolveClientFocusedEntity('sha-app', allEntities, []);
200
+ expect(result?.name).toBe('App');
201
+ expect(result?.filePath).toBe('src/App.tsx');
202
+ expect(result?.sha).toBe('sha-app');
203
+ });
204
+ it('should use displayName from matching scenario', () => {
205
+ const scenarios = [
206
+ makeScenario({
207
+ name: 'Home - Default',
208
+ entitySha: 'sha-app',
209
+ displayName: 'Home',
210
+ }),
211
+ ];
212
+ const result = resolveClientFocusedEntity('sha-app', allEntities, scenarios);
213
+ expect(result?.displayName).toBe('Home');
214
+ });
215
+ it('should fall back to entity name when no scenario has displayName', () => {
216
+ const result = resolveClientFocusedEntity('sha-lib', allEntities, []);
217
+ expect(result?.displayName).toBe('LibraryPage');
218
+ });
219
+ it('should return null for unknown SHA', () => {
220
+ expect(resolveClientFocusedEntity('unknown', allEntities, [])).toBeNull();
221
+ });
222
+ });
223
+ //# sourceMappingURL=editorEntityHelpers.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorEntityHelpers.test.js","sourceRoot":"","sources":["../../../../../src/utils/__tests__/editorEntityHelpers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAGhC,SAAS,YAAY,CACnB,SAAqD;IAErD,OAAO;QACL,EAAE,EAAE,SAAS,CAAC,EAAE,IAAI,MAAM,SAAS,CAAC,IAAI,EAAE;QAC1C,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,WAAW,EAAE,EAAE;QACf,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,IAAI;QACnB,cAAc,EAAE,IAAI;QACpB,GAAG,EAAE,IAAI;QACT,IAAI,EAAE,IAAI;QACV,aAAa,EAAE,IAAI;QACnB,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,IAAI;QAClB,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,IAAI;QACf,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,SAAS,GAAG;YAChB,YAAY,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;YAClE,YAAY,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;YAChE,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;SACpE,CAAC;QACF,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,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os from 'os';
4
+ import { extractImageUrls, resolveImageUrl, parseVerifyImagesInput, buildVerifyImagesReport, extractImageUrlsFromScenarioFiles, } from "../editorImageVerifier.js";
5
+ describe('extractImageUrls', () => {
6
+ it('should extract src from img tags', () => {
7
+ const html = '<img src="https://example.com/photo.jpg" alt="test">';
8
+ expect(extractImageUrls(html)).toContain('https://example.com/photo.jpg');
9
+ });
10
+ it('should extract src with single quotes', () => {
11
+ const html = "<img src='https://example.com/photo.jpg'>";
12
+ expect(extractImageUrls(html)).toContain('https://example.com/photo.jpg');
13
+ });
14
+ it('should extract multiple img tags', () => {
15
+ const html = `
16
+ <img src="https://example.com/a.jpg">
17
+ <p>some text</p>
18
+ <img src="https://example.com/b.png">
19
+ `;
20
+ const urls = extractImageUrls(html);
21
+ expect(urls).toContain('https://example.com/a.jpg');
22
+ expect(urls).toContain('https://example.com/b.png');
23
+ });
24
+ it('should extract relative src paths', () => {
25
+ const html = '<img src="/images/logo.png">';
26
+ expect(extractImageUrls(html)).toContain('/images/logo.png');
27
+ });
28
+ it('should extract URLs ending in image extensions from JSON data', () => {
29
+ // Next.js SSR pages embed data as JSON in <script> tags
30
+ const html = `
31
+ <script id="__NEXT_DATA__">
32
+ {"props":{"pageProps":{"drink":{"imageUrl":"https://images.unsplash.com/photo-123?w=400","name":"Earl Grey"}}}}
33
+ </script>
34
+ `;
35
+ const urls = extractImageUrls(html);
36
+ expect(urls).toContain('https://images.unsplash.com/photo-123?w=400');
37
+ });
38
+ it('should extract URLs with common image extensions from inline data', () => {
39
+ const html = `{"avatar":"https://i.pravatar.cc/150?u=sarah","bgImage":"https://cdn.example.com/bg.webp"}`;
40
+ const urls = extractImageUrls(html);
41
+ expect(urls).toContain('https://i.pravatar.cc/150?u=sarah');
42
+ expect(urls).toContain('https://cdn.example.com/bg.webp');
43
+ });
44
+ it('should deduplicate URLs', () => {
45
+ const html = `
46
+ <img src="https://example.com/photo.jpg">
47
+ <img src="https://example.com/photo.jpg">
48
+ `;
49
+ const urls = extractImageUrls(html);
50
+ expect(urls.filter((u) => u === 'https://example.com/photo.jpg')).toHaveLength(1);
51
+ });
52
+ it('should skip data: URIs', () => {
53
+ const html = '<img src="data:image/png;base64,iVBOR...">';
54
+ expect(extractImageUrls(html)).toHaveLength(0);
55
+ });
56
+ it('should skip empty src', () => {
57
+ const html = '<img src="">';
58
+ expect(extractImageUrls(html)).toHaveLength(0);
59
+ });
60
+ it('should handle srcset attribute', () => {
61
+ const html = '<img srcset="https://example.com/small.jpg 1x, https://example.com/large.jpg 2x">';
62
+ const urls = extractImageUrls(html);
63
+ expect(urls).toContain('https://example.com/small.jpg');
64
+ expect(urls).toContain('https://example.com/large.jpg');
65
+ });
66
+ it('should handle img tags with attributes before src', () => {
67
+ const html = '<img class="rounded" loading="lazy" src="https://example.com/photo.jpg">';
68
+ expect(extractImageUrls(html)).toContain('https://example.com/photo.jpg');
69
+ });
70
+ it('should return empty array for HTML with no images', () => {
71
+ const html = '<div><p>No images here</p></div>';
72
+ expect(extractImageUrls(html)).toEqual([]);
73
+ });
74
+ it('should extract pravatar-style URLs without file extension', () => {
75
+ // These don't end in .jpg/.png but are image URLs referenced in JSON
76
+ const html = `{"userImage":"https://i.pravatar.cc/150?u=marcus"}`;
77
+ expect(extractImageUrls(html)).toContain('https://i.pravatar.cc/150?u=marcus');
78
+ });
79
+ });
80
+ describe('resolveImageUrl', () => {
81
+ it('should return absolute URLs unchanged', () => {
82
+ expect(resolveImageUrl('https://example.com/photo.jpg', 'http://localhost:3000')).toBe('https://example.com/photo.jpg');
83
+ });
84
+ it('should resolve root-relative paths', () => {
85
+ expect(resolveImageUrl('/images/logo.png', 'http://localhost:3000')).toBe('http://localhost:3000/images/logo.png');
86
+ });
87
+ it('should resolve relative paths', () => {
88
+ expect(resolveImageUrl('photo.jpg', 'http://localhost:3000/page')).toBe('http://localhost:3000/photo.jpg');
89
+ });
90
+ it('should handle protocol-relative URLs', () => {
91
+ expect(resolveImageUrl('//cdn.example.com/img.png', 'http://localhost:3000')).toBe('http://cdn.example.com/img.png');
92
+ });
93
+ });
94
+ describe('parseVerifyImagesInput', () => {
95
+ it('should return defaults when no argument provided', () => {
96
+ const result = parseVerifyImagesInput('');
97
+ expect(result.paths).toEqual(['/']);
98
+ expect(result.imageUrls).toEqual([]);
99
+ });
100
+ it('should parse paths only', () => {
101
+ const result = parseVerifyImagesInput('{"paths":["/","/about"]}');
102
+ expect(result.paths).toEqual(['/', '/about']);
103
+ expect(result.imageUrls).toEqual([]);
104
+ });
105
+ it('should parse imageUrls only', () => {
106
+ const result = parseVerifyImagesInput('{"imageUrls":["https://images.unsplash.com/photo-123?w=400"]}');
107
+ expect(result.paths).toEqual(['/']);
108
+ expect(result.imageUrls).toEqual([
109
+ 'https://images.unsplash.com/photo-123?w=400',
110
+ ]);
111
+ });
112
+ it('should parse both paths and imageUrls', () => {
113
+ const result = parseVerifyImagesInput('{"paths":["/drinks"],"imageUrls":["https://i.pravatar.cc/150?u=alice","https://images.unsplash.com/photo-456"]}');
114
+ expect(result.paths).toEqual(['/drinks']);
115
+ expect(result.imageUrls).toEqual([
116
+ 'https://i.pravatar.cc/150?u=alice',
117
+ 'https://images.unsplash.com/photo-456',
118
+ ]);
119
+ });
120
+ it('should ignore non-array imageUrls', () => {
121
+ const result = parseVerifyImagesInput('{"imageUrls":"not-an-array"}');
122
+ expect(result.imageUrls).toEqual([]);
123
+ });
124
+ it('should throw on invalid JSON', () => {
125
+ expect(() => parseVerifyImagesInput('not json')).toThrow();
126
+ });
127
+ });
128
+ describe('buildVerifyImagesReport', () => {
129
+ it('should report zero images when none found', () => {
130
+ const report = buildVerifyImagesReport({
131
+ pagesChecked: 2,
132
+ imageUrls: [],
133
+ results: [],
134
+ });
135
+ expect(report.pagesChecked).toBe(2);
136
+ expect(report.imagesFound).toBe(0);
137
+ expect(report.imagesVerified).toBe(0);
138
+ expect(report.failures).toEqual([]);
139
+ });
140
+ it('should count verified images', () => {
141
+ const results = [
142
+ { url: 'https://example.com/a.jpg', status: 200, ok: true },
143
+ { url: 'https://example.com/b.png', status: 200, ok: true },
144
+ ];
145
+ const report = buildVerifyImagesReport({
146
+ pagesChecked: 1,
147
+ imageUrls: ['https://example.com/a.jpg', 'https://example.com/b.png'],
148
+ results,
149
+ });
150
+ expect(report.imagesFound).toBe(2);
151
+ expect(report.imagesVerified).toBe(2);
152
+ expect(report.failures).toEqual([]);
153
+ });
154
+ it('should include failures with status and error', () => {
155
+ const results = [
156
+ { url: 'https://example.com/good.jpg', status: 200, ok: true },
157
+ { url: 'https://example.com/missing.jpg', status: 404, ok: false },
158
+ {
159
+ url: 'https://example.com/down.jpg',
160
+ status: null,
161
+ ok: false,
162
+ error: 'ECONNREFUSED',
163
+ },
164
+ ];
165
+ const report = buildVerifyImagesReport({
166
+ pagesChecked: 1,
167
+ imageUrls: results.map((r) => r.url),
168
+ results,
169
+ });
170
+ expect(report.imagesFound).toBe(3);
171
+ expect(report.imagesVerified).toBe(1);
172
+ expect(report.failures).toHaveLength(2);
173
+ expect(report.failures[0]).toEqual({
174
+ url: 'https://example.com/missing.jpg',
175
+ status: 404,
176
+ error: undefined,
177
+ });
178
+ expect(report.failures[1]).toEqual({
179
+ url: 'https://example.com/down.jpg',
180
+ status: null,
181
+ error: 'ECONNREFUSED',
182
+ });
183
+ });
184
+ it('should include scenarioFilesScanned when provided', () => {
185
+ const report = buildVerifyImagesReport({
186
+ pagesChecked: 1,
187
+ imageUrls: ['https://example.com/a.jpg'],
188
+ results: [{ url: 'https://example.com/a.jpg', status: 200, ok: true }],
189
+ scenarioFilesScanned: 3,
190
+ });
191
+ expect(report.scenarioFilesScanned).toBe(3);
192
+ });
193
+ it('should omit scenarioFilesScanned when not provided', () => {
194
+ const report = buildVerifyImagesReport({
195
+ pagesChecked: 1,
196
+ imageUrls: [],
197
+ results: [],
198
+ });
199
+ expect(report.scenarioFilesScanned).toBeUndefined();
200
+ });
201
+ });
202
+ function makeTmpDir() {
203
+ return fs.mkdtempSync(path.join(os.tmpdir(), 'image-verifier-test-'));
204
+ }
205
+ describe('extractImageUrlsFromScenarioFiles', () => {
206
+ it('should extract image URLs from scenario JSON with routes', () => {
207
+ const dir = makeTmpDir();
208
+ fs.writeFileSync(path.join(dir, 'scenario-1.json'), JSON.stringify({
209
+ routes: [
210
+ {
211
+ path: '/api/drinks',
212
+ response: {
213
+ body: [
214
+ {
215
+ name: 'Earl Grey',
216
+ imageUrl: 'https://images.unsplash.com/photo-123?w=400',
217
+ },
218
+ ],
219
+ },
220
+ },
221
+ ],
222
+ }));
223
+ const result = extractImageUrlsFromScenarioFiles(dir);
224
+ expect(result.urls).toContain('https://images.unsplash.com/photo-123?w=400');
225
+ expect(result.filesScanned).toBe(1);
226
+ });
227
+ it('should extract from multiple scenario files', () => {
228
+ const dir = makeTmpDir();
229
+ fs.writeFileSync(path.join(dir, 'a.json'), JSON.stringify({
230
+ avatar: 'https://i.pravatar.cc/150?u=alice',
231
+ }));
232
+ fs.writeFileSync(path.join(dir, 'b.json'), JSON.stringify({
233
+ image: 'https://images.unsplash.com/photo-456?w=800',
234
+ }));
235
+ const result = extractImageUrlsFromScenarioFiles(dir);
236
+ expect(result.urls).toContain('https://i.pravatar.cc/150?u=alice');
237
+ expect(result.urls).toContain('https://images.unsplash.com/photo-456?w=800');
238
+ expect(result.filesScanned).toBe(2);
239
+ });
240
+ it('should deduplicate URLs across files', () => {
241
+ const dir = makeTmpDir();
242
+ const sharedUrl = 'https://images.unsplash.com/photo-same?w=400';
243
+ fs.writeFileSync(path.join(dir, 'a.json'), JSON.stringify({ image: sharedUrl }));
244
+ fs.writeFileSync(path.join(dir, 'b.json'), JSON.stringify({ image: sharedUrl }));
245
+ const result = extractImageUrlsFromScenarioFiles(dir);
246
+ expect(result.urls.filter((u) => u === sharedUrl)).toHaveLength(1);
247
+ });
248
+ it('should return empty when directory does not exist', () => {
249
+ const result = extractImageUrlsFromScenarioFiles('/tmp/nonexistent-dir-xyz-12345');
250
+ expect(result.urls).toEqual([]);
251
+ expect(result.filesScanned).toBe(0);
252
+ });
253
+ it('should skip non-JSON files', () => {
254
+ const dir = makeTmpDir();
255
+ fs.writeFileSync(path.join(dir, 'notes.txt'), 'https://images.unsplash.com/photo-txt?w=400');
256
+ fs.writeFileSync(path.join(dir, 'scenario.json'), JSON.stringify({ image: 'https://images.unsplash.com/photo-json?w=400' }));
257
+ const result = extractImageUrlsFromScenarioFiles(dir);
258
+ expect(result.urls).toContain('https://images.unsplash.com/photo-json?w=400');
259
+ expect(result.urls).not.toContain('https://images.unsplash.com/photo-txt?w=400');
260
+ expect(result.filesScanned).toBe(1);
261
+ });
262
+ it('should handle scenario files with no image URLs', () => {
263
+ const dir = makeTmpDir();
264
+ fs.writeFileSync(path.join(dir, 'empty.json'), JSON.stringify({ name: 'Test', count: 42 }));
265
+ const result = extractImageUrlsFromScenarioFiles(dir);
266
+ expect(result.urls).toEqual([]);
267
+ expect(result.filesScanned).toBe(1);
268
+ });
269
+ it('should handle deeply nested image URLs', () => {
270
+ const dir = makeTmpDir();
271
+ fs.writeFileSync(path.join(dir, 'deep.json'), JSON.stringify({
272
+ routes: [
273
+ {
274
+ response: {
275
+ body: {
276
+ data: {
277
+ items: [
278
+ {
279
+ nested: {
280
+ avatar: 'https://i.pravatar.cc/150?u=deep',
281
+ },
282
+ },
283
+ ],
284
+ },
285
+ },
286
+ },
287
+ },
288
+ ],
289
+ }));
290
+ const result = extractImageUrlsFromScenarioFiles(dir);
291
+ expect(result.urls).toContain('https://i.pravatar.cc/150?u=deep');
292
+ });
293
+ });
294
+ //# sourceMappingURL=editorImageVerifier.test.js.map