@codeyam/codeyam-cli 0.1.0-staging.eb21b2f → 0.1.0-staging.f3b710d

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 (882) 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 +24 -24
  4. package/analyzer-template/packages/ai/package.json +3 -3
  5. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +34 -3
  6. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +135 -0
  7. package/analyzer-template/packages/ai/src/lib/astScopes/nodeToSource.ts +19 -0
  8. package/analyzer-template/packages/ai/src/lib/astScopes/paths.ts +11 -4
  9. package/analyzer-template/packages/ai/src/lib/completionCall.ts +114 -113
  10. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +295 -14
  11. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.ts +10 -3
  12. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +16 -6
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.ts +62 -0
  14. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.ts +35 -0
  15. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +78 -2
  16. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +0 -33
  17. package/analyzer-template/packages/analyze/index.ts +4 -1
  18. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +19 -7
  19. package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
  20. package/analyzer-template/packages/analyze/src/lib/asts/nodes/getNodeType.ts +1 -0
  21. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +28 -2
  22. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +14 -37
  23. package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +0 -6
  24. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +22 -6
  25. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +9 -12
  26. package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts +21 -0
  27. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +82 -10
  28. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +4 -0
  29. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +4 -0
  30. package/analyzer-template/packages/analyze/src/lib/files/analyzeNextRoute.ts +8 -3
  31. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +65 -28
  32. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +322 -58
  33. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +0 -98
  34. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1707 -1466
  35. package/analyzer-template/packages/aws/package.json +10 -10
  36. package/analyzer-template/packages/database/index.ts +1 -0
  37. package/analyzer-template/packages/database/package.json +4 -4
  38. package/analyzer-template/packages/database/src/lib/kysely/db.ts +8 -0
  39. package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +164 -0
  40. package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +25 -15
  41. package/analyzer-template/packages/database/src/lib/loadCommits.ts +31 -20
  42. package/analyzer-template/packages/database/src/lib/loadEntities.ts +0 -6
  43. package/analyzer-template/packages/database/src/lib/loadEntity.ts +19 -8
  44. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +0 -5
  45. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +94 -143
  46. package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatus.ts +58 -42
  47. package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.ts +81 -65
  48. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +29 -1
  49. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +33 -5
  50. package/analyzer-template/packages/github/dist/database/index.d.ts +1 -0
  51. package/analyzer-template/packages/github/dist/database/index.d.ts.map +1 -1
  52. package/analyzer-template/packages/github/dist/database/index.js +1 -0
  53. package/analyzer-template/packages/github/dist/database/index.js.map +1 -1
  54. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -0
  55. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  56. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +5 -0
  57. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  58. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +29 -0
  59. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -0
  60. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +149 -0
  61. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
  62. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +5 -0
  63. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  64. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
  65. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +7 -1
  66. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
  67. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  68. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +23 -13
  69. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  70. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  71. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +0 -6
  72. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  73. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts +4 -1
  74. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts.map +1 -1
  75. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js +5 -5
  76. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js.map +1 -1
  77. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  78. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +1 -4
  79. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  80. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  81. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +76 -90
  82. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  83. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.d.ts.map +1 -1
  84. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js +41 -30
  85. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
  86. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.d.ts.map +1 -1
  87. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
  88. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js.map +1 -1
  89. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -1
  90. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +29 -1
  91. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -1
  92. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  93. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +33 -5
  94. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  95. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts +2 -0
  96. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
  97. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js +2 -0
  98. package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js.map +1 -1
  99. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +1 -0
  100. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  101. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +10 -0
  102. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  103. package/analyzer-template/packages/github/package.json +1 -1
  104. package/analyzer-template/packages/types/src/enums/ProjectFramework.ts +2 -0
  105. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
  106. package/analyzer-template/packages/types/src/types/Scenario.ts +10 -0
  107. package/analyzer-template/packages/ui-components/package.json +1 -1
  108. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts +2 -0
  109. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
  110. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js +2 -0
  111. package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js.map +1 -1
  112. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +1 -0
  113. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  114. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +10 -0
  115. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  116. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts +3 -1
  117. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
  118. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +28 -3
  119. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  120. package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +41 -2
  121. package/analyzer-template/playwright/captureFromUrl.ts +89 -82
  122. package/analyzer-template/project/analyzeFileEntities.ts +26 -0
  123. package/analyzer-template/project/constructMockCode.ts +168 -48
  124. package/analyzer-template/project/orchestrateCapture.ts +4 -1
  125. package/analyzer-template/project/reconcileMockDataKeys.ts +19 -14
  126. package/analyzer-template/project/runMultiScenarioServer.ts +26 -3
  127. package/analyzer-template/project/start.ts +3 -0
  128. package/analyzer-template/project/startScenarioCapture.ts +9 -0
  129. package/analyzer-template/project/writeClientLogRoute.ts +125 -0
  130. package/analyzer-template/project/writeMockDataTsx.ts +17 -0
  131. package/analyzer-template/project/writeScenarioComponents.ts +96 -17
  132. package/analyzer-template/tsconfig.json +13 -1
  133. package/background/src/lib/virtualized/project/analyzeFileEntities.js +22 -0
  134. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  135. package/background/src/lib/virtualized/project/constructMockCode.js +143 -39
  136. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  137. package/background/src/lib/virtualized/project/orchestrateCapture.js +4 -1
  138. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  139. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +17 -11
  140. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  141. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +23 -3
  142. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  143. package/background/src/lib/virtualized/project/start.js +2 -0
  144. package/background/src/lib/virtualized/project/start.js.map +1 -1
  145. package/background/src/lib/virtualized/project/startScenarioCapture.js +5 -0
  146. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  147. package/background/src/lib/virtualized/project/writeClientLogRoute.js +110 -0
  148. package/background/src/lib/virtualized/project/writeClientLogRoute.js.map +1 -0
  149. package/background/src/lib/virtualized/project/writeMockDataTsx.js +12 -0
  150. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  151. package/background/src/lib/virtualized/project/writeScenarioComponents.js +73 -12
  152. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  153. package/codeyam-cli/scripts/apply-setup.js +208 -11
  154. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  155. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
  156. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
  157. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
  158. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
  159. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
  160. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
  161. package/codeyam-cli/src/cli.js +56 -25
  162. package/codeyam-cli/src/cli.js.map +1 -1
  163. package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js +47 -0
  164. package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js.map +1 -0
  165. package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js +71 -0
  166. package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js.map +1 -0
  167. package/codeyam-cli/src/commands/__tests__/editor.designSystem.test.js +30 -0
  168. package/codeyam-cli/src/commands/__tests__/editor.designSystem.test.js.map +1 -0
  169. package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js +51 -0
  170. package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js.map +1 -0
  171. package/codeyam-cli/src/commands/__tests__/editor.statePersistence.test.js +55 -0
  172. package/codeyam-cli/src/commands/__tests__/editor.statePersistence.test.js.map +1 -0
  173. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +56 -0
  174. package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
  175. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +137 -47
  176. package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
  177. package/codeyam-cli/src/commands/analyze.js +17 -7
  178. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  179. package/codeyam-cli/src/commands/default.js +14 -2
  180. package/codeyam-cli/src/commands/default.js.map +1 -1
  181. package/codeyam-cli/src/commands/editor.js +6313 -0
  182. package/codeyam-cli/src/commands/editor.js.map +1 -0
  183. package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js +23 -0
  184. package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js.map +1 -0
  185. package/codeyam-cli/src/commands/editorIsolateArgs.js +25 -0
  186. package/codeyam-cli/src/commands/editorIsolateArgs.js.map +1 -0
  187. package/codeyam-cli/src/commands/init.js +129 -45
  188. package/codeyam-cli/src/commands/init.js.map +1 -1
  189. package/codeyam-cli/src/commands/memory.js +29 -58
  190. package/codeyam-cli/src/commands/memory.js.map +1 -1
  191. package/codeyam-cli/src/commands/telemetry.js +37 -0
  192. package/codeyam-cli/src/commands/telemetry.js.map +1 -0
  193. package/codeyam-cli/src/data/designSystems.js +27 -0
  194. package/codeyam-cli/src/data/designSystems.js.map +1 -0
  195. package/codeyam-cli/src/data/techStacks.js +77 -0
  196. package/codeyam-cli/src/data/techStacks.js.map +1 -0
  197. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +173 -0
  198. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
  199. package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js +46 -0
  200. package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js.map +1 -0
  201. package/codeyam-cli/src/utils/__tests__/devServerState.test.js +226 -0
  202. package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
  203. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +181 -0
  204. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
  205. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +4160 -0
  206. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -0
  207. package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js +76 -0
  208. package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js.map +1 -0
  209. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
  210. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
  211. package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js +137 -0
  212. package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js.map +1 -0
  213. package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js +100 -0
  214. package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js.map +1 -0
  215. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +304 -0
  216. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -0
  217. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +194 -0
  218. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
  219. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +381 -0
  220. package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -0
  221. package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js +67 -0
  222. package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js.map +1 -0
  223. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
  224. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
  225. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +542 -0
  226. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -0
  227. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +594 -0
  228. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
  229. package/codeyam-cli/src/utils/__tests__/editorMigration.test.js +435 -0
  230. package/codeyam-cli/src/utils/__tests__/editorMigration.test.js.map +1 -0
  231. package/codeyam-cli/src/utils/__tests__/editorMockState.test.js +270 -0
  232. package/codeyam-cli/src/utils/__tests__/editorMockState.test.js.map +1 -0
  233. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +217 -0
  234. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -0
  235. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +361 -0
  236. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -0
  237. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +250 -0
  238. package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -0
  239. package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js +1108 -0
  240. package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js.map +1 -0
  241. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
  242. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
  243. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +411 -0
  244. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
  245. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +1768 -0
  246. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -0
  247. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +413 -0
  248. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
  249. package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js +143 -0
  250. package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js.map +1 -0
  251. package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js +66 -0
  252. package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js.map +1 -0
  253. package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js +53 -0
  254. package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js.map +1 -0
  255. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +2121 -0
  256. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
  257. package/codeyam-cli/src/utils/__tests__/envFile.test.js +125 -0
  258. package/codeyam-cli/src/utils/__tests__/envFile.test.js.map +1 -0
  259. package/codeyam-cli/src/utils/__tests__/git.editor.test.js +134 -0
  260. package/codeyam-cli/src/utils/__tests__/git.editor.test.js.map +1 -0
  261. package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js +177 -0
  262. package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js.map +1 -0
  263. package/codeyam-cli/src/utils/__tests__/handoffContext.test.js +500 -0
  264. package/codeyam-cli/src/utils/__tests__/handoffContext.test.js.map +1 -0
  265. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +122 -0
  266. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
  267. package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js +302 -0
  268. package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js.map +1 -0
  269. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +6 -0
  270. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -1
  271. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +129 -0
  272. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
  273. package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js +9 -0
  274. package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js.map +1 -1
  275. package/codeyam-cli/src/utils/__tests__/project.test.js +65 -0
  276. package/codeyam-cli/src/utils/__tests__/project.test.js.map +1 -0
  277. package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js +127 -0
  278. package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js.map +1 -0
  279. package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js +118 -0
  280. package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js.map +1 -0
  281. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +284 -0
  282. package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
  283. package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js +121 -0
  284. package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js.map +1 -0
  285. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +672 -0
  286. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -0
  287. package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js +84 -0
  288. package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js.map +1 -0
  289. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +51 -4
  290. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  291. package/codeyam-cli/src/utils/__tests__/telemetry.test.js +159 -0
  292. package/codeyam-cli/src/utils/__tests__/telemetry.test.js.map +1 -0
  293. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +51 -0
  294. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
  295. package/codeyam-cli/src/utils/__tests__/testRunner.test.js +216 -0
  296. package/codeyam-cli/src/utils/__tests__/testRunner.test.js.map +1 -0
  297. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +148 -0
  298. package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -0
  299. package/codeyam-cli/src/utils/analysisRunner.js +39 -8
  300. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  301. package/codeyam-cli/src/utils/analyzer.js +19 -0
  302. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  303. package/codeyam-cli/src/utils/analyzerFinalization.js +100 -0
  304. package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
  305. package/codeyam-cli/src/utils/backgroundServer.js +105 -13
  306. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  307. package/codeyam-cli/src/utils/buildFlags.js +4 -0
  308. package/codeyam-cli/src/utils/buildFlags.js.map +1 -0
  309. package/codeyam-cli/src/utils/database.js +37 -2
  310. package/codeyam-cli/src/utils/database.js.map +1 -1
  311. package/codeyam-cli/src/utils/designSystemShowcase.js +810 -0
  312. package/codeyam-cli/src/utils/designSystemShowcase.js.map +1 -0
  313. package/codeyam-cli/src/utils/devModeEvents.js +40 -0
  314. package/codeyam-cli/src/utils/devModeEvents.js.map +1 -0
  315. package/codeyam-cli/src/utils/devServerState.js +103 -0
  316. package/codeyam-cli/src/utils/devServerState.js.map +1 -0
  317. package/codeyam-cli/src/utils/editorApi.js +95 -0
  318. package/codeyam-cli/src/utils/editorApi.js.map +1 -0
  319. package/codeyam-cli/src/utils/editorAudit.js +849 -0
  320. package/codeyam-cli/src/utils/editorAudit.js.map +1 -0
  321. package/codeyam-cli/src/utils/editorBroadcastViewport.js +26 -0
  322. package/codeyam-cli/src/utils/editorBroadcastViewport.js.map +1 -0
  323. package/codeyam-cli/src/utils/editorCapture.js +102 -0
  324. package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
  325. package/codeyam-cli/src/utils/editorDeleteScenario.js +67 -0
  326. package/codeyam-cli/src/utils/editorDeleteScenario.js.map +1 -0
  327. package/codeyam-cli/src/utils/editorDevServer.js +197 -0
  328. package/codeyam-cli/src/utils/editorDevServer.js.map +1 -0
  329. package/codeyam-cli/src/utils/editorEntityChangeStatus.js +50 -0
  330. package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
  331. package/codeyam-cli/src/utils/editorEntityHelpers.js +144 -0
  332. package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -0
  333. package/codeyam-cli/src/utils/editorGuard.js +36 -0
  334. package/codeyam-cli/src/utils/editorGuard.js.map +1 -0
  335. package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
  336. package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
  337. package/codeyam-cli/src/utils/editorJournal.js +225 -0
  338. package/codeyam-cli/src/utils/editorJournal.js.map +1 -0
  339. package/codeyam-cli/src/utils/editorLoaderHelpers.js +152 -0
  340. package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
  341. package/codeyam-cli/src/utils/editorMigration.js +224 -0
  342. package/codeyam-cli/src/utils/editorMigration.js.map +1 -0
  343. package/codeyam-cli/src/utils/editorMockState.js +248 -0
  344. package/codeyam-cli/src/utils/editorMockState.js.map +1 -0
  345. package/codeyam-cli/src/utils/editorPreloadHelpers.js +135 -0
  346. package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -0
  347. package/codeyam-cli/src/utils/editorPreview.js +139 -0
  348. package/codeyam-cli/src/utils/editorPreview.js.map +1 -0
  349. package/codeyam-cli/src/utils/editorRecapture.js +109 -0
  350. package/codeyam-cli/src/utils/editorRecapture.js.map +1 -0
  351. package/codeyam-cli/src/utils/editorRoadmap.js +574 -0
  352. package/codeyam-cli/src/utils/editorRoadmap.js.map +1 -0
  353. package/codeyam-cli/src/utils/editorScenarioSwitch.js +149 -0
  354. package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
  355. package/codeyam-cli/src/utils/editorScenarios.js +687 -0
  356. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -0
  357. package/codeyam-cli/src/utils/editorSeedAdapter.js +475 -0
  358. package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
  359. package/codeyam-cli/src/utils/editorShouldRevalidate.js +21 -0
  360. package/codeyam-cli/src/utils/editorShouldRevalidate.js.map +1 -0
  361. package/codeyam-cli/src/utils/entityChangeStatus.js +394 -0
  362. package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
  363. package/codeyam-cli/src/utils/entityChangeStatus.server.js +227 -0
  364. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
  365. package/codeyam-cli/src/utils/envFile.js +90 -0
  366. package/codeyam-cli/src/utils/envFile.js.map +1 -0
  367. package/codeyam-cli/src/utils/fileMetadata.js +5 -0
  368. package/codeyam-cli/src/utils/fileMetadata.js.map +1 -1
  369. package/codeyam-cli/src/utils/fileWatcher.js +63 -9
  370. package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
  371. package/codeyam-cli/src/utils/git.js +103 -0
  372. package/codeyam-cli/src/utils/git.js.map +1 -1
  373. package/codeyam-cli/src/utils/glossaryAdd.js +74 -0
  374. package/codeyam-cli/src/utils/glossaryAdd.js.map +1 -0
  375. package/codeyam-cli/src/utils/handoffContext.js +257 -0
  376. package/codeyam-cli/src/utils/handoffContext.js.map +1 -0
  377. package/codeyam-cli/src/utils/install-skills.js +101 -15
  378. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  379. package/codeyam-cli/src/utils/interactiveSyncWatcher.js +126 -0
  380. package/codeyam-cli/src/utils/interactiveSyncWatcher.js.map +1 -0
  381. package/codeyam-cli/src/utils/manualEntityAnalysis.js +196 -0
  382. package/codeyam-cli/src/utils/manualEntityAnalysis.js.map +1 -0
  383. package/codeyam-cli/src/utils/npmVersionCheck.js +2 -2
  384. package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -1
  385. package/codeyam-cli/src/utils/parseRegisterArg.js +31 -0
  386. package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
  387. package/codeyam-cli/src/utils/pathIgnoring.js +19 -7
  388. package/codeyam-cli/src/utils/pathIgnoring.js.map +1 -1
  389. package/codeyam-cli/src/utils/progress.js +2 -2
  390. package/codeyam-cli/src/utils/progress.js.map +1 -1
  391. package/codeyam-cli/src/utils/project.js +15 -5
  392. package/codeyam-cli/src/utils/project.js.map +1 -1
  393. package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js +11 -11
  394. package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js.map +1 -1
  395. package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js +159 -0
  396. package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js.map +1 -0
  397. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +22 -0
  398. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  399. package/codeyam-cli/src/utils/queue/heartbeat.js +13 -5
  400. package/codeyam-cli/src/utils/queue/heartbeat.js.map +1 -1
  401. package/codeyam-cli/src/utils/queue/job.js +105 -7
  402. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  403. package/codeyam-cli/src/utils/queue/manager.js +7 -6
  404. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  405. package/codeyam-cli/src/utils/registerScenarioResult.js +52 -0
  406. package/codeyam-cli/src/utils/registerScenarioResult.js.map +1 -0
  407. package/codeyam-cli/src/utils/requireSimulations.js +1 -1
  408. package/codeyam-cli/src/utils/requireSimulations.js.map +1 -1
  409. package/codeyam-cli/src/utils/routePatternMatching.js +129 -0
  410. package/codeyam-cli/src/utils/routePatternMatching.js.map +1 -0
  411. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +5 -6
  412. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -1
  413. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +1 -1
  414. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -1
  415. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +0 -1
  416. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -1
  417. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +2 -4
  418. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -1
  419. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +2 -5
  420. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -1
  421. package/codeyam-cli/src/utils/rules/__tests__/parser.test.js +83 -0
  422. package/codeyam-cli/src/utils/rules/__tests__/parser.test.js.map +1 -0
  423. package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js +118 -0
  424. package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js.map +1 -0
  425. package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js +72 -0
  426. package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js.map +1 -0
  427. package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js +76 -0
  428. package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js.map +1 -0
  429. package/codeyam-cli/src/utils/rules/index.js +1 -0
  430. package/codeyam-cli/src/utils/rules/index.js.map +1 -1
  431. package/codeyam-cli/src/utils/rules/parser.js +14 -4
  432. package/codeyam-cli/src/utils/rules/parser.js.map +1 -1
  433. package/codeyam-cli/src/utils/rules/pathMatcher.js +34 -3
  434. package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -1
  435. package/codeyam-cli/src/utils/rules/rulePlacement.js +65 -0
  436. package/codeyam-cli/src/utils/rules/rulePlacement.js.map +1 -0
  437. package/codeyam-cli/src/utils/rules/sourceFiles.js +43 -0
  438. package/codeyam-cli/src/utils/rules/sourceFiles.js.map +1 -0
  439. package/codeyam-cli/src/utils/scenarioCoverage.js +77 -0
  440. package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
  441. package/codeyam-cli/src/utils/scenarioMarkers.js +134 -0
  442. package/codeyam-cli/src/utils/scenarioMarkers.js.map +1 -0
  443. package/codeyam-cli/src/utils/scenariosManifest.js +313 -0
  444. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
  445. package/codeyam-cli/src/utils/screenshotHash.js +26 -0
  446. package/codeyam-cli/src/utils/screenshotHash.js.map +1 -0
  447. package/codeyam-cli/src/utils/serverState.js +57 -2
  448. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  449. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +83 -11
  450. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  451. package/codeyam-cli/src/utils/simulationGateMiddleware.js +175 -0
  452. package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -0
  453. package/codeyam-cli/src/utils/slugUtils.js +25 -0
  454. package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
  455. package/codeyam-cli/src/utils/syncMocksMiddleware.js +7 -26
  456. package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
  457. package/codeyam-cli/src/utils/techStackConfig.js +38 -0
  458. package/codeyam-cli/src/utils/techStackConfig.js.map +1 -0
  459. package/codeyam-cli/src/utils/techStackConfig.test.js +85 -0
  460. package/codeyam-cli/src/utils/techStackConfig.test.js.map +1 -0
  461. package/codeyam-cli/src/utils/telemetry.js +106 -0
  462. package/codeyam-cli/src/utils/telemetry.js.map +1 -0
  463. package/codeyam-cli/src/utils/telemetryMiddleware.js +22 -0
  464. package/codeyam-cli/src/utils/telemetryMiddleware.js.map +1 -0
  465. package/codeyam-cli/src/utils/testResultCache.js +53 -0
  466. package/codeyam-cli/src/utils/testResultCache.js.map +1 -0
  467. package/codeyam-cli/src/utils/testResultCache.server.js +81 -0
  468. package/codeyam-cli/src/utils/testResultCache.server.js.map +1 -0
  469. package/codeyam-cli/src/utils/testResultCache.server.test.js +187 -0
  470. package/codeyam-cli/src/utils/testResultCache.server.test.js.map +1 -0
  471. package/codeyam-cli/src/utils/testResultCache.test.js +230 -0
  472. package/codeyam-cli/src/utils/testResultCache.test.js.map +1 -0
  473. package/codeyam-cli/src/utils/testRunner.js +350 -0
  474. package/codeyam-cli/src/utils/testRunner.js.map +1 -0
  475. package/codeyam-cli/src/utils/transcriptPruning.js +67 -0
  476. package/codeyam-cli/src/utils/transcriptPruning.js.map +1 -0
  477. package/codeyam-cli/src/utils/versionInfo.js +21 -0
  478. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  479. package/codeyam-cli/src/utils/webappDetection.js +38 -3
  480. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  481. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js +99 -0
  482. package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js.map +1 -0
  483. package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js +153 -0
  484. package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js.map +1 -0
  485. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +107 -0
  486. package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -0
  487. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +1000 -0
  488. package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -0
  489. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +315 -0
  490. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
  491. package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js +135 -0
  492. package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js.map +1 -0
  493. package/codeyam-cli/src/webserver/app/lib/clientErrors.js +86 -0
  494. package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
  495. package/codeyam-cli/src/webserver/app/lib/database.js +41 -27
  496. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  497. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  498. package/codeyam-cli/src/webserver/app/lib/git.js +397 -0
  499. package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
  500. package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js +34 -0
  501. package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js.map +1 -0
  502. package/codeyam-cli/src/webserver/app/types/editor.js +8 -0
  503. package/codeyam-cli/src/webserver/app/types/editor.js.map +1 -0
  504. package/codeyam-cli/src/webserver/backgroundServer.js +141 -42
  505. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  506. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-DTBZZfSk.js +1 -0
  507. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-bwuHPyTa.js → EntityItem-BxclONWq.js} +5 -5
  508. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CQgyEGV-.js +1 -0
  509. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-BH0XDim7.js → EntityTypeIcon-BsnEOJZ_.js} +9 -9
  510. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-ByaELMbv.js +1 -0
  511. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-6WjVfhxX.js +25 -0
  512. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-ChX-Hp7W.js +3 -0
  513. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-BvMu2i-g.js → LoadingDots-By5zI316.js} +1 -1
  514. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-kgBTLoJD.js → LogViewer-C-9zQdXg.js} +3 -3
  515. package/codeyam-cli/src/webserver/build/client/assets/MiniClaudeChat-Bs2_Oua4.js +36 -0
  516. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-BzPgx-xO.js → ReportIssueModal-DQsceHVv.js} +4 -4
  517. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DThcm_9M.js +1 -0
  518. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-BX2Ny2Qj.js → ScenarioViewer-Cl4oOA3A.js} +3 -3
  519. package/codeyam-cli/src/webserver/build/client/assets/Spinner-CIil5-gb.js +34 -0
  520. package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CK7-NaPZ.js +1 -0
  521. package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-BqkA9zyZ.js +1 -0
  522. package/codeyam-cli/src/webserver/build/client/assets/{_index-BRx8ZGZo.js → _index-DnOgyseQ.js} +4 -4
  523. package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-4S4yPfFw.js → activity.(_tab)-DqM9hbNE.js} +8 -8
  524. package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
  525. package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
  526. package/codeyam-cli/src/webserver/build/client/assets/addon-web-links-C58dYPwR.js +1 -0
  527. package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
  528. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-B8NCeOrm.js +22 -0
  529. package/codeyam-cli/src/webserver/build/client/assets/api.dev-mode-events-l0sNRNKZ.js +1 -0
  530. package/codeyam-cli/src/webserver/build/client/assets/api.editor-audit-l0sNRNKZ.js +1 -0
  531. package/codeyam-cli/src/webserver/build/client/assets/api.editor-capture-scenario-l0sNRNKZ.js +1 -0
  532. package/codeyam-cli/src/webserver/build/client/assets/api.editor-client-errors-l0sNRNKZ.js +1 -0
  533. package/codeyam-cli/src/webserver/build/client/assets/api.editor-commit-l0sNRNKZ.js +1 -0
  534. package/codeyam-cli/src/webserver/build/client/assets/api.editor-database-verify-l0sNRNKZ.js +1 -0
  535. package/codeyam-cli/src/webserver/build/client/assets/api.editor-dev-server-l0sNRNKZ.js +1 -0
  536. package/codeyam-cli/src/webserver/build/client/assets/api.editor-entity-status-l0sNRNKZ.js +1 -0
  537. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
  538. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
  539. package/codeyam-cli/src/webserver/build/client/assets/api.editor-github-verify-l0sNRNKZ.js +1 -0
  540. package/codeyam-cli/src/webserver/build/client/assets/api.editor-handoff-l0sNRNKZ.js +1 -0
  541. package/codeyam-cli/src/webserver/build/client/assets/api.editor-hosting-verify-l0sNRNKZ.js +1 -0
  542. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-entry-l0sNRNKZ.js +1 -0
  543. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-image._-l0sNRNKZ.js +1 -0
  544. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-l0sNRNKZ.js +1 -0
  545. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-screenshot-l0sNRNKZ.js +1 -0
  546. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-update-l0sNRNKZ.js +1 -0
  547. package/codeyam-cli/src/webserver/build/client/assets/api.editor-load-commit-l0sNRNKZ.js +1 -0
  548. package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
  549. package/codeyam-cli/src/webserver/build/client/assets/api.editor-recapture-stale-l0sNRNKZ.js +1 -0
  550. package/codeyam-cli/src/webserver/build/client/assets/api.editor-refresh-l0sNRNKZ.js +1 -0
  551. package/codeyam-cli/src/webserver/build/client/assets/api.editor-register-scenario-l0sNRNKZ.js +1 -0
  552. package/codeyam-cli/src/webserver/build/client/assets/api.editor-rename-scenario-l0sNRNKZ.js +1 -0
  553. package/codeyam-cli/src/webserver/build/client/assets/api.editor-roadmap-l0sNRNKZ.js +1 -0
  554. package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-scenario-data-l0sNRNKZ.js +1 -0
  555. package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-seed-state-l0sNRNKZ.js +1 -0
  556. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-l0sNRNKZ.js +1 -0
  557. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-data-l0sNRNKZ.js +1 -0
  558. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-image._-l0sNRNKZ.js +1 -0
  559. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-prompt-l0sNRNKZ.js +1 -0
  560. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenarios-l0sNRNKZ.js +1 -0
  561. package/codeyam-cli/src/webserver/build/client/assets/api.editor-schema-l0sNRNKZ.js +1 -0
  562. package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
  563. package/codeyam-cli/src/webserver/build/client/assets/api.editor-switch-scenario-l0sNRNKZ.js +1 -0
  564. package/codeyam-cli/src/webserver/build/client/assets/api.editor-test-results-l0sNRNKZ.js +1 -0
  565. package/codeyam-cli/src/webserver/build/client/assets/api.editor-verify-routes-l0sNRNKZ.js +1 -0
  566. package/codeyam-cli/src/webserver/build/client/assets/api.interactive-switch-scenario-l0sNRNKZ.js +1 -0
  567. package/codeyam-cli/src/webserver/build/client/assets/api.rule-path-l0sNRNKZ.js +1 -0
  568. package/codeyam-cli/src/webserver/build/client/assets/{book-open-D4IPYH_y.js → book-open-BFSIqZgO.js} +2 -2
  569. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-CG65viiV.js → chevron-down-B9fDzFVh.js} +2 -2
  570. package/codeyam-cli/src/webserver/build/client/assets/chunk-UVKPFVEO-Bmq2apuh.js +43 -0
  571. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-igfMr5DY.js → circle-check-DLPObLUx.js} +2 -2
  572. package/codeyam-cli/src/webserver/build/client/assets/{copy-Coc4o_8c.js → copy-DXEmO0TD.js} +3 -3
  573. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BwyFiRot.js +41 -0
  574. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-Coe5NhbS.js +1 -0
  575. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-CCKUIm0S.svg → cy-logo-cli-DoA97ML3.svg} +2 -2
  576. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-iRhRIFlp.js +1 -0
  577. package/codeyam-cli/src/webserver/build/client/assets/editor._tab-BZPBzV73.js +1 -0
  578. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DhtVC4aI.js +161 -0
  579. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-C6fEYHrh.js +41 -0
  580. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-B0h9AqE6.js → entity._sha._-pc-vc6wO.js} +14 -13
  581. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-C8AyYgYT.js +6 -0
  582. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DziaVQX1.js +6 -0
  583. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-BTcpgIpC.js +6 -0
  584. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-PePWg17F.js → entity._sha_.edit._scenarioId-D_O_ajfZ.js} +2 -2
  585. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-I-Wo99C_.js → entry.client-j1Vi0bco.js} +6 -6
  586. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-Daa96Fr1.js +1 -0
  587. package/codeyam-cli/src/webserver/build/client/assets/files-kuny2Q_s.js +1 -0
  588. package/codeyam-cli/src/webserver/build/client/assets/git-DgCZPMie.js +1 -0
  589. package/codeyam-cli/src/webserver/build/client/assets/globals-L-aUIeux.css +1 -0
  590. package/codeyam-cli/src/webserver/build/client/assets/{index-_417gcQW.js → index-BliGSSpl.js} +1 -1
  591. package/codeyam-cli/src/webserver/build/client/assets/index-SqjQKTdH.js +15 -0
  592. package/codeyam-cli/src/webserver/build/client/assets/{index-CUM5iXwc.js → index-vyrZD2g4.js} +1 -1
  593. package/codeyam-cli/src/webserver/build/client/assets/jsx-runtime-D_zvdyIk.js +9 -0
  594. package/codeyam-cli/src/webserver/build/client/assets/labs-c3yLxSEp.js +1 -0
  595. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-TzRHMVog.js → loader-circle-D-q28GLF.js} +2 -2
  596. package/codeyam-cli/src/webserver/build/client/assets/manifest-79d0d81a.js +1 -0
  597. package/codeyam-cli/src/webserver/build/client/assets/memory-CEWIUC4t.js +101 -0
  598. package/codeyam-cli/src/webserver/build/client/assets/{pause-hjzB7t2z.js → pause-BP6fitdh.js} +3 -3
  599. package/codeyam-cli/src/webserver/build/client/assets/root-L2V0jea7.js +80 -0
  600. package/codeyam-cli/src/webserver/build/client/assets/{search-DcAwD_Ln.js → search-BooqacKS.js} +2 -2
  601. package/codeyam-cli/src/webserver/build/client/assets/settings-BM0nbryO.js +1 -0
  602. package/codeyam-cli/src/webserver/build/client/assets/simulations-ovy6FjRY.js +1 -0
  603. package/codeyam-cli/src/webserver/build/client/assets/{terminal-DbEAHMbA.js → terminal-DHemCJIs.js} +3 -3
  604. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CAD5b1o_.js → triangle-alert-D87ekDl8.js} +2 -2
  605. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-Dk0Tciqg.js +1 -0
  606. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-C8QvIe05.js +2 -0
  607. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-jkCytuYz.js +1 -0
  608. package/codeyam-cli/src/webserver/build/client/assets/useToast-BgqkixU9.js +1 -0
  609. package/codeyam-cli/src/webserver/build/client/assets/xterm-BqvuqXEL.js +27 -0
  610. package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
  611. package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-QgInFGdU.js +16 -0
  612. package/codeyam-cli/src/webserver/build/server/assets/index-zblh9auj.js +1 -0
  613. package/codeyam-cli/src/webserver/build/server/assets/init-DaE0CBjk.js +14 -0
  614. package/codeyam-cli/src/webserver/build/server/assets/progress-CHTtrxFG.js +1 -0
  615. package/codeyam-cli/src/webserver/build/server/assets/server-build-CNvgz1cC.js +853 -0
  616. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  617. package/codeyam-cli/src/webserver/build-info.json +5 -5
  618. package/codeyam-cli/src/webserver/devServer.js +39 -5
  619. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  620. package/codeyam-cli/src/webserver/editorProxy.js +1263 -0
  621. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -0
  622. package/codeyam-cli/src/webserver/idleDetector.js +130 -0
  623. package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
  624. package/codeyam-cli/src/webserver/mockStateEvents.js +28 -0
  625. package/codeyam-cli/src/webserver/mockStateEvents.js.map +1 -0
  626. package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
  627. package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +414 -0
  628. package/codeyam-cli/src/webserver/scripts/journalCapture.ts +283 -0
  629. package/codeyam-cli/src/webserver/server.js +446 -1
  630. package/codeyam-cli/src/webserver/server.js.map +1 -1
  631. package/codeyam-cli/src/webserver/terminalServer.js +1043 -0
  632. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -0
  633. package/codeyam-cli/templates/__tests__/editor-step-hook.prompt-capture.test.ts +118 -0
  634. package/codeyam-cli/templates/chrome-extension-react/EXTENSION_SETUP.md +75 -0
  635. package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
  636. package/codeyam-cli/templates/chrome-extension-react/gitignore +15 -0
  637. package/codeyam-cli/templates/chrome-extension-react/index.html +12 -0
  638. package/codeyam-cli/templates/chrome-extension-react/package.json +27 -0
  639. package/codeyam-cli/templates/chrome-extension-react/popup.html +12 -0
  640. package/codeyam-cli/templates/chrome-extension-react/public/manifest.json +15 -0
  641. package/codeyam-cli/templates/chrome-extension-react/src/background/service-worker.ts +7 -0
  642. package/codeyam-cli/templates/chrome-extension-react/src/globals.css +6 -0
  643. package/codeyam-cli/templates/chrome-extension-react/src/lib/storage.ts +37 -0
  644. package/codeyam-cli/templates/chrome-extension-react/src/popup/App.tsx +12 -0
  645. package/codeyam-cli/templates/chrome-extension-react/src/popup/main.tsx +10 -0
  646. package/codeyam-cli/templates/chrome-extension-react/tsconfig.json +24 -0
  647. package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +41 -0
  648. package/codeyam-cli/templates/codeyam-editor-claude.md +149 -0
  649. package/codeyam-cli/templates/codeyam-editor-codex.md +61 -0
  650. package/codeyam-cli/templates/codeyam-editor-gemini.md +59 -0
  651. package/codeyam-cli/templates/codeyam-editor-reference.md +216 -0
  652. package/codeyam-cli/templates/design-systems/clean-dashboard-design-system.md +255 -0
  653. package/codeyam-cli/templates/design-systems/editorial-design-system.md +267 -0
  654. package/codeyam-cli/templates/design-systems/mono-brutalist-design-system.md +256 -0
  655. package/codeyam-cli/templates/design-systems/neo-brutalist-design-system.md +294 -0
  656. package/codeyam-cli/templates/editor-step-hook.py +368 -0
  657. package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +288 -0
  658. package/codeyam-cli/templates/expo-react-native/README.md +41 -0
  659. package/codeyam-cli/templates/expo-react-native/__tests__/.gitkeep +0 -0
  660. package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +15 -0
  661. package/codeyam-cli/templates/expo-react-native/app/index.tsx +36 -0
  662. package/codeyam-cli/templates/expo-react-native/app.json +29 -0
  663. package/codeyam-cli/templates/expo-react-native/babel.config.js +10 -0
  664. package/codeyam-cli/templates/expo-react-native/gitignore +14 -0
  665. package/codeyam-cli/templates/expo-react-native/global.css +10 -0
  666. package/codeyam-cli/templates/expo-react-native/lib/storage.ts +32 -0
  667. package/codeyam-cli/templates/expo-react-native/lib/theme.ts +73 -0
  668. package/codeyam-cli/templates/expo-react-native/metro.config.js +6 -0
  669. package/codeyam-cli/templates/expo-react-native/nativewind-env.d.ts +1 -0
  670. package/codeyam-cli/templates/expo-react-native/package.json +54 -0
  671. package/codeyam-cli/templates/expo-react-native/patches/expo-modules-autolinking+3.0.24.patch +29 -0
  672. package/codeyam-cli/templates/expo-react-native/tailwind.config.js +10 -0
  673. package/codeyam-cli/templates/expo-react-native/tsconfig.json +10 -0
  674. package/codeyam-cli/templates/hooks/staleness-check.sh +43 -0
  675. package/codeyam-cli/templates/isolation-route/expo-router.tsx.template +54 -0
  676. package/codeyam-cli/templates/isolation-route/next-app.tsx.template +80 -0
  677. package/codeyam-cli/templates/isolation-route/next-pages.tsx.template +79 -0
  678. package/codeyam-cli/templates/isolation-route/vite-react.tsx.template +78 -0
  679. package/codeyam-cli/templates/msw/browser-setup.ts.template +47 -0
  680. package/codeyam-cli/templates/msw/handler-router.ts.template +47 -0
  681. package/codeyam-cli/templates/msw/server-setup.ts.template +52 -0
  682. package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_PATTERNS.md +308 -0
  683. package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_UPGRADE.md +304 -0
  684. package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +126 -0
  685. package/codeyam-cli/templates/nextjs-prisma-sqlite/FEATURE_PATTERNS.md +37 -0
  686. package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
  687. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/api/todos/route.ts +17 -0
  688. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
  689. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/globals.css +26 -0
  690. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/layout.tsx +34 -0
  691. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +24 -0
  692. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/page.tsx +10 -0
  693. package/codeyam-cli/templates/nextjs-prisma-sqlite/env +4 -0
  694. package/codeyam-cli/templates/nextjs-prisma-sqlite/eslint.config.mjs +11 -0
  695. package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +65 -0
  696. package/codeyam-cli/templates/nextjs-prisma-sqlite/next.config.ts +14 -0
  697. package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +39 -0
  698. package/codeyam-cli/templates/nextjs-prisma-sqlite/postcss.config.mjs +7 -0
  699. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/schema.prisma +27 -0
  700. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +40 -0
  701. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma.config.ts +12 -0
  702. package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +140 -0
  703. package/codeyam-cli/templates/nextjs-prisma-sqlite/tsconfig.json +34 -0
  704. package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
  705. package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
  706. package/codeyam-cli/templates/nextjs-prisma-supabase/SUPABASE_SETUP.md +104 -0
  707. package/codeyam-cli/templates/nextjs-prisma-supabase/app/api/todos/route.ts +17 -0
  708. package/codeyam-cli/templates/nextjs-prisma-supabase/app/globals.css +26 -0
  709. package/codeyam-cli/templates/nextjs-prisma-supabase/app/layout.tsx +34 -0
  710. package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/prisma.ts +20 -0
  711. package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/supabase.ts +12 -0
  712. package/codeyam-cli/templates/nextjs-prisma-supabase/app/page.tsx +10 -0
  713. package/codeyam-cli/templates/nextjs-prisma-supabase/env +9 -0
  714. package/codeyam-cli/templates/nextjs-prisma-supabase/eslint.config.mjs +11 -0
  715. package/codeyam-cli/templates/nextjs-prisma-supabase/gitignore +40 -0
  716. package/codeyam-cli/templates/nextjs-prisma-supabase/next.config.ts +11 -0
  717. package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +37 -0
  718. package/codeyam-cli/templates/nextjs-prisma-supabase/postcss.config.mjs +7 -0
  719. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/schema.prisma +27 -0
  720. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/seed.ts +39 -0
  721. package/codeyam-cli/templates/nextjs-prisma-supabase/prisma.config.ts +12 -0
  722. package/codeyam-cli/templates/nextjs-prisma-supabase/tsconfig.json +34 -0
  723. package/codeyam-cli/templates/prompts/conversation-guidance.txt +44 -0
  724. package/codeyam-cli/templates/prompts/conversation-prompt.txt +28 -0
  725. package/codeyam-cli/templates/prompts/interruption-prompt.txt +31 -0
  726. package/codeyam-cli/templates/prompts/stale-rules-prompt.txt +24 -0
  727. package/codeyam-cli/templates/rule-notification-hook.py +44 -17
  728. package/codeyam-cli/templates/rule-reflection-hook.py +24 -4
  729. package/codeyam-cli/templates/rules-instructions.md +34 -88
  730. package/codeyam-cli/templates/seed-adapters/supabase.ts +475 -0
  731. package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +237 -0
  732. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +244 -0
  733. package/codeyam-cli/templates/{codeyam-memory.md → skills/codeyam-memory/SKILL.md} +215 -0
  734. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/deprecated-prompt.md +100 -0
  735. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
  736. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
  737. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/misleading-api-prompt.md +117 -0
  738. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
  739. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
  740. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/analyze-prompt.md +46 -0
  741. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
  742. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
  743. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
  744. package/codeyam-cli/templates/{codeyam-new-rule.md → skills/codeyam-new-rule/SKILL.md} +0 -2
  745. package/package.json +22 -14
  746. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +22 -4
  747. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  748. package/packages/ai/src/lib/astScopes/methodSemantics.js +99 -0
  749. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  750. package/packages/ai/src/lib/astScopes/nodeToSource.js +16 -0
  751. package/packages/ai/src/lib/astScopes/nodeToSource.js.map +1 -1
  752. package/packages/ai/src/lib/astScopes/paths.js +12 -3
  753. package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
  754. package/packages/ai/src/lib/completionCall.js +10 -7
  755. package/packages/ai/src/lib/completionCall.js.map +1 -1
  756. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +261 -13
  757. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  758. package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js +9 -2
  759. package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js.map +1 -1
  760. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +14 -4
  761. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  762. package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js +54 -0
  763. package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js.map +1 -0
  764. package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js +34 -0
  765. package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js.map +1 -0
  766. package/packages/ai/src/lib/generateEntityScenarioData.js +57 -2
  767. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  768. package/packages/ai/src/lib/generateExecutionFlows.js +0 -11
  769. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
  770. package/packages/analyze/index.js +1 -1
  771. package/packages/analyze/index.js.map +1 -1
  772. package/packages/analyze/src/lib/ProjectAnalyzer.js +13 -4
  773. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  774. package/packages/analyze/src/lib/asts/index.js +4 -2
  775. package/packages/analyze/src/lib/asts/index.js.map +1 -1
  776. package/packages/analyze/src/lib/asts/nodes/getNodeType.js +1 -0
  777. package/packages/analyze/src/lib/asts/nodes/getNodeType.js.map +1 -1
  778. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +16 -2
  779. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  780. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +14 -27
  781. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  782. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +0 -5
  783. package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
  784. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +12 -2
  785. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  786. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +9 -7
  787. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  788. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +14 -0
  789. package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
  790. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +44 -11
  791. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  792. package/packages/analyze/src/lib/files/analyzeChange.js +1 -0
  793. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  794. package/packages/analyze/src/lib/files/analyzeInitial.js +1 -0
  795. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  796. package/packages/analyze/src/lib/files/analyzeNextRoute.js +5 -1
  797. package/packages/analyze/src/lib/files/analyzeNextRoute.js.map +1 -1
  798. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +54 -27
  799. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -1
  800. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +185 -28
  801. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  802. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +0 -40
  803. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
  804. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +1386 -1197
  805. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  806. package/packages/database/index.js +1 -0
  807. package/packages/database/index.js.map +1 -1
  808. package/packages/database/src/lib/kysely/db.js +5 -0
  809. package/packages/database/src/lib/kysely/db.js.map +1 -1
  810. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +149 -0
  811. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
  812. package/packages/database/src/lib/loadAnalysis.js +7 -1
  813. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  814. package/packages/database/src/lib/loadCommits.js +23 -13
  815. package/packages/database/src/lib/loadCommits.js.map +1 -1
  816. package/packages/database/src/lib/loadEntities.js +0 -6
  817. package/packages/database/src/lib/loadEntities.js.map +1 -1
  818. package/packages/database/src/lib/loadEntity.js +5 -5
  819. package/packages/database/src/lib/loadEntity.js.map +1 -1
  820. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +1 -4
  821. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  822. package/packages/database/src/lib/updateCommitMetadata.js +76 -90
  823. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  824. package/packages/database/src/lib/updateFreshAnalysisStatus.js +41 -30
  825. package/packages/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
  826. package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
  827. package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js.map +1 -1
  828. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +29 -1
  829. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -1
  830. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +33 -5
  831. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  832. package/packages/types/src/enums/ProjectFramework.js +2 -0
  833. package/packages/types/src/enums/ProjectFramework.js.map +1 -1
  834. package/packages/utils/src/lib/fs/rsyncCopy.js +28 -3
  835. package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  836. package/scripts/npm-post-install.cjs +34 -0
  837. package/codeyam-cli/src/commands/detect-universal-mocks.js +0 -120
  838. package/codeyam-cli/src/commands/detect-universal-mocks.js.map +0 -1
  839. package/codeyam-cli/src/commands/list.js +0 -31
  840. package/codeyam-cli/src/commands/list.js.map +0 -1
  841. package/codeyam-cli/src/commands/webapp-info.js +0 -146
  842. package/codeyam-cli/src/commands/webapp-info.js.map +0 -1
  843. package/codeyam-cli/src/utils/universal-mocks.js +0 -152
  844. package/codeyam-cli/src/utils/universal-mocks.js.map +0 -1
  845. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-jNYXRRNI.js +0 -1
  846. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CvzqMxcu.js +0 -1
  847. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-EhOseatT.js +0 -34
  848. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-yjIHlOGa.js +0 -25
  849. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-Cq5o8jL4.js +0 -3
  850. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CwZrv-Ok.js +0 -1
  851. package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CDpEprKa.js +0 -1
  852. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DHKuQSmR.js +0 -17
  853. package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-DB3aFuEO.js +0 -51
  854. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-D1zB-pYc.js +0 -21
  855. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +0 -1
  856. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-JTAjQ54M.js +0 -1
  857. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DjLxr2JB.js +0 -6
  858. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CtYowLOt.js +0 -6
  859. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-9sMMAiWJ.js +0 -1
  860. package/codeyam-cli/src/webserver/build/client/assets/files-Co65J0s3.js +0 -1
  861. package/codeyam-cli/src/webserver/build/client/assets/git-BdHOxVfg.js +0 -15
  862. package/codeyam-cli/src/webserver/build/client/assets/globals-CCgBKWy4.css +0 -1
  863. package/codeyam-cli/src/webserver/build/client/assets/labs-BK0C1H1T.js +0 -1
  864. package/codeyam-cli/src/webserver/build/client/assets/manifest-390cb8fa.js +0 -1
  865. package/codeyam-cli/src/webserver/build/client/assets/memory-CzZySbBE.js +0 -78
  866. package/codeyam-cli/src/webserver/build/client/assets/root-DnbDhvTU.js +0 -62
  867. package/codeyam-cli/src/webserver/build/client/assets/settings-CclxrcPK.js +0 -1
  868. package/codeyam-cli/src/webserver/build/client/assets/simulations-DVNJVQgD.js +0 -1
  869. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BqgrAzs3.js +0 -1
  870. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-DAFqfEDH.js +0 -2
  871. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DZlYx2c4.js +0 -1
  872. package/codeyam-cli/src/webserver/build/client/assets/useToast-ihdMtlf6.js +0 -1
  873. package/codeyam-cli/src/webserver/build/server/assets/index-CXfuiwt3.js +0 -1
  874. package/codeyam-cli/src/webserver/build/server/assets/server-build-BSvme_Ao.js +0 -259
  875. package/codeyam-cli/templates/codeyam-stop-hook.sh +0 -284
  876. package/scripts/finalize-analyzer.cjs +0 -13
  877. /package/codeyam-cli/templates/{codeyam-diagnose.md → commands/codeyam-diagnose.md} +0 -0
  878. /package/codeyam-cli/templates/{codeyam-debug.md → skills/codeyam-debug/SKILL.md} +0 -0
  879. /package/codeyam-cli/templates/{codeyam-setup.md → skills/codeyam-setup/SKILL.md} +0 -0
  880. /package/codeyam-cli/templates/{codeyam-sim.md → skills/codeyam-sim/SKILL.md} +0 -0
  881. /package/codeyam-cli/templates/{codeyam-test.md → skills/codeyam-test/SKILL.md} +0 -0
  882. /package/codeyam-cli/templates/{codeyam-verify.md → skills/codeyam-verify/SKILL.md} +0 -0
@@ -0,0 +1,1263 @@
1
+ import http from 'http';
2
+ import net from 'net';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { getProjectRoot } from "../state.js";
6
+ import { createMockStateManager, } from "../utils/editorMockState.js";
7
+ import { computeEditorPorts } from "../utils/editorDevServer.js";
8
+ import { mockStateEventEmitter } from "./mockStateEvents.js";
9
+ /**
10
+ * Normalize a target URL by stripping trailing slashes for consistency.
11
+ *
12
+ * Previously this also replaced `localhost` with `127.0.0.1`, but that broke
13
+ * forwarding to dev servers that bind to IPv6 only (e.g. Vite 6 on macOS
14
+ * binds to `[::1]`). The hostname is now left as-is — `resolveLoopbackAddress`
15
+ * probes the actual target at startup to pick the right address.
16
+ */
17
+ export function normalizeTargetUrl(url) {
18
+ try {
19
+ const parsed = new URL(url);
20
+ return parsed.toString().replace(/\/$/, '');
21
+ }
22
+ catch {
23
+ return url;
24
+ }
25
+ }
26
+ /**
27
+ * Probe a localhost port to determine the correct loopback address.
28
+ * Dev servers may bind to IPv4 (127.0.0.1), IPv6 (::1), or both.
29
+ * Returns the first address that accepts a TCP connection.
30
+ */
31
+ export async function resolveLoopbackAddress(port) {
32
+ const candidates = ['127.0.0.1', '::1'];
33
+ for (const host of candidates) {
34
+ try {
35
+ const connected = await new Promise((resolve) => {
36
+ const socket = new net.Socket();
37
+ socket.setTimeout(1000);
38
+ socket.once('connect', () => {
39
+ socket.destroy();
40
+ resolve(true);
41
+ });
42
+ socket.once('error', () => {
43
+ socket.destroy();
44
+ resolve(false);
45
+ });
46
+ socket.once('timeout', () => {
47
+ socket.destroy();
48
+ resolve(false);
49
+ });
50
+ socket.connect(port, host);
51
+ });
52
+ if (connected) {
53
+ return host;
54
+ }
55
+ }
56
+ catch {
57
+ // Try next candidate
58
+ }
59
+ }
60
+ return null;
61
+ }
62
+ // Global key so the proxy survives HMR
63
+ const GLOBAL_KEY = '__codeyam_editor_proxy__';
64
+ // ─── Live Preview Health ─────────────────────────────────────────────
65
+ const PREVIEW_HEALTH_KEY = '__codeyam_preview_health__';
66
+ function getPreviewHealth() {
67
+ return globalThis[PREVIEW_HEALTH_KEY] ?? null;
68
+ }
69
+ function setPreviewHealth(report) {
70
+ globalThis[PREVIEW_HEALTH_KEY] = report;
71
+ }
72
+ /**
73
+ * Get the current live preview health report (read by API endpoint).
74
+ */
75
+ export function getPreviewHealthReport() {
76
+ return getPreviewHealth();
77
+ }
78
+ /**
79
+ * Reset preview health state (called when a new HTML page is served).
80
+ */
81
+ export function resetPreviewHealth() {
82
+ setPreviewHealth(null);
83
+ }
84
+ /**
85
+ * Error-catching script injected into HTML responses.
86
+ * Uses vanilla JS for maximum compatibility.
87
+ */
88
+ export const PREVIEW_HEALTH_SCRIPT = `<script data-codeyam-health>
89
+ (function() {
90
+ var errors = [];
91
+ var reported = false;
92
+ function report(type, msg, stack) {
93
+ errors.push({ type: type, message: msg, stack: stack, timestamp: Date.now() });
94
+ if (!reported) {
95
+ reported = true;
96
+ setTimeout(function() { flush(); }, 500);
97
+ }
98
+ }
99
+ function flush() {
100
+ fetch('/__codeyam__/preview-health', {
101
+ method: 'POST',
102
+ headers: { 'Content-Type': 'application/json' },
103
+ body: JSON.stringify({ errors: errors, url: location.href })
104
+ }).catch(function(){});
105
+ reported = false;
106
+ errors = [];
107
+ }
108
+ window.addEventListener('error', function(e) {
109
+ report('error', e.message, e.error && e.error.stack);
110
+ });
111
+ window.addEventListener('unhandledrejection', function(e) {
112
+ report('unhandledrejection', String(e.reason), e.reason && e.reason.stack);
113
+ });
114
+ var origError = console.error;
115
+ console.error = function() {
116
+ report('console.error', Array.prototype.join.call(arguments, ' '));
117
+ origError.apply(console, arguments);
118
+ };
119
+ window.addEventListener('load', function() {
120
+ setTimeout(function() {
121
+ var hasContent = document.body && document.body.innerText.trim().length > 0;
122
+ fetch('/__codeyam__/preview-health', {
123
+ method: 'POST',
124
+ headers: { 'Content-Type': 'application/json' },
125
+ body: JSON.stringify({
126
+ loaded: true,
127
+ hasContent: hasContent,
128
+ url: location.href,
129
+ errorCount: errors.length
130
+ })
131
+ }).catch(function(){});
132
+ }, 1000);
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
+ });
170
+ })();
171
+ </script>`;
172
+ const CACHE_TTL_MS = 500;
173
+ let scenarioCache = { data: null, timestamp: 0 };
174
+ // Session config extracted from the active scenario — drives cookie injection
175
+ let sessionConfig = undefined;
176
+ /** Session cookies from the seed adapter (e.g. Supabase auth tokens). */
177
+ let seedSessionCookies = undefined;
178
+ // localStorage config extracted from the active scenario — drives HTML injection
179
+ let localStorageConfig = null;
180
+ // Active scenario ID — used to gate localStorage seeding (only re-seed on switch)
181
+ let activeScenarioId = null;
182
+ // Prototype ID — used to gate a one-time localStorage.clear() when a new project is scaffolded
183
+ let currentPrototypeId = null;
184
+ // Current scenario type — 'application'/'user' for seed-based, 'component' for mock-based
185
+ let currentScenarioType = null;
186
+ // Max body size to buffer for mock matching (10MB)
187
+ const MAX_BODY_SIZE = 10 * 1024 * 1024;
188
+ function getProxyState() {
189
+ return globalThis[GLOBAL_KEY] ?? null;
190
+ }
191
+ function setProxyState(state) {
192
+ globalThis[GLOBAL_KEY] = state;
193
+ }
194
+ /**
195
+ * Get or create the mock state manager (survives HMR via globalThis).
196
+ */
197
+ function getMockStateManager() {
198
+ const key = '__codeyam_mock_state__';
199
+ if (!globalThis[key]) {
200
+ globalThis[key] = createMockStateManager();
201
+ }
202
+ return globalThis[key];
203
+ }
204
+ /**
205
+ * Get the proxy URL if the proxy is running.
206
+ */
207
+ export function getProxyUrl() {
208
+ const state = getProxyState();
209
+ if (!state)
210
+ return null;
211
+ return `http://localhost:${state.port}`;
212
+ }
213
+ /**
214
+ * Read the active scenario's mock data from disk, with brief caching.
215
+ * Feeds the data into the MockStateManager.
216
+ *
217
+ * For application/user scenarios (type-aware): only loads `externalApis`
218
+ * into the mock state manager. All DB-backed routes flow through to the
219
+ * real app (database is seeded with real data).
220
+ *
221
+ * For component scenarios (or legacy): loads all routes as before.
222
+ */
223
+ function readScenarioData() {
224
+ const now = Date.now();
225
+ if (scenarioCache.data !== null &&
226
+ now - scenarioCache.timestamp < CACHE_TTL_MS) {
227
+ return scenarioCache.data;
228
+ }
229
+ const projectRoot = getProjectRoot() || process.env.CODEYAM_ROOT_PATH || process.cwd();
230
+ const activeScenarioPath = path.join(projectRoot, '.codeyam', 'active-scenario.json');
231
+ try {
232
+ if (!fs.existsSync(activeScenarioPath)) {
233
+ scenarioCache = { data: null, timestamp: now };
234
+ return null;
235
+ }
236
+ const active = JSON.parse(fs.readFileSync(activeScenarioPath, 'utf-8'));
237
+ const scenarioId = active.scenarioId;
238
+ if (!scenarioId) {
239
+ // No active scenario — but may have a prototypeId for localStorage clearing
240
+ currentPrototypeId = active.prototypeId || null;
241
+ scenarioCache = { data: null, timestamp: now };
242
+ return null;
243
+ }
244
+ const dataFilePath = path.join(projectRoot, '.codeyam', 'editor-scenarios', `${scenarioId}.json`);
245
+ if (!fs.existsSync(dataFilePath)) {
246
+ console.log(`[editorProxy] Scenario data file not found: ${dataFilePath}`);
247
+ scenarioCache = { data: null, timestamp: now };
248
+ return null;
249
+ }
250
+ const rawData = JSON.parse(fs.readFileSync(dataFilePath, 'utf-8'));
251
+ // Extract session config for cookie injection
252
+ sessionConfig = rawData.session || null;
253
+ // Extract seed adapter session cookies (e.g. Supabase auth)
254
+ seedSessionCookies = rawData.sessionCookies || undefined;
255
+ // Extract localStorage config for HTML injection
256
+ localStorageConfig = rawData.localStorage || null;
257
+ activeScenarioId = scenarioId;
258
+ // Type-aware: for seed-based scenarios, only serve externalApis via proxy
259
+ const scenarioType = active.type || rawData.type || null;
260
+ currentScenarioType = scenarioType;
261
+ let mockData;
262
+ if ((scenarioType === 'application' || scenarioType === 'user') &&
263
+ rawData.seed) {
264
+ // Seed-based scenario: only load externalApis as routes for the proxy
265
+ if (rawData.externalApis && typeof rawData.externalApis === 'object') {
266
+ mockData = { routes: rawData.externalApis };
267
+ }
268
+ else {
269
+ // No external APIs — proxy passes everything through
270
+ mockData = {};
271
+ }
272
+ }
273
+ else {
274
+ // Component/legacy scenario: load all data
275
+ mockData = rawData;
276
+ }
277
+ scenarioCache = { data: mockData, timestamp: now };
278
+ // Feed into mock state manager (smart reload handles dedup)
279
+ getMockStateManager().loadScenario(mockData);
280
+ return mockData;
281
+ }
282
+ catch (err) {
283
+ console.warn('[editorProxy] Error reading scenario data:', err);
284
+ scenarioCache = { data: null, timestamp: now };
285
+ return null;
286
+ }
287
+ }
288
+ /**
289
+ * Buffer the request body, up to MAX_BODY_SIZE.
290
+ * Returns null if the body exceeds the limit.
291
+ */
292
+ function bufferRequestBody(req) {
293
+ return new Promise((resolve) => {
294
+ const chunks = [];
295
+ let totalSize = 0;
296
+ req.on('data', (chunk) => {
297
+ totalSize += chunk.length;
298
+ if (totalSize > MAX_BODY_SIZE) {
299
+ resolve(null); // Too large — skip mock matching
300
+ req.resume(); // Drain remaining
301
+ }
302
+ else {
303
+ chunks.push(chunk);
304
+ }
305
+ });
306
+ req.on('end', () => {
307
+ if (totalSize > MAX_BODY_SIZE)
308
+ return; // Already resolved
309
+ resolve(Buffer.concat(chunks));
310
+ });
311
+ req.on('error', () => {
312
+ resolve(null);
313
+ });
314
+ });
315
+ }
316
+ /**
317
+ * Strip IPv6 bracket notation for use with http.request hostname.
318
+ * URL.hostname returns `[::1]` for IPv6 but http.request needs `::1`.
319
+ */
320
+ function stripIPv6Brackets(hostname) {
321
+ if (hostname.startsWith('[') && hostname.endsWith(']')) {
322
+ return hostname.slice(1, -1);
323
+ }
324
+ return hostname;
325
+ }
326
+ /**
327
+ * Forward a buffered request to the target dev server.
328
+ * Unlike the streaming forwardRequest, this replays a buffered body.
329
+ */
330
+ function forwardBufferedRequest(req, res, targetUrl, bodyBuffer) {
331
+ const target = new URL(targetUrl);
332
+ const hostname = stripIPv6Brackets(target.hostname);
333
+ const headers = { ...req.headers, host: `${target.hostname}:${target.port}` };
334
+ // Remove accept-encoding so the dev server returns uncompressed responses.
335
+ // The proxy injects a health script into HTML — this fails on compressed bodies.
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);
341
+ // Update content-length if we have the body buffer
342
+ if (bodyBuffer) {
343
+ headers['content-length'] = String(bodyBuffer.length);
344
+ }
345
+ const options = {
346
+ hostname,
347
+ port: target.port,
348
+ path: req.url,
349
+ method: req.method,
350
+ headers,
351
+ };
352
+ const proxyReq = http.request(options, (proxyRes) => {
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
+ }
357
+ if (status >= 400) {
358
+ console.warn(`[editorProxy] Target returned ${status} for ${req.method} ${req.url}`);
359
+ }
360
+ const headers = { ...proxyRes.headers };
361
+ injectSessionCookie(headers);
362
+ // Check if response is HTML — if so, buffer and inject health script
363
+ const contentType = proxyRes.headers['content-type'] || '';
364
+ if (contentType.includes('text/html')) {
365
+ resetPreviewHealth();
366
+ const chunks = [];
367
+ proxyRes.on('data', (chunk) => chunks.push(chunk));
368
+ proxyRes.on('end', () => {
369
+ const body = Buffer.concat(chunks).toString('utf-8');
370
+ delete headers['content-length'];
371
+ delete headers['content-encoding'];
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);
383
+ res.writeHead(status, headers);
384
+ res.end(injected);
385
+ });
386
+ return;
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
+ }
406
+ res.writeHead(status, headers);
407
+ proxyRes.pipe(res, { end: true });
408
+ });
409
+ proxyReq.on('error', (err) => {
410
+ console.warn(`[editorProxy] Forward error for ${req.method} ${req.url}: ${err.message}`);
411
+ if (!res.headersSent) {
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);
418
+ }
419
+ });
420
+ if (bodyBuffer && bodyBuffer.length > 0) {
421
+ proxyReq.end(bodyBuffer);
422
+ }
423
+ else {
424
+ proxyReq.end();
425
+ }
426
+ }
427
+ /**
428
+ * Forward an HTTP request to the target dev server.
429
+ * For HTML responses: buffers body to inject health-check script.
430
+ * For non-HTML responses: pipes directly (no buffering).
431
+ */
432
+ function forwardRequest(req, res, targetUrl) {
433
+ const target = new URL(targetUrl);
434
+ const hostname = stripIPv6Brackets(target.hostname);
435
+ // Build headers, stripping accept-encoding so the dev server returns uncompressed
436
+ // responses. The proxy injects a health script into HTML — this fails on compressed bodies.
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);
445
+ const options = {
446
+ hostname,
447
+ port: target.port,
448
+ path: req.url,
449
+ method: req.method,
450
+ headers: reqHeaders,
451
+ };
452
+ const proxyReq = http.request(options, (proxyRes) => {
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
+ }
457
+ if (status >= 400) {
458
+ console.warn(`[editorProxy] Target returned ${status} for ${req.method} ${req.url}`);
459
+ }
460
+ const headers = { ...proxyRes.headers };
461
+ injectSessionCookie(headers);
462
+ // Check if response is HTML — if so, buffer and inject health script
463
+ const contentType = proxyRes.headers['content-type'] || '';
464
+ if (contentType.includes('text/html')) {
465
+ // Reset health state for new page loads
466
+ resetPreviewHealth();
467
+ const chunks = [];
468
+ proxyRes.on('data', (chunk) => chunks.push(chunk));
469
+ proxyRes.on('end', () => {
470
+ const body = Buffer.concat(chunks).toString('utf-8');
471
+ delete headers['content-length'];
472
+ delete headers['content-encoding'];
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);
484
+ res.writeHead(status, headers);
485
+ res.end(injected);
486
+ });
487
+ return;
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
+ }
507
+ res.writeHead(status, headers);
508
+ proxyRes.pipe(res, { end: true });
509
+ });
510
+ proxyReq.on('error', (err) => {
511
+ console.warn(`[editorProxy] Forward error for ${req.method} ${req.url}: ${err.message}`);
512
+ if (!res.headersSent) {
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);
519
+ }
520
+ });
521
+ req.pipe(proxyReq, { end: true });
522
+ }
523
+ /**
524
+ * Inject or clear the session-token cookie on proxied responses.
525
+ * When a scenario has session.cookieValue, sets the cookie to auto-log the user in.
526
+ * When a scenario has no session field (null), clears any existing session cookie.
527
+ * When sessionConfig is undefined (no scenario loaded yet), does nothing.
528
+ */
529
+ function injectSessionCookie(headers) {
530
+ const cookies = [];
531
+ // Dev auth cookie (built-in session-token)
532
+ if (sessionConfig !== undefined) {
533
+ if (sessionConfig?.cookieValue) {
534
+ cookies.push(`session-token=${sessionConfig.cookieValue}; Path=/; SameSite=Lax`);
535
+ }
536
+ else {
537
+ cookies.push(`session-token=; Path=/; Max-Age=0`);
538
+ }
539
+ }
540
+ // Seed adapter session cookies (e.g. Supabase auth tokens)
541
+ if (seedSessionCookies && seedSessionCookies.length > 0) {
542
+ for (const sc of seedSessionCookies) {
543
+ const cookiePath = sc.path || '/';
544
+ const sameSite = sc.sameSite || 'Lax';
545
+ cookies.push(`${sc.name}=${sc.value}; Path=${cookiePath}; SameSite=${sameSite}`);
546
+ }
547
+ }
548
+ if (cookies.length === 0)
549
+ return;
550
+ const existing = headers['set-cookie'];
551
+ if (existing) {
552
+ headers['set-cookie'] = [
553
+ ...(Array.isArray(existing) ? existing : [existing]),
554
+ ...cookies,
555
+ ];
556
+ }
557
+ else {
558
+ headers['set-cookie'] = cookies;
559
+ }
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
+ }
620
+ /**
621
+ * Get the current session config (for testing).
622
+ */
623
+ export function getSessionConfig() {
624
+ return sessionConfig;
625
+ }
626
+ /**
627
+ * Get the current localStorage config (for testing and script generation).
628
+ */
629
+ export function getLocalStorageConfig() {
630
+ return localStorageConfig;
631
+ }
632
+ /**
633
+ * Get the active scenario ID (for testing and script generation).
634
+ */
635
+ export function getActiveScenarioId() {
636
+ return activeScenarioId;
637
+ }
638
+ /**
639
+ * Get the current prototype ID (for testing).
640
+ */
641
+ export function getCurrentPrototypeId() {
642
+ return currentPrototypeId;
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
+ }
655
+ /**
656
+ * Build a script tag that seeds localStorage with scenario data on first load.
657
+ * Gated by scenario ID — only seeds when the scenario changes, preserving
658
+ * interactive modifications across page reloads / HMR.
659
+ *
660
+ * Returns empty string if no localStorage config is provided.
661
+ */
662
+ export function buildLocalStorageScript(localStorageConfig, scenarioId, prototypeId) {
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.
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}` : '';
670
+ if (prototypeId) {
671
+ return `<script data-codeyam-ls>
672
+ (function() {
673
+ if (localStorage.getItem('__codeyam_proto__') === ${JSON.stringify(prototypeId)}) return;
674
+ localStorage.clear();
675
+ localStorage.setItem('__codeyam_proto__', ${JSON.stringify(prototypeId)});
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
+ })();
690
+ </script>`;
691
+ }
692
+ return '';
693
+ }
694
+ // Even an empty object needs a cleanup script — switching from a scenario
695
+ // with localStorage data to one without must clear the previous keys.
696
+ const entries = Object.entries(localStorageConfig);
697
+ const keys = entries.map(([k]) => k);
698
+ // Build setItem calls — stringify non-string values
699
+ const setStatements = entries
700
+ .map(([key, value]) => {
701
+ const serialized = typeof value === 'string' ? value : JSON.stringify(value);
702
+ return `localStorage.setItem(${JSON.stringify(key)}, ${JSON.stringify(serialized)});`;
703
+ })
704
+ .join('\n');
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>
712
+ (function() {
713
+ if (localStorage.getItem('__codeyam_ls_sid__') === ${JSON.stringify(guardValue)}) return;
714
+ var prev = JSON.parse(localStorage.getItem('__codeyam_ls_keys__') || '[]');
715
+ for (var i = 0; i < prev.length; i++) localStorage.removeItem(prev[i]);
716
+ ${setStatements}
717
+ localStorage.setItem('__codeyam_ls_keys__', ${JSON.stringify(JSON.stringify(keys))});
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
+ });
777
+ })();
778
+ </script>`;
779
+ }
780
+ /**
781
+ * Inject the health-check script (and optional localStorage script) into an HTML response body.
782
+ * Inserts before </head> if present, otherwise before </body>, otherwise appends.
783
+ * When a localStorageScript is provided, it's injected BEFORE the health script
784
+ * so localStorage is populated before the app loads.
785
+ */
786
+ export function injectHealthScript(html, localStorageScript) {
787
+ const scripts = (localStorageScript || '') + PREVIEW_HEALTH_SCRIPT;
788
+ if (html.includes('</head>')) {
789
+ return html.replace('</head>', scripts + '</head>');
790
+ }
791
+ if (html.includes('</body>')) {
792
+ return html.replace('</body>', scripts + '</body>');
793
+ }
794
+ return html + scripts;
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
+ }
906
+ /**
907
+ * Handle POST /__codeyam__/preview-health — store health data in globalThis.
908
+ */
909
+ function handlePreviewHealthPost(req, res) {
910
+ const chunks = [];
911
+ req.on('data', (chunk) => chunks.push(chunk));
912
+ req.on('end', () => {
913
+ try {
914
+ const body = JSON.parse(Buffer.concat(chunks).toString('utf-8'));
915
+ const current = getPreviewHealth() || {
916
+ errors: [],
917
+ loaded: false,
918
+ hasContent: false,
919
+ url: '',
920
+ lastUpdated: 0,
921
+ };
922
+ if (body.errors && Array.isArray(body.errors)) {
923
+ current.errors = current.errors.concat(body.errors);
924
+ }
925
+ if (body.loaded !== undefined) {
926
+ current.loaded = body.loaded;
927
+ }
928
+ if (body.hasContent !== undefined) {
929
+ current.hasContent = body.hasContent;
930
+ }
931
+ if (body.url) {
932
+ current.url = body.url;
933
+ }
934
+ current.lastUpdated = Date.now();
935
+ setPreviewHealth(current);
936
+ }
937
+ catch {
938
+ // Ignore malformed JSON
939
+ }
940
+ res.writeHead(204);
941
+ res.end();
942
+ });
943
+ }
944
+ /**
945
+ * Handle WebSocket upgrade by piping to the target dev server.
946
+ */
947
+ function handleUpgrade(req, socket, head, targetUrl) {
948
+ const target = new URL(targetUrl);
949
+ const hostname = stripIPv6Brackets(target.hostname);
950
+ const port = parseInt(target.port, 10) || 80;
951
+ console.log(`[editorProxy] WebSocket upgrade: ${req.url} → ${hostname}:${port}`);
952
+ const proxySocket = net.connect(port, hostname, () => {
953
+ // Reconstruct the HTTP upgrade request
954
+ const requestLine = `${req.method} ${req.url} HTTP/${req.httpVersion}\r\n`;
955
+ const headers = Object.entries(req.headers)
956
+ .filter(([, v]) => v != null)
957
+ .map(([k, v]) => `${k}: ${Array.isArray(v) ? v.join(', ') : v}`)
958
+ .join('\r\n');
959
+ proxySocket.write(requestLine + headers + '\r\n\r\n');
960
+ if (head.length > 0) {
961
+ proxySocket.write(head);
962
+ }
963
+ // Pipe both directions
964
+ proxySocket.pipe(socket, { end: true });
965
+ socket.pipe(proxySocket, { end: true });
966
+ });
967
+ proxySocket.on('error', (err) => {
968
+ console.warn(`[editorProxy] WebSocket proxy error: ${err.message}`);
969
+ socket.destroy();
970
+ });
971
+ socket.on('error', () => {
972
+ proxySocket.destroy();
973
+ });
974
+ }
975
+ /**
976
+ * Write proxy-config.json so the preload module can discover the proxy.
977
+ */
978
+ function writeProxyConfig(proxyPort, targetUrl) {
979
+ const projectRoot = getProjectRoot() || process.env.CODEYAM_ROOT_PATH || process.cwd();
980
+ const configPath = path.join(projectRoot, '.codeyam', 'proxy-config.json');
981
+ try {
982
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
983
+ fs.writeFileSync(configPath, JSON.stringify({
984
+ proxyUrl: `http://localhost:${proxyPort}`,
985
+ devServerUrl: targetUrl,
986
+ }), 'utf-8');
987
+ console.log(`[editorProxy] Wrote proxy config to ${configPath}`);
988
+ }
989
+ catch (err) {
990
+ console.warn('[editorProxy] Failed to write proxy-config.json:', err);
991
+ }
992
+ }
993
+ /**
994
+ * Remove proxy-config.json on proxy stop.
995
+ */
996
+ function removeProxyConfig() {
997
+ const projectRoot = getProjectRoot() || process.env.CODEYAM_ROOT_PATH || process.cwd();
998
+ const configPath = path.join(projectRoot, '.codeyam', 'proxy-config.json');
999
+ try {
1000
+ if (fs.existsSync(configPath)) {
1001
+ fs.unlinkSync(configPath);
1002
+ }
1003
+ }
1004
+ catch {
1005
+ // Best effort
1006
+ }
1007
+ }
1008
+ /**
1009
+ * Start the editor proxy server.
1010
+ * Intercepts requests to API routes matching the active scenario, forwards everything else.
1011
+ * Supports all HTTP methods (GET, POST, PUT, DELETE, PATCH) with body buffering.
1012
+ */
1013
+ export async function startEditorProxy(options) {
1014
+ // If proxy is already running, reuse it (prevents second tab from killing first tab's proxy)
1015
+ const existing = getProxyState();
1016
+ if (existing) {
1017
+ console.log(`[editorProxy] Proxy already running on port ${existing.port} → ${existing.targetUrl}`);
1018
+ return { port: existing.port };
1019
+ }
1020
+ // Stop any leftover state (shouldn't happen, but defensive)
1021
+ await stopEditorProxy();
1022
+ let targetUrl = normalizeTargetUrl(options.targetUrl);
1023
+ let port = options.port;
1024
+ // When the target is localhost, probe to find the correct loopback address.
1025
+ // Dev servers may bind to IPv4 (127.0.0.1) or IPv6 (::1) — Vite 6 on macOS
1026
+ // binds to ::1 by default. We need to match the actual binding.
1027
+ try {
1028
+ const parsed = new URL(targetUrl);
1029
+ if (parsed.hostname === 'localhost') {
1030
+ const targetPort = parseInt(parsed.port || '80', 10);
1031
+ const resolvedHost = await resolveLoopbackAddress(targetPort);
1032
+ if (resolvedHost) {
1033
+ parsed.hostname = resolvedHost;
1034
+ targetUrl = parsed.toString().replace(/\/$/, '');
1035
+ console.log(`[editorProxy] Resolved localhost to ${resolvedHost} for port ${targetPort}`);
1036
+ }
1037
+ }
1038
+ }
1039
+ catch {
1040
+ // Keep original targetUrl
1041
+ }
1042
+ console.log(`[editorProxy] Starting proxy (requested port ${port}, target ${targetUrl})`);
1043
+ const mockState = getMockStateManager();
1044
+ const server = http.createServer((req, res) => {
1045
+ void (async () => {
1046
+ const parsedUrl = new URL(req.url || '/', `http://localhost:${port}`);
1047
+ const pathname = parsedUrl.pathname;
1048
+ const method = req.method || 'GET';
1049
+ // CORS preflight — permissive 204 for browser cross-origin requests
1050
+ if (method === 'OPTIONS') {
1051
+ res.writeHead(204, {
1052
+ 'Access-Control-Allow-Origin': '*',
1053
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
1054
+ 'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With',
1055
+ 'Access-Control-Max-Age': '86400',
1056
+ });
1057
+ res.end();
1058
+ return;
1059
+ }
1060
+ // Intercept preview health reports from the injected script
1061
+ if (method === 'POST' && pathname === '/__codeyam__/preview-health') {
1062
+ handlePreviewHealthPost(req, res);
1063
+ return;
1064
+ }
1065
+ // Load scenario data (also feeds MockStateManager)
1066
+ readScenarioData();
1067
+ // For methods that may carry a body, buffer it first
1068
+ const needsBody = method === 'POST' ||
1069
+ method === 'PUT' ||
1070
+ method === 'DELETE' ||
1071
+ method === 'PATCH';
1072
+ if (needsBody) {
1073
+ const bodyBuffer = await bufferRequestBody(req);
1074
+ if (bodyBuffer === null) {
1075
+ // Body too large — forward without mock matching
1076
+ forwardBufferedRequest(req, res, targetUrl, null);
1077
+ return;
1078
+ }
1079
+ // Try to parse body as JSON for mock matching
1080
+ let parsedBody = undefined;
1081
+ if (bodyBuffer.length > 0) {
1082
+ try {
1083
+ parsedBody = JSON.parse(bodyBuffer.toString('utf-8'));
1084
+ }
1085
+ catch {
1086
+ // Not JSON — that's fine, still try mock matching without parsed body
1087
+ }
1088
+ }
1089
+ const match = mockState.matchRequest(method, pathname, parsedBody);
1090
+ if (match) {
1091
+ console.log(`[editorProxy] Intercepted ${method} ${pathname} → mock response (status ${match.status})`);
1092
+ res.writeHead(match.status, {
1093
+ 'Content-Type': 'application/json',
1094
+ 'Access-Control-Allow-Origin': '*',
1095
+ 'X-CodeYam-Proxy': 'scenario-data',
1096
+ 'Cache-Control': 'no-store',
1097
+ });
1098
+ res.end(match.body != null ? JSON.stringify(match.body) : '');
1099
+ return;
1100
+ }
1101
+ // No mock match — forward with buffered body
1102
+ if ((currentScenarioType === 'application' ||
1103
+ currentScenarioType === 'user') &&
1104
+ pathname.startsWith('/api/')) {
1105
+ mockStateEventEmitter.emitDataMutationForwarded(method, pathname);
1106
+ }
1107
+ forwardBufferedRequest(req, res, targetUrl, bodyBuffer);
1108
+ return;
1109
+ }
1110
+ // GET, HEAD, etc. — try mock matching (no body)
1111
+ const match = mockState.matchRequest(method, pathname);
1112
+ if (match) {
1113
+ console.log(`[editorProxy] Intercepted ${method} ${pathname} → mock response (status ${match.status})`);
1114
+ res.writeHead(match.status, {
1115
+ 'Content-Type': 'application/json',
1116
+ 'Access-Control-Allow-Origin': '*',
1117
+ 'X-CodeYam-Proxy': 'scenario-data',
1118
+ 'Cache-Control': 'no-store',
1119
+ });
1120
+ res.end(match.body != null ? JSON.stringify(match.body) : '');
1121
+ return;
1122
+ }
1123
+ // Forward everything else to the dev server
1124
+ forwardRequest(req, res, targetUrl);
1125
+ })();
1126
+ });
1127
+ // Handle WebSocket upgrades (for HMR)
1128
+ server.on('upgrade', (req, socket, head) => {
1129
+ handleUpgrade(req, socket, head, targetUrl);
1130
+ });
1131
+ // Try to bind, with port fallback
1132
+ const maxAttempts = 10;
1133
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
1134
+ const currentPort = port + attempt;
1135
+ try {
1136
+ await new Promise((resolve, reject) => {
1137
+ server.once('error', reject);
1138
+ server.listen(currentPort, '0.0.0.0', () => {
1139
+ server.removeListener('error', reject);
1140
+ resolve();
1141
+ });
1142
+ });
1143
+ // When port 0 is requested, the OS assigns an ephemeral port
1144
+ const addr = server.address();
1145
+ port =
1146
+ typeof addr === 'object' && addr !== null ? addr.port : currentPort;
1147
+ const state = { server, port, targetUrl };
1148
+ setProxyState(state);
1149
+ // Write proxy-config.json for the preload module
1150
+ writeProxyConfig(port, targetUrl);
1151
+ console.log(`[editorProxy] Proxy started on port ${port}, forwarding to ${targetUrl}`);
1152
+ return { port };
1153
+ }
1154
+ catch (err) {
1155
+ if (err?.code === 'EADDRINUSE' && attempt < maxAttempts - 1) {
1156
+ console.log(`[editorProxy] Port ${currentPort} in use, trying ${currentPort + 1}`);
1157
+ continue;
1158
+ }
1159
+ console.error(`[editorProxy] Failed to start proxy:`, err);
1160
+ return null;
1161
+ }
1162
+ }
1163
+ return null;
1164
+ }
1165
+ /**
1166
+ * Stop the editor proxy server.
1167
+ */
1168
+ export async function stopEditorProxy() {
1169
+ const state = getProxyState();
1170
+ if (!state)
1171
+ return;
1172
+ console.log(`[editorProxy] Stopping proxy on port ${state.port}`);
1173
+ removeProxyConfig();
1174
+ return new Promise((resolve) => {
1175
+ state.server.close(() => {
1176
+ console.log('[editorProxy] Proxy stopped');
1177
+ resolve();
1178
+ });
1179
+ setProxyState(null);
1180
+ // Force-close after 2s if graceful close doesn't happen
1181
+ setTimeout(resolve, 2000);
1182
+ });
1183
+ }
1184
+ /**
1185
+ * Invalidate the scenario data cache (e.g., after writing a new active-scenario.json).
1186
+ */
1187
+ export function invalidateScenarioCache() {
1188
+ scenarioCache = { data: null, timestamp: 0 };
1189
+ sessionConfig = undefined;
1190
+ seedSessionCookies = undefined;
1191
+ localStorageConfig = null;
1192
+ activeScenarioId = null;
1193
+ currentPrototypeId = null;
1194
+ }
1195
+ /**
1196
+ * Verify that the proxy can successfully forward a request to the target dev server.
1197
+ * Makes a HEAD request through the proxy and checks that it gets a response (any status).
1198
+ * Returns false if the proxy isn't running or if the request fails entirely.
1199
+ */
1200
+ export async function verifyProxyForwarding() {
1201
+ const state = getProxyState();
1202
+ if (!state) {
1203
+ console.warn('[editorProxy] Cannot verify — proxy is not running');
1204
+ return false;
1205
+ }
1206
+ try {
1207
+ const response = await fetch(`http://127.0.0.1:${state.port}/`, {
1208
+ method: 'HEAD',
1209
+ signal: AbortSignal.timeout(5000),
1210
+ });
1211
+ // Any response from the target (even 404) means forwarding works.
1212
+ // Only 502 (our own Bad Gateway) means the target is unreachable.
1213
+ if (response.status === 502) {
1214
+ console.warn(`[editorProxy] Verification failed — proxy returned 502 (target unreachable)`);
1215
+ return false;
1216
+ }
1217
+ console.log(`[editorProxy] Verification passed — proxy forwarding to ${state.targetUrl} (status ${response.status})`);
1218
+ return true;
1219
+ }
1220
+ catch (err) {
1221
+ console.warn(`[editorProxy] Verification failed — could not reach proxy on port ${state.port}`);
1222
+ return false;
1223
+ }
1224
+ }
1225
+ /**
1226
+ * Ensure the proxy is running. If it's not, start it using the current dev server URL.
1227
+ * Returns the proxy URL once ready, or null if it can't be started.
1228
+ *
1229
+ * Used by capture flows to guarantee the proxy is listening before Playwright navigates.
1230
+ */
1231
+ export async function ensureProxyRunning() {
1232
+ // Already running?
1233
+ const existing = getProxyUrl();
1234
+ if (existing) {
1235
+ console.log(`[editorProxy] Proxy already running at ${existing}`);
1236
+ return existing;
1237
+ }
1238
+ // Try to start it — we need the dev server URL
1239
+ const devServer = globalThis.__codeyam_editor_dev_server__;
1240
+ if (!devServer || devServer.status !== 'running' || !devServer.url) {
1241
+ console.log('[editorProxy] Cannot start proxy — dev server not running');
1242
+ return null;
1243
+ }
1244
+ const codeyamPort = parseInt(process.env.CODEYAM_PORT || '3111', 10);
1245
+ const { proxyPort } = computeEditorPorts(codeyamPort);
1246
+ console.log(`[editorProxy] Proxy not running, starting on-demand (port ${proxyPort}, target ${devServer.url})`);
1247
+ const result = await startEditorProxy({
1248
+ port: proxyPort,
1249
+ targetUrl: devServer.url,
1250
+ });
1251
+ if (result) {
1252
+ const url = `http://localhost:${result.port}`;
1253
+ console.log(`[editorProxy] On-demand proxy started at ${url}`);
1254
+ return url;
1255
+ }
1256
+ console.error('[editorProxy] Failed to start on-demand proxy');
1257
+ return null;
1258
+ }
1259
+ /**
1260
+ * Test-only export: trigger readScenarioData so tests can verify session config extraction.
1261
+ */
1262
+ export const _readScenarioDataForTest = readScenarioData;
1263
+ //# sourceMappingURL=editorProxy.js.map