@codeyam/codeyam-cli 0.1.0-staging.e38f7bd → 0.1.0-staging.f777668

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 (1310) hide show
  1. package/analyzer-template/.build-info.json +8 -8
  2. package/analyzer-template/common/execAsync.ts +1 -1
  3. package/analyzer-template/log.txt +3 -3
  4. package/analyzer-template/package.json +36 -32
  5. package/analyzer-template/packages/ai/index.ts +21 -5
  6. package/analyzer-template/packages/ai/package.json +5 -5
  7. package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
  8. package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +228 -24
  9. package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
  10. package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +239 -13
  11. package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
  12. package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
  13. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
  14. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
  15. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
  16. package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
  17. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1619 -125
  18. package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
  19. package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +324 -5
  20. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  21. package/analyzer-template/packages/ai/src/lib/completionCall.ts +247 -66
  22. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2788 -390
  23. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +21 -4
  24. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
  25. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
  26. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
  27. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
  28. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
  29. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
  30. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
  31. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.ts +62 -0
  32. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +163 -14
  33. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  34. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
  35. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
  36. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +441 -82
  37. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
  38. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.ts +35 -0
  39. package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -0
  40. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  41. package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
  42. package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
  43. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
  44. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
  45. package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
  46. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1495 -101
  47. package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
  48. package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +677 -0
  49. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
  50. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2484 -0
  51. package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
  52. package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
  53. package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
  54. package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
  55. package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
  56. package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
  57. package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
  58. package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
  59. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
  60. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
  61. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
  62. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
  63. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +110 -6
  64. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
  65. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
  66. package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
  67. package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
  68. package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
  69. package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
  70. package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
  71. package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
  72. package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
  73. package/analyzer-template/packages/analyze/index.ts +2 -0
  74. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
  75. package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +132 -33
  76. package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
  77. package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
  78. package/analyzer-template/packages/analyze/src/lib/asts/nodes/getNodeType.ts +1 -0
  79. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  80. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  81. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
  82. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
  83. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
  84. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
  85. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
  86. package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
  87. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +570 -180
  88. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +62 -1
  89. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +15 -0
  90. package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
  91. package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
  92. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
  93. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
  94. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
  95. package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
  96. package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
  97. package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +22 -13
  98. package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1352 -0
  99. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -0
  100. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  101. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +711 -78
  102. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
  103. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
  104. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +633 -137
  105. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +166 -0
  106. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
  107. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
  108. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1087 -168
  109. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
  110. package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
  111. package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
  112. package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
  113. package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
  114. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  115. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  116. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  117. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  118. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  119. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  120. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  121. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  122. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  123. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  124. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  125. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  126. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  127. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
  128. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
  129. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
  130. package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
  131. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  132. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  133. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  134. package/analyzer-template/packages/aws/package.json +10 -10
  135. package/analyzer-template/packages/aws/s3/index.ts +1 -0
  136. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  137. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  138. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  139. package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
  140. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  141. package/analyzer-template/packages/database/index.ts +1 -0
  142. package/analyzer-template/packages/database/package.json +4 -4
  143. package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
  144. package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
  145. package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
  146. package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
  147. package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
  148. package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
  149. package/analyzer-template/packages/database/src/lib/kysely/db.ts +26 -5
  150. package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
  151. package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
  152. package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
  153. package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +68 -0
  154. package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
  155. package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
  156. package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
  157. package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
  158. package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
  159. package/analyzer-template/packages/database/src/lib/loadCommits.ts +58 -19
  160. package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
  161. package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
  162. package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +25 -5
  163. package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
  164. package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
  165. package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
  166. package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +153 -144
  167. package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatus.ts +58 -42
  168. package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.ts +81 -65
  169. package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
  170. package/analyzer-template/packages/generate/index.ts +3 -0
  171. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  172. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +221 -0
  173. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  174. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +42 -9
  175. package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
  176. package/analyzer-template/packages/generate/src/lib/directExecutionScript.ts +17 -2
  177. package/analyzer-template/packages/generate/src/lib/getComponentScenarioPath.ts +8 -3
  178. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  179. package/analyzer-template/packages/github/dist/database/index.d.ts +1 -0
  180. package/analyzer-template/packages/github/dist/database/index.d.ts.map +1 -1
  181. package/analyzer-template/packages/github/dist/database/index.js +1 -0
  182. package/analyzer-template/packages/github/dist/database/index.js.map +1 -1
  183. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
  184. package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
  185. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
  186. package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
  187. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
  188. package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
  189. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
  190. package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
  191. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
  192. package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
  193. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
  194. package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
  195. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +6 -2
  196. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
  197. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +18 -3
  198. package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
  199. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
  200. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
  201. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
  202. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
  203. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
  204. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
  205. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  206. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
  207. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
  208. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  209. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  210. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +22 -0
  211. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -0
  212. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +51 -0
  213. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
  214. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  215. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  216. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
  217. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
  218. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  219. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  220. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +7 -6
  221. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  222. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
  223. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
  224. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
  225. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
  226. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
  227. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
  228. package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
  229. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
  230. package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
  231. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
  232. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
  233. package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
  234. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
  235. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
  236. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +45 -14
  237. package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
  238. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
  239. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
  240. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
  241. package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
  242. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
  243. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
  244. package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
  245. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
  246. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +20 -5
  247. package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  248. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
  249. package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
  250. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
  251. package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
  252. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
  253. package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
  254. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
  255. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
  256. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +100 -88
  257. package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
  258. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.d.ts.map +1 -1
  259. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js +41 -30
  260. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
  261. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.d.ts.map +1 -1
  262. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
  263. package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js.map +1 -1
  264. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  265. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  266. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  267. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  268. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  269. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  270. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  271. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  272. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  273. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +217 -0
  274. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  275. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  276. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  277. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  278. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  279. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
  280. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +41 -9
  281. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  282. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
  283. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
  284. package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
  285. package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.d.ts.map +1 -1
  286. package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js +10 -1
  287. package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js.map +1 -1
  288. package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.d.ts.map +1 -1
  289. package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js +7 -3
  290. package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js.map +1 -1
  291. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  292. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  293. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  294. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  295. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  296. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  297. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  298. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  299. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  300. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  301. package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
  302. package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
  303. package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
  304. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
  305. package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
  306. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
  307. package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
  308. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  309. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  310. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +8 -0
  311. package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  312. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +21 -6
  313. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  314. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
  315. package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  316. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  317. package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  318. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
  319. package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  320. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
  321. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js +26 -2
  322. package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
  323. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  324. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  325. package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  326. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
  327. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  328. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
  329. package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
  330. package/analyzer-template/packages/github/package.json +2 -2
  331. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  332. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  333. package/analyzer-template/packages/process/index.ts +2 -0
  334. package/analyzer-template/packages/process/package.json +12 -0
  335. package/analyzer-template/packages/process/tsconfig.json +8 -0
  336. package/analyzer-template/packages/types/index.ts +5 -0
  337. package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
  338. package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
  339. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  340. package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +8 -0
  341. package/analyzer-template/packages/types/src/types/Scenario.ts +21 -10
  342. package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
  343. package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
  344. package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
  345. package/analyzer-template/packages/ui-components/package.json +4 -4
  346. package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
  347. package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
  348. package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
  349. package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
  350. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
  351. package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
  352. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
  353. package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
  354. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  355. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  356. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +8 -0
  357. package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
  358. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +21 -6
  359. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  360. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
  361. package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
  362. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
  363. package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
  364. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
  365. package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
  366. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
  367. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js +26 -2
  368. package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
  369. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
  370. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +98 -3
  371. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  372. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
  373. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
  374. package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  375. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
  376. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
  377. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
  378. package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
  379. package/analyzer-template/packages/utils/src/lib/applyUniversalMocks.ts +28 -2
  380. package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +121 -3
  381. package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
  382. package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
  383. package/analyzer-template/playwright/capture.ts +57 -26
  384. package/analyzer-template/playwright/captureFromUrl.ts +89 -82
  385. package/analyzer-template/playwright/captureStatic.ts +1 -1
  386. package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
  387. package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
  388. package/analyzer-template/playwright/takeScreenshot.ts +15 -9
  389. package/analyzer-template/playwright/waitForServer.ts +21 -6
  390. package/analyzer-template/project/TESTING.md +83 -0
  391. package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
  392. package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
  393. package/analyzer-template/project/analyzeFileEntities.ts +4 -0
  394. package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
  395. package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
  396. package/analyzer-template/project/constructMockCode.ts +1459 -178
  397. package/analyzer-template/project/controller/startController.ts +16 -1
  398. package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
  399. package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
  400. package/analyzer-template/project/loadReadyToBeCaptured.ts +82 -42
  401. package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
  402. package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
  403. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +13 -9
  404. package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
  405. package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
  406. package/analyzer-template/project/orchestrateCapture.ts +92 -13
  407. package/analyzer-template/project/reconcileMockDataKeys.ts +251 -3
  408. package/analyzer-template/project/runAnalysis.ts +11 -0
  409. package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
  410. package/analyzer-template/project/serverOnlyModules.ts +413 -0
  411. package/analyzer-template/project/start.ts +75 -19
  412. package/analyzer-template/project/startScenarioCapture.ts +88 -41
  413. package/analyzer-template/project/writeClientLogRoute.ts +125 -0
  414. package/analyzer-template/project/writeMockDataTsx.ts +483 -73
  415. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  416. package/analyzer-template/project/writeScenarioComponents.ts +1538 -226
  417. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  418. package/analyzer-template/project/writeSimpleRoot.ts +56 -22
  419. package/analyzer-template/project/writeUniversalMocks.ts +32 -11
  420. package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
  421. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  422. package/analyzer-template/tsconfig.json +14 -1
  423. package/background/src/lib/local/createLocalAnalyzer.js +2 -30
  424. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  425. package/background/src/lib/local/execAsync.js +1 -1
  426. package/background/src/lib/local/execAsync.js.map +1 -1
  427. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  428. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  429. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +7 -1
  430. package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
  431. package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
  432. package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
  433. package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
  434. package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
  435. package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
  436. package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
  437. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
  438. package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
  439. package/background/src/lib/virtualized/project/constructMockCode.js +1288 -133
  440. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  441. package/background/src/lib/virtualized/project/controller/startController.js +11 -1
  442. package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
  443. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
  444. package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
  445. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
  446. package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
  447. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +34 -9
  448. package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
  449. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
  450. package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
  451. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
  452. package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
  453. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +12 -6
  454. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  455. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +73 -36
  456. package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
  457. package/background/src/lib/virtualized/project/orchestrateCapture.js +76 -14
  458. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  459. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +211 -3
  460. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  461. package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
  462. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  463. package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
  464. package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
  465. package/background/src/lib/virtualized/project/serverOnlyModules.js +338 -0
  466. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -0
  467. package/background/src/lib/virtualized/project/start.js +64 -19
  468. package/background/src/lib/virtualized/project/start.js.map +1 -1
  469. package/background/src/lib/virtualized/project/startScenarioCapture.js +66 -31
  470. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  471. package/background/src/lib/virtualized/project/writeClientLogRoute.js +110 -0
  472. package/background/src/lib/virtualized/project/writeClientLogRoute.js.map +1 -0
  473. package/background/src/lib/virtualized/project/writeMockDataTsx.js +416 -62
  474. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  475. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  476. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  477. package/background/src/lib/virtualized/project/writeScenarioComponents.js +1134 -153
  478. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  479. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  480. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  481. package/background/src/lib/virtualized/project/writeSimpleRoot.js +57 -20
  482. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  483. package/background/src/lib/virtualized/project/writeUniversalMocks.js +27 -12
  484. package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
  485. package/codeyam-cli/scripts/apply-setup.js +386 -9
  486. package/codeyam-cli/scripts/apply-setup.js.map +1 -1
  487. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
  488. package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
  489. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
  490. package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
  491. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
  492. package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
  493. package/codeyam-cli/src/cli.js +39 -22
  494. package/codeyam-cli/src/cli.js.map +1 -1
  495. package/codeyam-cli/src/codeyam-cli.js +18 -2
  496. package/codeyam-cli/src/codeyam-cli.js.map +1 -1
  497. package/codeyam-cli/src/commands/analyze.js +22 -10
  498. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  499. package/codeyam-cli/src/commands/baseline.js +176 -0
  500. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  501. package/codeyam-cli/src/commands/debug.js +44 -18
  502. package/codeyam-cli/src/commands/debug.js.map +1 -1
  503. package/codeyam-cli/src/commands/default.js +43 -35
  504. package/codeyam-cli/src/commands/default.js.map +1 -1
  505. package/codeyam-cli/src/commands/editor.js +2607 -0
  506. package/codeyam-cli/src/commands/editor.js.map +1 -0
  507. package/codeyam-cli/src/commands/init.js +81 -260
  508. package/codeyam-cli/src/commands/init.js.map +1 -1
  509. package/codeyam-cli/src/commands/memory.js +278 -0
  510. package/codeyam-cli/src/commands/memory.js.map +1 -0
  511. package/codeyam-cli/src/commands/recapture.js +228 -0
  512. package/codeyam-cli/src/commands/recapture.js.map +1 -0
  513. package/codeyam-cli/src/commands/report.js +72 -24
  514. package/codeyam-cli/src/commands/report.js.map +1 -1
  515. package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
  516. package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
  517. package/codeyam-cli/src/commands/setup-simulations.js +284 -0
  518. package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
  519. package/codeyam-cli/src/commands/start.js +8 -12
  520. package/codeyam-cli/src/commands/start.js.map +1 -1
  521. package/codeyam-cli/src/commands/status.js +23 -1
  522. package/codeyam-cli/src/commands/status.js.map +1 -1
  523. package/codeyam-cli/src/commands/test-startup.js +3 -1
  524. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  525. package/codeyam-cli/src/commands/verify.js +14 -2
  526. package/codeyam-cli/src/commands/verify.js.map +1 -1
  527. package/codeyam-cli/src/commands/wipe.js +108 -0
  528. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  529. package/codeyam-cli/src/utils/__tests__/devServerState.test.js +134 -0
  530. package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
  531. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +127 -0
  532. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
  533. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +635 -0
  534. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -0
  535. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
  536. package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
  537. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +155 -0
  538. package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -0
  539. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +121 -0
  540. package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
  541. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
  542. package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
  543. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +542 -0
  544. package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -0
  545. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +393 -0
  546. package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
  547. package/codeyam-cli/src/utils/__tests__/editorMockState.test.js +270 -0
  548. package/codeyam-cli/src/utils/__tests__/editorMockState.test.js.map +1 -0
  549. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +217 -0
  550. package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -0
  551. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +266 -0
  552. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -0
  553. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
  554. package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
  555. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +221 -0
  556. package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
  557. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +221 -0
  558. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -0
  559. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +213 -0
  560. package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
  561. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +1686 -0
  562. package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
  563. package/codeyam-cli/src/utils/__tests__/git.editor.test.js +134 -0
  564. package/codeyam-cli/src/utils/__tests__/git.editor.test.js.map +1 -0
  565. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +107 -0
  566. package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
  567. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +185 -0
  568. package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
  569. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +101 -0
  570. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
  571. package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js +9 -0
  572. package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js.map +1 -1
  573. package/codeyam-cli/src/utils/__tests__/project.test.js +65 -0
  574. package/codeyam-cli/src/utils/__tests__/project.test.js.map +1 -0
  575. package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js +121 -0
  576. package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js.map +1 -0
  577. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +246 -0
  578. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -0
  579. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
  580. package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
  581. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +174 -82
  582. package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
  583. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +50 -0
  584. package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
  585. package/codeyam-cli/src/utils/analysisRunner.js +29 -15
  586. package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
  587. package/codeyam-cli/src/utils/analyzer.js +7 -0
  588. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  589. package/codeyam-cli/src/utils/backgroundServer.js +122 -25
  590. package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
  591. package/codeyam-cli/src/utils/buildFlags.js +4 -0
  592. package/codeyam-cli/src/utils/buildFlags.js.map +1 -0
  593. package/codeyam-cli/src/utils/database.js +91 -5
  594. package/codeyam-cli/src/utils/database.js.map +1 -1
  595. package/codeyam-cli/src/utils/devModeEvents.js +40 -0
  596. package/codeyam-cli/src/utils/devModeEvents.js.map +1 -0
  597. package/codeyam-cli/src/utils/devServerState.js +71 -0
  598. package/codeyam-cli/src/utils/devServerState.js.map +1 -0
  599. package/codeyam-cli/src/utils/editorApi.js +73 -0
  600. package/codeyam-cli/src/utils/editorApi.js.map +1 -0
  601. package/codeyam-cli/src/utils/editorAudit.js +159 -0
  602. package/codeyam-cli/src/utils/editorAudit.js.map +1 -0
  603. package/codeyam-cli/src/utils/editorCapture.js +102 -0
  604. package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
  605. package/codeyam-cli/src/utils/editorDevServer.js +109 -0
  606. package/codeyam-cli/src/utils/editorDevServer.js.map +1 -0
  607. package/codeyam-cli/src/utils/editorEntityChangeStatus.js +44 -0
  608. package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
  609. package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
  610. package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
  611. package/codeyam-cli/src/utils/editorJournal.js +225 -0
  612. package/codeyam-cli/src/utils/editorJournal.js.map +1 -0
  613. package/codeyam-cli/src/utils/editorLoaderHelpers.js +81 -0
  614. package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
  615. package/codeyam-cli/src/utils/editorMockState.js +248 -0
  616. package/codeyam-cli/src/utils/editorMockState.js.map +1 -0
  617. package/codeyam-cli/src/utils/editorPreloadHelpers.js +135 -0
  618. package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -0
  619. package/codeyam-cli/src/utils/editorPreview.js +106 -0
  620. package/codeyam-cli/src/utils/editorPreview.js.map +1 -0
  621. package/codeyam-cli/src/utils/editorScenarioSwitch.js +112 -0
  622. package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
  623. package/codeyam-cli/src/utils/editorScenarios.js +96 -0
  624. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -0
  625. package/codeyam-cli/src/utils/editorSeedAdapter.js +173 -0
  626. package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
  627. package/codeyam-cli/src/utils/entityChangeStatus.js +337 -0
  628. package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
  629. package/codeyam-cli/src/utils/entityChangeStatus.server.js +107 -0
  630. package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
  631. package/codeyam-cli/src/utils/fileMetadata.js +5 -0
  632. package/codeyam-cli/src/utils/fileMetadata.js.map +1 -1
  633. package/codeyam-cli/src/utils/fileWatcher.js +25 -9
  634. package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
  635. package/codeyam-cli/src/utils/generateReport.js +253 -106
  636. package/codeyam-cli/src/utils/generateReport.js.map +1 -1
  637. package/codeyam-cli/src/utils/git.js +182 -0
  638. package/codeyam-cli/src/utils/git.js.map +1 -0
  639. package/codeyam-cli/src/utils/install-skills.js +120 -44
  640. package/codeyam-cli/src/utils/install-skills.js.map +1 -1
  641. package/codeyam-cli/src/utils/interactiveSyncWatcher.js +126 -0
  642. package/codeyam-cli/src/utils/interactiveSyncWatcher.js.map +1 -0
  643. package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
  644. package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
  645. package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
  646. package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
  647. package/codeyam-cli/src/utils/parseRegisterArg.js +31 -0
  648. package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
  649. package/codeyam-cli/src/utils/pathIgnoring.js +19 -7
  650. package/codeyam-cli/src/utils/pathIgnoring.js.map +1 -1
  651. package/codeyam-cli/src/utils/progress.js +7 -0
  652. package/codeyam-cli/src/utils/progress.js.map +1 -1
  653. package/codeyam-cli/src/utils/project.js +15 -5
  654. package/codeyam-cli/src/utils/project.js.map +1 -1
  655. package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js +11 -11
  656. package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js.map +1 -1
  657. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +60 -0
  658. package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
  659. package/codeyam-cli/src/utils/queue/heartbeat.js +13 -5
  660. package/codeyam-cli/src/utils/queue/heartbeat.js.map +1 -1
  661. package/codeyam-cli/src/utils/queue/job.js +319 -17
  662. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  663. package/codeyam-cli/src/utils/queue/manager.js +104 -7
  664. package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
  665. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  666. package/codeyam-cli/src/utils/requireSimulations.js +10 -0
  667. package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
  668. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
  669. package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
  670. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +229 -0
  671. package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
  672. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
  673. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
  674. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
  675. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
  676. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
  677. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
  678. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
  679. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
  680. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +74 -0
  681. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
  682. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +376 -0
  683. package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
  684. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +113 -0
  685. package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
  686. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
  687. package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
  688. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
  689. package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
  690. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
  691. package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
  692. package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
  693. package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
  694. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
  695. package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
  696. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
  697. package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
  698. package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
  699. package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
  700. package/codeyam-cli/src/utils/rules/__tests__/parser.test.js +83 -0
  701. package/codeyam-cli/src/utils/rules/__tests__/parser.test.js.map +1 -0
  702. package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js +118 -0
  703. package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js.map +1 -0
  704. package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js +72 -0
  705. package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js.map +1 -0
  706. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
  707. package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
  708. package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js +76 -0
  709. package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js.map +1 -0
  710. package/codeyam-cli/src/utils/rules/index.js +7 -0
  711. package/codeyam-cli/src/utils/rules/index.js.map +1 -0
  712. package/codeyam-cli/src/utils/rules/parser.js +93 -0
  713. package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
  714. package/codeyam-cli/src/utils/rules/pathMatcher.js +49 -0
  715. package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
  716. package/codeyam-cli/src/utils/rules/rulePlacement.js +65 -0
  717. package/codeyam-cli/src/utils/rules/rulePlacement.js.map +1 -0
  718. package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
  719. package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
  720. package/codeyam-cli/src/utils/rules/sourceFiles.js +43 -0
  721. package/codeyam-cli/src/utils/rules/sourceFiles.js.map +1 -0
  722. package/codeyam-cli/src/utils/rules/staleness.js +137 -0
  723. package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
  724. package/codeyam-cli/src/utils/scenarioMarkers.js +134 -0
  725. package/codeyam-cli/src/utils/scenarioMarkers.js.map +1 -0
  726. package/codeyam-cli/src/utils/scenariosManifest.js +112 -0
  727. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
  728. package/codeyam-cli/src/utils/serverState.js +64 -12
  729. package/codeyam-cli/src/utils/serverState.js.map +1 -1
  730. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +95 -45
  731. package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
  732. package/codeyam-cli/src/utils/simulationGateMiddleware.js +159 -0
  733. package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -0
  734. package/codeyam-cli/src/utils/syncMocksMiddleware.js +5 -24
  735. package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
  736. package/codeyam-cli/src/utils/testRunner.js +158 -0
  737. package/codeyam-cli/src/utils/testRunner.js.map +1 -0
  738. package/codeyam-cli/src/utils/transcriptPruning.js +67 -0
  739. package/codeyam-cli/src/utils/transcriptPruning.js.map +1 -0
  740. package/codeyam-cli/src/utils/versionInfo.js +67 -15
  741. package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
  742. package/codeyam-cli/src/utils/webappDetection.js +14 -2
  743. package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
  744. package/codeyam-cli/src/utils/wipe.js +128 -0
  745. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  746. package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js +66 -0
  747. package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
  748. package/codeyam-cli/src/webserver/app/lib/database.js +159 -33
  749. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  750. package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
  751. package/codeyam-cli/src/webserver/app/lib/git.js +396 -0
  752. package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
  753. package/codeyam-cli/src/webserver/backgroundServer.js +171 -26
  754. package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
  755. package/codeyam-cli/src/webserver/bootstrap.js +60 -0
  756. package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
  757. package/codeyam-cli/src/webserver/build/client/assets/CopyButton-DmJveP3T.js +1 -0
  758. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-C76mRRiF.js +11 -0
  759. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-kykTbcnD.js → EntityTypeBadge-g3saevPb.js} +1 -1
  760. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CobE682z.js +41 -0
  761. package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +1 -0
  762. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DYFW3lDD.js +25 -0
  763. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DLeucoVX.js +3 -0
  764. package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-BU_OAEMP.js +6 -0
  765. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-ceAyBX-H.js +3 -0
  766. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-djPLI-WV.js +11 -0
  767. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BED4B6sP.js +1 -0
  768. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-ZlRKbhrq.js +10 -0
  769. package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +34 -0
  770. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-C06nsHKY.js → TruncatedFilePath-C8OKAR5x.js} +1 -1
  771. package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-oAf2Kqsf.js +1 -0
  772. package/codeyam-cli/src/webserver/build/client/assets/_index-C96V0n15.js +11 -0
  773. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BpKzcsJz.js +27 -0
  774. package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
  775. package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
  776. package/codeyam-cli/src/webserver/build/client/assets/addon-web-links-Duc5hnl7.js +1 -0
  777. package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
  778. package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-D9hemwl6.js +22 -0
  779. package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
  780. package/codeyam-cli/src/webserver/build/client/assets/api.dev-mode-events-l0sNRNKZ.js +1 -0
  781. package/codeyam-cli/src/webserver/build/client/assets/api.editor-audit-l0sNRNKZ.js +1 -0
  782. package/codeyam-cli/src/webserver/build/client/assets/api.editor-capture-scenario-l0sNRNKZ.js +1 -0
  783. package/codeyam-cli/src/webserver/build/client/assets/api.editor-client-errors-l0sNRNKZ.js +1 -0
  784. package/codeyam-cli/src/webserver/build/client/assets/api.editor-commit-l0sNRNKZ.js +1 -0
  785. package/codeyam-cli/src/webserver/build/client/assets/api.editor-dev-server-l0sNRNKZ.js +1 -0
  786. package/codeyam-cli/src/webserver/build/client/assets/api.editor-entity-status-l0sNRNKZ.js +1 -0
  787. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
  788. package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
  789. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-entry-l0sNRNKZ.js +1 -0
  790. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-image._-l0sNRNKZ.js +1 -0
  791. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-l0sNRNKZ.js +1 -0
  792. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-screenshot-l0sNRNKZ.js +1 -0
  793. package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-update-l0sNRNKZ.js +1 -0
  794. package/codeyam-cli/src/webserver/build/client/assets/api.editor-load-commit-l0sNRNKZ.js +1 -0
  795. package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
  796. package/codeyam-cli/src/webserver/build/client/assets/api.editor-refresh-l0sNRNKZ.js +1 -0
  797. package/codeyam-cli/src/webserver/build/client/assets/api.editor-register-scenario-l0sNRNKZ.js +1 -0
  798. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-data-l0sNRNKZ.js +1 -0
  799. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-image._-l0sNRNKZ.js +1 -0
  800. package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenarios-l0sNRNKZ.js +1 -0
  801. package/codeyam-cli/src/webserver/build/client/assets/api.editor-switch-scenario-l0sNRNKZ.js +1 -0
  802. package/codeyam-cli/src/webserver/build/client/assets/api.editor-test-results-l0sNRNKZ.js +1 -0
  803. package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
  804. package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
  805. package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
  806. package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
  807. package/codeyam-cli/src/webserver/build/client/assets/api.rule-path-l0sNRNKZ.js +1 -0
  808. package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
  809. package/codeyam-cli/src/webserver/build/client/assets/book-open-D_nMCFmP.js +6 -0
  810. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-BH2h1Ea2.js +6 -0
  811. package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-C4pqxYJB.js +51 -0
  812. package/codeyam-cli/src/webserver/build/client/assets/circle-check-DyIKORY6.js +6 -0
  813. package/codeyam-cli/src/webserver/build/client/assets/copy-NDbZjXao.js +11 -0
  814. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CMT1jU2q.js +21 -0
  815. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
  816. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
  817. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CltMNppm.js +1 -0
  818. package/codeyam-cli/src/webserver/build/client/assets/editor-DTEBHY7Z.js +10 -0
  819. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-B7ztwLut.js +41 -0
  820. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CYqBrC9s.js → entity._sha._-DItJnD8s.js} +22 -15
  821. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-D5rYBT5x.js +6 -0
  822. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CF164ouH.js +6 -0
  823. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +6 -0
  824. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BMvVHNXU.js +5 -0
  825. package/codeyam-cli/src/webserver/build/client/assets/entry.client-DTvKq3TY.js +29 -0
  826. package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
  827. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-cPo8LiG3.js +1 -0
  828. package/codeyam-cli/src/webserver/build/client/assets/files-DO4CZ16O.js +1 -0
  829. package/codeyam-cli/src/webserver/build/client/assets/git-CdN8sCqs.js +1 -0
  830. package/codeyam-cli/src/webserver/build/client/assets/globals-JMY99HpD.css +1 -0
  831. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
  832. package/codeyam-cli/src/webserver/build/client/assets/index-10oVnAAH.js +9 -0
  833. package/codeyam-cli/src/webserver/build/client/assets/index-BcvgDzbZ.js +3 -0
  834. package/codeyam-cli/src/webserver/build/client/assets/index-yHOVb4rc.js +15 -0
  835. package/codeyam-cli/src/webserver/build/client/assets/labs-Zk7ryIM1.js +1 -0
  836. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-BAXYRVEO.js +6 -0
  837. package/codeyam-cli/src/webserver/build/client/assets/manifest-7aab51c4.js +1 -0
  838. package/codeyam-cli/src/webserver/build/client/assets/memory-Dg0mvYrI.js +96 -0
  839. package/codeyam-cli/src/webserver/build/client/assets/pause-DTAcYxBt.js +11 -0
  840. package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
  841. package/codeyam-cli/src/webserver/build/client/assets/root-FRztnN-P.js +67 -0
  842. package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
  843. package/codeyam-cli/src/webserver/build/client/assets/search-fKo7v0Zo.js +6 -0
  844. package/codeyam-cli/src/webserver/build/client/assets/settings-DfuTtcJP.js +1 -0
  845. package/codeyam-cli/src/webserver/build/client/assets/simulations-B3aOzpCZ.js +1 -0
  846. package/codeyam-cli/src/webserver/build/client/assets/terminal-BG4heKCG.js +11 -0
  847. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-DtSmdtM4.js +6 -0
  848. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-CrAK28Bc.js +1 -0
  849. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-C14nCb1q.js +2 -0
  850. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-O-jkvSPx.js +1 -0
  851. package/codeyam-cli/src/webserver/build/client/assets/{useToast-Bbf4Hokd.js → useToast-9FIWuYfK.js} +1 -1
  852. package/codeyam-cli/src/webserver/build/client/assets/xterm-BqvuqXEL.js +27 -0
  853. package/codeyam-cli/src/webserver/build/server/assets/index-Cz751Dm2.js +1 -0
  854. package/codeyam-cli/src/webserver/build/server/assets/server-build-DSylnYVM.js +367 -0
  855. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  856. package/codeyam-cli/src/webserver/build-info.json +5 -5
  857. package/codeyam-cli/src/webserver/devServer.js +40 -8
  858. package/codeyam-cli/src/webserver/devServer.js.map +1 -1
  859. package/codeyam-cli/src/webserver/editorProxy.js +431 -0
  860. package/codeyam-cli/src/webserver/editorProxy.js.map +1 -0
  861. package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +414 -0
  862. package/codeyam-cli/src/webserver/scripts/journalCapture.ts +230 -0
  863. package/codeyam-cli/src/webserver/server.js +293 -26
  864. package/codeyam-cli/src/webserver/server.js.map +1 -1
  865. package/codeyam-cli/src/webserver/terminalServer.js +706 -0
  866. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -0
  867. package/codeyam-cli/templates/codeyam-editor-claude.md +68 -0
  868. package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
  869. package/codeyam-cli/templates/commands/codeyam-diagnose.md +481 -0
  870. package/codeyam-cli/templates/editor-step-hook.py +208 -0
  871. package/codeyam-cli/templates/hooks/staleness-check.sh +43 -0
  872. package/codeyam-cli/templates/isolation-route/next-app.tsx.template +80 -0
  873. package/codeyam-cli/templates/isolation-route/next-pages.tsx.template +79 -0
  874. package/codeyam-cli/templates/isolation-route/vite-react.tsx.template +78 -0
  875. package/codeyam-cli/templates/msw/browser-setup.ts.template +47 -0
  876. package/codeyam-cli/templates/msw/handler-router.ts.template +47 -0
  877. package/codeyam-cli/templates/msw/server-setup.ts.template +52 -0
  878. package/codeyam-cli/templates/nextjs-prisma-sqlite/PRISMA_SETUP.md +84 -0
  879. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/api/todos/route.ts +17 -0
  880. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
  881. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/globals.css +26 -0
  882. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/layout.tsx +34 -0
  883. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +19 -0
  884. package/codeyam-cli/templates/nextjs-prisma-sqlite/app/page.tsx +10 -0
  885. package/codeyam-cli/templates/nextjs-prisma-sqlite/eslint.config.mjs +11 -0
  886. package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +64 -0
  887. package/codeyam-cli/templates/nextjs-prisma-sqlite/next.config.ts +14 -0
  888. package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +38 -0
  889. package/codeyam-cli/templates/nextjs-prisma-sqlite/postcss.config.mjs +7 -0
  890. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/schema.prisma +27 -0
  891. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +37 -0
  892. package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma.config.ts +12 -0
  893. package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +89 -0
  894. package/codeyam-cli/templates/nextjs-prisma-sqlite/tsconfig.json +34 -0
  895. package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
  896. package/codeyam-cli/templates/prompts/conversation-guidance.txt +44 -0
  897. package/codeyam-cli/templates/prompts/conversation-prompt.txt +28 -0
  898. package/codeyam-cli/templates/prompts/interruption-prompt.txt +31 -0
  899. package/codeyam-cli/templates/prompts/stale-rules-prompt.txt +24 -0
  900. package/codeyam-cli/templates/rule-notification-hook.py +83 -0
  901. package/codeyam-cli/templates/rule-reflection-hook.py +647 -0
  902. package/codeyam-cli/templates/rules-instructions.md +78 -0
  903. package/codeyam-cli/templates/{codeyam-debug-skill.md → skills/codeyam-debug/SKILL.md} +48 -4
  904. package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +237 -0
  905. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +136 -0
  906. package/codeyam-cli/templates/skills/codeyam-memory/SKILL.md +611 -0
  907. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/deprecated-prompt.md +100 -0
  908. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
  909. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
  910. package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/misleading-api-prompt.md +117 -0
  911. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
  912. package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
  913. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/analyze-prompt.md +46 -0
  914. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
  915. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
  916. package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
  917. package/codeyam-cli/templates/skills/codeyam-new-rule/SKILL.md +11 -0
  918. package/codeyam-cli/templates/{codeyam-setup-skill.md → skills/codeyam-setup/SKILL.md} +151 -4
  919. package/codeyam-cli/templates/{codeyam-sim-skill.md → skills/codeyam-sim/SKILL.md} +1 -1
  920. package/codeyam-cli/templates/{codeyam-test-skill.md → skills/codeyam-test/SKILL.md} +1 -1
  921. package/codeyam-cli/templates/{codeyam-verify-skill.md → skills/codeyam-verify/SKILL.md} +1 -1
  922. package/package.json +39 -29
  923. package/packages/ai/index.js +8 -6
  924. package/packages/ai/index.js.map +1 -1
  925. package/packages/ai/src/lib/analyzeScope.js +181 -13
  926. package/packages/ai/src/lib/analyzeScope.js.map +1 -1
  927. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
  928. package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
  929. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +176 -13
  930. package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
  931. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
  932. package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
  933. package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
  934. package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
  935. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
  936. package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
  937. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
  938. package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
  939. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
  940. package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
  941. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
  942. package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
  943. package/packages/ai/src/lib/astScopes/processExpression.js +1235 -104
  944. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  945. package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
  946. package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
  947. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  948. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  949. package/packages/ai/src/lib/completionCall.js +188 -38
  950. package/packages/ai/src/lib/completionCall.js.map +1 -1
  951. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +2192 -224
  952. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  953. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +19 -4
  954. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  955. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
  956. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
  957. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
  958. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  959. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
  960. package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
  961. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
  962. package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
  963. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
  964. package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
  965. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
  966. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  967. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
  968. package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
  969. package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js +54 -0
  970. package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js.map +1 -0
  971. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +142 -12
  972. package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
  973. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  974. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  975. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
  976. package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
  977. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
  978. package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
  979. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +371 -73
  980. package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
  981. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
  982. package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
  983. package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js +34 -0
  984. package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js.map +1 -0
  985. package/packages/ai/src/lib/dataStructureChunking.js +130 -0
  986. package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
  987. package/packages/ai/src/lib/deepEqual.js +32 -0
  988. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  989. package/packages/ai/src/lib/e2eDataTracking.js +241 -0
  990. package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
  991. package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
  992. package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
  993. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
  994. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  995. package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
  996. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  997. package/packages/ai/src/lib/generateEntityDataStructure.js +50 -1
  998. package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
  999. package/packages/ai/src/lib/generateEntityScenarioData.js +1182 -91
  1000. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  1001. package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
  1002. package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
  1003. package/packages/ai/src/lib/generateExecutionFlows.js +484 -0
  1004. package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
  1005. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
  1006. package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
  1007. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1807 -0
  1008. package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
  1009. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
  1010. package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
  1011. package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
  1012. package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
  1013. package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
  1014. package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
  1015. package/packages/ai/src/lib/isolateScopes.js +270 -7
  1016. package/packages/ai/src/lib/isolateScopes.js.map +1 -1
  1017. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
  1018. package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
  1019. package/packages/ai/src/lib/mergeStatements.js +88 -46
  1020. package/packages/ai/src/lib/mergeStatements.js.map +1 -1
  1021. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
  1022. package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
  1023. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
  1024. package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
  1025. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
  1026. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
  1027. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
  1028. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  1029. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
  1030. package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
  1031. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +83 -6
  1032. package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
  1033. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
  1034. package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
  1035. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
  1036. package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
  1037. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
  1038. package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
  1039. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
  1040. package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
  1041. package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
  1042. package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
  1043. package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
  1044. package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
  1045. package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
  1046. package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
  1047. package/packages/ai/src/lib/worker/analyzeScopeWorker.js +98 -1
  1048. package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
  1049. package/packages/analyze/index.js +1 -0
  1050. package/packages/analyze/index.js.map +1 -1
  1051. package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
  1052. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  1053. package/packages/analyze/src/lib/ProjectAnalyzer.js +109 -30
  1054. package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
  1055. package/packages/analyze/src/lib/analysisContext.js +30 -5
  1056. package/packages/analyze/src/lib/analysisContext.js.map +1 -1
  1057. package/packages/analyze/src/lib/asts/index.js +4 -2
  1058. package/packages/analyze/src/lib/asts/index.js.map +1 -1
  1059. package/packages/analyze/src/lib/asts/nodes/getNodeType.js +1 -0
  1060. package/packages/analyze/src/lib/asts/nodes/getNodeType.js.map +1 -1
  1061. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  1062. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  1063. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  1064. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  1065. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
  1066. package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
  1067. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
  1068. package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
  1069. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
  1070. package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
  1071. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
  1072. package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
  1073. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
  1074. package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
  1075. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
  1076. package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
  1077. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +428 -123
  1078. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  1079. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +49 -1
  1080. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  1081. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +11 -0
  1082. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  1083. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
  1084. package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
  1085. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
  1086. package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
  1087. package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
  1088. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  1089. package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
  1090. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  1091. package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
  1092. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  1093. package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
  1094. package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
  1095. package/packages/analyze/src/lib/files/enums/steps.js +1 -1
  1096. package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
  1097. package/packages/analyze/src/lib/files/getImportedExports.js +17 -8
  1098. package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
  1099. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +907 -0
  1100. package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
  1101. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -0
  1102. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
  1103. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  1104. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  1105. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +550 -62
  1106. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  1107. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
  1108. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
  1109. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
  1110. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  1111. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +469 -85
  1112. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  1113. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +104 -0
  1114. package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
  1115. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
  1116. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  1117. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
  1118. package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
  1119. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +891 -143
  1120. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  1121. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
  1122. package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
  1123. package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
  1124. package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
  1125. package/packages/analyze/src/lib/index.js +1 -0
  1126. package/packages/analyze/src/lib/index.js.map +1 -1
  1127. package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
  1128. package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
  1129. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  1130. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  1131. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  1132. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  1133. package/packages/database/index.js +1 -0
  1134. package/packages/database/index.js.map +1 -1
  1135. package/packages/database/src/lib/analysisBranchToDb.js +1 -1
  1136. package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
  1137. package/packages/database/src/lib/analysisToDb.js +1 -1
  1138. package/packages/database/src/lib/analysisToDb.js.map +1 -1
  1139. package/packages/database/src/lib/branchToDb.js +1 -1
  1140. package/packages/database/src/lib/branchToDb.js.map +1 -1
  1141. package/packages/database/src/lib/commitBranchToDb.js +1 -1
  1142. package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
  1143. package/packages/database/src/lib/commitToDb.js +1 -1
  1144. package/packages/database/src/lib/commitToDb.js.map +1 -1
  1145. package/packages/database/src/lib/fileToDb.js +1 -1
  1146. package/packages/database/src/lib/fileToDb.js.map +1 -1
  1147. package/packages/database/src/lib/kysely/db.js +18 -3
  1148. package/packages/database/src/lib/kysely/db.js.map +1 -1
  1149. package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
  1150. package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
  1151. package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
  1152. package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
  1153. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +51 -0
  1154. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
  1155. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
  1156. package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
  1157. package/packages/database/src/lib/loadAnalyses.js +45 -2
  1158. package/packages/database/src/lib/loadAnalyses.js.map +1 -1
  1159. package/packages/database/src/lib/loadAnalysis.js +8 -0
  1160. package/packages/database/src/lib/loadAnalysis.js.map +1 -1
  1161. package/packages/database/src/lib/loadBranch.js +11 -1
  1162. package/packages/database/src/lib/loadBranch.js.map +1 -1
  1163. package/packages/database/src/lib/loadCommit.js +7 -0
  1164. package/packages/database/src/lib/loadCommit.js.map +1 -1
  1165. package/packages/database/src/lib/loadCommits.js +45 -14
  1166. package/packages/database/src/lib/loadCommits.js.map +1 -1
  1167. package/packages/database/src/lib/loadEntities.js +23 -4
  1168. package/packages/database/src/lib/loadEntities.js.map +1 -1
  1169. package/packages/database/src/lib/loadEntityBranches.js +9 -0
  1170. package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
  1171. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +20 -5
  1172. package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
  1173. package/packages/database/src/lib/projectToDb.js +1 -1
  1174. package/packages/database/src/lib/projectToDb.js.map +1 -1
  1175. package/packages/database/src/lib/saveFiles.js +1 -1
  1176. package/packages/database/src/lib/saveFiles.js.map +1 -1
  1177. package/packages/database/src/lib/scenarioToDb.js +1 -1
  1178. package/packages/database/src/lib/scenarioToDb.js.map +1 -1
  1179. package/packages/database/src/lib/updateCommitMetadata.js +100 -88
  1180. package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
  1181. package/packages/database/src/lib/updateFreshAnalysisStatus.js +41 -30
  1182. package/packages/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
  1183. package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
  1184. package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js.map +1 -1
  1185. package/packages/generate/index.js +3 -0
  1186. package/packages/generate/index.js.map +1 -1
  1187. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  1188. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  1189. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +217 -0
  1190. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  1191. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  1192. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  1193. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +41 -9
  1194. package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
  1195. package/packages/generate/src/lib/deepMerge.js +27 -1
  1196. package/packages/generate/src/lib/deepMerge.js.map +1 -1
  1197. package/packages/generate/src/lib/directExecutionScript.js +10 -1
  1198. package/packages/generate/src/lib/directExecutionScript.js.map +1 -1
  1199. package/packages/generate/src/lib/getComponentScenarioPath.js +7 -3
  1200. package/packages/generate/src/lib/getComponentScenarioPath.js.map +1 -1
  1201. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  1202. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  1203. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  1204. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  1205. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  1206. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  1207. package/packages/process/index.js +3 -0
  1208. package/packages/process/index.js.map +1 -0
  1209. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  1210. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  1211. package/packages/process/src/ProcessManager.js.map +1 -0
  1212. package/packages/process/src/index.js.map +1 -0
  1213. package/packages/process/src/managedExecAsync.js.map +1 -0
  1214. package/packages/types/index.js.map +1 -1
  1215. package/packages/utils/src/lib/applyUniversalMocks.js +26 -2
  1216. package/packages/utils/src/lib/applyUniversalMocks.js.map +1 -1
  1217. package/packages/utils/src/lib/fs/rsyncCopy.js +98 -3
  1218. package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  1219. package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
  1220. package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
  1221. package/packages/utils/src/lib/safeFileName.js +29 -3
  1222. package/packages/utils/src/lib/safeFileName.js.map +1 -1
  1223. package/scripts/npm-post-install.cjs +34 -0
  1224. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
  1225. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
  1226. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
  1227. package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
  1228. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
  1229. package/analyzer-template/packages/ai/src/lib/transformMockDataToMatchSchema.ts +0 -156
  1230. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
  1231. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  1232. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  1233. package/analyzer-template/process/README.md +0 -507
  1234. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  1235. package/background/src/lib/process/ProcessManager.js.map +0 -1
  1236. package/background/src/lib/process/index.js.map +0 -1
  1237. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  1238. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  1239. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  1240. package/codeyam-cli/src/commands/detect-universal-mocks.js +0 -118
  1241. package/codeyam-cli/src/commands/detect-universal-mocks.js.map +0 -1
  1242. package/codeyam-cli/src/commands/list.js +0 -31
  1243. package/codeyam-cli/src/commands/list.js.map +0 -1
  1244. package/codeyam-cli/src/commands/webapp-info.js +0 -146
  1245. package/codeyam-cli/src/commands/webapp-info.js.map +0 -1
  1246. package/codeyam-cli/src/utils/universal-mocks.js +0 -152
  1247. package/codeyam-cli/src/utils/universal-mocks.js.map +0 -1
  1248. package/codeyam-cli/src/webserver/build/client/assets/EntityItem-D4htqD-x.js +0 -1
  1249. package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Catz6XEN.js +0 -1
  1250. package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-TlHocYno.js +0 -26
  1251. package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVMmGuIc.js +0 -3
  1252. package/codeyam-cli/src/webserver/build/client/assets/LogViewer-JkfQ-VaI.js +0 -3
  1253. package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-CVZ0H4BL.js +0 -1
  1254. package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BrMAP1nP.js +0 -1
  1255. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CJhE4cCv.js +0 -5
  1256. package/codeyam-cli/src/webserver/build/client/assets/_index-faVIcr_i.js +0 -1
  1257. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CLMa2sgx.js +0 -7
  1258. package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DwYjrK_h.js +0 -1
  1259. package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CgXbbZRx.js +0 -26
  1260. package/codeyam-cli/src/webserver/build/client/assets/circle-check-B2oHQ-zo.js +0 -1
  1261. package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BBYuR56H.js +0 -1
  1262. package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CT0Q5lVu.js +0 -1
  1263. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-Bj5GHkhb.js +0 -1
  1264. package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-eW5z9AyZ.js +0 -5
  1265. package/codeyam-cli/src/webserver/build/client/assets/entry.client-B9tSboXM.js +0 -5
  1266. package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-CmO-EZAB.js +0 -1
  1267. package/codeyam-cli/src/webserver/build/client/assets/files-DLinnTOx.js +0 -1
  1268. package/codeyam-cli/src/webserver/build/client/assets/git-CIxwBQvb.js +0 -12
  1269. package/codeyam-cli/src/webserver/build/client/assets/globals-xPz593l2.css +0 -1
  1270. package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
  1271. package/codeyam-cli/src/webserver/build/client/assets/index-_LjBsTxX.js +0 -8
  1272. package/codeyam-cli/src/webserver/build/client/assets/loader-circle-D_EGChhq.js +0 -1
  1273. package/codeyam-cli/src/webserver/build/client/assets/manifest-ca438c41.js +0 -1
  1274. package/codeyam-cli/src/webserver/build/client/assets/root-CHHYHuzL.js +0 -16
  1275. package/codeyam-cli/src/webserver/build/client/assets/search-DY8yoDpH.js +0 -1
  1276. package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
  1277. package/codeyam-cli/src/webserver/build/client/assets/settings-BT6wVHd5.js +0 -1
  1278. package/codeyam-cli/src/webserver/build/client/assets/simulations-gv3H7JV7.js +0 -1
  1279. package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BthANBVv.js +0 -1
  1280. package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-Blr5oZDE.js +0 -2
  1281. package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CANr3QJ5.js +0 -1
  1282. package/codeyam-cli/src/webserver/build/server/assets/index-BtBPtyHx.js +0 -1
  1283. package/codeyam-cli/src/webserver/build/server/assets/server-build-N2cTnejq.js +0 -166
  1284. package/codeyam-cli/templates/codeyam-stop-hook.sh +0 -284
  1285. package/codeyam-cli/templates/debug-command.md +0 -141
  1286. package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
  1287. package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
  1288. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
  1289. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
  1290. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
  1291. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
  1292. package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
  1293. package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
  1294. package/packages/ai/src/lib/isFrontend.js +0 -5
  1295. package/packages/ai/src/lib/isFrontend.js.map +0 -1
  1296. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
  1297. package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
  1298. package/packages/ai/src/lib/transformMockDataToMatchSchema.js +0 -124
  1299. package/packages/ai/src/lib/transformMockDataToMatchSchema.js.map +0 -1
  1300. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
  1301. package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
  1302. package/scripts/finalize-analyzer.cjs +0 -79
  1303. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  1304. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  1305. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  1306. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  1307. /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
  1308. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  1309. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  1310. /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
@@ -0,0 +1,2607 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import * as os from 'os';
4
+ import { fileURLToPath } from 'url';
5
+ import chalk from 'chalk';
6
+ import { runAnalysisForEntities } from "../utils/analysisRunner.js";
7
+ import { error as errorLog, ProgressReporter, withoutSpinner, } from "../utils/progress.js";
8
+ import { initializeEnvironment, requireBranchAndProject, testEnvironment, } from "../utils/database.js";
9
+ import { loadAnalyses, loadEntities, updateProjectMetadata, } from "../../../packages/database/index.js";
10
+ import { IS_INTERNAL_BUILD } from "../utils/buildFlags.js";
11
+ import { startBackgroundServer } from "../utils/backgroundServer.js";
12
+ import { installClaudeCodeSkills } from "../utils/install-skills.js";
13
+ import { setupClaudeCodeSettings } from "../utils/setupClaudeCodeSettings.js";
14
+ import { getAnalyzerTemplatePath, isAnalyzerFinalized, } from "../utils/analyzer.js";
15
+ import { getProjectRoot as getStateProjectRoot } from "../state.js";
16
+ import initCommand from "./init.js";
17
+ import { readManifest, syncManifestToDatabase, } from "../utils/scenariosManifest.js";
18
+ import { clearEditorState, clearEditorUserPrompt, } from "../utils/editorScenarios.js";
19
+ import { validateSeedData, detectSeedAdapter, } from "../utils/editorSeedAdapter.js";
20
+ import { buildEditorApiRequest, callEditorApi, EDITOR_API_SUBCOMMANDS, } from "../utils/editorApi.js";
21
+ import { parseRegisterArg } from "../utils/parseRegisterArg.js";
22
+ const __filename = fileURLToPath(import.meta.url);
23
+ const __dirname = path.dirname(__filename);
24
+ const STEP_LABELS = {
25
+ 1: 'Plan',
26
+ 2: 'Prototype',
27
+ 3: 'Confirm',
28
+ 4: 'Deconstruct',
29
+ 5: 'Extract',
30
+ 6: 'Glossary',
31
+ 7: 'Analyze',
32
+ 8: 'App Scenarios',
33
+ 9: 'User Scenarios',
34
+ 10: 'Verify',
35
+ 11: 'Journal',
36
+ 12: 'Review',
37
+ 13: 'Present',
38
+ };
39
+ /**
40
+ * Append a JSONL log entry to .codeyam/logs/editor-log.jsonl
41
+ */
42
+ function logEvent(root, event, data) {
43
+ try {
44
+ const logsDir = path.join(root, '.codeyam', 'logs');
45
+ fs.mkdirSync(logsDir, { recursive: true });
46
+ const logPath = path.join(logsDir, 'editor-log.jsonl');
47
+ const entry = JSON.stringify({
48
+ ts: new Date().toISOString(),
49
+ event,
50
+ ...data,
51
+ });
52
+ fs.appendFileSync(logPath, entry + '\n', 'utf8');
53
+ }
54
+ catch {
55
+ // Logging is best-effort
56
+ }
57
+ }
58
+ /**
59
+ * Get the project root (where .codeyam/ lives) or cwd.
60
+ */
61
+ function getProjectRoot() {
62
+ return process.env.CODEYAM_ROOT_PATH || process.cwd();
63
+ }
64
+ /**
65
+ * Path to the editor step state file.
66
+ */
67
+ function getStatePath(root) {
68
+ return path.join(root, '.codeyam', 'editor-step.json');
69
+ }
70
+ /**
71
+ * Read the current editor state, or null if none.
72
+ */
73
+ function readState(root) {
74
+ const statePath = getStatePath(root);
75
+ try {
76
+ const content = fs.readFileSync(statePath, 'utf8');
77
+ return JSON.parse(content);
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ }
83
+ /**
84
+ * Write the editor state.
85
+ */
86
+ function writeState(root, state) {
87
+ const statePath = getStatePath(root);
88
+ const dir = path.dirname(statePath);
89
+ fs.mkdirSync(dir, { recursive: true });
90
+ fs.writeFileSync(statePath, JSON.stringify(state, null, 2), 'utf8');
91
+ }
92
+ /**
93
+ * Clear the editor state (for starting a new feature).
94
+ * Does NOT clear the user prompt file — that's handled separately
95
+ * via clearEditorUserPrompt when the previous feature commits.
96
+ */
97
+ function clearState(root) {
98
+ clearEditorState(root);
99
+ }
100
+ /**
101
+ * Check if a project has been scaffolded (package.json exists).
102
+ */
103
+ function hasProject(root) {
104
+ return fs.existsSync(path.join(root, 'package.json'));
105
+ }
106
+ /**
107
+ * Get the CodeYam server port from env or default.
108
+ */
109
+ function getServerPort() {
110
+ return process.env.CODEYAM_PORT || '3111';
111
+ }
112
+ /**
113
+ * Print a checklist item.
114
+ * Inline backtick-wrapped text is highlighted in cyan for visibility.
115
+ */
116
+ function checkbox(text) {
117
+ // Highlight `backtick-wrapped` segments in cyan
118
+ const highlighted = text.replace(/`([^`]+)`/g, (_m, code) => chalk.cyan(code));
119
+ console.log(` ${chalk.dim('[ ]')} ${highlighted}`);
120
+ }
121
+ /**
122
+ * Print a section header.
123
+ */
124
+ function stepHeader(step, title, feature) {
125
+ console.log();
126
+ console.log(chalk.bold.cyan(`━━━ Step ${step}: ${title} ━━━`));
127
+ if (feature) {
128
+ console.log(chalk.dim(`Feature: "${feature}"`));
129
+ }
130
+ console.log();
131
+ }
132
+ /**
133
+ * Print a colored progress tracker showing all 13 steps.
134
+ * Steps before `current` are green ✓, `current` is bold cyan →, future steps are dim ○.
135
+ */
136
+ function printProgressTracker(current) {
137
+ console.log();
138
+ console.log(chalk.dim('┌─────────────────────────────────────┐'));
139
+ for (let i = 1; i <= 13; i++) {
140
+ const label = STEP_LABELS[i];
141
+ const num = i < 10 ? ` ${i}` : `${i}`;
142
+ const content = `${num}. ${label.padEnd(28)}`;
143
+ if (i < current) {
144
+ console.log(chalk.dim(' │') + chalk.green(` ✓ ${content}`) + chalk.dim('│'));
145
+ }
146
+ else if (i === current) {
147
+ console.log(chalk.dim(' │') + chalk.bold.cyan(` → ${content}`) + chalk.dim('│'));
148
+ }
149
+ else {
150
+ console.log(chalk.dim(` │ ○ ${content}│`));
151
+ }
152
+ }
153
+ console.log(chalk.dim(' └─────────────────────────────────────┘'));
154
+ }
155
+ /**
156
+ * Print a hard STOP gate directing to the next command.
157
+ *
158
+ * Options:
159
+ * - confirm: true → step requires user confirmation before proceeding (steps 1, 3, 11)
160
+ */
161
+ function stopGate(current, opts) {
162
+ console.log();
163
+ console.log(chalk.bold.red('━━━ STOP ━━━'));
164
+ console.log();
165
+ console.log(chalk.red('Complete each checklist item above before proceeding to the next step.'));
166
+ if (opts?.confirm) {
167
+ console.log();
168
+ console.log(chalk.yellow('Wait for user confirmation before moving on.'));
169
+ }
170
+ console.log();
171
+ console.log(chalk.bold.yellow('Present the following progress tracker to the user (copy it verbatim):'));
172
+ printProgressTracker(current);
173
+ console.log();
174
+ console.log(chalk.yellow('For the CURRENT step (→), show each checklist item with ✓ (done) or ✗ (skipped + reason).'));
175
+ console.log(chalk.yellow('If any items are ✗, explain why and ask if the user wants to address them.'));
176
+ console.log();
177
+ if (current < 13) {
178
+ console.log(chalk.green('When done, run: ') +
179
+ chalk.bold(`codeyam editor ${current + 1}`));
180
+ }
181
+ else {
182
+ console.log(chalk.green('Feature complete! Run: ') +
183
+ chalk.bold('codeyam editor 1') +
184
+ chalk.green(' to start the next feature'));
185
+ }
186
+ console.log();
187
+ }
188
+ /**
189
+ * Print a RESUMING header with step-specific investigation instructions.
190
+ * Called when a step is re-entered (prevState.step === current step).
191
+ */
192
+ function printResumptionHeader(step) {
193
+ const port = getServerPort();
194
+ const checks = {
195
+ 1: [
196
+ 'Check if plan was already written to context file:\n `cat .codeyam/editor-mode-context.md`',
197
+ ],
198
+ 2: ['Check if project files already exist:\n `ls package.json src/`'],
199
+ 3: ['This is a confirmation step — just re-present to user'],
200
+ 4: [
201
+ 'Check if extraction plan already exists in context file:\n `cat .codeyam/editor-mode-context.md`',
202
+ ],
203
+ 5: [
204
+ 'Check if components/functions already extracted:\n `ls src/components/ src/lib/`',
205
+ ],
206
+ 6: [
207
+ 'Check if glossary already populated:\n `cat .codeyam/glossary.json`',
208
+ ],
209
+ 7: ['Check if isolation routes and registered scenarios already exist'],
210
+ 8: ['Check existing scenarios:\n `codeyam editor scenarios`'],
211
+ 9: [
212
+ 'Check existing user-persona scenarios:\n `codeyam editor scenarios`',
213
+ ],
214
+ 10: ['Re-verify is safe to repeat — just re-run the checks'],
215
+ 11: [
216
+ 'Check if a journal entry already exists for this feature:\n `codeyam editor journal-list`',
217
+ 'If an entry exists, use PATCH to update it — do NOT create a new one',
218
+ ],
219
+ 12: ['Re-verify is safe to repeat — just re-run the checks'],
220
+ 13: ['Check if commit already made:\n `git log --oneline -3`'],
221
+ };
222
+ const label = STEP_LABELS[step] || 'Unknown';
223
+ console.log(chalk.bold.yellow(`━━━ RESUMING Step ${step}: ${label} ━━━`));
224
+ console.log(chalk.yellow('This step was already started. Before repeating any actions, investigate:'));
225
+ const items = checks[step] || [];
226
+ for (const item of items) {
227
+ checkbox(item);
228
+ }
229
+ console.log();
230
+ }
231
+ function captureOutput(fn) {
232
+ const stdoutWrite = process.stdout.write.bind(process.stdout);
233
+ const stderrWrite = process.stderr.write.bind(process.stderr);
234
+ const chunks = [];
235
+ const captureWrite = (chunk, encoding, cb) => {
236
+ const text = typeof chunk === 'string'
237
+ ? chunk
238
+ : chunk instanceof Buffer
239
+ ? chunk.toString(typeof encoding === 'string' ? encoding : undefined)
240
+ : String(chunk);
241
+ chunks.push(text);
242
+ if (typeof encoding === 'function') {
243
+ encoding();
244
+ }
245
+ if (typeof cb === 'function') {
246
+ cb();
247
+ }
248
+ return true;
249
+ };
250
+ process.stdout.write = captureWrite;
251
+ process.stderr.write = captureWrite;
252
+ try {
253
+ fn();
254
+ }
255
+ finally {
256
+ process.stdout.write = stdoutWrite;
257
+ process.stderr.write = stderrWrite;
258
+ }
259
+ return chunks.join('');
260
+ }
261
+ function withTempRoot(hasProject, fn) {
262
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'codeyam-editor-debug-'));
263
+ if (hasProject) {
264
+ fs.writeFileSync(path.join(root, 'package.json'), '{"name":"codeyam-editor-debug","private":true}', 'utf8');
265
+ }
266
+ try {
267
+ return fn(root);
268
+ }
269
+ finally {
270
+ try {
271
+ fs.rmSync(root, { recursive: true, force: true });
272
+ }
273
+ catch {
274
+ // Best-effort cleanup
275
+ }
276
+ }
277
+ }
278
+ function makeState(step, feature) {
279
+ const now = new Date().toISOString();
280
+ return {
281
+ feature,
282
+ step,
283
+ label: STEP_LABELS[step],
284
+ startedAt: now,
285
+ featureStartedAt: now,
286
+ };
287
+ }
288
+ function normalizeDebugTarget(raw) {
289
+ const value = raw.trim().toLowerCase();
290
+ if (!value)
291
+ return '';
292
+ if (value === 'setup')
293
+ return 'setup';
294
+ if (value === 'overview')
295
+ return 'overview';
296
+ if (value === 'overview-with-state' || value === 'overview-state') {
297
+ return 'overview-with-state';
298
+ }
299
+ if (/^\d+$/.test(value)) {
300
+ return `step-${value}`;
301
+ }
302
+ if (/^step-?\d+$/.test(value)) {
303
+ const num = value.replace('step', '').replace('-', '');
304
+ return `step-${num}`;
305
+ }
306
+ return value;
307
+ }
308
+ function parseDebugTargets(target) {
309
+ if (!target || target.trim().toLowerCase() === 'all')
310
+ return null;
311
+ const rawTargets = target
312
+ .split(',')
313
+ .map((t) => normalizeDebugTarget(t))
314
+ .filter(Boolean);
315
+ const valid = new Set();
316
+ for (const entry of rawTargets) {
317
+ if (entry === 'setup' ||
318
+ entry === 'overview' ||
319
+ entry === 'overview-with-state') {
320
+ valid.add(entry);
321
+ continue;
322
+ }
323
+ if (entry.startsWith('step-')) {
324
+ const num = parseInt(entry.replace('step-', ''), 10);
325
+ if (!isNaN(num) && num >= 1 && num <= 13) {
326
+ valid.add(`step-${num}`);
327
+ continue;
328
+ }
329
+ }
330
+ throw new Error(`Invalid debug target: "${entry}"`);
331
+ }
332
+ return valid;
333
+ }
334
+ function writeContextSnapshot(root, outDir) {
335
+ const contextDir = path.join(outDir, 'context');
336
+ fs.mkdirSync(contextDir, { recursive: true });
337
+ const entries = [];
338
+ const skillPath = path.join(root, '.claude', 'skills', 'codeyam-editor', 'SKILL.md');
339
+ const skillFallback = path.join(__dirname, '..', '..', 'templates', 'codeyam-editor.md');
340
+ const skillSource = fs.existsSync(skillPath) ? skillPath : skillFallback;
341
+ const skillDest = path.join(contextDir, 'codeyam-editor-skill.md');
342
+ fs.copyFileSync(skillSource, skillDest);
343
+ entries.push({
344
+ label: 'codeyam-editor skill',
345
+ source: skillSource,
346
+ file: path.relative(outDir, skillDest),
347
+ status: fs.existsSync(skillPath) ? 'installed' : 'template',
348
+ });
349
+ const claudePath = path.join(root, 'CLAUDE.md');
350
+ if (fs.existsSync(claudePath)) {
351
+ const dest = path.join(contextDir, 'CLAUDE.md');
352
+ fs.copyFileSync(claudePath, dest);
353
+ entries.push({
354
+ label: 'CLAUDE.md',
355
+ source: claudePath,
356
+ file: path.relative(outDir, dest),
357
+ status: 'project',
358
+ });
359
+ }
360
+ else {
361
+ const fallback = path.join(__dirname, '..', '..', 'templates', 'codeyam-editor-claude.md');
362
+ if (fs.existsSync(fallback)) {
363
+ const dest = path.join(contextDir, 'CLAUDE.md');
364
+ fs.copyFileSync(fallback, dest);
365
+ entries.push({
366
+ label: 'CLAUDE.md',
367
+ source: fallback,
368
+ file: path.relative(outDir, dest),
369
+ status: 'template',
370
+ });
371
+ }
372
+ else {
373
+ entries.push({
374
+ label: 'CLAUDE.md',
375
+ file: path.relative(outDir, path.join(contextDir, 'CLAUDE.md')),
376
+ status: 'missing',
377
+ });
378
+ }
379
+ }
380
+ const contextPath = path.join(root, '.codeyam', 'editor-mode-context.md');
381
+ if (fs.existsSync(contextPath)) {
382
+ const dest = path.join(contextDir, 'editor-mode-context.md');
383
+ fs.copyFileSync(contextPath, dest);
384
+ entries.push({
385
+ label: 'editor-mode-context.md',
386
+ source: contextPath,
387
+ file: path.relative(outDir, dest),
388
+ status: 'project',
389
+ });
390
+ }
391
+ else {
392
+ entries.push({
393
+ label: 'editor-mode-context.md',
394
+ file: path.relative(outDir, path.join(contextDir, 'editor-mode-context.md')),
395
+ status: 'missing',
396
+ });
397
+ }
398
+ return entries;
399
+ }
400
+ // ─── Setup (no args, no project) ──────────────────────────────────────
401
+ function printSetup(root) {
402
+ const port = getServerPort();
403
+ logEvent(root, 'setup');
404
+ console.log();
405
+ console.log(chalk.bold.cyan('━━━ Editor Mode: Project Setup ━━━'));
406
+ console.log();
407
+ console.log("No project detected. Let's get started.");
408
+ console.log();
409
+ console.log(chalk.bold('Checklist:'));
410
+ checkbox('Read `.codeyam/editor-mode-context.md` for session state');
411
+ checkbox('Ask the user what they want to build');
412
+ console.log();
413
+ console.log(chalk.bold.red('━━━ STOP ━━━'));
414
+ console.log();
415
+ console.log(chalk.red('Ask the user what they want to build, then run:'));
416
+ console.log();
417
+ console.log(chalk.green(' ') +
418
+ chalk.bold('codeyam editor 1 --feature "Feature Name" --prompt "the user\'s original message"'));
419
+ console.log(chalk.dim(' Replace "Feature Name" with a short title for what the user described.'));
420
+ console.log(chalk.dim(" Pass --prompt with the user's exact original request so it appears in the journal."));
421
+ console.log(chalk.dim(' Step 1 will guide you through planning and getting user confirmation before any code is written.'));
422
+ console.log();
423
+ }
424
+ // ─── Cycle overview (no args, has project) ────────────────────────────
425
+ function printCycleOverview(root, state) {
426
+ logEvent(root, 'overview', state ? { feature: state.feature, step: state.step } : {});
427
+ console.log();
428
+ console.log(chalk.bold.cyan('━━━ Editor Mode: Feature Cycle ━━━'));
429
+ console.log();
430
+ if (state) {
431
+ console.log(chalk.yellow(`Current: Step ${state.step} (${state.label}) — "${state.feature}"`));
432
+ console.log();
433
+ console.log(chalk.green('Continue with: ') +
434
+ chalk.bold(`codeyam editor ${state.step}`));
435
+ console.log(chalk.dim('Or run ') +
436
+ chalk.bold('codeyam editor 1') +
437
+ chalk.dim(' to start a new feature'));
438
+ }
439
+ else {
440
+ console.log('Each feature follows 13 steps. You MUST run each command in order:');
441
+ console.log();
442
+ console.log(` ${chalk.bold.yellow(' 1')} ${chalk.bold('Plan')} — Plan the feature, confirm with user`);
443
+ console.log(` ${chalk.bold.yellow(' 2')} ${chalk.bold('Prototype')} — Build a working prototype fast`);
444
+ console.log(` ${chalk.bold.yellow(' 3')} ${chalk.bold('Confirm')} — Confirm prototype with user`);
445
+ console.log(` ${chalk.bold.yellow(' 4')} ${chalk.bold('Deconstruct')} — Read code, plan all extractions`);
446
+ console.log(` ${chalk.bold.yellow(' 5')} ${chalk.bold('Extract')} — TDD extraction of functions + components`);
447
+ console.log(` ${chalk.bold.yellow(' 6')} ${chalk.bold('Glossary')} — Record functions in glossary`);
448
+ console.log(` ${chalk.bold.yellow(' 7')} ${chalk.bold('Analyze')} — Analyze and verify components`);
449
+ console.log(` ${chalk.bold.yellow(' 8')} ${chalk.bold('App Scenarios')} — Create app-level scenarios`);
450
+ console.log(` ${chalk.bold.yellow(' 9')} ${chalk.bold('User Scenarios')} — Create user-persona scenarios`);
451
+ console.log(` ${chalk.bold.yellow('10')} ${chalk.bold('Verify')} — Review screenshots, check for errors`);
452
+ console.log(` ${chalk.bold.yellow('11')} ${chalk.bold('Journal')} — Create/update journal entry`);
453
+ console.log(` ${chalk.bold.yellow('12')} ${chalk.bold('Review')} — Verify screenshots and audit`);
454
+ console.log(` ${chalk.bold.yellow('13')} ${chalk.bold('Present')} — Present summary, get approval`);
455
+ console.log();
456
+ console.log(chalk.green('Start now: ') + chalk.bold('codeyam editor 1'));
457
+ console.log(chalk.dim(' If the user already described what they want, pass it: codeyam editor 1 --prompt "their message"'));
458
+ }
459
+ console.log();
460
+ }
461
+ // ─── Step 1: Plan ─────────────────────────────────────────────────────
462
+ function printStep1(root, feature, userPrompt) {
463
+ const port = getServerPort();
464
+ const prevState = readState(root);
465
+ const isResuming = prevState?.step === 1;
466
+ if (!isResuming) {
467
+ clearState(root);
468
+ }
469
+ // If feature is provided, save initial state so step 2 can pick it up
470
+ if (feature) {
471
+ const now = new Date().toISOString();
472
+ writeState(root, {
473
+ feature,
474
+ step: 1,
475
+ label: STEP_LABELS[1],
476
+ startedAt: isResuming ? prevState.startedAt : now,
477
+ featureStartedAt: isResuming ? prevState.featureStartedAt : now,
478
+ });
479
+ }
480
+ // Save the user's original prompt to a separate file
481
+ if (userPrompt) {
482
+ const promptPath = path.join(root, '.codeyam', 'editor-user-prompt.txt');
483
+ fs.mkdirSync(path.dirname(promptPath), { recursive: true });
484
+ fs.writeFileSync(promptPath, userPrompt, 'utf8');
485
+ }
486
+ logEvent(root, 'step', { step: 1, label: 'Plan', feature });
487
+ stepHeader(1, 'Plan', feature);
488
+ if (isResuming) {
489
+ printResumptionHeader(1);
490
+ }
491
+ console.log('Plan the feature before writing ANY code.');
492
+ console.log();
493
+ console.log(chalk.bold('Checklist:'));
494
+ checkbox('Read `.codeyam/glossary.json` for reusable functions/components');
495
+ checkbox('Ask the user what they want to build (if not already described)');
496
+ checkbox('Ask clarifying questions using `AskUserQuestion` with selectable options');
497
+ console.log(chalk.dim(' Use AskUserQuestion for EVERY clarifying question — give 2-4 concrete options the user can pick from.'));
498
+ console.log(chalk.dim(' Focus on what the USER will see and do, not on databases, APIs, or components.'));
499
+ console.log(chalk.dim(' Do NOT ask about tech stack, frameworks, libraries, or implementation details — only ask about user-facing choices.'));
500
+ console.log(chalk.dim(' Good: "What should happen when there are no results?" → options: "Show empty state message", "Show suggestions"'));
501
+ console.log(chalk.dim(' Bad: Free-form text asking "What do you think about the data model?"'));
502
+ console.log(chalk.dim(' You can ask up to 4 questions at once. Bundle related questions into a single AskUserQuestion call.'));
503
+ checkbox("Summarize what you'll build in plain language the user can verify against their vision");
504
+ checkbox('Set the project title and description for the App tab:');
505
+ console.log(chalk.dim(` curl -s -X POST http://localhost:${port}/api/editor-project-info \\`));
506
+ console.log(chalk.dim(' -H "Content-Type: application/json" \\'));
507
+ console.log(chalk.dim(' -d \'{"projectTitle":"My App","projectDescription":"A short description of what this app does"}\''));
508
+ console.log();
509
+ console.log(chalk.bold('Present a selection menu to the user (use AskUserQuestion with these EXACT option labels):'));
510
+ console.log(chalk.green(' Option 1 label: "This plan is accurate, let\'s build the initial prototype!"') + chalk.dim(' — proceed to step 2'));
511
+ console.log(chalk.yellow(' Option 2 label: "I\'d like some changes"') +
512
+ chalk.dim(' — user describes changes, you revise the plan, then re-present'));
513
+ console.log();
514
+ console.log(chalk.dim('This step is for understanding user goals and getting buy-in. Code comes in Step 2.'));
515
+ console.log();
516
+ console.log(chalk.bold.red('━━━ STOP ━━━'));
517
+ console.log();
518
+ console.log(chalk.red('Complete each checklist item above before proceeding to the next step.'));
519
+ console.log();
520
+ console.log(chalk.yellow('Wait for user confirmation before moving on.'));
521
+ console.log();
522
+ console.log(chalk.bold.yellow('Present the following progress tracker to the user (copy it verbatim):'));
523
+ printProgressTracker(1);
524
+ console.log();
525
+ console.log(chalk.yellow('For the CURRENT step (→), show each checklist item with ✓ (done) or ✗ (skipped + reason).'));
526
+ console.log(chalk.yellow('If any items are ✗, explain why and ask if the user wants to address them.'));
527
+ console.log();
528
+ console.log(chalk.green('When done, run: ') +
529
+ chalk.bold('codeyam editor 2 --feature "Feature Name"'));
530
+ console.log(chalk.dim(' Replace "Feature Name" with a short title for what you just described.'));
531
+ console.log();
532
+ }
533
+ // ─── Step 2: Prototype ────────────────────────────────────────────────
534
+ function printStep2(root, feature) {
535
+ const port = getServerPort();
536
+ const projectExists = hasProject(root);
537
+ const prevState = readState(root);
538
+ const isResuming = prevState?.step === 2;
539
+ const now = new Date().toISOString();
540
+ writeState(root, {
541
+ feature,
542
+ step: 2,
543
+ label: STEP_LABELS[2],
544
+ startedAt: isResuming ? prevState.startedAt : now,
545
+ featureStartedAt: isResuming ? prevState.featureStartedAt : now,
546
+ });
547
+ logEvent(root, 'step', { step: 2, label: 'Prototype', feature });
548
+ stepHeader(2, 'Prototype', feature);
549
+ if (isResuming) {
550
+ printResumptionHeader(2);
551
+ }
552
+ console.log('Build fast with real data. Prioritize speed over quality.');
553
+ console.log();
554
+ // If no project exists yet, include scaffolding instructions first
555
+ if (!projectExists) {
556
+ console.log(chalk.bold('Scaffold the project:'));
557
+ checkbox('Run `codeyam editor template` to scaffold, install dependencies, init git, and configure CodeYam');
558
+ console.log(chalk.dim(' This copies the Next.js + Prisma 7 + SQLite template, runs npm install,'));
559
+ console.log(chalk.dim(' initializes git, runs codeyam init, and refreshes the editor — all in one command.'));
560
+ console.log();
561
+ checkbox('Define your data models in `prisma/schema.prisma`');
562
+ console.log(chalk.dim(" Replace the placeholder Todo model with your app's models"));
563
+ console.log();
564
+ checkbox('Push schema and seed the database');
565
+ console.log(chalk.dim(' npm run db:push'));
566
+ console.log(chalk.dim(' # Edit prisma/seed.ts with your seed data, then:'));
567
+ console.log(chalk.dim(' npm run db:seed'));
568
+ console.log(chalk.dim(` # After re-seeding, restart the dev server to pick up fresh data:`));
569
+ console.log(chalk.dim(` # codeyam editor dev-server '{"action":"restart"}'`));
570
+ console.log();
571
+ console.log(chalk.dim(' See PRISMA_SETUP.md for Prisma patterns and important warnings.'));
572
+ console.log(chalk.dim(' Key: import { prisma } from "@/app/lib/prisma" in API routes.'));
573
+ console.log(chalk.dim(' Key: Seed scripts must use the adapter pattern (see prisma/seed.ts).'));
574
+ console.log();
575
+ console.log(chalk.bold('Build the feature:'));
576
+ }
577
+ console.log(chalk.bold('Checklist:'));
578
+ checkbox('Create API routes that read from the database via Prisma');
579
+ checkbox('Seed the database with demo data');
580
+ checkbox('Create `.codeyam/seed-adapter.ts` so CodeYam can seed the database for scenarios');
581
+ console.log(chalk.dim(' The seed adapter reads a JSON file (path passed as CLI arg), wipes tables, inserts rows.'));
582
+ console.log(chalk.dim(" Use the project's own ORM (Prisma, Drizzle, etc.). See template for example."));
583
+ console.log(chalk.dim(' Run with: npx tsx .codeyam/seed-adapter.ts <path-to-seed-data.json>'));
584
+ checkbox('Verify the dev server shows the changes');
585
+ console.log();
586
+ console.log(chalk.bold.cyan('Keep the preview moving:'));
587
+ console.log(chalk.cyan(' The user is watching the preview. Refresh it after each meaningful change:'));
588
+ console.log(chalk.cyan(` codeyam editor preview`));
589
+ console.log(chalk.cyan(' Refresh after: first visible page, adding each UI section, seeding data, styling.'));
590
+ console.log(chalk.cyan(' Aim for 4-8+ refreshes during prototyping — not one big reveal at the end.'));
591
+ console.log(chalk.cyan(' If you build a NEW page (e.g., /drinks/[id]), navigate the preview there:'));
592
+ console.log(chalk.cyan(` codeyam editor preview '{"path":"/drinks/1"}'`));
593
+ console.log();
594
+ console.log(chalk.bold('Verify the dev server:'));
595
+ console.log(chalk.dim(` # Get dev server URL: codeyam editor dev-server`));
596
+ console.log(chalk.dim(' # Check page loads: curl -s -o /dev/null -w "%{http_code}" http://localhost:<dev-port>'));
597
+ console.log(chalk.dim(' # Check API routes: curl -s http://localhost:<dev-port>/api/your-route'));
598
+ console.log();
599
+ console.log(chalk.bold('Verify before proceeding:'));
600
+ console.log(chalk.yellow(' Verify everything works before presenting the prototype to the user.'));
601
+ checkbox('Verify the page loads: curl the dev server URL and confirm HTTP 200 (not an error page)');
602
+ checkbox('Verify API routes return valid JSON: curl each route and confirm no error responses');
603
+ checkbox('Check for broken images: `codeyam editor verify-images \'{"paths":["/"], "imageUrls":["url1","url2"]}\'`');
604
+ console.log(chalk.dim(' Pass ALL page paths and ALL image URLs you used in seed data / API responses.'));
605
+ console.log(chalk.dim(' Client-rendered pages need imageUrls — the HTML shell has no images to scan.'));
606
+ console.log(chalk.dim(' Fix or replace any broken image URLs in the seed data before proceeding.'));
607
+ checkbox('Check the dev server terminal output for runtime errors (missing modules, failed imports)');
608
+ console.log(chalk.dim(' If any check fails, fix the issue and re-verify before proceeding.'));
609
+ console.log();
610
+ console.log(chalk.dim('Focus on building the prototype. Scenarios and refactoring happen in later steps.'));
611
+ stopGate(2);
612
+ }
613
+ // ─── Step 3: Confirm ──────────────────────────────────────────────────
614
+ function printStep3(root, feature) {
615
+ const port = getServerPort();
616
+ const prevState = readState(root);
617
+ const isResuming = prevState?.step === 3;
618
+ const now = new Date().toISOString();
619
+ writeState(root, {
620
+ feature,
621
+ step: 3,
622
+ label: STEP_LABELS[3],
623
+ startedAt: isResuming ? prevState.startedAt : now,
624
+ featureStartedAt: prevState?.featureStartedAt || now,
625
+ });
626
+ logEvent(root, 'step', { step: 3, label: 'Confirm', feature });
627
+ stepHeader(3, 'Confirm', feature);
628
+ if (isResuming) {
629
+ printResumptionHeader(3);
630
+ }
631
+ console.log('Summarize what was built and get user confirmation.');
632
+ console.log();
633
+ console.log(chalk.bold('Before presenting — verify everything works:'));
634
+ checkbox(`Refresh the preview: \`codeyam editor preview\` — check the \`preview\` field for \`healthy: false\``);
635
+ checkbox('Verify API routes return valid data (curl each route)');
636
+ console.log();
637
+ console.log(chalk.bold.red(' Verify EVERY image loads (this is the #1 source of broken prototypes):'));
638
+ checkbox('Run `codeyam editor verify-images \'{"paths":["/"], "imageUrls":["url1","url2"]}\'`');
639
+ console.log(chalk.dim(' Include ALL page paths and ALL image URLs from seed data / API responses.'));
640
+ console.log(chalk.dim(' Client-rendered pages need imageUrls — the HTML shell has no images.'));
641
+ checkbox('Fix or remove any image that returns non-200 before continuing');
642
+ checkbox('Check for client-side errors: `codeyam editor client-errors`');
643
+ console.log(chalk.dim(' If there are errors, fix the underlying issue before presenting.'));
644
+ console.log();
645
+ console.log(chalk.bold('Then present to the user:'));
646
+ checkbox('Summarize what was built (routes, components, data)');
647
+ checkbox('Navigate the preview to the feature\'s primary page: `codeyam editor preview \'{"path":"/your-page"}\'`');
648
+ console.log(chalk.dim(' The user needs to SEE the new feature. If you built a new page, navigate there.'));
649
+ console.log(chalk.dim(' If you modified an existing page, refresh the preview to show the changes.'));
650
+ console.log();
651
+ console.log(chalk.bold('Present a selection menu to the user (use AskUserQuestion with these EXACT option labels):'));
652
+ console.log(chalk.green(' Option 1 label: "The live preview is displaying what I expected"') + chalk.dim(' — proceed to step 4'));
653
+ console.log(chalk.yellow(' Option 2 label: "I\'d like some changes"') +
654
+ chalk.dim(' — user describes changes, you make them, then re-present'));
655
+ console.log();
656
+ console.log(chalk.dim('Wait for user approval before moving on. Refactoring and scenarios happen in later steps.'));
657
+ stopGate(3, { confirm: true });
658
+ }
659
+ // ─── Step 4: Deconstruct ──────────────────────────────────────────────
660
+ function printStep4(root, feature) {
661
+ const prevState = readState(root);
662
+ const isResuming = prevState?.step === 4;
663
+ const now = new Date().toISOString();
664
+ writeState(root, {
665
+ feature,
666
+ step: 4,
667
+ label: STEP_LABELS[4],
668
+ startedAt: isResuming ? prevState.startedAt : now,
669
+ featureStartedAt: prevState?.featureStartedAt || now,
670
+ });
671
+ logEvent(root, 'step', { step: 4, label: 'Deconstruct', feature });
672
+ stepHeader(4, 'Deconstruct', feature);
673
+ if (isResuming) {
674
+ printResumptionHeader(4);
675
+ }
676
+ console.log(chalk.bold('Goal: pages contain ONLY components. Components contain ONLY sub-components.'));
677
+ console.log(chalk.yellow('This step is read and plan only. Code extraction happens in step 5.'));
678
+ console.log();
679
+ console.log(chalk.bold.red('THE RULE: No direct JSX in page files.'));
680
+ console.log(chalk.yellow(' After extraction, a page/route file should import and compose components — nothing else.'));
681
+ console.log(chalk.yellow(' Every distinct visual section in the page is its own component.'));
682
+ console.log(chalk.yellow(' Every component that renders multiple distinct sections should be split into sub-components.'));
683
+ console.log(chalk.yellow(' If a component has N visually distinct parts, it should compose N sub-components.'));
684
+ console.log();
685
+ console.log(chalk.bold('Checklist:'));
686
+ checkbox('Read `.codeyam/glossary.json` — note reusable functions/components');
687
+ checkbox('Read EVERY file created or modified in this session');
688
+ console.log(chalk.yellow(' For EACH file, identify EVERY extractable piece:'));
689
+ console.log(chalk.yellow(' Components: headers, nav, loading states, empty states, error states,'));
690
+ console.log(chalk.yellow(' badges/pills, image containers, card sections, form fields, modals,'));
691
+ console.log(chalk.yellow(' titles, descriptions, rating displays, status indicators, buttons'));
692
+ console.log(chalk.yellow(' Functions: data transforms, calculations, formatting, validation,'));
693
+ console.log(chalk.yellow(' API response shaping, any logic that is not directly about rendering'));
694
+ console.log(chalk.yellow(' Hooks: data fetching, state management, side effects'));
695
+ console.log();
696
+ checkbox('Write a numbered extraction plan listing EVERYTHING you will extract');
697
+ console.log(chalk.yellow(' The end state: every page file is ONLY imports + component composition.'));
698
+ console.log(chalk.yellow(' No raw <div>, <span>, <h1>, <p>, <img>, or <ul> in page files.'));
699
+ console.log(chalk.yellow(' Every visual section in every component is itself a component.'));
700
+ console.log();
701
+ console.log(chalk.yellow(' For each item in the plan, note:'));
702
+ console.log(chalk.yellow(' — What it is (component, function, hook)'));
703
+ console.log(chalk.yellow(' — Where it currently lives (source file + approximate lines)'));
704
+ console.log(chalk.yellow(' — Where it will go (new file path)'));
705
+ console.log();
706
+ console.log(chalk.dim('Present the numbered plan, then proceed to step 5 to execute it.'));
707
+ stopGate(4);
708
+ }
709
+ // ─── Step 5: Extract ──────────────────────────────────────────────────
710
+ function printStep5(root, feature) {
711
+ const port = getServerPort();
712
+ const prevState = readState(root);
713
+ const isResuming = prevState?.step === 5;
714
+ const now = new Date().toISOString();
715
+ writeState(root, {
716
+ feature,
717
+ step: 5,
718
+ label: STEP_LABELS[5],
719
+ startedAt: isResuming ? prevState.startedAt : now,
720
+ featureStartedAt: prevState?.featureStartedAt || now,
721
+ });
722
+ logEvent(root, 'step', { step: 5, label: 'Extract', feature });
723
+ stepHeader(5, 'Extract', feature);
724
+ if (isResuming) {
725
+ printResumptionHeader(5);
726
+ }
727
+ console.log('Execute your extraction plan from step 4.');
728
+ console.log();
729
+ console.log(chalk.bold('Components:'));
730
+ checkbox('Extract each component from your plan into its own file');
731
+ checkbox('Page/route files must contain ZERO direct JSX — only imported components');
732
+ checkbox('Every component that renders multiple sections must be split into sub-components');
733
+ console.log(chalk.dim(' No tests needed — visual verification happens in step 7'));
734
+ console.log();
735
+ console.log(chalk.bold('Library functions (TDD):'));
736
+ checkbox('For each function: write MULTIPLE failing tests FIRST, then extract to make them pass');
737
+ console.log(chalk.dim(' Cover: typical inputs, edge cases, empty/null inputs, error conditions'));
738
+ console.log(chalk.dim(' Aim for 3-8 test cases per function depending on complexity'));
739
+ checkbox('Place test files next to source: `app/lib/drinks.ts` → `app/lib/drinks.test.ts`');
740
+ console.log(chalk.yellow(' Tests ARE the only coverage for library functions — step 7 only captures component screenshots.'));
741
+ console.log();
742
+ console.log(chalk.bold('Recursive pass:'));
743
+ checkbox('Re-read EVERY new file you just created — extract components from components, functions from functions');
744
+ checkbox('Keep going until every file is a thin shell: just imports and composition');
745
+ console.log(chalk.yellow(' Check: does any file contain raw <div>, <span>, <h1>, <p>, <img>, or <ul>?'));
746
+ console.log(chalk.yellow(' If yes → that JSX section is a component waiting to be extracted.'));
747
+ console.log();
748
+ console.log(chalk.bold('Verify before proceeding:'));
749
+ checkbox('Run all tests and verify they pass');
750
+ checkbox('Page files contain ONLY imports + component composition — no raw HTML tags');
751
+ checkbox('Every component renders ONE thing or composes sub-components — no multi-section JSX');
752
+ checkbox(`Refresh the preview after each batch of extractions: \`codeyam editor preview\``);
753
+ console.log(chalk.dim(' The user should see the preview stay healthy as you refactor — refresh periodically, not just at the end.'));
754
+ console.log(chalk.dim('Reuse glossary functions when they fit naturally. Extract a new function when the use case diverges.'));
755
+ console.log();
756
+ console.log(chalk.dim('Focus on TDD for functions and extraction for components. Scenarios come in later steps.'));
757
+ stopGate(5);
758
+ }
759
+ // ─── Step 6: Glossary ─────────────────────────────────────────────────
760
+ function printStep6(root, feature) {
761
+ const prevState = readState(root);
762
+ const isResuming = prevState?.step === 6;
763
+ const now = new Date().toISOString();
764
+ writeState(root, {
765
+ feature,
766
+ step: 6,
767
+ label: STEP_LABELS[6],
768
+ startedAt: isResuming ? prevState.startedAt : now,
769
+ featureStartedAt: prevState?.featureStartedAt || now,
770
+ });
771
+ logEvent(root, 'step', { step: 6, label: 'Glossary', feature });
772
+ stepHeader(6, 'Glossary', feature);
773
+ if (isResuming) {
774
+ printResumptionHeader(6);
775
+ }
776
+ console.log('Record all new functions/components in `.codeyam/glossary.json`.');
777
+ console.log();
778
+ console.log(chalk.bold('Checklist:'));
779
+ checkbox("Read `.codeyam/glossary.json` (create if it doesn't exist)");
780
+ checkbox('Add an entry for each new function/component extracted in step 5');
781
+ checkbox('Each entry should have: name, filePath, description, parameters, returnType, tags, feature');
782
+ checkbox('For each function with a test file from step 5, set `testFile` to the relative path');
783
+ console.log();
784
+ console.log(chalk.bold('Entry format:'));
785
+ console.log(chalk.dim(' { "name": "calculateTotal", "filePath": "app/utils/pricing.ts",'));
786
+ console.log(chalk.dim(' "description": "Calculates total price including tax and discounts",'));
787
+ console.log(chalk.dim(' "parameters": [{ "name": "items", "type": "CartItem[]" }],'));
788
+ console.log(chalk.dim(' "returnType": "number", "tags": ["pricing"],'));
789
+ console.log(chalk.dim(' "testFile": "app/utils/pricing.test.ts",'));
790
+ console.log(chalk.dim(` "feature": "${feature}", "createdAt": "..." }`));
791
+ console.log();
792
+ console.log(chalk.dim('Focus on updating the glossary. Application code and scenarios come in later steps.'));
793
+ stopGate(6);
794
+ }
795
+ // ─── Step 7: Analyze ──────────────────────────────────────────────────
796
+ function printStep7(root, feature) {
797
+ const port = getServerPort();
798
+ const prevState = readState(root);
799
+ const isResuming = prevState?.step === 7;
800
+ const now = new Date().toISOString();
801
+ writeState(root, {
802
+ feature,
803
+ step: 7,
804
+ label: STEP_LABELS[7],
805
+ startedAt: isResuming ? prevState.startedAt : now,
806
+ featureStartedAt: prevState?.featureStartedAt || now,
807
+ });
808
+ logEvent(root, 'step', { step: 7, label: 'Analyze', feature });
809
+ stepHeader(7, 'Analyze and Verify', feature);
810
+ if (isResuming) {
811
+ printResumptionHeader(7);
812
+ }
813
+ console.log('Verify visual components (via isolation routes) and library functions (via tests).');
814
+ console.log();
815
+ console.log(chalk.bold('Visual Components — Component Isolation:'));
816
+ checkbox('List all files with new/modified visual components from step 5');
817
+ checkbox('Create isolation route dirs: `codeyam editor isolate ComponentA ComponentB ...`');
818
+ console.log(chalk.dim(' This creates app/codeyam-isolate/layout.tsx (with production notFound() guard) and'));
819
+ console.log(chalk.dim(' a directory per component. List ALL components that need isolation routes.'));
820
+ checkbox('Check existing scenarios: `codeyam editor scenarios`');
821
+ console.log(chalk.dim(' Reuse and improve existing scenarios where possible — update mock data'));
822
+ console.log(chalk.dim(' to reflect current changes. Add new scenarios only for genuinely new states.'));
823
+ console.log(chalk.dim(' Ensure at least one scenario clearly demonstrates what changed in this session.'));
824
+ checkbox('For each visual component:');
825
+ console.log(chalk.dim(' 1. Read the source AND find where it is used in the app to understand:'));
826
+ console.log(chalk.dim(' — Props/interface'));
827
+ console.log(chalk.dim(' — Container width in the real app (e.g. card in a 3-col grid → max-w-sm)'));
828
+ console.log(chalk.dim(' 2. Plan multiple scenarios that exercise the component like tests:'));
829
+ console.log(chalk.dim(' — Default/happy path with typical data'));
830
+ console.log(chalk.dim(' — Edge cases: empty/missing data, long text, maximum items, zero counts'));
831
+ console.log(chalk.dim(' — Different visual states: loading, error, disabled, selected, hover'));
832
+ console.log(chalk.dim(' — Boundary values: single item vs many, min/max ratings, very long names'));
833
+ console.log(chalk.dim(' 3. Create ONE isolation route per component with a scenarios map and ?s= query param:'));
834
+ console.log(chalk.dim(' Remix: app/routes/codeyam-isolate.ComponentName.tsx → /codeyam-isolate/ComponentName'));
835
+ console.log(chalk.dim(' Next.js: app/codeyam-isolate/ComponentName/page.tsx → /codeyam-isolate/ComponentName'));
836
+ console.log(chalk.dim(' The route defines a `scenarios` object mapping scenario names to props,'));
837
+ console.log(chalk.dim(' reads `?s=ScenarioName` from the URL, and renders the component with those props.'));
838
+ console.log(chalk.dim(' Wrap the component in a capture container with id="codeyam-capture":'));
839
+ console.log(chalk.dim(' <div id="codeyam-capture" style={{ display:"inline-block", padding:"20px" }}>'));
840
+ console.log(chalk.dim(' <div style={{ width:"100%", maxWidth:"..." }}> ← match the app\'s container width'));
841
+ console.log(chalk.dim(' e.g. card in a 3-col grid → maxWidth:"24rem", full-width component → omit maxWidth'));
842
+ console.log(chalk.dim(' The screenshot captures just this wrapper, so the component fills the image.'));
843
+ console.log(chalk.dim(' Center the wrapper on the page (flexbox center both axes) and set a page background'));
844
+ console.log(chalk.dim(' color that matches where the component normally appears (e.g. white for light UIs).'));
845
+ console.log(chalk.dim(' 4. Wait 2 seconds for HMR, then register + capture each scenario:'));
846
+ console.log(chalk.dim(` codeyam editor register '{"name":"ComponentName - Scenario",`));
847
+ console.log(chalk.dim(` "componentName":"ComponentName","componentPath":"path/to/file.tsx",`));
848
+ console.log(chalk.dim(` "url":"/codeyam-isolate/ComponentName?s=Scenario",`));
849
+ console.log(chalk.dim(` "mockData":{"routes":{"/api/...":{"body":[...]}}}}'`));
850
+ console.log(chalk.dim(' url is a PATH (starts with /) — the proxy routes it and intercepts API calls'));
851
+ console.log(chalk.dim(' mockData.routes provides data for API calls the component makes internally'));
852
+ console.log(chalk.dim(' (omit mockData if the component has no internal API calls)'));
853
+ console.log(chalk.yellow(' 5. IMPORTANT: Check the register response for `clientErrors` array'));
854
+ console.log(chalk.yellow(' If clientErrors is non-empty → fix the isolation route and re-register'));
855
+ console.log(chalk.yellow(' Fix client errors and re-register before moving on'));
856
+ console.log(chalk.dim(' Isolation routes are committed to git — the layout guard blocks them in production'));
857
+ console.log();
858
+ console.log(chalk.bold('Library Functions — run tests:'));
859
+ checkbox('Run ALL test files created in step 5');
860
+ console.log(chalk.dim(' Example: npx vitest run app/lib/drinks.test.ts'));
861
+ checkbox('Verify every test passes');
862
+ checkbox('If any test fails, fix the source code and re-run');
863
+ console.log();
864
+ console.log(chalk.dim('Do not proceed until both component isolations and library tests pass.'));
865
+ console.log();
866
+ checkbox('Run `codeyam editor audit` to verify all components have scenarios and all functions have tests');
867
+ console.log();
868
+ console.log(chalk.bold('Build import graph (for change tracking):'));
869
+ checkbox('Run `codeyam editor analyze-imports`');
870
+ console.log(chalk.dim(' This populates the import graph so the system can detect impacted entities when code changes.'));
871
+ console.log(chalk.dim(' It must run AFTER the audit passes so the glossary and entity data are complete.'));
872
+ stopGate(7);
873
+ }
874
+ // ─── Step 8: App Scenarios ────────────────────────────────────────────
875
+ function printStep8(root, feature) {
876
+ const port = getServerPort();
877
+ const prevState = readState(root);
878
+ const isResuming = prevState?.step === 8;
879
+ const now = new Date().toISOString();
880
+ writeState(root, {
881
+ feature,
882
+ step: 8,
883
+ label: STEP_LABELS[8],
884
+ startedAt: isResuming ? prevState.startedAt : now,
885
+ featureStartedAt: prevState?.featureStartedAt || now,
886
+ });
887
+ logEvent(root, 'step', { step: 8, label: 'App Scenarios', feature });
888
+ stepHeader(8, 'App Scenarios', feature);
889
+ if (isResuming) {
890
+ printResumptionHeader(8);
891
+ }
892
+ console.log('Create app-level scenarios representing different data states.');
893
+ console.log();
894
+ console.log(chalk.bold('Checklist:'));
895
+ checkbox('Check existing scenarios: `codeyam editor scenarios`');
896
+ console.log(chalk.dim(' Review existing scenarios — reuse and update their data rather than'));
897
+ console.log(chalk.dim(' creating duplicates. Re-register with the same name to update a scenario.'));
898
+ checkbox('Ensure scenarios clearly demonstrate what changed in this session');
899
+ console.log(chalk.dim(' If data models changed: update existing scenarios seed data to match'));
900
+ console.log(chalk.dim(' If UI changed: re-register existing scenarios so screenshots reflect the update'));
901
+ console.log(chalk.dim(' Add new scenarios only for genuinely new data states not covered by existing ones'));
902
+ checkbox('Cover key data states for EVERY page/route (at least 2-3 scenarios per page)');
903
+ console.log(chalk.yellow(' Each page needs its own scenarios — a detail page needs different data than the catalog'));
904
+ console.log(chalk.dim(' Catalog: "Full Catalog", "Empty Catalog", "Single Category"'));
905
+ console.log(chalk.dim(' Detail: "Detail - With Reviews", "Detail - No Reviews", "Detail - High Rated"'));
906
+ console.log(chalk.dim(' Each scenario provides seed data to populate the database for that state'));
907
+ checkbox('If the project has a database + seed adapter, use seed-based scenarios:');
908
+ console.log(chalk.dim(` codeyam editor register '{"name":"Full Catalog","type":"application","url":"/","seed":{"products":[...],"categories":[...]}}'`));
909
+ console.log(chalk.dim(' Seed data is written to the DB via the seed adapter. Real app renders real data.'));
910
+ checkbox('IMPORTANT: Always include "url" — the page path to screenshot for this scenario');
911
+ console.log(chalk.dim(' Use "/" for home page, "/drinks/1" for detail pages, etc.'));
912
+ console.log(chalk.dim(' Without url, the screenshot captures the root page regardless of the scenario.'));
913
+ console.log(chalk.yellow(' Create separate scenarios for each page that shows different data.'));
914
+ checkbox('For large seed data, write JSON to a project temp file and use @ prefix:');
915
+ console.log(chalk.dim(' Write JSON to .codeyam/tmp/scenario.json then register with:'));
916
+ console.log(chalk.dim(' codeyam editor register @.codeyam/tmp/scenario.json'));
917
+ checkbox('For external API mocks (Stripe, weather, etc.), add externalApis:');
918
+ console.log(chalk.dim(` "externalApis":{"GET https://api.stripe.com/v1/prices":{"body":[...],"status":200}}`));
919
+ checkbox('If no database, use component-style mock scenarios (unchanged):');
920
+ console.log(chalk.dim(` codeyam editor register '{"name":"Empty","description":"...","url":"/","mockData":{"routes":{"/api/...":{"body":[...]}}}}'`));
921
+ checkbox('After each registration, check the response for `clientErrors`');
922
+ console.log(chalk.yellow(' If clientErrors is non-empty → fix the issue and re-register the scenario'));
923
+ console.log(chalk.yellow(' Fix client errors and re-register before moving on'));
924
+ console.log();
925
+ console.log(chalk.dim('Focus on creating and registering app-level scenarios. Code fixes happen in step 10 if needed.'));
926
+ stopGate(8);
927
+ }
928
+ // ─── Step 9: User Scenarios ───────────────────────────────────────────
929
+ function printStep9(root, feature) {
930
+ const port = getServerPort();
931
+ const prevState = readState(root);
932
+ const isResuming = prevState?.step === 9;
933
+ const now = new Date().toISOString();
934
+ writeState(root, {
935
+ feature,
936
+ step: 9,
937
+ label: STEP_LABELS[9],
938
+ startedAt: isResuming ? prevState.startedAt : now,
939
+ featureStartedAt: prevState?.featureStartedAt || now,
940
+ });
941
+ logEvent(root, 'step', { step: 9, label: 'User Scenarios', feature });
942
+ stepHeader(9, 'User Scenarios', feature);
943
+ if (isResuming) {
944
+ printResumptionHeader(9);
945
+ }
946
+ console.log('Create per-persona scenarios if the app has users. Skip to step 10 if no users.');
947
+ console.log();
948
+ console.log(chalk.bold('If the app has users:'));
949
+ checkbox('Check existing scenarios: `codeyam editor scenarios`');
950
+ console.log(chalk.dim(' Reuse existing persona scenarios — update data to reflect current changes.'));
951
+ console.log(chalk.dim(' Re-register with the same name to update. Only add new personas if needed.'));
952
+ checkbox('Ensure scenarios for each user persona (admin, regular user, new user)');
953
+ console.log(chalk.dim(' Each persona scenario layers user-specific seed data on top of an app scenario'));
954
+ checkbox('If using seed-based scenarios, register with type "user" and baseScenario:');
955
+ console.log(chalk.dim(` codeyam editor register '{"name":"Admin User","type":"user","url":"/","baseScenario":"<app-scenario-id>","seed":{"users":[{"id":1,"role":"admin"}]}}'`));
956
+ console.log(chalk.dim(' Always include "url" — the page to screenshot (e.g. "/", "/dashboard", "/drinks/1")'));
957
+ console.log(chalk.dim(" The base scenario's seed data is merged with this scenario's seed data (overlay wins)."));
958
+ checkbox('If using mock-based scenarios, register with mockData as before:');
959
+ console.log(chalk.dim(` codeyam editor register '{"name":"...","description":"...","mockData":{"routes":{"/api/...":{"body":[...]}}}}'`));
960
+ checkbox('After each registration, check the response for `clientErrors`');
961
+ console.log(chalk.yellow(' If clientErrors is non-empty → fix the issue and re-register the scenario'));
962
+ console.log(chalk.yellow(' Fix client errors and re-register before moving on'));
963
+ console.log();
964
+ console.log(chalk.bold('If the app has NO users:'));
965
+ console.log(chalk.dim(' Skip this step and proceed to step 10 (Verify).'));
966
+ console.log();
967
+ console.log(chalk.dim('Focus on creating user-persona scenarios (or skip if no users). Code fixes happen in step 10 if needed.'));
968
+ stopGate(9);
969
+ }
970
+ // ─── Step 10: Verify ──────────────────────────────────────────────────
971
+ function printStep10(root, feature) {
972
+ const port = getServerPort();
973
+ const prevState = readState(root);
974
+ const isResuming = prevState?.step === 10;
975
+ const now = new Date().toISOString();
976
+ writeState(root, {
977
+ feature,
978
+ step: 10,
979
+ label: STEP_LABELS[10],
980
+ startedAt: isResuming ? prevState.startedAt : now,
981
+ featureStartedAt: prevState?.featureStartedAt || now,
982
+ });
983
+ logEvent(root, 'step', { step: 10, label: 'Verify', feature });
984
+ stepHeader(10, 'Verify', feature);
985
+ if (isResuming) {
986
+ printResumptionHeader(10);
987
+ }
988
+ console.log('Verify component isolation screenshots, editor scenarios, and library tests.');
989
+ console.log();
990
+ console.log(chalk.bold('Component isolation screenshots — verify:'));
991
+ checkbox('Review component screenshots in the App tab (grouped under Components)');
992
+ checkbox('If any screenshot looks wrong, fix the component code');
993
+ console.log(chalk.yellow(' After fixing a visual component, re-register the affected scenarios:'));
994
+ console.log(chalk.dim(` codeyam editor register '{"name":"ComponentName - Scenario",...}'`));
995
+ console.log();
996
+ console.log(chalk.bold('Editor scenarios (App tab) — visual + error check:'));
997
+ checkbox(`Refresh the preview: \`codeyam editor preview\``);
998
+ checkbox('Click through each app-level and user-persona scenario in the preview');
999
+ checkbox('For seed-based scenarios: verify data renders correctly after switching');
1000
+ console.log(chalk.dim(' Switch between scenarios and confirm the app reflects the seeded data each time'));
1001
+ checkbox(`Check for client-side errors: \`codeyam editor client-errors\``);
1002
+ console.log(chalk.yellow(' If `hasErrors` is true: list each scenario with errors, fix the source code,'));
1003
+ console.log(chalk.yellow(' re-register the affected scenarios, and re-check until hasErrors is false'));
1004
+ console.log(chalk.dim(' Common errors: React errors, failed fetches, undefined references, hydration mismatches'));
1005
+ checkbox('Verify no broken images: `codeyam editor verify-images \'{"paths":["/"], "imageUrls":["url1"]}\'` with all page paths and image URLs');
1006
+ console.log();
1007
+ console.log(chalk.bold('Library functions — test check:'));
1008
+ checkbox('Re-run all test files from step 5 to confirm they still pass');
1009
+ console.log(chalk.dim(' Example: npx vitest run app/lib/drinks.test.ts'));
1010
+ checkbox('If any test fails, fix the source code and re-run');
1011
+ console.log();
1012
+ console.log(chalk.dim('Focus on fixing issues. All component screenshots, scenarios, and tests must be clean before proceeding.'));
1013
+ stopGate(10);
1014
+ }
1015
+ // ─── Step 11: Journal ─────────────────────────────────────────────────
1016
+ function printStep11(root, feature) {
1017
+ const port = getServerPort();
1018
+ const prevState = readState(root);
1019
+ const isResuming = prevState?.step === 11;
1020
+ const now = new Date().toISOString();
1021
+ writeState(root, {
1022
+ feature,
1023
+ step: 11,
1024
+ label: STEP_LABELS[11],
1025
+ startedAt: isResuming ? prevState.startedAt : now,
1026
+ featureStartedAt: prevState?.featureStartedAt || now,
1027
+ });
1028
+ logEvent(root, 'step', { step: 11, label: 'Journal', feature });
1029
+ stepHeader(11, 'Journal', feature);
1030
+ if (isResuming) {
1031
+ printResumptionHeader(11);
1032
+ }
1033
+ console.log('Create or update the journal entry for this feature.');
1034
+ console.log();
1035
+ console.log(chalk.bold('Checklist:'));
1036
+ checkbox('Write a concise description of what was built (2-3 sentences)');
1037
+ checkbox(`First time at step 11 — create journal entry with ALL session screenshots:`);
1038
+ console.log(chalk.dim(` codeyam editor journal '{"title":"...","type":"feature","description":"...","includeSessionScenarios":true}'`));
1039
+ console.log(chalk.dim(' includeSessionScenarios auto-discovers component + app + user persona screenshots'));
1040
+ checkbox(`Returning to step 11 (before commit) — update the existing journal entry:`);
1041
+ console.log(chalk.dim(` codeyam editor journal-update '{"time":"<journal entry time>","description":"<updated>","includeSessionScenarios":true}'`));
1042
+ console.log(chalk.dim(' Note: PATCH only works before the entry is committed. After commit, use POST to create a new entry.'));
1043
+ console.log();
1044
+ console.log(chalk.dim('Focus on creating or updating the journal entry. Summary and presentation happen in step 13.'));
1045
+ stopGate(11);
1046
+ }
1047
+ // ─── Step 12: Review ──────────────────────────────────────────────────
1048
+ function printStep12(root, feature) {
1049
+ const port = getServerPort();
1050
+ const prevState = readState(root);
1051
+ const isResuming = prevState?.step === 12;
1052
+ const now = new Date().toISOString();
1053
+ writeState(root, {
1054
+ feature,
1055
+ step: 12,
1056
+ label: STEP_LABELS[12],
1057
+ startedAt: isResuming ? prevState.startedAt : now,
1058
+ featureStartedAt: prevState?.featureStartedAt || now,
1059
+ });
1060
+ logEvent(root, 'step', { step: 12, label: 'Review', feature });
1061
+ stepHeader(12, 'Review', feature);
1062
+ if (isResuming) {
1063
+ printResumptionHeader(12);
1064
+ }
1065
+ console.log('Verify all screenshots and checks pass before presenting to the user.');
1066
+ console.log();
1067
+ console.log(chalk.bold('Checklist (do all of this silently):'));
1068
+ checkbox(`Refresh the preview: \`codeyam editor preview\``);
1069
+ checkbox('Verify each component has screenshots in the App tab (grouped under Components)');
1070
+ checkbox('If any are missing, re-register them using `codeyam editor register`');
1071
+ checkbox(`Check for client errors: \`codeyam editor client-errors\``);
1072
+ checkbox('If `hasErrors` is true, fix them and re-capture affected scenarios');
1073
+ checkbox('Run `codeyam editor verify-images \'{"paths":["/"], "imageUrls":["url1"]}\'` with all page paths and image URLs');
1074
+ checkbox('Fix or remove any broken images before continuing');
1075
+ checkbox('Run `codeyam editor audit` to verify completeness of scenarios and tests');
1076
+ checkbox('Do not proceed until all checks pass');
1077
+ stopGate(12);
1078
+ }
1079
+ // ─── Step 13: Present ─────────────────────────────────────────────────
1080
+ function printStep13(root, feature) {
1081
+ const port = getServerPort();
1082
+ const prevState = readState(root);
1083
+ const isResuming = prevState?.step === 13;
1084
+ const now = new Date().toISOString();
1085
+ writeState(root, {
1086
+ feature,
1087
+ step: 13,
1088
+ label: STEP_LABELS[13],
1089
+ startedAt: isResuming ? prevState.startedAt : now,
1090
+ featureStartedAt: prevState?.featureStartedAt || now,
1091
+ });
1092
+ logEvent(root, 'step', { step: 13, label: 'Present', feature });
1093
+ stepHeader(13, 'Present', feature);
1094
+ if (isResuming) {
1095
+ printResumptionHeader(13);
1096
+ }
1097
+ console.log('Present the results to the user and get their approval.');
1098
+ console.log();
1099
+ console.log(chalk.bold('Checklist:'));
1100
+ checkbox('Fetch all scenarios: `codeyam editor scenarios`');
1101
+ console.log(chalk.dim(' Each scenario has a `changeStatus` field: "new", "edited", "impacted", or null.'));
1102
+ checkbox('Pick the best scenario to showcase from this working session:');
1103
+ console.log(chalk.dim(' Prefer scenarios with changeStatus "new" or "edited" (directly changed in this session).'));
1104
+ console.log(chalk.dim(' For app-level scenarios, prefer those showing the new/changed functionality.'));
1105
+ console.log(chalk.dim(' NEVER pick a scenario with changeStatus null — those are unchanged from a previous commit.'));
1106
+ checkbox('Switch the preview to that scenario using its `id`:');
1107
+ console.log(chalk.dim(` codeyam editor preview '{"scenarioId":"<id>"}'`));
1108
+ checkbox(`Show the results panel: \`codeyam editor show-results\``);
1109
+ console.log(chalk.dim(' This opens a visual panel below the terminal showing all scenarios with screenshots.'));
1110
+ console.log(chalk.dim(' The user can click scenarios to switch the live preview.'));
1111
+ checkbox('Write a 1-2 sentence summary of what was built');
1112
+ checkbox('Report test count and audit status (one line)');
1113
+ console.log();
1114
+ console.log(chalk.bold('Present a selection menu to the user (use AskUserQuestion with these EXACT option labels):'));
1115
+ console.log(chalk.green(' Option 1 label: "Save & commit"') +
1116
+ chalk.dim(' — git commit all changes and record in journal'));
1117
+ console.log(chalk.yellow(' Option 2 label: "I\'d like to make some changes"') +
1118
+ chalk.dim(' — describe changes, then re-verify'));
1119
+ console.log();
1120
+ console.log(chalk.bold('If the user chooses "Save & commit":'));
1121
+ checkbox(`Hide the results panel first: \`codeyam editor hide-results\``);
1122
+ checkbox(`Git commit using the journal description: \`codeyam editor commit '{"message":"feat: <title>\\n\\n<journal description>"}'\``);
1123
+ console.log(chalk.dim(' The commit message body MUST match the journal description exactly'));
1124
+ checkbox(`Update journal with commit SHA: \`codeyam editor journal-update '{"time":"<journal entry time>","commitSha":"<sha>","commitMessage":"feat: <title>"}'\``);
1125
+ console.log(chalk.green(' Then run: ') +
1126
+ chalk.bold('codeyam editor steps') +
1127
+ chalk.green(' to start the next feature'));
1128
+ console.log();
1129
+ console.log(chalk.bold('If the user chooses "Make changes" (or asks for ANY change, even as a question):'));
1130
+ checkbox(`Hide the results panel: \`codeyam editor hide-results\``);
1131
+ checkbox('Ask what changes the user wants (if not already clear)');
1132
+ checkbox(`Run: \`codeyam editor change "${feature}"\` — this gives you the change checklist`);
1133
+ checkbox('THEN make the requested changes and follow the checklist');
1134
+ console.log(chalk.red.bold(' IMPORTANT: Always run the change command BEFORE writing any code.'));
1135
+ stopGate(13, { confirm: true });
1136
+ }
1137
+ // ─── Command definition ───────────────────────────────────────────────
1138
+ // ─── Analyze-imports subcommand ────────────────────────────────────────
1139
+ /**
1140
+ * `codeyam editor analyze-imports`
1141
+ *
1142
+ * Runs data-structure-only analysis for all glossary entities, then outputs
1143
+ * an import graph and entity data structures as JSON to stdout.
1144
+ */
1145
+ async function handleAnalyzeImports() {
1146
+ const root = getProjectRoot();
1147
+ // Read glossary
1148
+ const glossaryPath = path.join(root, '.codeyam', 'glossary.json');
1149
+ if (!fs.existsSync(glossaryPath)) {
1150
+ console.error(chalk.red('Error: .codeyam/glossary.json not found.'));
1151
+ console.error(chalk.dim(' Run codeyam editor 6 to create the glossary first.'));
1152
+ process.exit(1);
1153
+ }
1154
+ let glossaryEntries;
1155
+ try {
1156
+ glossaryEntries = JSON.parse(fs.readFileSync(glossaryPath, 'utf8'));
1157
+ }
1158
+ catch {
1159
+ console.error(chalk.red('Error: Could not parse .codeyam/glossary.json.'));
1160
+ process.exit(1);
1161
+ }
1162
+ if (!Array.isArray(glossaryEntries) || glossaryEntries.length === 0) {
1163
+ console.error(chalk.red('Error: glossary.json is empty.'));
1164
+ process.exit(1);
1165
+ }
1166
+ const filePaths = glossaryEntries.map((e) => e.filePath);
1167
+ const entityNames = glossaryEntries.map((e) => e.name);
1168
+ const progress = new ProgressReporter();
1169
+ // Run data-structure-only analysis for all entities
1170
+ progress.start('Running import analysis for all glossary entities...');
1171
+ try {
1172
+ await runAnalysisForEntities({
1173
+ projectRoot: root,
1174
+ filePaths,
1175
+ entityNames,
1176
+ progress,
1177
+ onlyDataStructure: true,
1178
+ });
1179
+ }
1180
+ catch (err) {
1181
+ progress.fail('Analysis failed');
1182
+ const msg = err instanceof Error ? err.message : String(err);
1183
+ console.error(chalk.red(`Error: ${msg}`));
1184
+ process.exit(1);
1185
+ }
1186
+ progress.succeed('Analysis complete');
1187
+ // Load entities WITH metadata from database
1188
+ progress.start('Loading entity metadata...');
1189
+ await initializeEnvironment();
1190
+ const entities = await loadEntities({});
1191
+ if (!entities || entities.length === 0) {
1192
+ progress.succeed('No entities found in database yet — skipping import analysis. This is normal on the first feature.');
1193
+ console.log(JSON.stringify({ imports: {}, entities: {} }));
1194
+ return;
1195
+ }
1196
+ // Deduplicate to latest versions
1197
+ const latestByKey = new Map();
1198
+ for (const entity of entities) {
1199
+ const key = `${entity.name}::${entity.filePath}`;
1200
+ const existing = latestByKey.get(key);
1201
+ if (!existing ||
1202
+ (entity.createdAt &&
1203
+ existing.createdAt &&
1204
+ entity.createdAt > existing.createdAt)) {
1205
+ latestByKey.set(key, entity);
1206
+ }
1207
+ }
1208
+ const entityNameSet = new Set(entityNames);
1209
+ const latestEntities = [...latestByKey.values()].filter((e) => entityNameSet.has(e.name));
1210
+ // Build import graph from importedExports metadata
1211
+ const imports = {};
1212
+ const entityData = {};
1213
+ // Also load analyses for data structures
1214
+ const entityShas = latestEntities.map((e) => e.sha);
1215
+ const analyses = await loadAnalyses({ entityShas });
1216
+ const analysisMap = new Map();
1217
+ if (analyses) {
1218
+ for (const a of analyses) {
1219
+ if (!analysisMap.has(a.entitySha) ||
1220
+ (a.createdAt &&
1221
+ (!analysisMap.get(a.entitySha).createdAt ||
1222
+ a.createdAt > analysisMap.get(a.entitySha).createdAt))) {
1223
+ analysisMap.set(a.entitySha, a);
1224
+ }
1225
+ }
1226
+ }
1227
+ for (const entity of latestEntities) {
1228
+ const importedExports = entity.metadata?.importedExports || [];
1229
+ const importedNames = importedExports
1230
+ .map((ie) => ie.name)
1231
+ .filter((name) => entityNameSet.has(name));
1232
+ if (importedNames.length > 0) {
1233
+ imports[entity.name] = importedNames;
1234
+ }
1235
+ // Collect entity data with analysis data structures
1236
+ const analysis = analysisMap.get(entity.sha);
1237
+ const analysisMetadata = analysis?.metadata;
1238
+ entityData[entity.name] = {
1239
+ filePath: entity.filePath || '',
1240
+ entityType: entity.entityType || 'visual',
1241
+ dataForMocks: analysisMetadata?.scenariosDataStructure?.dataForMocks,
1242
+ dependencySchemas: analysisMetadata?.mergedDataStructure?.dependencySchemas,
1243
+ };
1244
+ }
1245
+ progress.succeed('Done');
1246
+ // Output combined JSON
1247
+ const output = { imports, entities: entityData };
1248
+ console.log(JSON.stringify(output, null, 2));
1249
+ }
1250
+ // ─── Validate-seed subcommand ─────────────────────────────────────────
1251
+ /**
1252
+ * Validate seed data structure and check for a seed adapter.
1253
+ * Usage: codeyam editor validate-seed '{"products":[...]}'
1254
+ */
1255
+ function handleValidateSeed(jsonArg) {
1256
+ const root = process.cwd();
1257
+ // Check for seed adapter
1258
+ const adapterPath = detectSeedAdapter(root);
1259
+ if (adapterPath) {
1260
+ console.log(chalk.green(`Seed adapter found: ${adapterPath}`));
1261
+ }
1262
+ else {
1263
+ console.log(chalk.yellow('No seed adapter found. Create .codeyam/seed-adapter.ts to use seed-based scenarios.'));
1264
+ }
1265
+ if (!jsonArg) {
1266
+ return;
1267
+ }
1268
+ let data;
1269
+ try {
1270
+ data = JSON.parse(jsonArg);
1271
+ }
1272
+ catch {
1273
+ console.error(chalk.red('Error: Invalid JSON.'));
1274
+ process.exit(1);
1275
+ }
1276
+ const result = validateSeedData(data);
1277
+ if (result.valid) {
1278
+ const tables = Object.keys(data);
1279
+ const totalRows = tables.reduce((sum, t) => sum + (Array.isArray(data[t]) ? data[t].length : 0), 0);
1280
+ console.log(chalk.green(`Seed data valid: ${tables.length} table(s), ${totalRows} total row(s)`));
1281
+ for (const table of tables) {
1282
+ const rows = Array.isArray(data[table])
1283
+ ? data[table].length
1284
+ : 0;
1285
+ console.log(chalk.dim(` ${table}: ${rows} row(s)`));
1286
+ }
1287
+ }
1288
+ else {
1289
+ console.error(chalk.red('Seed data validation failed:'));
1290
+ for (const err of result.errors) {
1291
+ console.error(chalk.red(` - ${err}`));
1292
+ }
1293
+ process.exit(1);
1294
+ }
1295
+ }
1296
+ // ─── Isolate subcommand ───────────────────────────────────────────────
1297
+ /**
1298
+ * `codeyam editor isolate StarRating CategoryBadge DrinkCard`
1299
+ *
1300
+ * Creates isolation route directories and the layout guard file.
1301
+ * This avoids brace-expansion permission prompts in the embedded terminal.
1302
+ */
1303
+ function handleIsolate(componentNames) {
1304
+ const root = process.cwd();
1305
+ if (componentNames.length === 0) {
1306
+ console.error(chalk.red('Usage: codeyam editor isolate ComponentA ComponentB ...'));
1307
+ process.exit(1);
1308
+ }
1309
+ const isolateDir = path.join(root, 'app', 'codeyam-isolate');
1310
+ // Create layout.tsx with production guard if missing
1311
+ const layoutPath = path.join(isolateDir, 'layout.tsx');
1312
+ if (!fs.existsSync(layoutPath)) {
1313
+ fs.mkdirSync(isolateDir, { recursive: true });
1314
+ fs.writeFileSync(layoutPath, [
1315
+ 'import { notFound } from "next/navigation";',
1316
+ '',
1317
+ 'export default function CaptureLayout({ children }: { children: React.ReactNode }) {',
1318
+ ' if (process.env.NODE_ENV === "production") notFound();',
1319
+ ' return <>{children}</>;',
1320
+ '}',
1321
+ '',
1322
+ ].join('\n'), 'utf8');
1323
+ console.log(chalk.green(`Created layout guard: app/codeyam-isolate/layout.tsx`));
1324
+ }
1325
+ // Create a directory for each component
1326
+ const created = [];
1327
+ const existed = [];
1328
+ for (const name of componentNames) {
1329
+ const dir = path.join(isolateDir, name);
1330
+ if (fs.existsSync(dir)) {
1331
+ existed.push(name);
1332
+ }
1333
+ else {
1334
+ fs.mkdirSync(dir, { recursive: true });
1335
+ created.push(name);
1336
+ }
1337
+ }
1338
+ if (created.length > 0) {
1339
+ console.log(chalk.green(`Created ${created.length} isolation route dir(s): ${created.join(', ')}`));
1340
+ }
1341
+ if (existed.length > 0) {
1342
+ console.log(chalk.dim(`Already existed: ${existed.join(', ')}`));
1343
+ }
1344
+ }
1345
+ // ─── Register subcommand ──────────────────────────────────────────────
1346
+ /**
1347
+ * Format API subcommand results as concise one-line summaries.
1348
+ * Prevents Claude from piping output to python3 just to extract key fields.
1349
+ * Returns null for subcommands that should keep raw JSON output.
1350
+ */
1351
+ function formatApiSubcommandResult(subcommand, data) {
1352
+ if (!data || typeof data !== 'object')
1353
+ return null;
1354
+ switch (subcommand) {
1355
+ case 'journal': {
1356
+ const parts = [`success=${data.success}`];
1357
+ if (data.entry?.time)
1358
+ parts.push(`time="${data.entry.time}"`);
1359
+ if (data.entry?.title)
1360
+ parts.push(`title="${data.entry.title}"`);
1361
+ if (data.scenarioScreenshotsFound != null) {
1362
+ parts.push(`screenshots=${data.scenarioScreenshotsFound}`);
1363
+ }
1364
+ return parts.join(' ');
1365
+ }
1366
+ case 'journal-update': {
1367
+ const parts = [`success=${data.success}`];
1368
+ if (data.entry?.time)
1369
+ parts.push(`time="${data.entry.time}"`);
1370
+ if (data.scenarioScreenshotsFound != null) {
1371
+ parts.push(`screenshots=${data.scenarioScreenshotsFound}`);
1372
+ }
1373
+ return parts.join(' ');
1374
+ }
1375
+ case 'commit': {
1376
+ const parts = [`success=${data.success}`];
1377
+ if (data.sha)
1378
+ parts.push(`sha=${data.sha}`);
1379
+ if (data.message)
1380
+ parts.push(`message="${data.message.split('\n')[0]}"`);
1381
+ return parts.join(' ');
1382
+ }
1383
+ case 'preview': {
1384
+ const parts = [
1385
+ `success=${!!data.ok || data.success !== false}`,
1386
+ ];
1387
+ if (data.path)
1388
+ parts.push(`path="${data.path}"`);
1389
+ if (data.scenarioId)
1390
+ parts.push(`scenarioId="${data.scenarioId}"`);
1391
+ if (data.sessionsNotified != null)
1392
+ parts.push(`notified=${data.sessionsNotified}`);
1393
+ return parts.join(' ');
1394
+ }
1395
+ case 'dev-server': {
1396
+ if (data.status) {
1397
+ return `status=${data.status} pid=${data.pid || 'none'} port=${data.port || 'none'}`;
1398
+ }
1399
+ return null;
1400
+ }
1401
+ default:
1402
+ return null; // journal-list, client-errors, show/hide-results: keep full JSON
1403
+ }
1404
+ }
1405
+ /**
1406
+ * `codeyam editor register '{"name":"...","componentName":"...",...}'`
1407
+ *
1408
+ * Thin CLI wrapper around POST /api/editor-register-scenario.
1409
+ * Auto-approved via `Bash(codeyam:*)` — no manual approval needed.
1410
+ */
1411
+ async function handleRegister(jsonArg) {
1412
+ if (!jsonArg) {
1413
+ console.error(chalk.red('Error: JSON argument required.'));
1414
+ console.error(chalk.dim(' Usage: codeyam editor register \'{"name":"DrinkCard - Default","componentName":"DrinkCard","url":"/codeyam-isolate/DrinkCard?s=Default"}\''));
1415
+ console.error(chalk.dim(' For large payloads: codeyam editor register @/tmp/scenario.json'));
1416
+ process.exit(1);
1417
+ }
1418
+ const parsed = parseRegisterArg(jsonArg);
1419
+ if (parsed.error) {
1420
+ console.error(chalk.red(`Error: ${parsed.error}`));
1421
+ if (parsed.error === 'Invalid JSON') {
1422
+ console.error(chalk.dim(` Received: ${jsonArg.slice(0, 200)}`));
1423
+ }
1424
+ process.exit(1);
1425
+ }
1426
+ const body = parsed.body;
1427
+ const port = getServerPort();
1428
+ const url = `http://localhost:${port}/api/editor-register-scenario`;
1429
+ try {
1430
+ const res = await fetch(url, {
1431
+ method: 'POST',
1432
+ headers: { 'Content-Type': 'application/json' },
1433
+ body: JSON.stringify(body),
1434
+ });
1435
+ const data = await res.json();
1436
+ // Print concise summary instead of raw JSON so Claude doesn't need python3
1437
+ const parts = [];
1438
+ parts.push(`success=${data.success}`);
1439
+ if (data.scenario?.name)
1440
+ parts.push(`name="${data.scenario.name}"`);
1441
+ parts.push(`screenshot=${!!data.screenshotCaptured}`);
1442
+ if (data.clientErrors?.length > 0) {
1443
+ parts.push(chalk.red(`errors=${data.clientErrors.length}`));
1444
+ }
1445
+ else {
1446
+ parts.push(`errors=0`);
1447
+ }
1448
+ if (data.seedResult)
1449
+ parts.push(`seed=${data.seedResult.success}`);
1450
+ if (data.captureError)
1451
+ parts.push(chalk.yellow(`captureError="${data.captureError}"`));
1452
+ console.log(parts.join(' '));
1453
+ // Surface client errors prominently so they can't be missed
1454
+ if (data.clientErrors && data.clientErrors.length > 0) {
1455
+ console.log(chalk.red.bold(`⚠ WARNING: ${data.clientErrors.length} client error${data.clientErrors.length !== 1 ? 's' : ''} detected during capture:`));
1456
+ for (const err of data.clientErrors) {
1457
+ console.log(chalk.red(` → ${err}`));
1458
+ }
1459
+ console.log(chalk.yellow(' The screenshot may show an error screen instead of the actual component.'));
1460
+ console.log(chalk.yellow(' Fix the issue and re-register this scenario.'));
1461
+ }
1462
+ if (!res.ok) {
1463
+ console.error(chalk.dim(JSON.stringify(data, null, 2)));
1464
+ process.exit(1);
1465
+ }
1466
+ }
1467
+ catch (error) {
1468
+ const msg = error instanceof Error ? error.message : String(error);
1469
+ console.error(chalk.red(`Error: Could not reach editor server at ${url}`));
1470
+ console.error(chalk.dim(` ${msg}`));
1471
+ console.error(chalk.dim(' Is the editor running? Start it with: codeyam editor'));
1472
+ process.exit(1);
1473
+ }
1474
+ }
1475
+ // ─── Dependents subcommand ────────────────────────────────────────────
1476
+ /**
1477
+ * `codeyam editor dependents <EntityName>`
1478
+ *
1479
+ * Walks the importedBy reverse dependency tree to find all ancestors of a
1480
+ * given entity — i.e., every component or page that transitively imports it.
1481
+ * Used after code changes to determine what needs recapturing.
1482
+ */
1483
+ async function handleDependents(entityName) {
1484
+ if (!entityName) {
1485
+ console.error(chalk.red('Error: Entity name required.'));
1486
+ console.error(chalk.dim(' Usage: codeyam editor dependents DrinkCard'));
1487
+ process.exit(1);
1488
+ }
1489
+ const progress = new ProgressReporter();
1490
+ progress.start('Loading entities from database...');
1491
+ await initializeEnvironment();
1492
+ const allEntities = await loadEntities({});
1493
+ if (!allEntities || allEntities.length === 0) {
1494
+ progress.fail('No entities found in database');
1495
+ console.error(chalk.dim(' Run codeyam editor analyze-imports first to populate entity data.'));
1496
+ process.exit(1);
1497
+ }
1498
+ // Find the target entity by name (case-insensitive match)
1499
+ const targetEntities = allEntities.filter((e) => e.name.toLowerCase() === entityName.toLowerCase());
1500
+ if (targetEntities.length === 0) {
1501
+ progress.fail(`Entity "${entityName}" not found in database`);
1502
+ const names = [...new Set(allEntities.map((e) => e.name))].sort();
1503
+ console.error(chalk.dim(` Available entities: ${names.join(', ')}`));
1504
+ process.exit(1);
1505
+ }
1506
+ progress.succeed('Entities loaded');
1507
+ // Build lookup: entityName -> Set<entityName> of entities that import it.
1508
+ // Each entity's metadata.importedBy is the pre-computed reverse graph:
1509
+ // { [filePath]: { [importerName]: { shas: string[] } } }
1510
+ const importedByName = new Map();
1511
+ for (const entity of allEntities) {
1512
+ const importedBy = entity.metadata?.importedBy;
1513
+ if (!importedBy || typeof importedBy !== 'object')
1514
+ continue;
1515
+ const importers = new Set();
1516
+ for (const filePath of Object.keys(importedBy)) {
1517
+ for (const importerName of Object.keys(importedBy[filePath])) {
1518
+ importers.add(importerName);
1519
+ }
1520
+ }
1521
+ if (importers.size > 0) {
1522
+ importedByName.set(entity.name, importers);
1523
+ }
1524
+ }
1525
+ // BFS walk up the dependency tree from the changed entity
1526
+ const visited = new Set();
1527
+ const result = [];
1528
+ const queue = [
1529
+ { name: entityName, depth: 0 },
1530
+ ];
1531
+ visited.add(entityName.toLowerCase());
1532
+ // Collect entity types for display
1533
+ const entityTypes = new Map();
1534
+ for (const e of allEntities) {
1535
+ if (!entityTypes.has(e.name)) {
1536
+ entityTypes.set(e.name, e.entityType || 'unknown');
1537
+ }
1538
+ }
1539
+ while (queue.length > 0) {
1540
+ const { name, depth } = queue.shift();
1541
+ result.push({
1542
+ name,
1543
+ entityType: entityTypes.get(name) || 'unknown',
1544
+ depth,
1545
+ });
1546
+ // Find all entities that import this one
1547
+ const importers = importedByName.get(name);
1548
+ if (!importers)
1549
+ continue;
1550
+ for (const importerName of importers) {
1551
+ if (visited.has(importerName.toLowerCase()))
1552
+ continue;
1553
+ visited.add(importerName.toLowerCase());
1554
+ queue.push({ name: importerName, depth: depth + 1 });
1555
+ }
1556
+ }
1557
+ // Output
1558
+ if (result.length <= 1) {
1559
+ console.log(chalk.yellow(`No dependents found for "${entityName}".`));
1560
+ console.log(chalk.dim(' This entity is not imported by any other known entities.'));
1561
+ console.log(chalk.dim(' Run codeyam editor analyze-imports to populate import data.'));
1562
+ return;
1563
+ }
1564
+ console.log(chalk.bold(`Dependency tree for ${entityName} (${result.length} entities):`));
1565
+ console.log();
1566
+ for (const entry of result) {
1567
+ const indent = ' '.repeat(entry.depth);
1568
+ const prefix = entry.depth === 0 ? chalk.cyan('●') : chalk.dim('├──');
1569
+ const label = entry.depth === 0
1570
+ ? chalk.cyan(`${entry.name} (changed)`)
1571
+ : chalk.white(entry.name);
1572
+ const type = chalk.dim(`[${entry.entityType}]`);
1573
+ console.log(`${indent}${prefix} ${label} ${type}`);
1574
+ }
1575
+ console.log();
1576
+ console.log(chalk.dim('All listed entities need their scenarios recaptured after changes.'));
1577
+ }
1578
+ // ─── Change subcommand ───────────────────────────────────────────────
1579
+ /**
1580
+ * `codeyam editor change <feature>`
1581
+ *
1582
+ * Prints a condensed post-change checklist that guides Claude through
1583
+ * re-verifying after user-requested modifications. This is the "change
1584
+ * loop" — it replaces the freeform "make changes" path with structured
1585
+ * instructions that always loop back to step 13 present.
1586
+ */
1587
+ function handleChange(feature) {
1588
+ const root = getProjectRoot();
1589
+ if (!feature) {
1590
+ // Try to read feature from state
1591
+ const state = readState(root);
1592
+ if (state?.feature) {
1593
+ feature = state.feature;
1594
+ }
1595
+ else {
1596
+ console.error(chalk.red('Error: Feature name required.'));
1597
+ console.error(chalk.dim(' Usage: codeyam editor change "My Feature"'));
1598
+ process.exit(1);
1599
+ }
1600
+ }
1601
+ const port = getServerPort();
1602
+ console.log();
1603
+ console.log(chalk.bold.cyan('━━━ Change Loop ━━━'));
1604
+ console.log(chalk.dim(`Feature: ${feature}`));
1605
+ console.log();
1606
+ console.log('The user has requested changes. Follow this checklist after making them.');
1607
+ console.log();
1608
+ console.log(chalk.bold.cyan('Keep the preview moving:'));
1609
+ console.log(chalk.cyan(` Refresh after EACH individual change — not after all changes are done:`));
1610
+ console.log(chalk.cyan(` codeyam editor preview`));
1611
+ console.log(chalk.cyan(' The user is watching the preview. Let them see progress incrementally.'));
1612
+ console.log();
1613
+ console.log(chalk.bold('0. Close the results panel:'));
1614
+ checkbox(`Hide results: \`codeyam editor hide-results\``);
1615
+ console.log();
1616
+ console.log(chalk.bold('1. Re-register affected component scenarios:'));
1617
+ checkbox('For each component you modified, re-register ALL its scenarios');
1618
+ console.log(chalk.dim(` codeyam editor register '{"name":"ComponentName - ScenarioName","componentName":"ComponentName","componentPath":"app/components/ComponentName.tsx","url":"/codeyam-isolate/ComponentName?s=ScenarioName"}'`));
1619
+ checkbox('For any NEW components: `codeyam editor isolate NewComponent` then create isolation routes and register scenarios');
1620
+ console.log();
1621
+ console.log(chalk.bold('2. Re-run affected tests:'));
1622
+ checkbox('Re-run test files for any functions you modified');
1623
+ console.log(chalk.dim(' Example: npx vitest run app/lib/drinks.test.ts'));
1624
+ checkbox('If any test fails, fix the source code and re-run');
1625
+ checkbox('If you re-seeded the database, restart the dev server to pick up fresh data');
1626
+ console.log(chalk.dim(` codeyam editor dev-server '{"action":"restart"}'`));
1627
+ console.log();
1628
+ console.log(chalk.bold('3. Re-capture app-level scenarios:'));
1629
+ checkbox('Run `codeyam editor analyze-imports` to refresh the import graph after code changes');
1630
+ checkbox('If component changes affect app-level pages, re-register affected app scenarios');
1631
+ checkbox(`Use \`codeyam editor dependents ComponentName\` to find what needs recapturing`);
1632
+ console.log();
1633
+ console.log(chalk.bold('4. Verify completeness:'));
1634
+ checkbox(`Refresh the preview: \`codeyam editor preview\``);
1635
+ checkbox(`Navigate to key pages to verify changes: \`codeyam editor preview '{"path":"/your-route"}'\``);
1636
+ checkbox('Run `codeyam editor audit` — all checks must pass');
1637
+ checkbox(`Check for client-side errors: \`codeyam editor client-errors\``);
1638
+ checkbox('Fix any errors, then re-register affected scenarios');
1639
+ console.log();
1640
+ console.log(chalk.bold('5. Update the existing journal entry:'));
1641
+ checkbox('Get existing entry: `codeyam editor journal-list`');
1642
+ checkbox('Find the uncommitted entry (commitSha is null) from this feature session');
1643
+ checkbox(`Update it: \`codeyam editor journal-update '{"time":"<entry time>","description":"<updated description including changes>","includeSessionScenarios":true}'\``);
1644
+ console.log(chalk.dim(' Always update the existing uncommitted entry — do NOT create a new one.'));
1645
+ console.log(chalk.dim(' Only create a new entry (POST) if no uncommitted entry exists for this feature.'));
1646
+ console.log();
1647
+ console.log(chalk.bold.green('When all checks pass, run: ') +
1648
+ chalk.bold(`codeyam editor 13`));
1649
+ console.log(chalk.dim(' This enters the present step to show the updated results to the user.'));
1650
+ console.log();
1651
+ }
1652
+ // ─── Audit subcommand ────────────────────────────────────────────────
1653
+ /**
1654
+ * `codeyam editor audit`
1655
+ *
1656
+ * Fetches the /api/editor-audit endpoint and prints a checklist showing
1657
+ * which glossary components have registered scenarios and which functions
1658
+ * have test files. Exits with code 1 if anything is missing.
1659
+ */
1660
+ async function handleAudit() {
1661
+ const port = getServerPort();
1662
+ const url = `http://localhost:${port}/api/editor-audit`;
1663
+ let data;
1664
+ try {
1665
+ const res = await fetch(url);
1666
+ if (!res.ok) {
1667
+ console.error(chalk.red(`Error: Audit endpoint returned ${res.status}`));
1668
+ process.exit(1);
1669
+ }
1670
+ data = await res.json();
1671
+ }
1672
+ catch (err) {
1673
+ console.error(chalk.red('Error: Could not reach the CodeYam server. Is it running?'));
1674
+ console.error(chalk.dim(` ${err.message}`));
1675
+ process.exit(1);
1676
+ }
1677
+ const { components, functions, summary } = data;
1678
+ console.log();
1679
+ console.log(chalk.bold.cyan('━━━ Editor Audit ━━━'));
1680
+ console.log();
1681
+ // Components
1682
+ if (components.length > 0) {
1683
+ console.log(chalk.bold('Components (scenarios):'));
1684
+ for (const c of components) {
1685
+ const icon = c.status === 'ok' ? chalk.green('✓') : chalk.red('✗');
1686
+ let detail;
1687
+ if (c.status === 'has_errors') {
1688
+ detail = chalk.red(` — ${c.scenarioCount} scenario${c.scenarioCount !== 1 ? 's' : ''} but has client errors`);
1689
+ }
1690
+ else if (c.status === 'ok') {
1691
+ detail = chalk.dim(` (${c.scenarioCount} scenario${c.scenarioCount !== 1 ? 's' : ''})`);
1692
+ }
1693
+ else {
1694
+ detail = chalk.red(' — no scenarios registered');
1695
+ }
1696
+ console.log(` ${icon} ${c.name}${detail}`);
1697
+ if (c.clientErrors && c.clientErrors.length > 0) {
1698
+ for (const err of c.clientErrors.slice(0, 3)) {
1699
+ console.log(chalk.red(` → ${err}`));
1700
+ }
1701
+ if (c.clientErrors.length > 3) {
1702
+ console.log(chalk.dim(` … and ${c.clientErrors.length - 3} more`));
1703
+ }
1704
+ }
1705
+ }
1706
+ console.log();
1707
+ }
1708
+ // Functions
1709
+ if (functions.length > 0) {
1710
+ console.log(chalk.bold('Functions (test files):'));
1711
+ for (const f of functions) {
1712
+ const icon = f.status === 'ok' ? chalk.green('✓') : chalk.red('✗');
1713
+ let detail;
1714
+ switch (f.status) {
1715
+ case 'ok':
1716
+ detail = chalk.dim(` (${f.testFile})`);
1717
+ break;
1718
+ case 'failing':
1719
+ detail = chalk.red(` — tests failing: ${f.testFile}`);
1720
+ break;
1721
+ case 'name_mismatch':
1722
+ detail = chalk.red(` — tests pass but missing top-level describe("${f.name}", ...) — tests won't display in UI`);
1723
+ break;
1724
+ case 'missing':
1725
+ default:
1726
+ detail = f.testFile
1727
+ ? chalk.red(` — test file missing: ${f.testFile}`)
1728
+ : chalk.red(' — no test file specified');
1729
+ break;
1730
+ }
1731
+ console.log(` ${icon} ${f.name}${detail}`);
1732
+ }
1733
+ console.log();
1734
+ }
1735
+ // Summary
1736
+ const allOk = summary.allPassing;
1737
+ if (allOk) {
1738
+ console.log(chalk.green.bold('All checks passed!') +
1739
+ chalk.dim(` (${summary.totalComponents} component${summary.totalComponents !== 1 ? 's' : ''}, ${summary.totalFunctions} function${summary.totalFunctions !== 1 ? 's' : ''})`));
1740
+ }
1741
+ else {
1742
+ const parts = [];
1743
+ if (summary.componentsMissing > 0) {
1744
+ parts.push(`${summary.componentsMissing} component${summary.componentsMissing !== 1 ? 's' : ''} missing scenarios`);
1745
+ }
1746
+ if (summary.componentsWithErrors > 0) {
1747
+ parts.push(`${summary.componentsWithErrors} component${summary.componentsWithErrors !== 1 ? 's' : ''} with client errors`);
1748
+ }
1749
+ if (summary.functionsMissing > 0) {
1750
+ parts.push(`${summary.functionsMissing} function${summary.functionsMissing !== 1 ? 's' : ''} missing tests`);
1751
+ }
1752
+ if (summary.functionsFailing > 0) {
1753
+ parts.push(`${summary.functionsFailing} function${summary.functionsFailing !== 1 ? 's' : ''} with failing tests`);
1754
+ }
1755
+ if (summary.functionsNameMismatch > 0) {
1756
+ parts.push(`${summary.functionsNameMismatch} function${summary.functionsNameMismatch !== 1 ? 's' : ''} with test name mismatch (missing top-level describe)`);
1757
+ }
1758
+ console.log(chalk.red.bold('Audit failed: ') + parts.join(', '));
1759
+ }
1760
+ console.log();
1761
+ if (!allOk) {
1762
+ process.exit(1);
1763
+ }
1764
+ }
1765
+ // ─── Scenarios subcommand ─────────────────────────────────────────────
1766
+ async function handleScenarios() {
1767
+ const port = getServerPort();
1768
+ const url = `http://localhost:${port}/api/editor-scenarios`;
1769
+ let data;
1770
+ try {
1771
+ const res = await fetch(url);
1772
+ if (!res.ok) {
1773
+ console.error(chalk.red(`Error: Scenarios endpoint returned ${res.status}`));
1774
+ process.exit(1);
1775
+ }
1776
+ data = await res.json();
1777
+ }
1778
+ catch (err) {
1779
+ console.error(chalk.red('Error: Could not reach the CodeYam server. Is it running?'));
1780
+ console.error(chalk.dim(` ${err.message}`));
1781
+ process.exit(1);
1782
+ }
1783
+ const scenarios = data.scenarios;
1784
+ if (scenarios.length === 0) {
1785
+ console.log();
1786
+ console.log(chalk.yellow('No scenarios found for this feature session.'));
1787
+ console.log();
1788
+ return;
1789
+ }
1790
+ // Group by componentName (null → "Uncategorized")
1791
+ const groups = new Map();
1792
+ for (const s of scenarios) {
1793
+ const key = s.componentName || 'Uncategorized';
1794
+ if (!groups.has(key))
1795
+ groups.set(key, []);
1796
+ groups.get(key).push(s);
1797
+ }
1798
+ // Strip component prefix from names (e.g. "DrinkCard - Default" → "Default")
1799
+ function stripPrefix(name, componentName) {
1800
+ if (!componentName)
1801
+ return name;
1802
+ const prefix = `${componentName} - `;
1803
+ return name.startsWith(prefix) ? name.slice(prefix.length) : name;
1804
+ }
1805
+ // Calculate column widths
1806
+ let maxCompLen = 'Component'.length;
1807
+ let maxScenLen = 'Scenario'.length;
1808
+ for (const [comp, items] of groups) {
1809
+ maxCompLen = Math.max(maxCompLen, comp.length);
1810
+ for (const s of items) {
1811
+ const display = stripPrefix(s.name, s.componentName);
1812
+ maxScenLen = Math.max(maxScenLen, display.length);
1813
+ }
1814
+ }
1815
+ const pad = (str, len) => str + ' '.repeat(Math.max(0, len - str.length));
1816
+ // Build OSC 8 hyperlink (display length = visible text only)
1817
+ const osc8 = (url, text) => `\x1b]8;;${url}\x07${text}\x1b]8;;\x07`;
1818
+ // Print table
1819
+ console.log();
1820
+ console.log(chalk.bold.cyan('━━━ Scenario Table ━━━'));
1821
+ console.log();
1822
+ const divComp = '─'.repeat(maxCompLen + 2);
1823
+ const divScen = '─'.repeat(maxScenLen + 2);
1824
+ // Header
1825
+ console.log(`┌${divComp}┬${divScen}┐`);
1826
+ console.log(`│ ${chalk.bold(pad('Component', maxCompLen))} │ ${chalk.bold(pad('Scenario', maxScenLen))} │`);
1827
+ console.log(`├${divComp}┼${divScen}┤`);
1828
+ // Rows
1829
+ let groupIndex = 0;
1830
+ for (const [comp, items] of groups) {
1831
+ if (groupIndex > 0) {
1832
+ console.log(`├${divComp}┼${divScen}┤`);
1833
+ }
1834
+ for (let i = 0; i < items.length; i++) {
1835
+ const s = items[i];
1836
+ const compCell = i === 0 ? chalk.bold(pad(comp, maxCompLen)) : pad('', maxCompLen);
1837
+ const display = stripPrefix(s.name, s.componentName);
1838
+ const linked = osc8(s.link, display);
1839
+ // linked has invisible escape chars; pad based on display length
1840
+ const scenPad = ' '.repeat(Math.max(0, maxScenLen - display.length));
1841
+ console.log(`│ ${compCell} │ ${linked}${scenPad} │`);
1842
+ }
1843
+ groupIndex++;
1844
+ }
1845
+ // Footer
1846
+ console.log(`└${divComp}┴${divScen}┘`);
1847
+ console.log();
1848
+ const total = scenarios.length;
1849
+ const groupCount = groups.size;
1850
+ console.log(chalk.dim(`${total} scenario${total !== 1 ? 's' : ''} across ${groupCount} component${groupCount !== 1 ? 's' : ''}`));
1851
+ console.log();
1852
+ }
1853
+ // ─── Template subcommand ─────────────────────────────────────────────
1854
+ async function handleTemplate() {
1855
+ const root = getProjectRoot();
1856
+ const port = getServerPort();
1857
+ if (hasProject(root)) {
1858
+ console.log(chalk.yellow('Project already exists (package.json found). Skipping.'));
1859
+ return;
1860
+ }
1861
+ const templateDir = path.join(__dirname, '..', '..', 'templates', 'nextjs-prisma-sqlite');
1862
+ if (!fs.existsSync(templateDir)) {
1863
+ console.error(chalk.red('Error: Template directory not found at ' + templateDir));
1864
+ process.exit(1);
1865
+ }
1866
+ const { execSync } = await import('child_process');
1867
+ // 1. Copy template files
1868
+ console.log(chalk.bold('Copying template files...'));
1869
+ execSync(`cp -r ${templateDir}/* .`, { cwd: root, stdio: 'inherit' });
1870
+ execSync(`cp ${templateDir}/.env .`, { cwd: root, stdio: 'inherit' });
1871
+ execSync(`cp ${templateDir}/gitignore .gitignore`, {
1872
+ cwd: root,
1873
+ stdio: 'inherit',
1874
+ });
1875
+ // Copy seed adapter into .codeyam/ (stored outside .codeyam/ in the template
1876
+ // to avoid gitignore issues — .codeyam/ is selectively ignored in user projects)
1877
+ const seedAdapterSrc = path.join(templateDir, 'seed-adapter.ts');
1878
+ if (fs.existsSync(seedAdapterSrc)) {
1879
+ const codeyamDir = path.join(root, '.codeyam');
1880
+ if (!fs.existsSync(codeyamDir)) {
1881
+ fs.mkdirSync(codeyamDir, { recursive: true });
1882
+ }
1883
+ fs.copyFileSync(seedAdapterSrc, path.join(codeyamDir, 'seed-adapter.ts'));
1884
+ }
1885
+ console.log(chalk.green(' Template files copied.'));
1886
+ // 2. Install dependencies
1887
+ console.log(chalk.bold('Installing dependencies...'));
1888
+ execSync('npm install', { cwd: root, stdio: 'inherit' });
1889
+ console.log(chalk.green(' Dependencies installed.'));
1890
+ // 3. Initialize git
1891
+ const hasGit = fs.existsSync(path.join(root, '.git'));
1892
+ if (!hasGit) {
1893
+ console.log(chalk.bold('Initializing git...'));
1894
+ execSync('git init && git add -A && git commit -m "Initial commit"', {
1895
+ cwd: root,
1896
+ stdio: 'inherit',
1897
+ });
1898
+ console.log(chalk.green(' Git initialized.'));
1899
+ }
1900
+ // 4. Run codeyam init
1901
+ console.log(chalk.bold('Running codeyam init...'));
1902
+ await initCommand.handler({
1903
+ force: true,
1904
+ 'keep-server': true,
1905
+ autoInit: false,
1906
+ $0: '',
1907
+ _: [],
1908
+ });
1909
+ console.log(chalk.green(' CodeYam initialized.'));
1910
+ // 5. Verify config has startCommand
1911
+ const configPath = path.join(root, '.codeyam', 'config.json');
1912
+ if (fs.existsSync(configPath)) {
1913
+ try {
1914
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
1915
+ const webapps = config.webapps || [];
1916
+ const hasStartCommand = webapps.some((w) => w.startCommand);
1917
+ if (!hasStartCommand) {
1918
+ console.log(chalk.yellow(' Warning: No startCommand found in .codeyam/config.json webapps.'));
1919
+ console.log(chalk.dim(' You may need to add: "startCommand": { "command": "sh", "args": ["-c", "npm run dev -- --port $PORT"] }'));
1920
+ }
1921
+ }
1922
+ catch {
1923
+ // Config parse error is non-fatal
1924
+ }
1925
+ }
1926
+ // 6. Trigger editor-refresh so the server picks up the new project
1927
+ console.log(chalk.bold('Refreshing editor...'));
1928
+ try {
1929
+ await fetch(`http://localhost:${port}/api/editor-refresh`, {
1930
+ method: 'POST',
1931
+ });
1932
+ console.log(chalk.green(' Editor refreshed.'));
1933
+ }
1934
+ catch {
1935
+ console.log(chalk.yellow(' Could not reach the CodeYam server for refresh. You may need to restart it.'));
1936
+ }
1937
+ console.log();
1938
+ console.log(chalk.green.bold('Project scaffolded and ready!'));
1939
+ console.log(chalk.dim('Next: Define your Prisma models, push the schema, seed the database, and build your feature.'));
1940
+ }
1941
+ // ─── Sync subcommand ─────────────────────────────────────────────────
1942
+ /**
1943
+ * `codeyam editor sync`
1944
+ * Import scenarios from scenarios-manifest.json into the local database.
1945
+ */
1946
+ async function handleSync() {
1947
+ const root = getProjectRoot();
1948
+ const manifest = readManifest(root);
1949
+ if (!manifest) {
1950
+ console.log(chalk.yellow('No scenarios-manifest.json found. Nothing to sync.'));
1951
+ return;
1952
+ }
1953
+ if (manifest.scenarios.length === 0) {
1954
+ console.log(chalk.dim('Manifest is empty. Nothing to sync.'));
1955
+ return;
1956
+ }
1957
+ const configPath = path.join(root, '.codeyam', 'config.json');
1958
+ let projectSlug = null;
1959
+ try {
1960
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
1961
+ projectSlug = config.projectSlug || null;
1962
+ }
1963
+ catch {
1964
+ // fall through
1965
+ }
1966
+ if (!projectSlug) {
1967
+ console.error(chalk.red('Error: No project slug found. Run codeyam init first.'));
1968
+ process.exit(1);
1969
+ }
1970
+ const connectionOk = await withoutSpinner(() => testEnvironment());
1971
+ if (!connectionOk) {
1972
+ errorLog('Environment validation failed');
1973
+ return;
1974
+ }
1975
+ const { project } = await requireBranchAndProject(projectSlug);
1976
+ const { getDatabase } = await import('../../../packages/database/index.js');
1977
+ const db = getDatabase();
1978
+ // Fetch existing editor scenarios
1979
+ const existingRows = await db
1980
+ .selectFrom('editor_scenarios')
1981
+ .select(['id', 'updated_at'])
1982
+ .where('project_id', '=', project.id)
1983
+ .execute();
1984
+ const result = await syncManifestToDatabase(root, project.id, existingRows, async (row) => {
1985
+ await db
1986
+ .insertInto('editor_scenarios')
1987
+ .values(row)
1988
+ .execute();
1989
+ }, async (id, row) => {
1990
+ await db
1991
+ .updateTable('editor_scenarios')
1992
+ .set(row)
1993
+ .where('id', '=', id)
1994
+ .execute();
1995
+ });
1996
+ if (result.inserted === 0 && result.updated === 0) {
1997
+ console.log(chalk.dim('All scenarios up to date.'));
1998
+ }
1999
+ else {
2000
+ const parts = [];
2001
+ if (result.inserted > 0)
2002
+ parts.push(`${result.inserted} imported`);
2003
+ if (result.updated > 0)
2004
+ parts.push(`${result.updated} updated`);
2005
+ if (result.skipped > 0)
2006
+ parts.push(`${result.skipped} unchanged`);
2007
+ console.log(chalk.green(`Synced scenarios: ${parts.join(', ')}`));
2008
+ }
2009
+ }
2010
+ // ─── Verify Images subcommand ─────────────────────────────────────────
2011
+ async function handleVerifyImages(jsonArg) {
2012
+ const port = getServerPort();
2013
+ const { parseVerifyImagesInput, extractImageUrls, resolveImageUrl, verifyImageUrls, buildVerifyImagesReport, extractImageUrlsFromScenarioFiles, } = await import('../utils/editorImageVerifier.js');
2014
+ let paths;
2015
+ let explicitImageUrls;
2016
+ try {
2017
+ const input = parseVerifyImagesInput(jsonArg);
2018
+ paths = input.paths;
2019
+ explicitImageUrls = input.imageUrls;
2020
+ }
2021
+ catch {
2022
+ console.error(chalk.red('Error: Invalid JSON argument'));
2023
+ process.exit(1);
2024
+ }
2025
+ // Get dev server URL
2026
+ let devServerUrl;
2027
+ try {
2028
+ const res = await fetch(`http://localhost:${port}/api/editor-dev-server`);
2029
+ const data = await res.json();
2030
+ devServerUrl = data.url || `http://localhost:${data.port || 3000}`;
2031
+ }
2032
+ catch {
2033
+ console.error(chalk.red('Error: Could not reach the CodeYam server. Is it running?'));
2034
+ process.exit(1);
2035
+ }
2036
+ const allUrls = new Set();
2037
+ let pagesChecked = 0;
2038
+ for (const pagePath of paths) {
2039
+ const pageUrl = `${devServerUrl}${pagePath}`;
2040
+ try {
2041
+ const res = await fetch(pageUrl);
2042
+ if (!res.ok) {
2043
+ console.error(chalk.red(` ✗ ${pagePath} — HTTP ${res.status}`));
2044
+ continue;
2045
+ }
2046
+ const html = await res.text();
2047
+ const imageUrls = extractImageUrls(html);
2048
+ for (const url of imageUrls) {
2049
+ allUrls.add(resolveImageUrl(url, devServerUrl));
2050
+ }
2051
+ pagesChecked++;
2052
+ }
2053
+ catch (err) {
2054
+ console.error(chalk.red(` ✗ ${pagePath} — ${err.message}`));
2055
+ }
2056
+ }
2057
+ // Add explicitly-provided image URLs (Claude passes these directly)
2058
+ for (const url of explicitImageUrls) {
2059
+ allUrls.add(resolveImageUrl(url, devServerUrl));
2060
+ }
2061
+ // Also scan scenario mock data files for image URLs (client-rendered pages)
2062
+ const scenariosDir = path.join(getProjectRoot(), '.codeyam', 'editor-scenarios');
2063
+ const { urls: scenarioUrls, filesScanned: scenarioFilesScanned } = extractImageUrlsFromScenarioFiles(scenariosDir);
2064
+ for (const url of scenarioUrls) {
2065
+ allUrls.add(resolveImageUrl(url, devServerUrl));
2066
+ }
2067
+ const urlList = [...allUrls];
2068
+ const results = urlList.length > 0 ? await verifyImageUrls(urlList) : [];
2069
+ const report = buildVerifyImagesReport({
2070
+ pagesChecked,
2071
+ imageUrls: urlList,
2072
+ results,
2073
+ scenarioFilesScanned,
2074
+ });
2075
+ console.log(JSON.stringify(report, null, 2));
2076
+ if (report.failures.length > 0) {
2077
+ process.exit(1);
2078
+ }
2079
+ }
2080
+ // ─── Debug subcommand ────────────────────────────────────────────────
2081
+ function handleEditorDebug(args) {
2082
+ const root = getProjectRoot();
2083
+ const feature = args.feature || 'Sample Feature';
2084
+ const includeContext = args.includeContext !== false;
2085
+ let targets;
2086
+ try {
2087
+ targets = parseDebugTargets(args.target);
2088
+ }
2089
+ catch (err) {
2090
+ const msg = err instanceof Error ? err.message : String(err);
2091
+ console.error(chalk.red(`Error: ${msg}`));
2092
+ process.exit(1);
2093
+ }
2094
+ const includeResume = typeof args.resume === 'boolean' ? args.resume : true;
2095
+ const includeNormal = typeof args.resume === 'boolean' ? !args.resume : true;
2096
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
2097
+ const outputDir = args.output
2098
+ ? path.resolve(args.output)
2099
+ : path.join(root, '.codeyam', 'logs', 'editor-debug', timestamp);
2100
+ fs.mkdirSync(outputDir, { recursive: true });
2101
+ const contextEntries = includeContext
2102
+ ? writeContextSnapshot(root, outputDir)
2103
+ : [];
2104
+ const scenarios = [];
2105
+ const wants = (id) => (targets ? targets.has(id) : true);
2106
+ if (wants('setup')) {
2107
+ scenarios.push({
2108
+ id: 'setup',
2109
+ title: 'Setup (no project)',
2110
+ render: () => withTempRoot(false, (tempRoot) => captureOutput(() => printSetup(tempRoot))),
2111
+ });
2112
+ }
2113
+ if (wants('overview')) {
2114
+ scenarios.push({
2115
+ id: 'overview',
2116
+ title: 'Cycle overview (project, no state)',
2117
+ render: () => withTempRoot(true, (tempRoot) => captureOutput(() => printCycleOverview(tempRoot, null))),
2118
+ });
2119
+ }
2120
+ if (wants('overview-with-state')) {
2121
+ scenarios.push({
2122
+ id: 'overview-with-state',
2123
+ title: 'Cycle overview (project, with state)',
2124
+ render: () => withTempRoot(true, (tempRoot) => captureOutput(() => printCycleOverview(tempRoot, makeState(4, feature)))),
2125
+ });
2126
+ }
2127
+ const stepFns = {
2128
+ 1: (r, f) => printStep1(r, f),
2129
+ 2: printStep2,
2130
+ 3: printStep3,
2131
+ 4: printStep4,
2132
+ 5: printStep5,
2133
+ 6: printStep6,
2134
+ 7: printStep7,
2135
+ 8: printStep8,
2136
+ 9: printStep9,
2137
+ 10: printStep10,
2138
+ 11: printStep11,
2139
+ 12: printStep12,
2140
+ 13: printStep13,
2141
+ };
2142
+ for (let step = 1; step <= 13; step++) {
2143
+ const stepId = `step-${step}`;
2144
+ if (!wants(stepId))
2145
+ continue;
2146
+ if (includeNormal) {
2147
+ scenarios.push({
2148
+ id: stepId,
2149
+ title: `Step ${step} (${STEP_LABELS[step]})`,
2150
+ render: () => withTempRoot(true, (tempRoot) => captureOutput(() => stepFns[step](tempRoot, feature))),
2151
+ });
2152
+ if (step === 1 && !args.feature) {
2153
+ scenarios.push({
2154
+ id: 'step-1-no-feature',
2155
+ title: 'Step 1 (Plan) — no feature provided',
2156
+ render: () => withTempRoot(true, (tempRoot) => captureOutput(() => printStep1(tempRoot, undefined))),
2157
+ });
2158
+ }
2159
+ if (step === 2) {
2160
+ scenarios.push({
2161
+ id: 'step-2-scaffold',
2162
+ title: 'Step 2 (Prototype) — scaffold flow (no project)',
2163
+ render: () => withTempRoot(false, (tempRoot) => captureOutput(() => printStep2(tempRoot, feature))),
2164
+ });
2165
+ }
2166
+ }
2167
+ if (includeResume) {
2168
+ scenarios.push({
2169
+ id: `${stepId}-resume`,
2170
+ title: `Step ${step} (${STEP_LABELS[step]}) — resuming`,
2171
+ render: () => withTempRoot(true, (tempRoot) => {
2172
+ writeState(tempRoot, makeState(step, feature));
2173
+ return captureOutput(() => stepFns[step](tempRoot, feature));
2174
+ }),
2175
+ });
2176
+ }
2177
+ }
2178
+ const indexLines = [
2179
+ '# CodeYam Editor Debug Bundle',
2180
+ '',
2181
+ `Generated: ${new Date().toISOString()}`,
2182
+ `Feature: "${feature}"`,
2183
+ `Resume variants: ${includeResume ? 'included' : 'skipped'}`,
2184
+ 'Note: Output files preserve ANSI color codes (as printed to the terminal).',
2185
+ '',
2186
+ ];
2187
+ if (includeContext) {
2188
+ indexLines.push('## Context snapshot');
2189
+ if (contextEntries.length === 0) {
2190
+ indexLines.push('- (none)');
2191
+ }
2192
+ else {
2193
+ for (const entry of contextEntries) {
2194
+ const source = entry.source ? ` ← ${entry.source}` : '';
2195
+ indexLines.push(`- ${entry.label}: ${entry.file} (${entry.status})${source}`);
2196
+ }
2197
+ }
2198
+ indexLines.push('');
2199
+ }
2200
+ indexLines.push('## Scenarios');
2201
+ for (const scenario of scenarios) {
2202
+ const fileName = `${scenario.id}.txt`;
2203
+ const output = scenario.render();
2204
+ fs.writeFileSync(path.join(outputDir, fileName), output, 'utf8');
2205
+ indexLines.push(`- ${scenario.title}: ${fileName}`);
2206
+ }
2207
+ fs.writeFileSync(path.join(outputDir, 'index.md'), indexLines.join('\n'), 'utf8');
2208
+ console.log();
2209
+ console.log(chalk.bold.cyan('━━━ Editor Debug Bundle ━━━'));
2210
+ console.log();
2211
+ console.log(chalk.green('Wrote debug bundle to: ') + chalk.bold(outputDir));
2212
+ console.log(chalk.dim(' Open index.md for the full list of scenario outputs.'));
2213
+ console.log();
2214
+ }
2215
+ // ─── Command definition ───────────────────────────────────────────────
2216
+ const editorCommand = {
2217
+ command: 'editor [step] [json]',
2218
+ describe: 'Editor mode guided workflow',
2219
+ builder: (yargs) => {
2220
+ const stepDescription = IS_INTERNAL_BUILD
2221
+ ? 'Step number (1-13) or subcommand (template, register, isolate, analyze-imports, dependents, audit, scenarios, change, sync, debug, preview, show-results, hide-results, commit, journal, journal-list, journal-update, dev-server, client-errors)'
2222
+ : 'Step number (1-13) or subcommand (template, register, isolate, analyze-imports, dependents, audit, scenarios, change, sync, preview, show-results, hide-results, commit, journal, journal-list, journal-update, dev-server, client-errors)';
2223
+ let builder = yargs
2224
+ .positional('step', {
2225
+ type: 'string',
2226
+ describe: stepDescription,
2227
+ })
2228
+ .positional('json', {
2229
+ type: 'string',
2230
+ describe: 'JSON argument for register subcommand',
2231
+ })
2232
+ .option('feature', {
2233
+ type: 'string',
2234
+ describe: 'Feature name (required for step 2)',
2235
+ })
2236
+ .option('prompt', {
2237
+ type: 'string',
2238
+ describe: "User's original prompt (captured for journal/results)",
2239
+ })
2240
+ .option('port', {
2241
+ type: 'number',
2242
+ alias: 'p',
2243
+ describe: 'Port to run the web server on',
2244
+ default: 3111,
2245
+ });
2246
+ if (IS_INTERNAL_BUILD) {
2247
+ builder = builder
2248
+ .option('target', {
2249
+ type: 'string',
2250
+ describe: 'Debug target (setup, overview, overview-with-state, step-1..step-13, or comma-separated list)',
2251
+ })
2252
+ .option('resume', {
2253
+ type: 'boolean',
2254
+ describe: 'Debug: only render resume variants (use --no-resume for only normal)',
2255
+ })
2256
+ .option('include-context', {
2257
+ type: 'boolean',
2258
+ default: true,
2259
+ describe: 'Debug: include CLAUDE.md, skill, and editor-mode-context snapshots',
2260
+ })
2261
+ .option('output', {
2262
+ type: 'string',
2263
+ describe: 'Debug: output directory for the bundle',
2264
+ });
2265
+ }
2266
+ return builder;
2267
+ },
2268
+ handler: async (argv) => {
2269
+ const root = getProjectRoot();
2270
+ // API subcommands: preview, show-results, hide-results, commit,
2271
+ // journal, journal-update, dev-server, client-errors
2272
+ if (argv.step && EDITOR_API_SUBCOMMANDS.includes(argv.step)) {
2273
+ const port = getServerPort();
2274
+ try {
2275
+ const request = buildEditorApiRequest(argv.step, argv.json || undefined);
2276
+ const result = await callEditorApi(request, port);
2277
+ if (!result.ok) {
2278
+ console.error(chalk.red(`Error: ${request.endpoint} returned ${result.status}`));
2279
+ if (result.data)
2280
+ console.error(JSON.stringify(result.data, null, 2));
2281
+ process.exit(1);
2282
+ }
2283
+ if (result.data != null) {
2284
+ const summary = formatApiSubcommandResult(argv.step, result.data);
2285
+ if (summary) {
2286
+ console.log(summary);
2287
+ }
2288
+ else {
2289
+ console.log(JSON.stringify(result.data, null, 2));
2290
+ }
2291
+ }
2292
+ }
2293
+ catch (err) {
2294
+ console.error(chalk.red('Error: Could not reach the CodeYam server. Is it running?'));
2295
+ console.error(chalk.dim(` ${err.message}`));
2296
+ process.exit(1);
2297
+ }
2298
+ return;
2299
+ }
2300
+ // Subcommand: codeyam editor register '{"name":"..."}'
2301
+ if (argv.step === 'register') {
2302
+ await handleRegister(argv.json || '');
2303
+ return;
2304
+ }
2305
+ // Subcommand: codeyam editor analyze-imports
2306
+ if (argv.step === 'analyze-imports') {
2307
+ await handleAnalyzeImports();
2308
+ return;
2309
+ }
2310
+ // Subcommand: codeyam editor dependents <EntityName>
2311
+ if (argv.step === 'dependents') {
2312
+ await handleDependents(argv.json || '');
2313
+ return;
2314
+ }
2315
+ // Subcommand: codeyam editor audit
2316
+ if (argv.step === 'audit') {
2317
+ await handleAudit();
2318
+ return;
2319
+ }
2320
+ // Subcommand: codeyam editor scenarios
2321
+ if (argv.step === 'scenarios') {
2322
+ await handleScenarios();
2323
+ return;
2324
+ }
2325
+ // Subcommand: codeyam editor change <feature>
2326
+ if (argv.step === 'change') {
2327
+ handleChange(argv.json || '');
2328
+ return;
2329
+ }
2330
+ // Subcommand: codeyam editor verify-images '{"paths":["/","/drinks/1"]}'
2331
+ if (argv.step === 'verify-images') {
2332
+ await handleVerifyImages(argv.json || '');
2333
+ return;
2334
+ }
2335
+ // Subcommand: codeyam editor validate-seed '{"products":[...]}'
2336
+ if (argv.step === 'validate-seed') {
2337
+ await handleValidateSeed(argv.json || '');
2338
+ return;
2339
+ }
2340
+ // Subcommand: codeyam editor isolate StarRating CategoryBadge DrinkCard
2341
+ if (argv.step === 'isolate') {
2342
+ const names = [];
2343
+ if (argv.json)
2344
+ names.push(...argv.json.split(/[\s,]+/).filter(Boolean));
2345
+ // Collect any extra positional args (yargs puts them in argv._)
2346
+ const extras = argv._.filter((a) => typeof a === 'string' && a !== 'editor');
2347
+ names.push(...extras);
2348
+ handleIsolate(names);
2349
+ return;
2350
+ }
2351
+ // Subcommand: codeyam editor template — scaffold project from template
2352
+ if (argv.step === 'template') {
2353
+ await handleTemplate();
2354
+ return;
2355
+ }
2356
+ // Subcommand: codeyam editor sync — import scenarios from manifest
2357
+ if (argv.step === 'sync') {
2358
+ await handleSync();
2359
+ return;
2360
+ }
2361
+ // Subcommand: codeyam editor debug [--target ...]
2362
+ if (argv.step === 'debug') {
2363
+ if (!IS_INTERNAL_BUILD) {
2364
+ console.error(chalk.red('Error: "codeyam editor debug" is internal-only.'));
2365
+ process.exit(1);
2366
+ }
2367
+ await handleEditorDebug(argv);
2368
+ return;
2369
+ }
2370
+ // Subcommand: codeyam editor steps — show setup or cycle overview
2371
+ if (argv.step === 'steps') {
2372
+ if (!hasProject(root)) {
2373
+ printSetup(root);
2374
+ }
2375
+ else {
2376
+ const state = readState(root);
2377
+ // Clear prompt file when feature is done (step 13) so the hook
2378
+ // can capture the next feature request from the user.
2379
+ if (state?.step === 13) {
2380
+ clearEditorUserPrompt(root);
2381
+ }
2382
+ printCycleOverview(root, state);
2383
+ }
2384
+ return;
2385
+ }
2386
+ const step = argv.step ? parseInt(argv.step, 10) : undefined;
2387
+ if (step != null && (isNaN(step) || step < 1 || step > 13)) {
2388
+ console.error(chalk.red(`Error: Invalid step "${argv.step}". Must be 1-13.`));
2389
+ process.exit(1);
2390
+ }
2391
+ if (step == null) {
2392
+ // No step specified: launch editor server + open browser
2393
+ // Auto-init if needed
2394
+ let projectRoot = getStateProjectRoot();
2395
+ if (!projectRoot) {
2396
+ await initCommand.handler({
2397
+ force: false,
2398
+ autoInit: true,
2399
+ $0: '',
2400
+ _: [],
2401
+ });
2402
+ projectRoot = getStateProjectRoot();
2403
+ if (!projectRoot) {
2404
+ return;
2405
+ }
2406
+ }
2407
+ const configPath = path.join(projectRoot, '.codeyam', 'config.json');
2408
+ try {
2409
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
2410
+ const { projectSlug } = config;
2411
+ if (!projectSlug) {
2412
+ errorLog('Missing project slug. Try reinitializing with: codeyam init --force');
2413
+ return;
2414
+ }
2415
+ const connectionOk = await withoutSpinner(() => testEnvironment());
2416
+ if (!connectionOk) {
2417
+ errorLog('Environment validation failed');
2418
+ return;
2419
+ }
2420
+ const { project, branch } = await requireBranchAndProject(projectSlug);
2421
+ // Auto-sync scenarios from manifest if it exists
2422
+ const manifestData = readManifest(projectRoot);
2423
+ if (manifestData && manifestData.scenarios.length > 0) {
2424
+ try {
2425
+ const { getDatabase } = await import('../../../packages/database/index.js');
2426
+ const db = getDatabase();
2427
+ const existingRows = await db
2428
+ .selectFrom('editor_scenarios')
2429
+ .select(['id', 'updated_at'])
2430
+ .where('project_id', '=', project.id)
2431
+ .execute();
2432
+ const syncResult = await syncManifestToDatabase(projectRoot, project.id, existingRows, async (row) => {
2433
+ await db
2434
+ .insertInto('editor_scenarios')
2435
+ .values(row)
2436
+ .execute();
2437
+ }, async (id, row) => {
2438
+ await db
2439
+ .updateTable('editor_scenarios')
2440
+ .set(row)
2441
+ .where('id', '=', id)
2442
+ .execute();
2443
+ });
2444
+ if (syncResult.inserted > 0 || syncResult.updated > 0) {
2445
+ const parts = [];
2446
+ if (syncResult.inserted > 0)
2447
+ parts.push(`${syncResult.inserted} imported`);
2448
+ if (syncResult.updated > 0)
2449
+ parts.push(`${syncResult.updated} updated`);
2450
+ console.log(chalk.green(` Synced scenarios from manifest: ${parts.join(', ')}`));
2451
+ }
2452
+ }
2453
+ catch {
2454
+ // Non-fatal — sync failure shouldn't block editor startup
2455
+ }
2456
+ }
2457
+ // `codeyam editor` (no step) always implies editor mode.
2458
+ // The empty-folder heuristic is no longer needed here — running this
2459
+ // command IS the signal. We still detect empty folders so that
2460
+ // the very first `codeyam editor` in a bare directory works before
2461
+ // metadata has been persisted.
2462
+ const editorMode = true;
2463
+ if (editorMode && !project.metadata?.labs?.simulations) {
2464
+ try {
2465
+ await updateProjectMetadata({
2466
+ projectSlug,
2467
+ metadataUpdate: {
2468
+ editorMode: true,
2469
+ labs: { simulations: true },
2470
+ },
2471
+ });
2472
+ const refreshed = await requireBranchAndProject(projectSlug);
2473
+ Object.assign(project, refreshed.project);
2474
+ }
2475
+ catch {
2476
+ // Non-fatal
2477
+ }
2478
+ }
2479
+ // Install skills/hooks
2480
+ const simulationsEnabled = project.metadata?.labs?.simulations ?? false;
2481
+ const skillMode = simulationsEnabled
2482
+ ? 'full'
2483
+ : editorMode
2484
+ ? 'editor'
2485
+ : 'memory';
2486
+ await installClaudeCodeSkills(projectRoot, {
2487
+ mode: skillMode,
2488
+ editorMode,
2489
+ });
2490
+ setupClaudeCodeSettings(projectRoot, {
2491
+ mode: skillMode,
2492
+ editorMode,
2493
+ });
2494
+ // Auto-finalize analyzer so codeyam analyze works
2495
+ if (editorMode && !isAnalyzerFinalized()) {
2496
+ try {
2497
+ const { execSync } = await import('child_process');
2498
+ const templatePath = getAnalyzerTemplatePath();
2499
+ if (fs.existsSync(templatePath)) {
2500
+ console.log(' Setting up simulations (first time only)...');
2501
+ execSync('npm install --include=dev', {
2502
+ cwd: templatePath,
2503
+ stdio: 'pipe',
2504
+ });
2505
+ execSync('npx playwright install chromium', {
2506
+ cwd: templatePath,
2507
+ stdio: 'pipe',
2508
+ });
2509
+ execSync('npm run build', {
2510
+ cwd: templatePath,
2511
+ stdio: 'pipe',
2512
+ });
2513
+ fs.writeFileSync(path.join(templatePath, '.finalized'), new Date().toISOString());
2514
+ }
2515
+ }
2516
+ catch {
2517
+ // Non-fatal
2518
+ }
2519
+ }
2520
+ // Start background server
2521
+ const { url } = await startBackgroundServer({
2522
+ port: argv.port || 3111,
2523
+ rootPath: projectRoot,
2524
+ project,
2525
+ branch,
2526
+ });
2527
+ console.log();
2528
+ console.log(` Dashboard: ${url}`);
2529
+ console.log(' Run "codeyam --help" for all commands');
2530
+ console.log(chalk.bold(' Run "codeyam editor" to launch the editor at any time'));
2531
+ console.log();
2532
+ // Open browser to /editor
2533
+ try {
2534
+ const { execSync } = await import('child_process');
2535
+ const openCommand = process.platform === 'darwin'
2536
+ ? 'open'
2537
+ : process.platform === 'win32'
2538
+ ? 'start ""'
2539
+ : 'xdg-open';
2540
+ execSync(`${openCommand} "${url}/editor"`, { stdio: 'ignore' });
2541
+ }
2542
+ catch {
2543
+ // Silently fail if open command doesn't work
2544
+ }
2545
+ }
2546
+ catch (err) {
2547
+ errorLog('Failed to start CodeYam editor server');
2548
+ errorLog(err);
2549
+ process.exit(1);
2550
+ }
2551
+ return;
2552
+ }
2553
+ const state = readState(root);
2554
+ switch (step) {
2555
+ case 1: {
2556
+ const feature = argv.feature || undefined;
2557
+ const prompt = argv.prompt || undefined;
2558
+ printStep1(root, feature, prompt);
2559
+ break;
2560
+ }
2561
+ case 2: {
2562
+ const feature = argv.feature || state?.feature;
2563
+ if (!feature) {
2564
+ console.error(chalk.red('Error: --feature "Feature Name" is required for step 2.'));
2565
+ console.error(chalk.dim(' Usage: codeyam editor 2 --feature "Drink Rating System"'));
2566
+ process.exit(1);
2567
+ }
2568
+ printStep2(root, feature);
2569
+ break;
2570
+ }
2571
+ case 3:
2572
+ case 4:
2573
+ case 5:
2574
+ case 6:
2575
+ case 7:
2576
+ case 8:
2577
+ case 9:
2578
+ case 10:
2579
+ case 11:
2580
+ case 12:
2581
+ case 13: {
2582
+ const feature = argv.feature || state?.feature;
2583
+ if (!feature) {
2584
+ console.error(chalk.red('Error: No feature in progress. Run codeyam editor 1 first.'));
2585
+ process.exit(1);
2586
+ }
2587
+ const stepFns = {
2588
+ 3: printStep3,
2589
+ 4: printStep4,
2590
+ 5: printStep5,
2591
+ 6: printStep6,
2592
+ 7: printStep7,
2593
+ 8: printStep8,
2594
+ 9: printStep9,
2595
+ 10: printStep10,
2596
+ 11: printStep11,
2597
+ 12: printStep12,
2598
+ 13: printStep13,
2599
+ };
2600
+ stepFns[step](root, feature);
2601
+ break;
2602
+ }
2603
+ }
2604
+ },
2605
+ };
2606
+ export default editorCommand;
2607
+ //# sourceMappingURL=editor.js.map