@codeyam/codeyam-cli 0.1.0-staging.a890816 → 0.1.0-staging.aa28063
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.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +12 -12
- package/analyzer-template/packages/ai/package.json +2 -2
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +135 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/nodeToSource.ts +19 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/paths.ts +11 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +36 -9
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.ts +10 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +16 -6
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +0 -33
- package/analyzer-template/packages/analyze/index.ts +4 -1
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +13 -7
- package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +28 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +5 -36
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +10 -6
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +9 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts +21 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +82 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +4 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +4 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyzeNextRoute.ts +8 -3
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +239 -58
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +0 -98
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1684 -1462
- package/analyzer-template/packages/aws/package.json +7 -7
- package/analyzer-template/packages/database/package.json +4 -4
- package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +102 -0
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +25 -15
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +0 -6
- package/analyzer-template/packages/database/src/lib/loadEntity.ts +19 -8
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +0 -65
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +104 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +7 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +0 -6
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts +4 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js +5 -5
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +0 -25
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js +2 -0
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/types/src/enums/ProjectFramework.ts +2 -0
- package/analyzer-template/packages/ui-components/package.json +1 -1
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js +2 -0
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts +3 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +22 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +27 -0
- package/analyzer-template/project/analyzeFileEntities.ts +26 -0
- package/analyzer-template/project/runMultiScenarioServer.ts +26 -3
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +22 -0
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js +23 -3
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
- package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
- package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
- package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
- package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
- package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
- package/codeyam-cli/src/cli.js +24 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js +47 -0
- package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js +71 -0
- package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.designSystem.test.js +30 -0
- package/codeyam-cli/src/commands/__tests__/editor.designSystem.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js +51 -0
- package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.statePersistence.test.js +55 -0
- package/codeyam-cli/src/commands/__tests__/editor.statePersistence.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +56 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +137 -47
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +3 -46
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/editor.js +5802 -526
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js +23 -0
- package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js.map +1 -0
- package/codeyam-cli/src/commands/editorIsolateArgs.js +25 -0
- package/codeyam-cli/src/commands/editorIsolateArgs.js.map +1 -0
- package/codeyam-cli/src/commands/init.js +95 -35
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/telemetry.js +37 -0
- package/codeyam-cli/src/commands/telemetry.js.map +1 -0
- package/codeyam-cli/src/data/designSystems.js +27 -0
- package/codeyam-cli/src/data/designSystems.js.map +1 -0
- package/codeyam-cli/src/data/techStacks.js +77 -0
- package/codeyam-cli/src/data/techStacks.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +173 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js +46 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js +134 -0
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js +181 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +4160 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js +76 -0
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
- package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js +137 -0
- package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js +100 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +304 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +194 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +381 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js +67 -0
- package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
- package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +542 -0
- package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +594 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js +435 -0
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorMockState.test.js +270 -0
- package/codeyam-cli/src/utils/__tests__/editorMockState.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +217 -0
- package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +361 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +250 -0
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js +1108 -0
- package/codeyam-cli/src/utils/__tests__/editorRoadmap.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +411 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +1768 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +413 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js +143 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js +66 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js +53 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +2121 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/envFile.test.js +125 -0
- package/codeyam-cli/src/utils/__tests__/envFile.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/git.editor.test.js +134 -0
- package/codeyam-cli/src/utils/__tests__/git.editor.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js +177 -0
- package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/handoffContext.test.js +500 -0
- package/codeyam-cli/src/utils/__tests__/handoffContext.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +122 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js +302 -0
- package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +129 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/project.test.js +65 -0
- package/codeyam-cli/src/utils/__tests__/project.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js +127 -0
- package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js +118 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +284 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js +121 -0
- package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +672 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js +84 -0
- package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +26 -5
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/telemetry.test.js +159 -0
- package/codeyam-cli/src/utils/__tests__/telemetry.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +51 -0
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/testRunner.test.js +216 -0
- package/codeyam-cli/src/utils/__tests__/testRunner.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +148 -0
- package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -0
- package/codeyam-cli/src/utils/analysisRunner.js +39 -8
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +19 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js +100 -0
- package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
- package/codeyam-cli/src/utils/backgroundServer.js +95 -19
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/buildFlags.js +4 -0
- package/codeyam-cli/src/utils/buildFlags.js.map +1 -0
- package/codeyam-cli/src/utils/database.js +37 -2
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/designSystemShowcase.js +810 -0
- package/codeyam-cli/src/utils/designSystemShowcase.js.map +1 -0
- package/codeyam-cli/src/utils/devServerState.js +71 -0
- package/codeyam-cli/src/utils/devServerState.js.map +1 -0
- package/codeyam-cli/src/utils/editorApi.js +95 -0
- package/codeyam-cli/src/utils/editorApi.js.map +1 -0
- package/codeyam-cli/src/utils/editorAudit.js +849 -0
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -0
- package/codeyam-cli/src/utils/editorBroadcastViewport.js +26 -0
- package/codeyam-cli/src/utils/editorBroadcastViewport.js.map +1 -0
- package/codeyam-cli/src/utils/editorCapture.js +102 -0
- package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js +67 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js.map +1 -0
- package/codeyam-cli/src/utils/editorDevServer.js +197 -0
- package/codeyam-cli/src/utils/editorDevServer.js.map +1 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js +50 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/editorEntityHelpers.js +144 -0
- package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorGuard.js +36 -0
- package/codeyam-cli/src/utils/editorGuard.js.map +1 -0
- package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
- package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
- package/codeyam-cli/src/utils/editorJournal.js +225 -0
- package/codeyam-cli/src/utils/editorJournal.js.map +1 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js +152 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorMigration.js +224 -0
- package/codeyam-cli/src/utils/editorMigration.js.map +1 -0
- package/codeyam-cli/src/utils/editorMockState.js +248 -0
- package/codeyam-cli/src/utils/editorMockState.js.map +1 -0
- package/codeyam-cli/src/utils/editorPreloadHelpers.js +135 -0
- package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorPreview.js +139 -0
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -0
- package/codeyam-cli/src/utils/editorRecapture.js +109 -0
- package/codeyam-cli/src/utils/editorRecapture.js.map +1 -0
- package/codeyam-cli/src/utils/editorRoadmap.js +574 -0
- package/codeyam-cli/src/utils/editorRoadmap.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js +149 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarios.js +687 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js +475 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
- package/codeyam-cli/src/utils/editorShouldRevalidate.js +21 -0
- package/codeyam-cli/src/utils/editorShouldRevalidate.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js +394 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +227 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
- package/codeyam-cli/src/utils/envFile.js +90 -0
- package/codeyam-cli/src/utils/envFile.js.map +1 -0
- package/codeyam-cli/src/utils/fileWatcher.js +38 -0
- package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +51 -0
- package/codeyam-cli/src/utils/git.js.map +1 -1
- package/codeyam-cli/src/utils/glossaryAdd.js +74 -0
- package/codeyam-cli/src/utils/glossaryAdd.js.map +1 -0
- package/codeyam-cli/src/utils/handoffContext.js +257 -0
- package/codeyam-cli/src/utils/handoffContext.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +78 -23
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/manualEntityAnalysis.js +196 -0
- package/codeyam-cli/src/utils/manualEntityAnalysis.js.map +1 -0
- package/codeyam-cli/src/utils/parseRegisterArg.js +31 -0
- package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +2 -2
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/project.js +15 -5
- package/codeyam-cli/src/utils/project.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js +159 -0
- package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js.map +1 -0
- package/codeyam-cli/src/utils/queue/job.js +35 -6
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/registerScenarioResult.js +52 -0
- package/codeyam-cli/src/utils/registerScenarioResult.js.map +1 -0
- package/codeyam-cli/src/utils/routePatternMatching.js +129 -0
- package/codeyam-cli/src/utils/routePatternMatching.js.map +1 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js +77 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
- package/codeyam-cli/src/utils/scenarioMarkers.js +134 -0
- package/codeyam-cli/src/utils/scenarioMarkers.js.map +1 -0
- package/codeyam-cli/src/utils/scenariosManifest.js +313 -0
- package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
- package/codeyam-cli/src/utils/screenshotHash.js +26 -0
- package/codeyam-cli/src/utils/screenshotHash.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +30 -0
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +47 -16
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js +17 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/slugUtils.js +25 -0
- package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
- package/codeyam-cli/src/utils/syncMocksMiddleware.js +2 -2
- package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/techStackConfig.js +38 -0
- package/codeyam-cli/src/utils/techStackConfig.js.map +1 -0
- package/codeyam-cli/src/utils/techStackConfig.test.js +85 -0
- package/codeyam-cli/src/utils/techStackConfig.test.js.map +1 -0
- package/codeyam-cli/src/utils/telemetry.js +106 -0
- package/codeyam-cli/src/utils/telemetry.js.map +1 -0
- package/codeyam-cli/src/utils/telemetryMiddleware.js +22 -0
- package/codeyam-cli/src/utils/telemetryMiddleware.js.map +1 -0
- package/codeyam-cli/src/utils/testResultCache.js +53 -0
- package/codeyam-cli/src/utils/testResultCache.js.map +1 -0
- package/codeyam-cli/src/utils/testResultCache.server.js +81 -0
- package/codeyam-cli/src/utils/testResultCache.server.js.map +1 -0
- package/codeyam-cli/src/utils/testResultCache.server.test.js +187 -0
- package/codeyam-cli/src/utils/testResultCache.server.test.js.map +1 -0
- package/codeyam-cli/src/utils/testResultCache.test.js +230 -0
- package/codeyam-cli/src/utils/testResultCache.test.js.map +1 -0
- package/codeyam-cli/src/utils/testRunner.js +194 -2
- package/codeyam-cli/src/utils/testRunner.js.map +1 -1
- package/codeyam-cli/src/utils/webappDetection.js +25 -2
- package/codeyam-cli/src/utils/webappDetection.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js +99 -0
- package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js +129 -0
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +107 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +762 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +315 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js +135 -0
- package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js +86 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/git.js +397 -0
- package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
- package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js +34 -0
- package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js.map +1 -0
- package/codeyam-cli/src/webserver/app/types/editor.js +8 -0
- package/codeyam-cli/src/webserver/app/types/editor.js.map +1 -0
- package/codeyam-cli/src/webserver/backgroundServer.js +60 -61
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-DTBZZfSk.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-C76mRRiF.js → EntityItem-BxclONWq.js} +5 -5
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CQgyEGV-.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CobE682z.js → EntityTypeIcon-BsnEOJZ_.js} +9 -9
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-ByaELMbv.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-6WjVfhxX.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-ChX-Hp7W.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-BU_OAEMP.js → LoadingDots-By5zI316.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-ceAyBX-H.js → LogViewer-C-9zQdXg.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/MiniClaudeChat-Bs2_Oua4.js +36 -0
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-djPLI-WV.js → ReportIssueModal-DQsceHVv.js} +4 -4
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DThcm_9M.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-B76aig_2.js → ScenarioViewer-Cl4oOA3A.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-CIil5-gb.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CK7-NaPZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-BqkA9zyZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{_index-C96V0n15.js → _index-DnOgyseQ.js} +4 -4
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BpKzcsJz.js → activity.(_tab)-DqM9hbNE.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
- package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-Duc5hnl7.js → addon-web-links-C58dYPwR.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
- package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-D9hemwl6.js → agent-transcripts-B8NCeOrm.js} +7 -7
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-audit-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-database-verify-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-github-verify-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-handoff-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-hosting-verify-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-load-commit-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-recapture-stale-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-rename-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-roadmap-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-scenario-data-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-seed-state-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-prompt-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-schema-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-verify-routes-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.interactive-switch-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{book-open-D_nMCFmP.js → book-open-BFSIqZgO.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BH2h1Ea2.js → chevron-down-B9fDzFVh.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/chunk-UVKPFVEO-Bmq2apuh.js +43 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-DyIKORY6.js → circle-check-DLPObLUx.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{copy-NDbZjXao.js → copy-DXEmO0TD.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BwyFiRot.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-Coe5NhbS.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-CCKUIm0S.svg → cy-logo-cli-DoA97ML3.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-iRhRIFlp.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor._tab-BZPBzV73.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DOXe0Qx7.js +161 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-C6fEYHrh.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CrjR3zZW.js → entity._sha._-pc-vc6wO.js} +14 -13
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-C8AyYgYT.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DziaVQX1.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-BTcpgIpC.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMvVHNXU.js → entity._sha_.edit._scenarioId-D_O_ajfZ.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DTvKq3TY.js → entry.client-j1Vi0bco.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-Daa96Fr1.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-kuny2Q_s.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-DgCZPMie.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-L-aUIeux.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-BcvgDzbZ.js → index-BliGSSpl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/index-SqjQKTdH.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-10oVnAAH.js → index-vyrZD2g4.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-c3yLxSEp.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-BAXYRVEO.js → loader-circle-D-q28GLF.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/manifest-30c44d84.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CEWIUC4t.js +101 -0
- package/codeyam-cli/src/webserver/build/client/assets/{pause-DTAcYxBt.js → pause-BP6fitdh.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/root-CLedrjXQ.js +80 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-fKo7v0Zo.js → search-BooqacKS.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/settings-BM0nbryO.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-ovy6FjRY.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{terminal-BG4heKCG.js → terminal-DHemCJIs.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-DtSmdtM4.js → triangle-alert-D87ekDl8.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-Dk0Tciqg.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-C8QvIe05.js +2 -0
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-jkCytuYz.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useToast-BgqkixU9.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/xterm-BqvuqXEL.js +27 -0
- package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-CuR5TvUx.js +16 -0
- package/codeyam-cli/src/webserver/build/server/assets/index-D4MWAsqb.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/init-JObA4lXD.js +14 -0
- package/codeyam-cli/src/webserver/build/server/assets/progress-CHTtrxFG.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-i8OXK4oL.js +765 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/editorProxy.js +881 -52
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
- package/codeyam-cli/src/webserver/idleDetector.js +130 -0
- package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js +28 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js.map +1 -0
- package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +414 -0
- package/codeyam-cli/src/webserver/scripts/journalCapture.ts +147 -4
- package/codeyam-cli/src/webserver/server.js +281 -12
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +433 -157
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
- package/codeyam-cli/templates/__tests__/editor-step-hook.prompt-capture.test.ts +118 -0
- package/codeyam-cli/templates/chrome-extension-react/EXTENSION_SETUP.md +75 -0
- package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
- package/codeyam-cli/templates/chrome-extension-react/gitignore +15 -0
- package/codeyam-cli/templates/chrome-extension-react/index.html +12 -0
- package/codeyam-cli/templates/chrome-extension-react/package.json +27 -0
- package/codeyam-cli/templates/chrome-extension-react/popup.html +12 -0
- package/codeyam-cli/templates/chrome-extension-react/public/manifest.json +15 -0
- package/codeyam-cli/templates/chrome-extension-react/src/background/service-worker.ts +7 -0
- package/codeyam-cli/templates/chrome-extension-react/src/globals.css +6 -0
- package/codeyam-cli/templates/chrome-extension-react/src/lib/storage.ts +37 -0
- package/codeyam-cli/templates/chrome-extension-react/src/popup/App.tsx +12 -0
- package/codeyam-cli/templates/chrome-extension-react/src/popup/main.tsx +10 -0
- package/codeyam-cli/templates/chrome-extension-react/tsconfig.json +24 -0
- package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +41 -0
- package/codeyam-cli/templates/codeyam-editor-claude.md +86 -5
- package/codeyam-cli/templates/codeyam-editor-codex.md +61 -0
- package/codeyam-cli/templates/codeyam-editor-gemini.md +59 -0
- package/codeyam-cli/templates/codeyam-editor-reference.md +216 -0
- package/codeyam-cli/templates/design-systems/clean-dashboard-design-system.md +255 -0
- package/codeyam-cli/templates/design-systems/editorial-design-system.md +267 -0
- package/codeyam-cli/templates/design-systems/mono-brutalist-design-system.md +256 -0
- package/codeyam-cli/templates/design-systems/neo-brutalist-design-system.md +294 -0
- package/codeyam-cli/templates/editor-step-hook.py +262 -39
- package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +288 -0
- package/codeyam-cli/templates/expo-react-native/README.md +41 -0
- package/codeyam-cli/templates/expo-react-native/__tests__/.gitkeep +0 -0
- package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +15 -0
- package/codeyam-cli/templates/expo-react-native/app/index.tsx +36 -0
- package/codeyam-cli/templates/expo-react-native/app.json +29 -0
- package/codeyam-cli/templates/expo-react-native/babel.config.js +10 -0
- package/codeyam-cli/templates/expo-react-native/gitignore +14 -0
- package/codeyam-cli/templates/expo-react-native/global.css +10 -0
- package/codeyam-cli/templates/expo-react-native/lib/storage.ts +32 -0
- package/codeyam-cli/templates/expo-react-native/lib/theme.ts +73 -0
- package/codeyam-cli/templates/expo-react-native/metro.config.js +6 -0
- package/codeyam-cli/templates/expo-react-native/nativewind-env.d.ts +1 -0
- package/codeyam-cli/templates/expo-react-native/package.json +54 -0
- package/codeyam-cli/templates/expo-react-native/patches/expo-modules-autolinking+3.0.24.patch +29 -0
- package/codeyam-cli/templates/expo-react-native/tailwind.config.js +10 -0
- package/codeyam-cli/templates/expo-react-native/tsconfig.json +10 -0
- package/codeyam-cli/templates/isolation-route/expo-router.tsx.template +54 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_PATTERNS.md +308 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_UPGRADE.md +304 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +126 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/FEATURE_PATTERNS.md +37 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +9 -4
- package/codeyam-cli/templates/nextjs-prisma-sqlite/env +4 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +22 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +6 -2
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +4 -1
- package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +140 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
- package/codeyam-cli/templates/{nextjs-prisma-sqlite/PRISMA_SETUP.md → nextjs-prisma-supabase/SUPABASE_SETUP.md} +37 -17
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/api/todos/route.ts +17 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/globals.css +26 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/layout.tsx +34 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/prisma.ts +20 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/supabase.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/page.tsx +10 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/env +9 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/eslint.config.mjs +11 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/gitignore +40 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/next.config.ts +11 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +37 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/postcss.config.mjs +7 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/schema.prisma +27 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/seed.ts +39 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma.config.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/tsconfig.json +34 -0
- package/codeyam-cli/templates/seed-adapters/supabase.ts +475 -0
- package/codeyam-cli/templates/{codeyam-dev-mode.md → skills/codeyam-dev-mode/SKILL.md} +3 -3
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +244 -0
- package/codeyam-cli/templates/{codeyam-memory.md → skills/codeyam-memory/SKILL.md} +215 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/deprecated-prompt.md +100 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/misleading-api-prompt.md +117 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/analyze-prompt.md +46 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
- package/package.json +16 -10
- package/packages/ai/src/lib/astScopes/methodSemantics.js +99 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/nodeToSource.js +16 -0
- package/packages/ai/src/lib/astScopes/nodeToSource.js.map +1 -1
- package/packages/ai/src/lib/astScopes/paths.js +12 -3
- package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +27 -10
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js +9 -2
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +14 -4
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +0 -11
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/index.js +1 -1
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +10 -4
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/asts/index.js +4 -2
- package/packages/analyze/src/lib/asts/index.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +16 -2
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +6 -26
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +3 -2
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +9 -7
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +14 -0
- package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +44 -11
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +1 -0
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +1 -0
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeNextRoute.js +5 -1
- package/packages/analyze/src/lib/files/analyzeNextRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +120 -28
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +0 -40
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +1368 -1193
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +104 -0
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +7 -1
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +0 -6
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntity.js +5 -5
- package/packages/database/src/lib/loadEntity.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +0 -25
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/types/src/enums/ProjectFramework.js +2 -0
- package/packages/types/src/enums/ProjectFramework.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +22 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/scripts/npm-post-install.cjs +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-DmJveP3T.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-g3saevPb.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DYFW3lDD.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DLeucoVX.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BED4B6sP.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +0 -34
- package/codeyam-cli/src/webserver/build/client/assets/Terminal-CcG8YTLx.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-C8OKAR5x.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/addon-fit-CUXOrorO.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-C4pqxYJB.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CMT1jU2q.js +0 -21
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BiM6z3Do.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-W_IGJ2Kd.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-D6SEzMCu.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-C28BiQzt.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-cPo8LiG3.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-DO4CZ16O.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-CFCTYk9I.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/globals-BZB_H1w2.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-Zk7ryIM1.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-8daa4147.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-FweZHj5U.js +0 -93
- package/codeyam-cli/src/webserver/build/client/assets/root-DiRdBreB.js +0 -67
- package/codeyam-cli/src/webserver/build/client/assets/settings-DfuTtcJP.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-B3aOzpCZ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-ByhSyh0W.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-C14nCb1q.js +0 -2
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-O-jkvSPx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useToast-9FIWuYfK.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/xterm-DMSzMhqy.js +0 -9
- package/codeyam-cli/src/webserver/build/server/assets/index-BzAbACSx.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-OdUocH6P.js +0 -362
- package/codeyam-cli/templates/codeyam-editor.md +0 -68
- package/scripts/finalize-analyzer.cjs +0 -13
- /package/codeyam-cli/templates/{codeyam-diagnose.md → commands/codeyam-diagnose.md} +0 -0
- /package/codeyam-cli/templates/{codeyam-debug.md → skills/codeyam-debug/SKILL.md} +0 -0
- /package/codeyam-cli/templates/{codeyam-new-rule.md → skills/codeyam-new-rule/SKILL.md} +0 -0
- /package/codeyam-cli/templates/{codeyam-setup.md → skills/codeyam-setup/SKILL.md} +0 -0
- /package/codeyam-cli/templates/{codeyam-sim.md → skills/codeyam-sim/SKILL.md} +0 -0
- /package/codeyam-cli/templates/{codeyam-test.md → skills/codeyam-test/SKILL.md} +0 -0
- /package/codeyam-cli/templates/{codeyam-verify.md → skills/codeyam-verify/SKILL.md} +0 -0
|
@@ -3,16 +3,204 @@ import net from 'net';
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { getProjectRoot } from "../state.js";
|
|
6
|
+
import { createMockStateManager, } from "../utils/editorMockState.js";
|
|
7
|
+
import { computeEditorPorts } from "../utils/editorDevServer.js";
|
|
8
|
+
import { mockStateEventEmitter } from "./mockStateEvents.js";
|
|
9
|
+
/**
|
|
10
|
+
* Normalize a target URL by stripping trailing slashes for consistency.
|
|
11
|
+
*
|
|
12
|
+
* Previously this also replaced `localhost` with `127.0.0.1`, but that broke
|
|
13
|
+
* forwarding to dev servers that bind to IPv6 only (e.g. Vite 6 on macOS
|
|
14
|
+
* binds to `[::1]`). The hostname is now left as-is — `resolveLoopbackAddress`
|
|
15
|
+
* probes the actual target at startup to pick the right address.
|
|
16
|
+
*/
|
|
17
|
+
export function normalizeTargetUrl(url) {
|
|
18
|
+
try {
|
|
19
|
+
const parsed = new URL(url);
|
|
20
|
+
return parsed.toString().replace(/\/$/, '');
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return url;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Probe a localhost port to determine the correct loopback address.
|
|
28
|
+
* Dev servers may bind to IPv4 (127.0.0.1), IPv6 (::1), or both.
|
|
29
|
+
* Returns the first address that accepts a TCP connection.
|
|
30
|
+
*/
|
|
31
|
+
export async function resolveLoopbackAddress(port) {
|
|
32
|
+
const candidates = ['127.0.0.1', '::1'];
|
|
33
|
+
for (const host of candidates) {
|
|
34
|
+
try {
|
|
35
|
+
const connected = await new Promise((resolve) => {
|
|
36
|
+
const socket = new net.Socket();
|
|
37
|
+
socket.setTimeout(1000);
|
|
38
|
+
socket.once('connect', () => {
|
|
39
|
+
socket.destroy();
|
|
40
|
+
resolve(true);
|
|
41
|
+
});
|
|
42
|
+
socket.once('error', () => {
|
|
43
|
+
socket.destroy();
|
|
44
|
+
resolve(false);
|
|
45
|
+
});
|
|
46
|
+
socket.once('timeout', () => {
|
|
47
|
+
socket.destroy();
|
|
48
|
+
resolve(false);
|
|
49
|
+
});
|
|
50
|
+
socket.connect(port, host);
|
|
51
|
+
});
|
|
52
|
+
if (connected) {
|
|
53
|
+
return host;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Try next candidate
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
6
62
|
// Global key so the proxy survives HMR
|
|
7
63
|
const GLOBAL_KEY = '__codeyam_editor_proxy__';
|
|
64
|
+
// ─── Live Preview Health ─────────────────────────────────────────────
|
|
65
|
+
const PREVIEW_HEALTH_KEY = '__codeyam_preview_health__';
|
|
66
|
+
function getPreviewHealth() {
|
|
67
|
+
return globalThis[PREVIEW_HEALTH_KEY] ?? null;
|
|
68
|
+
}
|
|
69
|
+
function setPreviewHealth(report) {
|
|
70
|
+
globalThis[PREVIEW_HEALTH_KEY] = report;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the current live preview health report (read by API endpoint).
|
|
74
|
+
*/
|
|
75
|
+
export function getPreviewHealthReport() {
|
|
76
|
+
return getPreviewHealth();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Reset preview health state (called when a new HTML page is served).
|
|
80
|
+
*/
|
|
81
|
+
export function resetPreviewHealth() {
|
|
82
|
+
setPreviewHealth(null);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Error-catching script injected into HTML responses.
|
|
86
|
+
* Uses vanilla JS for maximum compatibility.
|
|
87
|
+
*/
|
|
88
|
+
export const PREVIEW_HEALTH_SCRIPT = `<script data-codeyam-health>
|
|
89
|
+
(function() {
|
|
90
|
+
var errors = [];
|
|
91
|
+
var reported = false;
|
|
92
|
+
function report(type, msg, stack) {
|
|
93
|
+
errors.push({ type: type, message: msg, stack: stack, timestamp: Date.now() });
|
|
94
|
+
if (!reported) {
|
|
95
|
+
reported = true;
|
|
96
|
+
setTimeout(function() { flush(); }, 500);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function flush() {
|
|
100
|
+
fetch('/__codeyam__/preview-health', {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: { 'Content-Type': 'application/json' },
|
|
103
|
+
body: JSON.stringify({ errors: errors, url: location.href })
|
|
104
|
+
}).catch(function(){});
|
|
105
|
+
reported = false;
|
|
106
|
+
errors = [];
|
|
107
|
+
}
|
|
108
|
+
window.addEventListener('error', function(e) {
|
|
109
|
+
report('error', e.message, e.error && e.error.stack);
|
|
110
|
+
});
|
|
111
|
+
window.addEventListener('unhandledrejection', function(e) {
|
|
112
|
+
report('unhandledrejection', String(e.reason), e.reason && e.reason.stack);
|
|
113
|
+
});
|
|
114
|
+
var origError = console.error;
|
|
115
|
+
console.error = function() {
|
|
116
|
+
report('console.error', Array.prototype.join.call(arguments, ' '));
|
|
117
|
+
origError.apply(console, arguments);
|
|
118
|
+
};
|
|
119
|
+
window.addEventListener('load', function() {
|
|
120
|
+
setTimeout(function() {
|
|
121
|
+
var hasContent = document.body && document.body.innerText.trim().length > 0;
|
|
122
|
+
fetch('/__codeyam__/preview-health', {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
headers: { 'Content-Type': 'application/json' },
|
|
125
|
+
body: JSON.stringify({
|
|
126
|
+
loaded: true,
|
|
127
|
+
hasContent: hasContent,
|
|
128
|
+
url: location.href,
|
|
129
|
+
errorCount: errors.length
|
|
130
|
+
})
|
|
131
|
+
}).catch(function(){});
|
|
132
|
+
}, 1000);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Network-idle detection: notify the parent editor when all initial
|
|
136
|
+
// fetch requests have completed, so it can show the preview after
|
|
137
|
+
// client-side data (API calls) has arrived — not just when the DOM loads.
|
|
138
|
+
var inflight = 0;
|
|
139
|
+
var settled = false;
|
|
140
|
+
var settleTimer = null;
|
|
141
|
+
var origFetch = window.fetch;
|
|
142
|
+
window.fetch = function() {
|
|
143
|
+
if (!settled) inflight++;
|
|
144
|
+
return origFetch.apply(this, arguments).then(function(resp) {
|
|
145
|
+
if (!settled) { inflight--; checkSettle(); }
|
|
146
|
+
return resp;
|
|
147
|
+
}, function(err) {
|
|
148
|
+
if (!settled) { inflight--; checkSettle(); }
|
|
149
|
+
throw err;
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
function checkSettle() {
|
|
153
|
+
if (inflight <= 0 && !settled) {
|
|
154
|
+
clearTimeout(settleTimer);
|
|
155
|
+
// Small delay to allow React to re-render with the fetched data
|
|
156
|
+
settleTimer = setTimeout(function() {
|
|
157
|
+
if (inflight <= 0) {
|
|
158
|
+
settled = true;
|
|
159
|
+
try {
|
|
160
|
+
window.parent.postMessage({ type: 'codeyam-preview-ready' }, '*');
|
|
161
|
+
} catch(e) {}
|
|
162
|
+
}
|
|
163
|
+
}, 100);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Fallback: if no fetches happen (static page), settle after load
|
|
167
|
+
window.addEventListener('load', function() {
|
|
168
|
+
setTimeout(function() { checkSettle(); }, 200);
|
|
169
|
+
});
|
|
170
|
+
})();
|
|
171
|
+
</script>`;
|
|
8
172
|
const CACHE_TTL_MS = 500;
|
|
9
173
|
let scenarioCache = { data: null, timestamp: 0 };
|
|
174
|
+
// Session config extracted from the active scenario — drives cookie injection
|
|
175
|
+
let sessionConfig = undefined;
|
|
176
|
+
/** Session cookies from the seed adapter (e.g. Supabase auth tokens). */
|
|
177
|
+
let seedSessionCookies = undefined;
|
|
178
|
+
// localStorage config extracted from the active scenario — drives HTML injection
|
|
179
|
+
let localStorageConfig = null;
|
|
180
|
+
// Active scenario ID — used to gate localStorage seeding (only re-seed on switch)
|
|
181
|
+
let activeScenarioId = null;
|
|
182
|
+
// Prototype ID — used to gate a one-time localStorage.clear() when a new project is scaffolded
|
|
183
|
+
let currentPrototypeId = null;
|
|
184
|
+
// Current scenario type — 'application'/'user' for seed-based, 'component' for mock-based
|
|
185
|
+
let currentScenarioType = null;
|
|
186
|
+
// Max body size to buffer for mock matching (10MB)
|
|
187
|
+
const MAX_BODY_SIZE = 10 * 1024 * 1024;
|
|
10
188
|
function getProxyState() {
|
|
11
189
|
return globalThis[GLOBAL_KEY] ?? null;
|
|
12
190
|
}
|
|
13
191
|
function setProxyState(state) {
|
|
14
192
|
globalThis[GLOBAL_KEY] = state;
|
|
15
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Get or create the mock state manager (survives HMR via globalThis).
|
|
196
|
+
*/
|
|
197
|
+
function getMockStateManager() {
|
|
198
|
+
const key = '__codeyam_mock_state__';
|
|
199
|
+
if (!globalThis[key]) {
|
|
200
|
+
globalThis[key] = createMockStateManager();
|
|
201
|
+
}
|
|
202
|
+
return globalThis[key];
|
|
203
|
+
}
|
|
16
204
|
/**
|
|
17
205
|
* Get the proxy URL if the proxy is running.
|
|
18
206
|
*/
|
|
@@ -24,6 +212,13 @@ export function getProxyUrl() {
|
|
|
24
212
|
}
|
|
25
213
|
/**
|
|
26
214
|
* Read the active scenario's mock data from disk, with brief caching.
|
|
215
|
+
* Feeds the data into the MockStateManager.
|
|
216
|
+
*
|
|
217
|
+
* For application/user scenarios (type-aware): only loads `externalApis`
|
|
218
|
+
* into the mock state manager. All DB-backed routes flow through to the
|
|
219
|
+
* real app (database is seeded with real data).
|
|
220
|
+
*
|
|
221
|
+
* For component scenarios (or legacy): loads all routes as before.
|
|
27
222
|
*/
|
|
28
223
|
function readScenarioData() {
|
|
29
224
|
const now = Date.now();
|
|
@@ -41,6 +236,8 @@ function readScenarioData() {
|
|
|
41
236
|
const active = JSON.parse(fs.readFileSync(activeScenarioPath, 'utf-8'));
|
|
42
237
|
const scenarioId = active.scenarioId;
|
|
43
238
|
if (!scenarioId) {
|
|
239
|
+
// No active scenario — but may have a prototypeId for localStorage clearing
|
|
240
|
+
currentPrototypeId = active.prototypeId || null;
|
|
44
241
|
scenarioCache = { data: null, timestamp: now };
|
|
45
242
|
return null;
|
|
46
243
|
}
|
|
@@ -50,9 +247,37 @@ function readScenarioData() {
|
|
|
50
247
|
scenarioCache = { data: null, timestamp: now };
|
|
51
248
|
return null;
|
|
52
249
|
}
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
250
|
+
const rawData = JSON.parse(fs.readFileSync(dataFilePath, 'utf-8'));
|
|
251
|
+
// Extract session config for cookie injection
|
|
252
|
+
sessionConfig = rawData.session || null;
|
|
253
|
+
// Extract seed adapter session cookies (e.g. Supabase auth)
|
|
254
|
+
seedSessionCookies = rawData.sessionCookies || undefined;
|
|
255
|
+
// Extract localStorage config for HTML injection
|
|
256
|
+
localStorageConfig = rawData.localStorage || null;
|
|
257
|
+
activeScenarioId = scenarioId;
|
|
258
|
+
// Type-aware: for seed-based scenarios, only serve externalApis via proxy
|
|
259
|
+
const scenarioType = active.type || rawData.type || null;
|
|
260
|
+
currentScenarioType = scenarioType;
|
|
261
|
+
let mockData;
|
|
262
|
+
if ((scenarioType === 'application' || scenarioType === 'user') &&
|
|
263
|
+
rawData.seed) {
|
|
264
|
+
// Seed-based scenario: only load externalApis as routes for the proxy
|
|
265
|
+
if (rawData.externalApis && typeof rawData.externalApis === 'object') {
|
|
266
|
+
mockData = { routes: rawData.externalApis };
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// No external APIs — proxy passes everything through
|
|
270
|
+
mockData = {};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// Component/legacy scenario: load all data
|
|
275
|
+
mockData = rawData;
|
|
276
|
+
}
|
|
277
|
+
scenarioCache = { data: mockData, timestamp: now };
|
|
278
|
+
// Feed into mock state manager (smart reload handles dedup)
|
|
279
|
+
getMockStateManager().loadScenario(mockData);
|
|
280
|
+
return mockData;
|
|
56
281
|
}
|
|
57
282
|
catch (err) {
|
|
58
283
|
console.warn('[editorProxy] Error reading scenario data:', err);
|
|
@@ -61,50 +286,177 @@ function readScenarioData() {
|
|
|
61
286
|
}
|
|
62
287
|
}
|
|
63
288
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
289
|
+
* Buffer the request body, up to MAX_BODY_SIZE.
|
|
290
|
+
* Returns null if the body exceeds the limit.
|
|
291
|
+
*/
|
|
292
|
+
function bufferRequestBody(req) {
|
|
293
|
+
return new Promise((resolve) => {
|
|
294
|
+
const chunks = [];
|
|
295
|
+
let totalSize = 0;
|
|
296
|
+
req.on('data', (chunk) => {
|
|
297
|
+
totalSize += chunk.length;
|
|
298
|
+
if (totalSize > MAX_BODY_SIZE) {
|
|
299
|
+
resolve(null); // Too large — skip mock matching
|
|
300
|
+
req.resume(); // Drain remaining
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
chunks.push(chunk);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
req.on('end', () => {
|
|
307
|
+
if (totalSize > MAX_BODY_SIZE)
|
|
308
|
+
return; // Already resolved
|
|
309
|
+
resolve(Buffer.concat(chunks));
|
|
310
|
+
});
|
|
311
|
+
req.on('error', () => {
|
|
312
|
+
resolve(null);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Strip IPv6 bracket notation for use with http.request hostname.
|
|
318
|
+
* URL.hostname returns `[::1]` for IPv6 but http.request needs `::1`.
|
|
319
|
+
*/
|
|
320
|
+
function stripIPv6Brackets(hostname) {
|
|
321
|
+
if (hostname.startsWith('[') && hostname.endsWith(']')) {
|
|
322
|
+
return hostname.slice(1, -1);
|
|
323
|
+
}
|
|
324
|
+
return hostname;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Forward a buffered request to the target dev server.
|
|
328
|
+
* Unlike the streaming forwardRequest, this replays a buffered body.
|
|
329
|
+
*/
|
|
330
|
+
function forwardBufferedRequest(req, res, targetUrl, bodyBuffer) {
|
|
331
|
+
const target = new URL(targetUrl);
|
|
332
|
+
const hostname = stripIPv6Brackets(target.hostname);
|
|
333
|
+
const headers = { ...req.headers, host: `${target.hostname}:${target.port}` };
|
|
334
|
+
// Remove accept-encoding so the dev server returns uncompressed responses.
|
|
335
|
+
// The proxy injects a health script into HTML — this fails on compressed bodies.
|
|
336
|
+
delete headers['accept-encoding'];
|
|
337
|
+
// Inject session cookies into the request so the dev server sees auth
|
|
338
|
+
// on the first request after a scenario switch (before the browser has
|
|
339
|
+
// stored them from Set-Cookie responses).
|
|
340
|
+
injectRequestCookies(headers);
|
|
341
|
+
// Update content-length if we have the body buffer
|
|
342
|
+
if (bodyBuffer) {
|
|
343
|
+
headers['content-length'] = String(bodyBuffer.length);
|
|
82
344
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
345
|
+
const options = {
|
|
346
|
+
hostname,
|
|
347
|
+
port: target.port,
|
|
348
|
+
path: req.url,
|
|
349
|
+
method: req.method,
|
|
350
|
+
headers,
|
|
351
|
+
};
|
|
352
|
+
const proxyReq = http.request(options, (proxyRes) => {
|
|
353
|
+
const status = proxyRes.statusCode || 200;
|
|
354
|
+
if (status >= 300 && status < 400) {
|
|
355
|
+
console.log(`[editorProxy] Target redirect ${status} for ${req.method} ${req.url} → ${proxyRes.headers.location}`);
|
|
356
|
+
}
|
|
357
|
+
if (status >= 400) {
|
|
358
|
+
console.warn(`[editorProxy] Target returned ${status} for ${req.method} ${req.url}`);
|
|
90
359
|
}
|
|
360
|
+
const headers = { ...proxyRes.headers };
|
|
361
|
+
injectSessionCookie(headers);
|
|
362
|
+
// Check if response is HTML — if so, buffer and inject health script
|
|
363
|
+
const contentType = proxyRes.headers['content-type'] || '';
|
|
364
|
+
if (contentType.includes('text/html')) {
|
|
365
|
+
resetPreviewHealth();
|
|
366
|
+
const chunks = [];
|
|
367
|
+
proxyRes.on('data', (chunk) => chunks.push(chunk));
|
|
368
|
+
proxyRes.on('end', () => {
|
|
369
|
+
const body = Buffer.concat(chunks).toString('utf-8');
|
|
370
|
+
const lsScript = buildLocalStorageScript(localStorageConfig, activeScenarioId || '', currentPrototypeId);
|
|
371
|
+
const injected = injectHealthScript(body, lsScript);
|
|
372
|
+
delete headers['content-length'];
|
|
373
|
+
delete headers['content-encoding'];
|
|
374
|
+
// Prevent browser from caching HTML responses — scenario switches
|
|
375
|
+
// serve different content from the same URL (seed data changes the
|
|
376
|
+
// rendered page but the proxy URL stays the same).
|
|
377
|
+
headers['cache-control'] = 'no-store, must-revalidate';
|
|
378
|
+
res.writeHead(status, headers);
|
|
379
|
+
res.end(injected);
|
|
380
|
+
});
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
res.writeHead(status, headers);
|
|
384
|
+
proxyRes.pipe(res, { end: true });
|
|
385
|
+
});
|
|
386
|
+
proxyReq.on('error', (err) => {
|
|
387
|
+
console.warn(`[editorProxy] Forward error for ${req.method} ${req.url}: ${err.message}`);
|
|
388
|
+
if (!res.headersSent) {
|
|
389
|
+
res.writeHead(502, { 'Content-Type': 'text/plain' });
|
|
390
|
+
res.end('Bad Gateway — dev server unreachable');
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
if (bodyBuffer && bodyBuffer.length > 0) {
|
|
394
|
+
proxyReq.end(bodyBuffer);
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
proxyReq.end();
|
|
91
398
|
}
|
|
92
|
-
return null;
|
|
93
399
|
}
|
|
94
400
|
/**
|
|
95
401
|
* Forward an HTTP request to the target dev server.
|
|
402
|
+
* For HTML responses: buffers body to inject health-check script.
|
|
403
|
+
* For non-HTML responses: pipes directly (no buffering).
|
|
96
404
|
*/
|
|
97
405
|
function forwardRequest(req, res, targetUrl) {
|
|
98
406
|
const target = new URL(targetUrl);
|
|
407
|
+
const hostname = stripIPv6Brackets(target.hostname);
|
|
408
|
+
// Build headers, stripping accept-encoding so the dev server returns uncompressed
|
|
409
|
+
// responses. The proxy injects a health script into HTML — this fails on compressed bodies.
|
|
410
|
+
const { 'accept-encoding': _ae, ...forwardHeaders } = req.headers;
|
|
411
|
+
const reqHeaders = {
|
|
412
|
+
...forwardHeaders,
|
|
413
|
+
host: `${target.hostname}:${target.port}`,
|
|
414
|
+
};
|
|
415
|
+
// Inject session cookies into the request so the dev server sees auth
|
|
416
|
+
// on the first request after a scenario switch.
|
|
417
|
+
injectRequestCookies(reqHeaders);
|
|
99
418
|
const options = {
|
|
100
|
-
hostname
|
|
419
|
+
hostname,
|
|
101
420
|
port: target.port,
|
|
102
421
|
path: req.url,
|
|
103
422
|
method: req.method,
|
|
104
|
-
headers:
|
|
423
|
+
headers: reqHeaders,
|
|
105
424
|
};
|
|
106
425
|
const proxyReq = http.request(options, (proxyRes) => {
|
|
107
|
-
|
|
426
|
+
const status = proxyRes.statusCode || 200;
|
|
427
|
+
if (status >= 300 && status < 400) {
|
|
428
|
+
console.log(`[editorProxy] Target redirect ${status} for ${req.method} ${req.url} → ${proxyRes.headers.location}`);
|
|
429
|
+
}
|
|
430
|
+
if (status >= 400) {
|
|
431
|
+
console.warn(`[editorProxy] Target returned ${status} for ${req.method} ${req.url}`);
|
|
432
|
+
}
|
|
433
|
+
const headers = { ...proxyRes.headers };
|
|
434
|
+
injectSessionCookie(headers);
|
|
435
|
+
// Check if response is HTML — if so, buffer and inject health script
|
|
436
|
+
const contentType = proxyRes.headers['content-type'] || '';
|
|
437
|
+
if (contentType.includes('text/html')) {
|
|
438
|
+
// Reset health state for new page loads
|
|
439
|
+
resetPreviewHealth();
|
|
440
|
+
const chunks = [];
|
|
441
|
+
proxyRes.on('data', (chunk) => chunks.push(chunk));
|
|
442
|
+
proxyRes.on('end', () => {
|
|
443
|
+
const body = Buffer.concat(chunks).toString('utf-8');
|
|
444
|
+
const lsScript = buildLocalStorageScript(localStorageConfig, activeScenarioId || '', currentPrototypeId);
|
|
445
|
+
const injected = injectHealthScript(body, lsScript);
|
|
446
|
+
// Remove content-length since body size changed; use chunked transfer
|
|
447
|
+
delete headers['content-length'];
|
|
448
|
+
// Remove content-encoding since we're serving uncompressed
|
|
449
|
+
delete headers['content-encoding'];
|
|
450
|
+
// Prevent browser from caching HTML responses — scenario switches
|
|
451
|
+
// serve different content from the same URL (seed data changes the
|
|
452
|
+
// rendered page but the proxy URL stays the same).
|
|
453
|
+
headers['cache-control'] = 'no-store, must-revalidate';
|
|
454
|
+
res.writeHead(status, headers);
|
|
455
|
+
res.end(injected);
|
|
456
|
+
});
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
res.writeHead(status, headers);
|
|
108
460
|
proxyRes.pipe(res, { end: true });
|
|
109
461
|
});
|
|
110
462
|
proxyReq.on('error', (err) => {
|
|
@@ -116,14 +468,326 @@ function forwardRequest(req, res, targetUrl) {
|
|
|
116
468
|
});
|
|
117
469
|
req.pipe(proxyReq, { end: true });
|
|
118
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Inject or clear the session-token cookie on proxied responses.
|
|
473
|
+
* When a scenario has session.cookieValue, sets the cookie to auto-log the user in.
|
|
474
|
+
* When a scenario has no session field (null), clears any existing session cookie.
|
|
475
|
+
* When sessionConfig is undefined (no scenario loaded yet), does nothing.
|
|
476
|
+
*/
|
|
477
|
+
function injectSessionCookie(headers) {
|
|
478
|
+
const cookies = [];
|
|
479
|
+
// Dev auth cookie (built-in session-token)
|
|
480
|
+
if (sessionConfig !== undefined) {
|
|
481
|
+
if (sessionConfig?.cookieValue) {
|
|
482
|
+
cookies.push(`session-token=${sessionConfig.cookieValue}; Path=/; SameSite=Lax`);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
cookies.push(`session-token=; Path=/; Max-Age=0`);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
// Seed adapter session cookies (e.g. Supabase auth tokens)
|
|
489
|
+
if (seedSessionCookies && seedSessionCookies.length > 0) {
|
|
490
|
+
for (const sc of seedSessionCookies) {
|
|
491
|
+
const cookiePath = sc.path || '/';
|
|
492
|
+
const sameSite = sc.sameSite || 'Lax';
|
|
493
|
+
cookies.push(`${sc.name}=${sc.value}; Path=${cookiePath}; SameSite=${sameSite}`);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (cookies.length === 0)
|
|
497
|
+
return;
|
|
498
|
+
const existing = headers['set-cookie'];
|
|
499
|
+
if (existing) {
|
|
500
|
+
headers['set-cookie'] = [
|
|
501
|
+
...(Array.isArray(existing) ? existing : [existing]),
|
|
502
|
+
...cookies,
|
|
503
|
+
];
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
headers['set-cookie'] = cookies;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Get session cookies that should be injected into requests forwarded to the
|
|
511
|
+
* dev server. Returns an array of {name, value} pairs, or null if no session
|
|
512
|
+
* cookies are configured.
|
|
513
|
+
*
|
|
514
|
+
* This is the counterpart to `injectSessionCookie()` (which adds Set-Cookie
|
|
515
|
+
* to responses). Without request-side injection, the first request after a
|
|
516
|
+
* scenario switch has no cookies — the dev server's auth middleware sees no
|
|
517
|
+
* session and redirects to the login page before the browser ever receives
|
|
518
|
+
* the Set-Cookie response.
|
|
519
|
+
*/
|
|
520
|
+
export function getRequestCookieInjection() {
|
|
521
|
+
const cookies = [];
|
|
522
|
+
if (sessionConfig?.cookieValue) {
|
|
523
|
+
cookies.push({ name: 'session-token', value: sessionConfig.cookieValue });
|
|
524
|
+
}
|
|
525
|
+
if (seedSessionCookies && seedSessionCookies.length > 0) {
|
|
526
|
+
for (const sc of seedSessionCookies) {
|
|
527
|
+
cookies.push({ name: sc.name, value: sc.value });
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return cookies.length > 0 ? cookies : null;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Inject session cookies into the request's Cookie header before forwarding
|
|
534
|
+
* to the dev server. This ensures the dev server sees auth cookies on the
|
|
535
|
+
* very first request after a scenario switch (before the browser has stored
|
|
536
|
+
* them from Set-Cookie responses).
|
|
537
|
+
*/
|
|
538
|
+
function injectRequestCookies(headers) {
|
|
539
|
+
const injection = getRequestCookieInjection();
|
|
540
|
+
if (!injection)
|
|
541
|
+
return;
|
|
542
|
+
// Parse existing cookies from the request
|
|
543
|
+
const existing = typeof headers.cookie === 'string' ? headers.cookie : '';
|
|
544
|
+
const existingPairs = existing
|
|
545
|
+
? existing.split(';').map((s) => s.trim())
|
|
546
|
+
: [];
|
|
547
|
+
// Build a map of existing cookies for deduplication
|
|
548
|
+
const cookieMap = new Map();
|
|
549
|
+
for (const pair of existingPairs) {
|
|
550
|
+
const eqIdx = pair.indexOf('=');
|
|
551
|
+
if (eqIdx !== -1) {
|
|
552
|
+
cookieMap.set(pair.slice(0, eqIdx), pair.slice(eqIdx + 1));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
// Override with injected cookies
|
|
556
|
+
for (const { name, value } of injection) {
|
|
557
|
+
cookieMap.set(name, value);
|
|
558
|
+
}
|
|
559
|
+
// Reassemble
|
|
560
|
+
const parts = [];
|
|
561
|
+
for (const [k, v] of cookieMap) {
|
|
562
|
+
parts.push(`${k}=${v}`);
|
|
563
|
+
}
|
|
564
|
+
if (parts.length > 0) {
|
|
565
|
+
headers.cookie = parts.join('; ');
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Get the current session config (for testing).
|
|
570
|
+
*/
|
|
571
|
+
export function getSessionConfig() {
|
|
572
|
+
return sessionConfig;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Get the current localStorage config (for testing and script generation).
|
|
576
|
+
*/
|
|
577
|
+
export function getLocalStorageConfig() {
|
|
578
|
+
return localStorageConfig;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Get the active scenario ID (for testing and script generation).
|
|
582
|
+
*/
|
|
583
|
+
export function getActiveScenarioId() {
|
|
584
|
+
return activeScenarioId;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Get the current prototype ID (for testing).
|
|
588
|
+
*/
|
|
589
|
+
export function getCurrentPrototypeId() {
|
|
590
|
+
return currentPrototypeId;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Simple djb2 hash — fast, deterministic, good enough for cache busting.
|
|
594
|
+
* Not cryptographic — just detects when localStorage config content changes.
|
|
595
|
+
*/
|
|
596
|
+
function simpleHash(str) {
|
|
597
|
+
let hash = 5381;
|
|
598
|
+
for (let i = 0; i < str.length; i++) {
|
|
599
|
+
hash = ((hash << 5) + hash + str.charCodeAt(i)) | 0;
|
|
600
|
+
}
|
|
601
|
+
return (hash >>> 0).toString(36);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Build a script tag that seeds localStorage with scenario data on first load.
|
|
605
|
+
* Gated by scenario ID — only seeds when the scenario changes, preserving
|
|
606
|
+
* interactive modifications across page reloads / HMR.
|
|
607
|
+
*
|
|
608
|
+
* Returns empty string if no localStorage config is provided.
|
|
609
|
+
*/
|
|
610
|
+
export function buildLocalStorageScript(localStorageConfig, scenarioId, prototypeId) {
|
|
611
|
+
// null/undefined means no localStorage config at all — clean up keys
|
|
612
|
+
// that were set by a previous scenario so stale filter/sort state
|
|
613
|
+
// doesn't bleed through and hide data in the new scenario.
|
|
614
|
+
if (!localStorageConfig || typeof localStorageConfig !== 'object') {
|
|
615
|
+
// Always clean up previous scenario's keys, gated by scenarioId
|
|
616
|
+
// so it only runs once per switch (not on every HMR reload).
|
|
617
|
+
const guardValue = scenarioId ? `clear:${scenarioId}` : '';
|
|
618
|
+
if (prototypeId) {
|
|
619
|
+
return `<script data-codeyam-ls>
|
|
620
|
+
(function() {
|
|
621
|
+
if (localStorage.getItem('__codeyam_proto__') === ${JSON.stringify(prototypeId)}) return;
|
|
622
|
+
localStorage.clear();
|
|
623
|
+
localStorage.setItem('__codeyam_proto__', ${JSON.stringify(prototypeId)});
|
|
624
|
+
})();
|
|
625
|
+
</script>`;
|
|
626
|
+
}
|
|
627
|
+
if (scenarioId) {
|
|
628
|
+
// No prototypeId but we do have a scenarioId — clean up keys
|
|
629
|
+
// from the previous scenario without doing a full clear.
|
|
630
|
+
return `<script data-codeyam-ls>
|
|
631
|
+
(function() {
|
|
632
|
+
if (localStorage.getItem('__codeyam_ls_sid__') === ${JSON.stringify(guardValue)}) return;
|
|
633
|
+
var prev = JSON.parse(localStorage.getItem('__codeyam_ls_keys__') || '[]');
|
|
634
|
+
for (var i = 0; i < prev.length; i++) localStorage.removeItem(prev[i]);
|
|
635
|
+
localStorage.removeItem('__codeyam_ls_keys__');
|
|
636
|
+
localStorage.setItem('__codeyam_ls_sid__', ${JSON.stringify(guardValue)});
|
|
637
|
+
})();
|
|
638
|
+
</script>`;
|
|
639
|
+
}
|
|
640
|
+
return '';
|
|
641
|
+
}
|
|
642
|
+
// Even an empty object needs a cleanup script — switching from a scenario
|
|
643
|
+
// with localStorage data to one without must clear the previous keys.
|
|
644
|
+
const entries = Object.entries(localStorageConfig);
|
|
645
|
+
const keys = entries.map(([k]) => k);
|
|
646
|
+
// Build setItem calls — stringify non-string values
|
|
647
|
+
const setStatements = entries
|
|
648
|
+
.map(([key, value]) => {
|
|
649
|
+
const serialized = typeof value === 'string' ? value : JSON.stringify(value);
|
|
650
|
+
return `localStorage.setItem(${JSON.stringify(key)}, ${JSON.stringify(serialized)});`;
|
|
651
|
+
})
|
|
652
|
+
.join('\n');
|
|
653
|
+
// Guard value includes a content hash so re-registering a scenario with
|
|
654
|
+
// updated data (same ID, different content) busts the cache. Without this,
|
|
655
|
+
// the browser skips re-seeding because the scenario ID hasn't changed,
|
|
656
|
+
// causing stale data in the live preview while screenshots show fresh data.
|
|
657
|
+
const contentHash = simpleHash(JSON.stringify(localStorageConfig));
|
|
658
|
+
const guardValue = `${scenarioId}:${contentHash}`;
|
|
659
|
+
return (`<script data-codeyam-ls>
|
|
660
|
+
(function() {
|
|
661
|
+
if (localStorage.getItem('__codeyam_ls_sid__') === ${JSON.stringify(guardValue)}) return;
|
|
662
|
+
var prev = JSON.parse(localStorage.getItem('__codeyam_ls_keys__') || '[]');
|
|
663
|
+
for (var i = 0; i < prev.length; i++) localStorage.removeItem(prev[i]);
|
|
664
|
+
${setStatements}
|
|
665
|
+
localStorage.setItem('__codeyam_ls_keys__', ${JSON.stringify(JSON.stringify(keys))});
|
|
666
|
+
localStorage.setItem('__codeyam_ls_sid__', ${JSON.stringify(guardValue)});
|
|
667
|
+
})();
|
|
668
|
+
</script>` + buildLocalStorageWatcherScript());
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Build a script that watches for localStorage mutations and notifies the parent
|
|
672
|
+
* frame via postMessage. Also responds to `codeyam-get-localstorage` requests so
|
|
673
|
+
* the editor can read the current localStorage state when saving.
|
|
674
|
+
*/
|
|
675
|
+
function buildLocalStorageWatcherScript() {
|
|
676
|
+
return `<script data-codeyam-ls-watcher>
|
|
677
|
+
(function() {
|
|
678
|
+
if (window.__codeyam_ls_watcher_installed__) return;
|
|
679
|
+
window.__codeyam_ls_watcher_installed__ = true;
|
|
680
|
+
|
|
681
|
+
var origSet = localStorage.setItem.bind(localStorage);
|
|
682
|
+
var origRemove = localStorage.removeItem.bind(localStorage);
|
|
683
|
+
var origClear = localStorage.clear.bind(localStorage);
|
|
684
|
+
window.__codeyam_orig_setItem__ = origSet;
|
|
685
|
+
window.__codeyam_orig_removeItem__ = origRemove;
|
|
686
|
+
window.__codeyam_orig_clear__ = origClear;
|
|
687
|
+
|
|
688
|
+
function isInternal(key) {
|
|
689
|
+
return typeof key === 'string' && key.indexOf('__codeyam_') === 0;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
localStorage.setItem = function(key, value) {
|
|
693
|
+
origSet(key, value);
|
|
694
|
+
if (!isInternal(key) && window.parent !== window) {
|
|
695
|
+
window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'set', key: key }, '*');
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
localStorage.removeItem = function(key) {
|
|
700
|
+
origRemove(key);
|
|
701
|
+
if (!isInternal(key) && window.parent !== window) {
|
|
702
|
+
window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'remove', key: key }, '*');
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
localStorage.clear = function() {
|
|
707
|
+
origClear();
|
|
708
|
+
if (window.parent !== window) {
|
|
709
|
+
window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'clear' }, '*');
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
window.addEventListener('message', function(event) {
|
|
714
|
+
if (event.data && event.data.type === 'codeyam-get-localstorage') {
|
|
715
|
+
var data = {};
|
|
716
|
+
for (var i = 0; i < localStorage.length; i++) {
|
|
717
|
+
var k = localStorage.key(i);
|
|
718
|
+
if (k && !isInternal(k)) {
|
|
719
|
+
data[k] = localStorage.getItem(k);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
event.source.postMessage({ type: 'codeyam-localstorage-state', data: data }, '*');
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
})();
|
|
726
|
+
</script>`;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Inject the health-check script (and optional localStorage script) into an HTML response body.
|
|
730
|
+
* Inserts before </head> if present, otherwise before </body>, otherwise appends.
|
|
731
|
+
* When a localStorageScript is provided, it's injected BEFORE the health script
|
|
732
|
+
* so localStorage is populated before the app loads.
|
|
733
|
+
*/
|
|
734
|
+
export function injectHealthScript(html, localStorageScript) {
|
|
735
|
+
const scripts = (localStorageScript || '') + PREVIEW_HEALTH_SCRIPT;
|
|
736
|
+
if (html.includes('</head>')) {
|
|
737
|
+
return html.replace('</head>', scripts + '</head>');
|
|
738
|
+
}
|
|
739
|
+
if (html.includes('</body>')) {
|
|
740
|
+
return html.replace('</body>', scripts + '</body>');
|
|
741
|
+
}
|
|
742
|
+
return html + scripts;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Handle POST /__codeyam__/preview-health — store health data in globalThis.
|
|
746
|
+
*/
|
|
747
|
+
function handlePreviewHealthPost(req, res) {
|
|
748
|
+
const chunks = [];
|
|
749
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
750
|
+
req.on('end', () => {
|
|
751
|
+
try {
|
|
752
|
+
const body = JSON.parse(Buffer.concat(chunks).toString('utf-8'));
|
|
753
|
+
const current = getPreviewHealth() || {
|
|
754
|
+
errors: [],
|
|
755
|
+
loaded: false,
|
|
756
|
+
hasContent: false,
|
|
757
|
+
url: '',
|
|
758
|
+
lastUpdated: 0,
|
|
759
|
+
};
|
|
760
|
+
if (body.errors && Array.isArray(body.errors)) {
|
|
761
|
+
current.errors = current.errors.concat(body.errors);
|
|
762
|
+
}
|
|
763
|
+
if (body.loaded !== undefined) {
|
|
764
|
+
current.loaded = body.loaded;
|
|
765
|
+
}
|
|
766
|
+
if (body.hasContent !== undefined) {
|
|
767
|
+
current.hasContent = body.hasContent;
|
|
768
|
+
}
|
|
769
|
+
if (body.url) {
|
|
770
|
+
current.url = body.url;
|
|
771
|
+
}
|
|
772
|
+
current.lastUpdated = Date.now();
|
|
773
|
+
setPreviewHealth(current);
|
|
774
|
+
}
|
|
775
|
+
catch {
|
|
776
|
+
// Ignore malformed JSON
|
|
777
|
+
}
|
|
778
|
+
res.writeHead(204);
|
|
779
|
+
res.end();
|
|
780
|
+
});
|
|
781
|
+
}
|
|
119
782
|
/**
|
|
120
783
|
* Handle WebSocket upgrade by piping to the target dev server.
|
|
121
784
|
*/
|
|
122
785
|
function handleUpgrade(req, socket, head, targetUrl) {
|
|
123
786
|
const target = new URL(targetUrl);
|
|
787
|
+
const hostname = stripIPv6Brackets(target.hostname);
|
|
124
788
|
const port = parseInt(target.port, 10) || 80;
|
|
125
|
-
console.log(`[editorProxy] WebSocket upgrade: ${req.url} → ${
|
|
126
|
-
const proxySocket = net.connect(port,
|
|
789
|
+
console.log(`[editorProxy] WebSocket upgrade: ${req.url} → ${hostname}:${port}`);
|
|
790
|
+
const proxySocket = net.connect(port, hostname, () => {
|
|
127
791
|
// Reconstruct the HTTP upgrade request
|
|
128
792
|
const requestLine = `${req.method} ${req.url} HTTP/${req.httpVersion}\r\n`;
|
|
129
793
|
const headers = Object.entries(req.headers)
|
|
@@ -146,38 +810,157 @@ function handleUpgrade(req, socket, head, targetUrl) {
|
|
|
146
810
|
proxySocket.destroy();
|
|
147
811
|
});
|
|
148
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* Write proxy-config.json so the preload module can discover the proxy.
|
|
815
|
+
*/
|
|
816
|
+
function writeProxyConfig(proxyPort, targetUrl) {
|
|
817
|
+
const projectRoot = getProjectRoot() || process.env.CODEYAM_ROOT_PATH || process.cwd();
|
|
818
|
+
const configPath = path.join(projectRoot, '.codeyam', 'proxy-config.json');
|
|
819
|
+
try {
|
|
820
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
821
|
+
fs.writeFileSync(configPath, JSON.stringify({
|
|
822
|
+
proxyUrl: `http://localhost:${proxyPort}`,
|
|
823
|
+
devServerUrl: targetUrl,
|
|
824
|
+
}), 'utf-8');
|
|
825
|
+
console.log(`[editorProxy] Wrote proxy config to ${configPath}`);
|
|
826
|
+
}
|
|
827
|
+
catch (err) {
|
|
828
|
+
console.warn('[editorProxy] Failed to write proxy-config.json:', err);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Remove proxy-config.json on proxy stop.
|
|
833
|
+
*/
|
|
834
|
+
function removeProxyConfig() {
|
|
835
|
+
const projectRoot = getProjectRoot() || process.env.CODEYAM_ROOT_PATH || process.cwd();
|
|
836
|
+
const configPath = path.join(projectRoot, '.codeyam', 'proxy-config.json');
|
|
837
|
+
try {
|
|
838
|
+
if (fs.existsSync(configPath)) {
|
|
839
|
+
fs.unlinkSync(configPath);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
catch {
|
|
843
|
+
// Best effort
|
|
844
|
+
}
|
|
845
|
+
}
|
|
149
846
|
/**
|
|
150
847
|
* Start the editor proxy server.
|
|
151
|
-
* Intercepts
|
|
848
|
+
* Intercepts requests to API routes matching the active scenario, forwards everything else.
|
|
849
|
+
* Supports all HTTP methods (GET, POST, PUT, DELETE, PATCH) with body buffering.
|
|
152
850
|
*/
|
|
153
851
|
export async function startEditorProxy(options) {
|
|
154
|
-
//
|
|
852
|
+
// If proxy is already running, reuse it (prevents second tab from killing first tab's proxy)
|
|
853
|
+
const existing = getProxyState();
|
|
854
|
+
if (existing) {
|
|
855
|
+
console.log(`[editorProxy] Proxy already running on port ${existing.port} → ${existing.targetUrl}`);
|
|
856
|
+
return { port: existing.port };
|
|
857
|
+
}
|
|
858
|
+
// Stop any leftover state (shouldn't happen, but defensive)
|
|
155
859
|
await stopEditorProxy();
|
|
156
|
-
|
|
860
|
+
let targetUrl = normalizeTargetUrl(options.targetUrl);
|
|
157
861
|
let port = options.port;
|
|
862
|
+
// When the target is localhost, probe to find the correct loopback address.
|
|
863
|
+
// Dev servers may bind to IPv4 (127.0.0.1) or IPv6 (::1) — Vite 6 on macOS
|
|
864
|
+
// binds to ::1 by default. We need to match the actual binding.
|
|
865
|
+
try {
|
|
866
|
+
const parsed = new URL(targetUrl);
|
|
867
|
+
if (parsed.hostname === 'localhost') {
|
|
868
|
+
const targetPort = parseInt(parsed.port || '80', 10);
|
|
869
|
+
const resolvedHost = await resolveLoopbackAddress(targetPort);
|
|
870
|
+
if (resolvedHost) {
|
|
871
|
+
parsed.hostname = resolvedHost;
|
|
872
|
+
targetUrl = parsed.toString().replace(/\/$/, '');
|
|
873
|
+
console.log(`[editorProxy] Resolved localhost to ${resolvedHost} for port ${targetPort}`);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
catch {
|
|
878
|
+
// Keep original targetUrl
|
|
879
|
+
}
|
|
158
880
|
console.log(`[editorProxy] Starting proxy (requested port ${port}, target ${targetUrl})`);
|
|
881
|
+
const mockState = getMockStateManager();
|
|
159
882
|
const server = http.createServer((req, res) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
|
|
883
|
+
void (async () => {
|
|
884
|
+
const parsedUrl = new URL(req.url || '/', `http://localhost:${port}`);
|
|
885
|
+
const pathname = parsedUrl.pathname;
|
|
886
|
+
const method = req.method || 'GET';
|
|
887
|
+
// CORS preflight — permissive 204 for browser cross-origin requests
|
|
888
|
+
if (method === 'OPTIONS') {
|
|
889
|
+
res.writeHead(204, {
|
|
890
|
+
'Access-Control-Allow-Origin': '*',
|
|
891
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
892
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With',
|
|
893
|
+
'Access-Control-Max-Age': '86400',
|
|
894
|
+
});
|
|
895
|
+
res.end();
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
// Intercept preview health reports from the injected script
|
|
899
|
+
if (method === 'POST' && pathname === '/__codeyam__/preview-health') {
|
|
900
|
+
handlePreviewHealthPost(req, res);
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
// Load scenario data (also feeds MockStateManager)
|
|
904
|
+
readScenarioData();
|
|
905
|
+
// For methods that may carry a body, buffer it first
|
|
906
|
+
const needsBody = method === 'POST' ||
|
|
907
|
+
method === 'PUT' ||
|
|
908
|
+
method === 'DELETE' ||
|
|
909
|
+
method === 'PATCH';
|
|
910
|
+
if (needsBody) {
|
|
911
|
+
const bodyBuffer = await bufferRequestBody(req);
|
|
912
|
+
if (bodyBuffer === null) {
|
|
913
|
+
// Body too large — forward without mock matching
|
|
914
|
+
forwardBufferedRequest(req, res, targetUrl, null);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
// Try to parse body as JSON for mock matching
|
|
918
|
+
let parsedBody = undefined;
|
|
919
|
+
if (bodyBuffer.length > 0) {
|
|
920
|
+
try {
|
|
921
|
+
parsedBody = JSON.parse(bodyBuffer.toString('utf-8'));
|
|
922
|
+
}
|
|
923
|
+
catch {
|
|
924
|
+
// Not JSON — that's fine, still try mock matching without parsed body
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
const match = mockState.matchRequest(method, pathname, parsedBody);
|
|
167
928
|
if (match) {
|
|
168
|
-
console.log(`[editorProxy] Intercepted ${
|
|
929
|
+
console.log(`[editorProxy] Intercepted ${method} ${pathname} → mock response (status ${match.status})`);
|
|
169
930
|
res.writeHead(match.status, {
|
|
170
931
|
'Content-Type': 'application/json',
|
|
171
932
|
'Access-Control-Allow-Origin': '*',
|
|
172
933
|
'X-CodeYam-Proxy': 'scenario-data',
|
|
934
|
+
'Cache-Control': 'no-store',
|
|
173
935
|
});
|
|
174
|
-
res.end(JSON.stringify(match.body));
|
|
936
|
+
res.end(match.body != null ? JSON.stringify(match.body) : '');
|
|
175
937
|
return;
|
|
176
938
|
}
|
|
939
|
+
// No mock match — forward with buffered body
|
|
940
|
+
if ((currentScenarioType === 'application' ||
|
|
941
|
+
currentScenarioType === 'user') &&
|
|
942
|
+
pathname.startsWith('/api/')) {
|
|
943
|
+
mockStateEventEmitter.emitDataMutationForwarded(method, pathname);
|
|
944
|
+
}
|
|
945
|
+
forwardBufferedRequest(req, res, targetUrl, bodyBuffer);
|
|
946
|
+
return;
|
|
177
947
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
948
|
+
// GET, HEAD, etc. — try mock matching (no body)
|
|
949
|
+
const match = mockState.matchRequest(method, pathname);
|
|
950
|
+
if (match) {
|
|
951
|
+
console.log(`[editorProxy] Intercepted ${method} ${pathname} → mock response (status ${match.status})`);
|
|
952
|
+
res.writeHead(match.status, {
|
|
953
|
+
'Content-Type': 'application/json',
|
|
954
|
+
'Access-Control-Allow-Origin': '*',
|
|
955
|
+
'X-CodeYam-Proxy': 'scenario-data',
|
|
956
|
+
'Cache-Control': 'no-store',
|
|
957
|
+
});
|
|
958
|
+
res.end(match.body != null ? JSON.stringify(match.body) : '');
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
// Forward everything else to the dev server
|
|
962
|
+
forwardRequest(req, res, targetUrl);
|
|
963
|
+
})();
|
|
181
964
|
});
|
|
182
965
|
// Handle WebSocket upgrades (for HMR)
|
|
183
966
|
server.on('upgrade', (req, socket, head) => {
|
|
@@ -195,9 +978,14 @@ export async function startEditorProxy(options) {
|
|
|
195
978
|
resolve();
|
|
196
979
|
});
|
|
197
980
|
});
|
|
198
|
-
port
|
|
981
|
+
// When port 0 is requested, the OS assigns an ephemeral port
|
|
982
|
+
const addr = server.address();
|
|
983
|
+
port =
|
|
984
|
+
typeof addr === 'object' && addr !== null ? addr.port : currentPort;
|
|
199
985
|
const state = { server, port, targetUrl };
|
|
200
986
|
setProxyState(state);
|
|
987
|
+
// Write proxy-config.json for the preload module
|
|
988
|
+
writeProxyConfig(port, targetUrl);
|
|
201
989
|
console.log(`[editorProxy] Proxy started on port ${port}, forwarding to ${targetUrl}`);
|
|
202
990
|
return { port };
|
|
203
991
|
}
|
|
@@ -220,6 +1008,7 @@ export async function stopEditorProxy() {
|
|
|
220
1008
|
if (!state)
|
|
221
1009
|
return;
|
|
222
1010
|
console.log(`[editorProxy] Stopping proxy on port ${state.port}`);
|
|
1011
|
+
removeProxyConfig();
|
|
223
1012
|
return new Promise((resolve) => {
|
|
224
1013
|
state.server.close(() => {
|
|
225
1014
|
console.log('[editorProxy] Proxy stopped');
|
|
@@ -235,6 +1024,41 @@ export async function stopEditorProxy() {
|
|
|
235
1024
|
*/
|
|
236
1025
|
export function invalidateScenarioCache() {
|
|
237
1026
|
scenarioCache = { data: null, timestamp: 0 };
|
|
1027
|
+
sessionConfig = undefined;
|
|
1028
|
+
seedSessionCookies = undefined;
|
|
1029
|
+
localStorageConfig = null;
|
|
1030
|
+
activeScenarioId = null;
|
|
1031
|
+
currentPrototypeId = null;
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Verify that the proxy can successfully forward a request to the target dev server.
|
|
1035
|
+
* Makes a HEAD request through the proxy and checks that it gets a response (any status).
|
|
1036
|
+
* Returns false if the proxy isn't running or if the request fails entirely.
|
|
1037
|
+
*/
|
|
1038
|
+
export async function verifyProxyForwarding() {
|
|
1039
|
+
const state = getProxyState();
|
|
1040
|
+
if (!state) {
|
|
1041
|
+
console.warn('[editorProxy] Cannot verify — proxy is not running');
|
|
1042
|
+
return false;
|
|
1043
|
+
}
|
|
1044
|
+
try {
|
|
1045
|
+
const response = await fetch(`http://127.0.0.1:${state.port}/`, {
|
|
1046
|
+
method: 'HEAD',
|
|
1047
|
+
signal: AbortSignal.timeout(5000),
|
|
1048
|
+
});
|
|
1049
|
+
// Any response from the target (even 404) means forwarding works.
|
|
1050
|
+
// Only 502 (our own Bad Gateway) means the target is unreachable.
|
|
1051
|
+
if (response.status === 502) {
|
|
1052
|
+
console.warn(`[editorProxy] Verification failed — proxy returned 502 (target unreachable)`);
|
|
1053
|
+
return false;
|
|
1054
|
+
}
|
|
1055
|
+
console.log(`[editorProxy] Verification passed — proxy forwarding to ${state.targetUrl} (status ${response.status})`);
|
|
1056
|
+
return true;
|
|
1057
|
+
}
|
|
1058
|
+
catch (err) {
|
|
1059
|
+
console.warn(`[editorProxy] Verification failed — could not reach proxy on port ${state.port}`);
|
|
1060
|
+
return false;
|
|
1061
|
+
}
|
|
238
1062
|
}
|
|
239
1063
|
/**
|
|
240
1064
|
* Ensure the proxy is running. If it's not, start it using the current dev server URL.
|
|
@@ -256,9 +1080,10 @@ export async function ensureProxyRunning() {
|
|
|
256
1080
|
return null;
|
|
257
1081
|
}
|
|
258
1082
|
const codeyamPort = parseInt(process.env.CODEYAM_PORT || '3111', 10);
|
|
259
|
-
|
|
1083
|
+
const { proxyPort } = computeEditorPorts(codeyamPort);
|
|
1084
|
+
console.log(`[editorProxy] Proxy not running, starting on-demand (port ${proxyPort}, target ${devServer.url})`);
|
|
260
1085
|
const result = await startEditorProxy({
|
|
261
|
-
port:
|
|
1086
|
+
port: proxyPort,
|
|
262
1087
|
targetUrl: devServer.url,
|
|
263
1088
|
});
|
|
264
1089
|
if (result) {
|
|
@@ -269,4 +1094,8 @@ export async function ensureProxyRunning() {
|
|
|
269
1094
|
console.error('[editorProxy] Failed to start on-demand proxy');
|
|
270
1095
|
return null;
|
|
271
1096
|
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Test-only export: trigger readScenarioData so tests can verify session config extraction.
|
|
1099
|
+
*/
|
|
1100
|
+
export const _readScenarioDataForTest = readScenarioData;
|
|
272
1101
|
//# sourceMappingURL=editorProxy.js.map
|