@codeyam/codeyam-cli 0.1.0-staging.9574237 → 0.1.0-staging.a2f381a

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 (392) hide show
  1. package/analyzer-template/.build-info.json +8 -8
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +4 -4
  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 +6 -6
  23. package/analyzer-template/packages/database/package.json +2 -2
  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 +24 -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.isolateArgs.test.js +51 -0
  53. package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js.map +1 -0
  54. package/codeyam-cli/src/commands/__tests__/editor.statePersistence.test.js +55 -0
  55. package/codeyam-cli/src/commands/__tests__/editor.statePersistence.test.js.map +1 -0
  56. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +9 -9
  57. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +39 -3
  58. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
  59. package/codeyam-cli/src/commands/editor.js +2497 -467
  60. package/codeyam-cli/src/commands/editor.js.map +1 -1
  61. package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js +23 -0
  62. package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js.map +1 -0
  63. package/codeyam-cli/src/commands/editorIsolateArgs.js +25 -0
  64. package/codeyam-cli/src/commands/editorIsolateArgs.js.map +1 -0
  65. package/codeyam-cli/src/commands/init.js +21 -0
  66. package/codeyam-cli/src/commands/init.js.map +1 -1
  67. package/codeyam-cli/src/commands/telemetry.js +37 -0
  68. package/codeyam-cli/src/commands/telemetry.js.map +1 -0
  69. package/codeyam-cli/src/data/designSystems.js +27 -0
  70. package/codeyam-cli/src/data/designSystems.js.map +1 -0
  71. package/codeyam-cli/src/data/techStacks.js +1 -1
  72. package/codeyam-cli/src/utils/__tests__/devServerState.test.js +93 -1
  73. package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -1
  74. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +44 -0
  75. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -1
  76. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +3174 -1
  77. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  78. package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js +137 -0
  79. package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js.map +1 -0
  80. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +70 -0
  81. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -1
  82. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +163 -4
  83. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -1
  84. package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js +67 -0
  85. package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js.map +1 -0
  86. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +11 -3
  87. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
  88. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +98 -1
  89. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -1
  90. package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js +1108 -0
  91. package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js.map +1 -0
  92. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +190 -0
  93. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -1
  94. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +344 -7
  95. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
  96. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +134 -1
  97. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -1
  98. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +294 -2
  99. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
  100. package/codeyam-cli/src/utils/__tests__/envFile.test.js +125 -0
  101. package/codeyam-cli/src/utils/__tests__/envFile.test.js.map +1 -0
  102. package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js +177 -0
  103. package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js.map +1 -0
  104. package/codeyam-cli/src/utils/__tests__/handoffContext.test.js +500 -0
  105. package/codeyam-cli/src/utils/__tests__/handoffContext.test.js.map +1 -0
  106. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +16 -1
  107. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -1
  108. package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js +302 -0
  109. package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js.map +1 -0
  110. package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js +127 -0
  111. package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js.map +1 -0
  112. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +57 -0
  113. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -1
  114. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +180 -1
  115. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -1
  116. package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js +84 -0
  117. package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js.map +1 -0
  118. package/codeyam-cli/src/utils/__tests__/telemetry.test.js +159 -0
  119. package/codeyam-cli/src/utils/__tests__/telemetry.test.js.map +1 -0
  120. package/codeyam-cli/src/utils/__tests__/testRunner.test.js +216 -0
  121. package/codeyam-cli/src/utils/__tests__/testRunner.test.js.map +1 -0
  122. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +6 -0
  123. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -1
  124. package/codeyam-cli/src/utils/analysisRunner.js +36 -7
  125. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  126. package/codeyam-cli/src/utils/analyzer.js +11 -1
  127. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  128. package/codeyam-cli/src/utils/backgroundServer.js +1 -1
  129. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  130. package/codeyam-cli/src/utils/designSystemShowcase.js +810 -0
  131. package/codeyam-cli/src/utils/designSystemShowcase.js.map +1 -0
  132. package/codeyam-cli/src/utils/devServerState.js +32 -0
  133. package/codeyam-cli/src/utils/devServerState.js.map +1 -1
  134. package/codeyam-cli/src/utils/editorApi.js +16 -0
  135. package/codeyam-cli/src/utils/editorApi.js.map +1 -1
  136. package/codeyam-cli/src/utils/editorAudit.js +649 -10
  137. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  138. package/codeyam-cli/src/utils/editorEntityChangeStatus.js +13 -7
  139. package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -1
  140. package/codeyam-cli/src/utils/editorEntityHelpers.js +18 -3
  141. package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -1
  142. package/codeyam-cli/src/utils/editorGuard.js +36 -0
  143. package/codeyam-cli/src/utils/editorGuard.js.map +1 -0
  144. package/codeyam-cli/src/utils/editorPreview.js +5 -3
  145. package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
  146. package/codeyam-cli/src/utils/editorRecapture.js +109 -0
  147. package/codeyam-cli/src/utils/editorRecapture.js.map +1 -0
  148. package/codeyam-cli/src/utils/editorRoadmap.js +574 -0
  149. package/codeyam-cli/src/utils/editorRoadmap.js.map +1 -0
  150. package/codeyam-cli/src/utils/editorScenarioSwitch.js +39 -2
  151. package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -1
  152. package/codeyam-cli/src/utils/editorScenarios.js +181 -17
  153. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
  154. package/codeyam-cli/src/utils/editorSeedAdapter.js +69 -16
  155. package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -1
  156. package/codeyam-cli/src/utils/entityChangeStatus.js +39 -5
  157. package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -1
  158. package/codeyam-cli/src/utils/entityChangeStatus.server.js +31 -0
  159. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
  160. package/codeyam-cli/src/utils/envFile.js +90 -0
  161. package/codeyam-cli/src/utils/envFile.js.map +1 -0
  162. package/codeyam-cli/src/utils/fileWatcher.js +38 -0
  163. package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
  164. package/codeyam-cli/src/utils/glossaryAdd.js +74 -0
  165. package/codeyam-cli/src/utils/glossaryAdd.js.map +1 -0
  166. package/codeyam-cli/src/utils/handoffContext.js +257 -0
  167. package/codeyam-cli/src/utils/handoffContext.js.map +1 -0
  168. package/codeyam-cli/src/utils/install-skills.js +41 -6
  169. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  170. package/codeyam-cli/src/utils/manualEntityAnalysis.js +196 -0
  171. package/codeyam-cli/src/utils/manualEntityAnalysis.js.map +1 -0
  172. package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js +159 -0
  173. package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js.map +1 -0
  174. package/codeyam-cli/src/utils/queue/job.js +35 -6
  175. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  176. package/codeyam-cli/src/utils/registerScenarioResult.js +52 -0
  177. package/codeyam-cli/src/utils/registerScenarioResult.js.map +1 -0
  178. package/codeyam-cli/src/utils/scenarioCoverage.js +4 -1
  179. package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -1
  180. package/codeyam-cli/src/utils/scenariosManifest.js +66 -2
  181. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -1
  182. package/codeyam-cli/src/utils/screenshotHash.js +26 -0
  183. package/codeyam-cli/src/utils/screenshotHash.js.map +1 -0
  184. package/codeyam-cli/src/utils/simulationGateMiddleware.js +9 -0
  185. package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
  186. package/codeyam-cli/src/utils/techStackConfig.js +38 -0
  187. package/codeyam-cli/src/utils/techStackConfig.js.map +1 -0
  188. package/codeyam-cli/src/utils/techStackConfig.test.js +85 -0
  189. package/codeyam-cli/src/utils/techStackConfig.test.js.map +1 -0
  190. package/codeyam-cli/src/utils/telemetry.js +106 -0
  191. package/codeyam-cli/src/utils/telemetry.js.map +1 -0
  192. package/codeyam-cli/src/utils/telemetryMiddleware.js +22 -0
  193. package/codeyam-cli/src/utils/telemetryMiddleware.js.map +1 -0
  194. package/codeyam-cli/src/utils/testResultCache.js +53 -0
  195. package/codeyam-cli/src/utils/testResultCache.js.map +1 -0
  196. package/codeyam-cli/src/utils/testResultCache.server.js +81 -0
  197. package/codeyam-cli/src/utils/testResultCache.server.js.map +1 -0
  198. package/codeyam-cli/src/utils/testResultCache.server.test.js +187 -0
  199. package/codeyam-cli/src/utils/testResultCache.server.test.js.map +1 -0
  200. package/codeyam-cli/src/utils/testResultCache.test.js +230 -0
  201. package/codeyam-cli/src/utils/testResultCache.test.js.map +1 -0
  202. package/codeyam-cli/src/utils/testRunner.js +193 -1
  203. package/codeyam-cli/src/utils/testRunner.js.map +1 -1
  204. package/codeyam-cli/src/utils/webappDetection.js +4 -2
  205. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  206. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js +99 -0
  207. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js.map +1 -0
  208. package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js +119 -1
  209. package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js.map +1 -1
  210. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +68 -1
  211. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -1
  212. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +442 -9
  213. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
  214. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +190 -21
  215. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -1
  216. package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js +135 -0
  217. package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js.map +1 -0
  218. package/codeyam-cli/src/webserver/app/lib/clientErrors.js +22 -1
  219. package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -1
  220. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  221. package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js +34 -0
  222. package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js.map +1 -0
  223. package/codeyam-cli/src/webserver/backgroundServer.js +42 -57
  224. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  225. package/codeyam-cli/src/webserver/build/client/assets/{CopyButton-CzTDWkF2.js → CopyButton-DTBZZfSk.js} +1 -1
  226. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-BFbq6iFk.js → EntityItem-BxclONWq.js} +1 -1
  227. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-B6OMi58N.js → EntityTypeIcon-BsnEOJZ_.js} +1 -1
  228. package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-DuYodzo1.js → InlineSpinner-ByaELMbv.js} +1 -1
  229. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CXo9EeCl.js → InteractivePreview-6WjVfhxX.js} +2 -2
  230. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-DYCNb2It.js → LibraryFunctionPreview-ChX-Hp7W.js} +1 -1
  231. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CZgY3sxX.js → LogViewer-C-9zQdXg.js} +1 -1
  232. package/codeyam-cli/src/webserver/build/client/assets/MiniClaudeChat-Bs2_Oua4.js +36 -0
  233. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-CnYYwRDw.js → ReportIssueModal-DQsceHVv.js} +1 -1
  234. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-CDoF7ZpU.js → SafeScreenshot-DThcm_9M.js} +1 -1
  235. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DrnfvaLL.js → ScenarioViewer-Cl4oOA3A.js} +1 -1
  236. package/codeyam-cli/src/webserver/build/client/assets/Spinner-CIil5-gb.js +34 -0
  237. package/codeyam-cli/src/webserver/build/client/assets/{ViewportInspectBar-DRKR9T0U.js → ViewportInspectBar-BqkA9zyZ.js} +1 -1
  238. package/codeyam-cli/src/webserver/build/client/assets/{_index-ClR-g3tY.js → _index-DnOgyseQ.js} +1 -1
  239. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-DTH6ydEA.js → activity.(_tab)-DqM9hbNE.js} +1 -1
  240. package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-74hnHF59.js → addon-web-links-C58dYPwR.js} +1 -1
  241. package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-B8CYhCO9.js → agent-transcripts-B8NCeOrm.js} +1 -1
  242. package/codeyam-cli/src/webserver/build/client/assets/api.editor-database-verify-l0sNRNKZ.js +1 -0
  243. package/codeyam-cli/src/webserver/build/client/assets/api.editor-github-verify-l0sNRNKZ.js +1 -0
  244. package/codeyam-cli/src/webserver/build/client/assets/api.editor-handoff-l0sNRNKZ.js +1 -0
  245. package/codeyam-cli/src/webserver/build/client/assets/api.editor-hosting-verify-l0sNRNKZ.js +1 -0
  246. package/codeyam-cli/src/webserver/build/client/assets/api.editor-recapture-stale-l0sNRNKZ.js +1 -0
  247. package/codeyam-cli/src/webserver/build/client/assets/api.editor-roadmap-l0sNRNKZ.js +1 -0
  248. package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-scenario-data-l0sNRNKZ.js +1 -0
  249. package/codeyam-cli/src/webserver/build/client/assets/api.editor-schema-l0sNRNKZ.js +1 -0
  250. package/codeyam-cli/src/webserver/build/client/assets/api.editor-verify-routes-l0sNRNKZ.js +1 -0
  251. package/codeyam-cli/src/webserver/build/client/assets/api.interactive-switch-scenario-l0sNRNKZ.js +1 -0
  252. package/codeyam-cli/src/webserver/build/client/assets/{book-open-CLaoh4ac.js → book-open-BFSIqZgO.js} +1 -1
  253. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BZ2DZxbW.js → chevron-down-B9fDzFVh.js} +1 -1
  254. package/codeyam-cli/src/webserver/build/client/assets/chunk-UVKPFVEO-Bmq2apuh.js +43 -0
  255. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CT4unAk-.js → circle-check-DLPObLUx.js} +1 -1
  256. package/codeyam-cli/src/webserver/build/client/assets/{copy-zK0B6Nu-.js → copy-DXEmO0TD.js} +1 -1
  257. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-DJB0YQJL.js → createLucideIcon-BwyFiRot.js} +1 -1
  258. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-Coe5NhbS.js +1 -0
  259. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-CCKUIm0S.svg → cy-logo-cli-DoA97ML3.svg} +2 -2
  260. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-CkXFP_i-.js → dev.empty-iRhRIFlp.js} +1 -1
  261. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-BZPBzV73.js +1 -0
  262. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DhtVC4aI.js +161 -0
  263. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-C6fEYHrh.js +41 -0
  264. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BqAN7hyG.js → entity._sha._-pc-vc6wO.js} +13 -12
  265. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-BOi8kpwd.js → entity._sha.scenarios._scenarioId.dev-C8AyYgYT.js} +1 -1
  266. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-Dg1NhIms.js → entity._sha.scenarios._scenarioId.fullscreen-DziaVQX1.js} +1 -1
  267. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-CJX6kkkV.js → entity._sha_.create-scenario-BTcpgIpC.js} +1 -1
  268. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BhVjZhKg.js → entity._sha_.edit._scenarioId-D_O_ajfZ.js} +1 -1
  269. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-_gzKltPN.js → entry.client-j1Vi0bco.js} +6 -6
  270. package/codeyam-cli/src/webserver/build/client/assets/{files-CV_17tZS.js → files-kuny2Q_s.js} +1 -1
  271. package/codeyam-cli/src/webserver/build/client/assets/{git-D-YXmMbR.js → git-DgCZPMie.js} +1 -1
  272. package/codeyam-cli/src/webserver/build/client/assets/globals-L-aUIeux.css +1 -0
  273. package/codeyam-cli/src/webserver/build/client/assets/{index-CCrgCshv.js → index-BliGSSpl.js} +1 -1
  274. package/codeyam-cli/src/webserver/build/client/assets/{index-Blo6EK8G.js → index-SqjQKTdH.js} +1 -1
  275. package/codeyam-cli/src/webserver/build/client/assets/{index-BsX0F-9C.js → index-vyrZD2g4.js} +1 -1
  276. package/codeyam-cli/src/webserver/build/client/assets/{labs-Byazq8Pv.js → labs-c3yLxSEp.js} +1 -1
  277. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-DVQ0oHR7.js → loader-circle-D-q28GLF.js} +1 -1
  278. package/codeyam-cli/src/webserver/build/client/assets/manifest-79d0d81a.js +1 -0
  279. package/codeyam-cli/src/webserver/build/client/assets/{memory-b-VmA2Vj.js → memory-CEWIUC4t.js} +1 -1
  280. package/codeyam-cli/src/webserver/build/client/assets/{pause-DGcndCAa.js → pause-BP6fitdh.js} +1 -1
  281. package/codeyam-cli/src/webserver/build/client/assets/root-L2V0jea7.js +80 -0
  282. package/codeyam-cli/src/webserver/build/client/assets/{search-C0Uw0bcK.js → search-BooqacKS.js} +1 -1
  283. package/codeyam-cli/src/webserver/build/client/assets/{settings-OoNgHIfW.js → settings-BM0nbryO.js} +1 -1
  284. package/codeyam-cli/src/webserver/build/client/assets/{simulations-Bcemfu8a.js → simulations-ovy6FjRY.js} +1 -1
  285. package/codeyam-cli/src/webserver/build/client/assets/{terminal-BgMmG7R9.js → terminal-DHemCJIs.js} +1 -1
  286. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-Cs87hJYK.js → triangle-alert-D87ekDl8.js} +1 -1
  287. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-BR3Rs7JY.js → useCustomSizes-Dk0Tciqg.js} +1 -1
  288. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-C8QvIe05.js +2 -0
  289. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-BermyNU5.js → useReportContext-jkCytuYz.js} +1 -1
  290. package/codeyam-cli/src/webserver/build/client/assets/{useToast-a_QN_W9_.js → useToast-BgqkixU9.js} +1 -1
  291. package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-QgInFGdU.js +16 -0
  292. package/codeyam-cli/src/webserver/build/server/assets/{index-CHSrVJtC.js → index-zblh9auj.js} +1 -1
  293. package/codeyam-cli/src/webserver/build/server/assets/init-DaE0CBjk.js +14 -0
  294. package/codeyam-cli/src/webserver/build/server/assets/server-build-CNvgz1cC.js +853 -0
  295. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  296. package/codeyam-cli/src/webserver/build-info.json +5 -5
  297. package/codeyam-cli/src/webserver/editorProxy.js +388 -26
  298. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
  299. package/codeyam-cli/src/webserver/idleDetector.js +65 -8
  300. package/codeyam-cli/src/webserver/idleDetector.js.map +1 -1
  301. package/codeyam-cli/src/webserver/scripts/journalCapture.ts +53 -0
  302. package/codeyam-cli/src/webserver/server.js +151 -14
  303. package/codeyam-cli/src/webserver/server.js.map +1 -1
  304. package/codeyam-cli/src/webserver/terminalServer.js +253 -41
  305. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  306. package/codeyam-cli/templates/__tests__/editor-step-hook.prompt-capture.test.ts +118 -0
  307. package/codeyam-cli/templates/codeyam-editor-claude.md +2 -0
  308. package/codeyam-cli/templates/codeyam-editor-codex.md +61 -0
  309. package/codeyam-cli/templates/codeyam-editor-gemini.md +59 -0
  310. package/codeyam-cli/templates/codeyam-editor-reference.md +216 -0
  311. package/codeyam-cli/templates/design-systems/clean-dashboard-design-system.md +255 -0
  312. package/codeyam-cli/templates/design-systems/editorial-design-system.md +267 -0
  313. package/codeyam-cli/templates/design-systems/mono-brutalist-design-system.md +256 -0
  314. package/codeyam-cli/templates/design-systems/neo-brutalist-design-system.md +294 -0
  315. package/codeyam-cli/templates/editor-step-hook.py +93 -46
  316. package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +204 -5
  317. package/codeyam-cli/templates/expo-react-native/__tests__/.gitkeep +0 -0
  318. package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +6 -3
  319. package/codeyam-cli/templates/expo-react-native/app/index.tsx +36 -0
  320. package/codeyam-cli/templates/expo-react-native/app.json +11 -0
  321. package/codeyam-cli/templates/expo-react-native/babel.config.js +1 -0
  322. package/codeyam-cli/templates/expo-react-native/gitignore +2 -0
  323. package/codeyam-cli/templates/expo-react-native/global.css +7 -0
  324. package/codeyam-cli/templates/expo-react-native/lib/theme.ts +73 -0
  325. package/codeyam-cli/templates/expo-react-native/package.json +32 -16
  326. package/codeyam-cli/templates/expo-react-native/patches/expo-modules-autolinking+3.0.24.patch +29 -0
  327. package/codeyam-cli/templates/isolation-route/expo-router.tsx.template +54 -0
  328. package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +1 -0
  329. package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +1 -1
  330. package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +47 -34
  331. package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +1 -1
  332. package/codeyam-cli/templates/seed-adapters/supabase.ts +271 -78
  333. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +34 -1
  334. package/package.json +2 -1
  335. package/packages/ai/src/lib/astScopes/methodSemantics.js +99 -0
  336. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  337. package/packages/ai/src/lib/astScopes/nodeToSource.js +16 -0
  338. package/packages/ai/src/lib/astScopes/nodeToSource.js.map +1 -1
  339. package/packages/ai/src/lib/astScopes/paths.js +12 -3
  340. package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
  341. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +27 -10
  342. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  343. package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js +9 -2
  344. package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js.map +1 -1
  345. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +14 -4
  346. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  347. package/packages/analyze/index.js +1 -1
  348. package/packages/analyze/index.js.map +1 -1
  349. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +16 -2
  350. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  351. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +6 -26
  352. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  353. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +3 -2
  354. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  355. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +9 -7
  356. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  357. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +14 -0
  358. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
  359. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +44 -11
  360. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  361. package/packages/analyze/src/lib/files/analyzeChange.js +1 -0
  362. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  363. package/packages/analyze/src/lib/files/analyzeInitial.js +1 -0
  364. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  365. package/packages/analyze/src/lib/files/analyzeNextRoute.js +5 -1
  366. package/packages/analyze/src/lib/files/analyzeNextRoute.js.map +1 -1
  367. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +120 -28
  368. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  369. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +1368 -1193
  370. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  371. package/packages/database/src/lib/loadAnalysis.js +7 -1
  372. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  373. package/packages/database/src/lib/loadEntity.js +5 -5
  374. package/packages/database/src/lib/loadEntity.js.map +1 -1
  375. package/packages/utils/src/lib/fs/rsyncCopy.js +22 -1
  376. package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  377. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Df3UCi8k.js +0 -34
  378. package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-BBXArFPl.js +0 -43
  379. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +0 -1
  380. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-DPw7NZHc.js +0 -1
  381. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-Dmg9cGK3.js +0 -58
  382. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-DBa7T2FK.js +0 -41
  383. package/codeyam-cli/src/webserver/build/client/assets/globals-Bqg9V6XV.css +0 -1
  384. package/codeyam-cli/src/webserver/build/client/assets/manifest-422a3551.js +0 -1
  385. package/codeyam-cli/src/webserver/build/client/assets/root-ue8uWVRS.js +0 -67
  386. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-BxxP_XF9.js +0 -2
  387. package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-DXQyOV0G.js +0 -13
  388. package/codeyam-cli/src/webserver/build/server/assets/init-DL8vWZ6m.js +0 -10
  389. package/codeyam-cli/src/webserver/build/server/assets/server-build-BUKVjBSZ.js +0 -501
  390. package/codeyam-cli/templates/expo-react-native/app/(tabs)/_layout.tsx +0 -33
  391. package/codeyam-cli/templates/expo-react-native/app/(tabs)/index.tsx +0 -12
  392. package/codeyam-cli/templates/expo-react-native/app/(tabs)/settings.tsx +0 -12
@@ -1 +1 @@
1
- import{aG as Z,aH as _,aw as $,ax as rr,aE as tr,ay as or,aA as ir,aB as pr,aD as mr,aC as ar,aF as sr,az as er}from"./assets/server-build-BUKVjBSZ.js";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"fetch-retry";import"better-sqlite3";import"pg";import"fs";import"path";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"typescript";import"fs/promises";import"os";import"prompts";import"chalk";import"crypto";import"child_process";import"url";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";export{Z as allowedActionOrigins,_ as assets,$ as assetsBuildDirectory,rr as basename,tr as entry,or as future,ir as isSpaMode,pr as prerender,mr as publicPath,ar as routeDiscovery,sr as routes,er as ssr};
1
+ import{aG as Z,aH as _,aw as $,ax as rr,aE as tr,ay as or,aA as ir,aB as pr,aD as mr,aC as ar,aF as sr,az as er}from"./assets/server-build-CNvgz1cC.js";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"fetch-retry";import"better-sqlite3";import"pg";import"fs";import"path";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"typescript";import"fs/promises";import"os";import"prompts";import"chalk";import"crypto";import"child_process";import"url";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";export{Z as allowedActionOrigins,_ as assets,$ as assetsBuildDirectory,rr as basename,tr as entry,or as future,ir as isSpaMode,pr as prerender,mr as publicPath,ar as routeDiscovery,sr as routes,er as ssr};
@@ -1,7 +1,7 @@
1
1
  {
2
- "buildTimestamp": "2026-03-16T19:28:14.810Z",
3
- "buildTime": 1773689294810,
4
- "buildNumber": 1086,
5
- "semanticVersion": "0.1.1086",
6
- "version": "0.1.1086 (2026-03-16T19:28)"
2
+ "buildTimestamp": "2026-04-15T11:36:45.683Z",
3
+ "buildTime": 1776253005683,
4
+ "buildNumber": 1378,
5
+ "semanticVersion": "0.1.1378",
6
+ "version": "0.1.1378 (2026-04-15T11:36)"
7
7
  }
@@ -131,6 +131,42 @@ export const PREVIEW_HEALTH_SCRIPT = `<script data-codeyam-health>
131
131
  }).catch(function(){});
132
132
  }, 1000);
133
133
  });
134
+
135
+ // Network-idle detection: notify the parent editor when all initial
136
+ // fetch requests have completed, so it can show the preview after
137
+ // client-side data (API calls) has arrived — not just when the DOM loads.
138
+ var inflight = 0;
139
+ var settled = false;
140
+ var settleTimer = null;
141
+ var origFetch = window.fetch;
142
+ window.fetch = function() {
143
+ if (!settled) inflight++;
144
+ return origFetch.apply(this, arguments).then(function(resp) {
145
+ if (!settled) { inflight--; checkSettle(); }
146
+ return resp;
147
+ }, function(err) {
148
+ if (!settled) { inflight--; checkSettle(); }
149
+ throw err;
150
+ });
151
+ };
152
+ function checkSettle() {
153
+ if (inflight <= 0 && !settled) {
154
+ clearTimeout(settleTimer);
155
+ // Small delay to allow React to re-render with the fetched data
156
+ settleTimer = setTimeout(function() {
157
+ if (inflight <= 0) {
158
+ settled = true;
159
+ try {
160
+ window.parent.postMessage({ type: 'codeyam-preview-ready' }, '*');
161
+ } catch(e) {}
162
+ }
163
+ }, 100);
164
+ }
165
+ }
166
+ // Fallback: if no fetches happen (static page), settle after load
167
+ window.addEventListener('load', function() {
168
+ setTimeout(function() { checkSettle(); }, 200);
169
+ });
134
170
  })();
135
171
  </script>`;
136
172
  const CACHE_TTL_MS = 500;
@@ -298,6 +334,10 @@ function forwardBufferedRequest(req, res, targetUrl, bodyBuffer) {
298
334
  // Remove accept-encoding so the dev server returns uncompressed responses.
299
335
  // The proxy injects a health script into HTML — this fails on compressed bodies.
300
336
  delete headers['accept-encoding'];
337
+ // Inject session cookies into the request so the dev server sees auth
338
+ // on the first request after a scenario switch (before the browser has
339
+ // stored them from Set-Cookie responses).
340
+ injectRequestCookies(headers);
301
341
  // Update content-length if we have the body buffer
302
342
  if (bodyBuffer) {
303
343
  headers['content-length'] = String(bodyBuffer.length);
@@ -311,6 +351,9 @@ function forwardBufferedRequest(req, res, targetUrl, bodyBuffer) {
311
351
  };
312
352
  const proxyReq = http.request(options, (proxyRes) => {
313
353
  const status = proxyRes.statusCode || 200;
354
+ if (status >= 300 && status < 400) {
355
+ console.log(`[editorProxy] Target redirect ${status} for ${req.method} ${req.url} → ${proxyRes.headers.location}`);
356
+ }
314
357
  if (status >= 400) {
315
358
  console.warn(`[editorProxy] Target returned ${status} for ${req.method} ${req.url}`);
316
359
  }
@@ -324,27 +367,54 @@ function forwardBufferedRequest(req, res, targetUrl, bodyBuffer) {
324
367
  proxyRes.on('data', (chunk) => chunks.push(chunk));
325
368
  proxyRes.on('end', () => {
326
369
  const body = Buffer.concat(chunks).toString('utf-8');
327
- const lsScript = buildLocalStorageScript(localStorageConfig, activeScenarioId || '', currentPrototypeId);
328
- const injected = injectHealthScript(body, lsScript);
329
370
  delete headers['content-length'];
330
371
  delete headers['content-encoding'];
331
- // Prevent browser from caching HTML responses — scenario switches
332
- // serve different content from the same URL (seed data changes the
333
- // rendered page but the proxy URL stays the same).
334
372
  headers['cache-control'] = 'no-store, must-revalidate';
373
+ // Serve a friendly error page for 5xx responses instead of
374
+ // forwarding the raw error HTML (e.g. Next.js "Internal Server Error")
375
+ if (status >= 500) {
376
+ const errorPage = buildErrorPage(status, 'Internal Server Error', body);
377
+ res.writeHead(status, headers);
378
+ res.end(errorPage);
379
+ return;
380
+ }
381
+ const lsScript = buildLocalStorageScript(localStorageConfig, activeScenarioId || '', currentPrototypeId);
382
+ const injected = injectHealthScript(body, lsScript);
335
383
  res.writeHead(status, headers);
336
384
  res.end(injected);
337
385
  });
338
386
  return;
339
387
  }
388
+ // For 5xx responses without a content type or with text/plain,
389
+ // serve a friendly error page. These are typically broken dev servers
390
+ // (e.g. Next.js returning bare "Internal Server Error" with no headers).
391
+ // JSON API errors are left alone — they're legitimate responses.
392
+ if (status >= 500 && !contentType.includes('application/json')) {
393
+ const chunks = [];
394
+ proxyRes.on('data', (chunk) => chunks.push(chunk));
395
+ proxyRes.on('end', () => {
396
+ const body = Buffer.concat(chunks).toString('utf-8');
397
+ const errorPage = buildErrorPage(status, 'Internal Server Error', body);
398
+ res.writeHead(status, {
399
+ 'Content-Type': 'text/html',
400
+ 'Cache-Control': 'no-store',
401
+ });
402
+ res.end(errorPage);
403
+ });
404
+ return;
405
+ }
340
406
  res.writeHead(status, headers);
341
407
  proxyRes.pipe(res, { end: true });
342
408
  });
343
409
  proxyReq.on('error', (err) => {
344
410
  console.warn(`[editorProxy] Forward error for ${req.method} ${req.url}: ${err.message}`);
345
411
  if (!res.headersSent) {
346
- res.writeHead(502, { 'Content-Type': 'text/plain' });
347
- res.end('Bad Gateway — dev server unreachable');
412
+ const errorPage = buildErrorPage(502, 'Dev Server Unreachable', `The proxy could not connect to the dev server. It may be starting up, restarting, or crashed.\n\n${err.message}`);
413
+ res.writeHead(502, {
414
+ 'Content-Type': 'text/html',
415
+ 'Cache-Control': 'no-store',
416
+ });
417
+ res.end(errorPage);
348
418
  }
349
419
  });
350
420
  if (bodyBuffer && bodyBuffer.length > 0) {
@@ -365,18 +435,25 @@ function forwardRequest(req, res, targetUrl) {
365
435
  // Build headers, stripping accept-encoding so the dev server returns uncompressed
366
436
  // responses. The proxy injects a health script into HTML — this fails on compressed bodies.
367
437
  const { 'accept-encoding': _ae, ...forwardHeaders } = req.headers;
438
+ const reqHeaders = {
439
+ ...forwardHeaders,
440
+ host: `${target.hostname}:${target.port}`,
441
+ };
442
+ // Inject session cookies into the request so the dev server sees auth
443
+ // on the first request after a scenario switch.
444
+ injectRequestCookies(reqHeaders);
368
445
  const options = {
369
446
  hostname,
370
447
  port: target.port,
371
448
  path: req.url,
372
449
  method: req.method,
373
- headers: {
374
- ...forwardHeaders,
375
- host: `${target.hostname}:${target.port}`,
376
- },
450
+ headers: reqHeaders,
377
451
  };
378
452
  const proxyReq = http.request(options, (proxyRes) => {
379
453
  const status = proxyRes.statusCode || 200;
454
+ if (status >= 300 && status < 400) {
455
+ console.log(`[editorProxy] Target redirect ${status} for ${req.method} ${req.url} → ${proxyRes.headers.location}`);
456
+ }
380
457
  if (status >= 400) {
381
458
  console.warn(`[editorProxy] Target returned ${status} for ${req.method} ${req.url}`);
382
459
  }
@@ -391,29 +468,54 @@ function forwardRequest(req, res, targetUrl) {
391
468
  proxyRes.on('data', (chunk) => chunks.push(chunk));
392
469
  proxyRes.on('end', () => {
393
470
  const body = Buffer.concat(chunks).toString('utf-8');
394
- const lsScript = buildLocalStorageScript(localStorageConfig, activeScenarioId || '', currentPrototypeId);
395
- const injected = injectHealthScript(body, lsScript);
396
- // Remove content-length since body size changed; use chunked transfer
397
471
  delete headers['content-length'];
398
- // Remove content-encoding since we're serving uncompressed
399
472
  delete headers['content-encoding'];
400
- // Prevent browser from caching HTML responses — scenario switches
401
- // serve different content from the same URL (seed data changes the
402
- // rendered page but the proxy URL stays the same).
403
473
  headers['cache-control'] = 'no-store, must-revalidate';
474
+ // Serve a friendly error page for 5xx responses instead of
475
+ // forwarding the raw error HTML (e.g. Next.js "Internal Server Error")
476
+ if (status >= 500) {
477
+ const errorPage = buildErrorPage(status, 'Internal Server Error', body);
478
+ res.writeHead(status, headers);
479
+ res.end(errorPage);
480
+ return;
481
+ }
482
+ const lsScript = buildLocalStorageScript(localStorageConfig, activeScenarioId || '', currentPrototypeId);
483
+ const injected = injectHealthScript(body, lsScript);
404
484
  res.writeHead(status, headers);
405
485
  res.end(injected);
406
486
  });
407
487
  return;
408
488
  }
489
+ // For 5xx responses without a content type or with text/plain,
490
+ // serve a friendly error page. These are typically broken dev servers
491
+ // (e.g. Next.js returning bare "Internal Server Error" with no headers).
492
+ // JSON API errors are left alone — they're legitimate responses.
493
+ if (status >= 500 && !contentType.includes('application/json')) {
494
+ const chunks = [];
495
+ proxyRes.on('data', (chunk) => chunks.push(chunk));
496
+ proxyRes.on('end', () => {
497
+ const body = Buffer.concat(chunks).toString('utf-8');
498
+ const errorPage = buildErrorPage(status, 'Internal Server Error', body);
499
+ res.writeHead(status, {
500
+ 'Content-Type': 'text/html',
501
+ 'Cache-Control': 'no-store',
502
+ });
503
+ res.end(errorPage);
504
+ });
505
+ return;
506
+ }
409
507
  res.writeHead(status, headers);
410
508
  proxyRes.pipe(res, { end: true });
411
509
  });
412
510
  proxyReq.on('error', (err) => {
413
511
  console.warn(`[editorProxy] Forward error for ${req.method} ${req.url}: ${err.message}`);
414
512
  if (!res.headersSent) {
415
- res.writeHead(502, { 'Content-Type': 'text/plain' });
416
- res.end('Bad Gateway — dev server unreachable');
513
+ const errorPage = buildErrorPage(502, 'Dev Server Unreachable', `The proxy could not connect to the dev server. It may be starting up, restarting, or crashed.\n\n${err.message}`);
514
+ res.writeHead(502, {
515
+ 'Content-Type': 'text/html',
516
+ 'Cache-Control': 'no-store',
517
+ });
518
+ res.end(errorPage);
417
519
  }
418
520
  });
419
521
  req.pipe(proxyReq, { end: true });
@@ -456,6 +558,65 @@ function injectSessionCookie(headers) {
456
558
  headers['set-cookie'] = cookies;
457
559
  }
458
560
  }
561
+ /**
562
+ * Get session cookies that should be injected into requests forwarded to the
563
+ * dev server. Returns an array of {name, value} pairs, or null if no session
564
+ * cookies are configured.
565
+ *
566
+ * This is the counterpart to `injectSessionCookie()` (which adds Set-Cookie
567
+ * to responses). Without request-side injection, the first request after a
568
+ * scenario switch has no cookies — the dev server's auth middleware sees no
569
+ * session and redirects to the login page before the browser ever receives
570
+ * the Set-Cookie response.
571
+ */
572
+ export function getRequestCookieInjection() {
573
+ const cookies = [];
574
+ if (sessionConfig?.cookieValue) {
575
+ cookies.push({ name: 'session-token', value: sessionConfig.cookieValue });
576
+ }
577
+ if (seedSessionCookies && seedSessionCookies.length > 0) {
578
+ for (const sc of seedSessionCookies) {
579
+ cookies.push({ name: sc.name, value: sc.value });
580
+ }
581
+ }
582
+ return cookies.length > 0 ? cookies : null;
583
+ }
584
+ /**
585
+ * Inject session cookies into the request's Cookie header before forwarding
586
+ * to the dev server. This ensures the dev server sees auth cookies on the
587
+ * very first request after a scenario switch (before the browser has stored
588
+ * them from Set-Cookie responses).
589
+ */
590
+ function injectRequestCookies(headers) {
591
+ const injection = getRequestCookieInjection();
592
+ if (!injection)
593
+ return;
594
+ // Parse existing cookies from the request
595
+ const existing = typeof headers.cookie === 'string' ? headers.cookie : '';
596
+ const existingPairs = existing
597
+ ? existing.split(';').map((s) => s.trim())
598
+ : [];
599
+ // Build a map of existing cookies for deduplication
600
+ const cookieMap = new Map();
601
+ for (const pair of existingPairs) {
602
+ const eqIdx = pair.indexOf('=');
603
+ if (eqIdx !== -1) {
604
+ cookieMap.set(pair.slice(0, eqIdx), pair.slice(eqIdx + 1));
605
+ }
606
+ }
607
+ // Override with injected cookies
608
+ for (const { name, value } of injection) {
609
+ cookieMap.set(name, value);
610
+ }
611
+ // Reassemble
612
+ const parts = [];
613
+ for (const [k, v] of cookieMap) {
614
+ parts.push(`${k}=${v}`);
615
+ }
616
+ if (parts.length > 0) {
617
+ headers.cookie = parts.join('; ');
618
+ }
619
+ }
459
620
  /**
460
621
  * Get the current session config (for testing).
461
622
  */
@@ -480,6 +641,17 @@ export function getActiveScenarioId() {
480
641
  export function getCurrentPrototypeId() {
481
642
  return currentPrototypeId;
482
643
  }
644
+ /**
645
+ * Simple djb2 hash — fast, deterministic, good enough for cache busting.
646
+ * Not cryptographic — just detects when localStorage config content changes.
647
+ */
648
+ function simpleHash(str) {
649
+ let hash = 5381;
650
+ for (let i = 0; i < str.length; i++) {
651
+ hash = ((hash << 5) + hash + str.charCodeAt(i)) | 0;
652
+ }
653
+ return (hash >>> 0).toString(36);
654
+ }
483
655
  /**
484
656
  * Build a script tag that seeds localStorage with scenario data on first load.
485
657
  * Gated by scenario ID — only seeds when the scenario changes, preserving
@@ -488,10 +660,13 @@ export function getCurrentPrototypeId() {
488
660
  * Returns empty string if no localStorage config is provided.
489
661
  */
490
662
  export function buildLocalStorageScript(localStorageConfig, scenarioId, prototypeId) {
491
- // null/undefined means no localStorage config at all — but if we have a
492
- // prototypeId, emit a one-time localStorage.clear() to flush stale data
493
- // from a previous prototype session.
663
+ // null/undefined means no localStorage config at all — clean up keys
664
+ // that were set by a previous scenario so stale filter/sort state
665
+ // doesn't bleed through and hide data in the new scenario.
494
666
  if (!localStorageConfig || typeof localStorageConfig !== 'object') {
667
+ // Always clean up previous scenario's keys, gated by scenarioId
668
+ // so it only runs once per switch (not on every HMR reload).
669
+ const guardValue = scenarioId ? `clear:${scenarioId}` : '';
495
670
  if (prototypeId) {
496
671
  return `<script data-codeyam-ls>
497
672
  (function() {
@@ -499,6 +674,19 @@ export function buildLocalStorageScript(localStorageConfig, scenarioId, prototyp
499
674
  localStorage.clear();
500
675
  localStorage.setItem('__codeyam_proto__', ${JSON.stringify(prototypeId)});
501
676
  })();
677
+ </script>`;
678
+ }
679
+ if (scenarioId) {
680
+ // No prototypeId but we do have a scenarioId — clean up keys
681
+ // from the previous scenario without doing a full clear.
682
+ return `<script data-codeyam-ls>
683
+ (function() {
684
+ if (localStorage.getItem('__codeyam_ls_sid__') === ${JSON.stringify(guardValue)}) return;
685
+ var prev = JSON.parse(localStorage.getItem('__codeyam_ls_keys__') || '[]');
686
+ for (var i = 0; i < prev.length; i++) localStorage.removeItem(prev[i]);
687
+ localStorage.removeItem('__codeyam_ls_keys__');
688
+ localStorage.setItem('__codeyam_ls_sid__', ${JSON.stringify(guardValue)});
689
+ })();
502
690
  </script>`;
503
691
  }
504
692
  return '';
@@ -514,14 +702,78 @@ export function buildLocalStorageScript(localStorageConfig, scenarioId, prototyp
514
702
  return `localStorage.setItem(${JSON.stringify(key)}, ${JSON.stringify(serialized)});`;
515
703
  })
516
704
  .join('\n');
517
- return `<script data-codeyam-ls>
705
+ // Guard value includes a content hash so re-registering a scenario with
706
+ // updated data (same ID, different content) busts the cache. Without this,
707
+ // the browser skips re-seeding because the scenario ID hasn't changed,
708
+ // causing stale data in the live preview while screenshots show fresh data.
709
+ const contentHash = simpleHash(JSON.stringify(localStorageConfig));
710
+ const guardValue = `${scenarioId}:${contentHash}`;
711
+ return (`<script data-codeyam-ls>
518
712
  (function() {
519
- if (localStorage.getItem('__codeyam_ls_sid__') === ${JSON.stringify(scenarioId)}) return;
713
+ if (localStorage.getItem('__codeyam_ls_sid__') === ${JSON.stringify(guardValue)}) return;
520
714
  var prev = JSON.parse(localStorage.getItem('__codeyam_ls_keys__') || '[]');
521
715
  for (var i = 0; i < prev.length; i++) localStorage.removeItem(prev[i]);
522
716
  ${setStatements}
523
717
  localStorage.setItem('__codeyam_ls_keys__', ${JSON.stringify(JSON.stringify(keys))});
524
- localStorage.setItem('__codeyam_ls_sid__', ${JSON.stringify(scenarioId)});
718
+ localStorage.setItem('__codeyam_ls_sid__', ${JSON.stringify(guardValue)});
719
+ })();
720
+ </script>` + buildLocalStorageWatcherScript());
721
+ }
722
+ /**
723
+ * Build a script that watches for localStorage mutations and notifies the parent
724
+ * frame via postMessage. Also responds to `codeyam-get-localstorage` requests so
725
+ * the editor can read the current localStorage state when saving.
726
+ */
727
+ function buildLocalStorageWatcherScript() {
728
+ return `<script data-codeyam-ls-watcher>
729
+ (function() {
730
+ if (window.__codeyam_ls_watcher_installed__) return;
731
+ window.__codeyam_ls_watcher_installed__ = true;
732
+
733
+ var origSet = localStorage.setItem.bind(localStorage);
734
+ var origRemove = localStorage.removeItem.bind(localStorage);
735
+ var origClear = localStorage.clear.bind(localStorage);
736
+ window.__codeyam_orig_setItem__ = origSet;
737
+ window.__codeyam_orig_removeItem__ = origRemove;
738
+ window.__codeyam_orig_clear__ = origClear;
739
+
740
+ function isInternal(key) {
741
+ return typeof key === 'string' && key.indexOf('__codeyam_') === 0;
742
+ }
743
+
744
+ localStorage.setItem = function(key, value) {
745
+ origSet(key, value);
746
+ if (!isInternal(key) && window.parent !== window) {
747
+ window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'set', key: key }, '*');
748
+ }
749
+ };
750
+
751
+ localStorage.removeItem = function(key) {
752
+ origRemove(key);
753
+ if (!isInternal(key) && window.parent !== window) {
754
+ window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'remove', key: key }, '*');
755
+ }
756
+ };
757
+
758
+ localStorage.clear = function() {
759
+ origClear();
760
+ if (window.parent !== window) {
761
+ window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'clear' }, '*');
762
+ }
763
+ };
764
+
765
+ window.addEventListener('message', function(event) {
766
+ if (event.data && event.data.type === 'codeyam-get-localstorage') {
767
+ var data = {};
768
+ for (var i = 0; i < localStorage.length; i++) {
769
+ var k = localStorage.key(i);
770
+ if (k && !isInternal(k)) {
771
+ data[k] = localStorage.getItem(k);
772
+ }
773
+ }
774
+ event.source.postMessage({ type: 'codeyam-localstorage-state', data: data }, '*');
775
+ }
776
+ });
525
777
  })();
526
778
  </script>`;
527
779
  }
@@ -541,6 +793,116 @@ export function injectHealthScript(html, localStorageScript) {
541
793
  }
542
794
  return html + scripts;
543
795
  }
796
+ /**
797
+ * Escape HTML special characters to prevent XSS when embedding
798
+ * dev server error output into the error page.
799
+ */
800
+ export function escapeHtml(str) {
801
+ return str
802
+ .replace(/&/g, '&amp;')
803
+ .replace(/</g, '&lt;')
804
+ .replace(/>/g, '&gt;')
805
+ .replace(/"/g, '&quot;')
806
+ .replace(/'/g, '&#39;');
807
+ }
808
+ /**
809
+ * Build a self-contained HTML error page for display in the preview iframe.
810
+ *
811
+ * - Sends `codeyam-server-error` postMessage to the parent editor on load
812
+ * so the editor can auto-restart the dev server.
813
+ * - Includes a "Retry" button that sends `codeyam-server-error-retry`.
814
+ * - Does NOT send `codeyam-preview-ready` (so the editor doesn't
815
+ * mistake the error page for a successful load).
816
+ */
817
+ export function buildErrorPage(statusCode, title, detail) {
818
+ const escapedDetail = escapeHtml(detail);
819
+ const escapedTitle = escapeHtml(title);
820
+ return `<!DOCTYPE html>
821
+ <html lang="en">
822
+ <head>
823
+ <meta charset="utf-8" />
824
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
825
+ <title>${escapedTitle}</title>
826
+ <style>
827
+ * { margin: 0; padding: 0; box-sizing: border-box; }
828
+ body {
829
+ background: #1e1e1e;
830
+ color: #e0e0e0;
831
+ font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
832
+ display: flex;
833
+ align-items: center;
834
+ justify-content: center;
835
+ min-height: 100vh;
836
+ padding: 24px;
837
+ }
838
+ .container {
839
+ max-width: 560px;
840
+ width: 100%;
841
+ text-align: center;
842
+ }
843
+ .status-code {
844
+ font-size: 48px;
845
+ font-weight: 600;
846
+ color: #f87171;
847
+ line-height: 1;
848
+ margin-bottom: 8px;
849
+ }
850
+ .title {
851
+ font-size: 18px;
852
+ font-weight: 500;
853
+ color: #f87171;
854
+ margin-bottom: 16px;
855
+ }
856
+ .detail {
857
+ background: #2a2a2a;
858
+ border: 1px solid #3a3a3a;
859
+ border-radius: 6px;
860
+ padding: 16px;
861
+ margin-bottom: 20px;
862
+ max-height: 240px;
863
+ overflow: auto;
864
+ text-align: left;
865
+ }
866
+ .detail pre {
867
+ font-family: 'IBM Plex Mono', monospace;
868
+ font-size: 12px;
869
+ color: #b0b0b0;
870
+ white-space: pre-wrap;
871
+ word-break: break-word;
872
+ }
873
+ .message {
874
+ font-size: 13px;
875
+ color: #888;
876
+ margin-bottom: 16px;
877
+ }
878
+ button {
879
+ background: #005c75;
880
+ color: white;
881
+ border: none;
882
+ border-radius: 4px;
883
+ padding: 8px 20px;
884
+ font-size: 14px;
885
+ font-weight: 500;
886
+ cursor: pointer;
887
+ transition: background 0.15s;
888
+ }
889
+ button:hover { background: #004d63; }
890
+ </style>
891
+ </head>
892
+ <body>
893
+ <div class="container">
894
+ <div class="status-code">${statusCode}</div>
895
+ <div class="title">${escapedTitle}</div>
896
+ <div class="detail"><pre>${escapedDetail}</pre></div>
897
+ <p class="message">Attempting to restart the dev server...</p>
898
+ <button onclick="window.parent.postMessage({type:'codeyam-server-error-retry'},'*')">Retry</button>
899
+ </div>
900
+ <script>
901
+ try { window.parent.postMessage({type:'codeyam-server-error',statusCode:${statusCode}},'*'); } catch(e) {}
902
+ </script>
903
+ </body>
904
+ </html>`;
905
+ }
544
906
  /**
545
907
  * Handle POST /__codeyam__/preview-health — store health data in globalThis.
546
908
  */