@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.6e699e5
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/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +10 -6
- package/analyzer-template/packages/ai/index.ts +10 -3
- package/analyzer-template/packages/ai/package.json +1 -1
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +128 -6
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +138 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +140 -6
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1239 -104
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +304 -0
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1501 -138
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +103 -6
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +23 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +42 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +6 -0
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1111 -91
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +207 -104
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +570 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1977 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +276 -3
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +33 -3
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +90 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +812 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +123 -0
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +455 -267
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +18 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +265 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +588 -52
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +336 -133
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +156 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +461 -94
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +3 -3
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +4 -4
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +196 -0
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +5 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +224 -0
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +196 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +37 -18
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
- package/analyzer-template/playwright/takeScreenshot.ts +9 -7
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/analyzeBaselineCommit.ts +4 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +4 -0
- package/analyzer-template/project/constructMockCode.ts +1181 -160
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +82 -36
- package/analyzer-template/project/orchestrateCapture.ts +36 -3
- package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
- package/analyzer-template/project/serverOnlyModules.ts +194 -21
- package/analyzer-template/project/start.ts +26 -4
- package/analyzer-template/project/startScenarioCapture.ts +79 -41
- package/analyzer-template/project/writeMockDataTsx.ts +232 -57
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +769 -181
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +13 -15
- package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +1 -29
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/local/execAsync.js +1 -1
- package/background/src/lib/local/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/common/execAsync.js +1 -1
- package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +1053 -124
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +69 -32
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +27 -4
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +163 -23
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +21 -4
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +199 -50
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +552 -125
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +13 -13
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/src/cli.js +7 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +1 -1
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +174 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +40 -18
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +0 -15
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/recapture.js +226 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -0
- package/codeyam-cli/src/commands/report.js +72 -24
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +1 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +8 -13
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +14 -4
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +31 -17
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +245 -16
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +25 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/versionInfo.js +25 -19
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +98 -1
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +49 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BXhEawa3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Ba2JVPzP.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-C8lyxW9k.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-aht4aafF.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVtiBnY5.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-B0GLXMsr.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-xgeCVgSM.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-D4TZhLuw.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DuDvi0jm.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DEx02QDa.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-BwqWJOgH.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DoLIqZX2.js +37 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.rules-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-Cx24_aWc.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-CXRTFQ3F.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-BOARzkeR.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BdhJEx6B.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BRb-0kQl.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-C2N4Op8e.js +23 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D1T4TGjf.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-CTBG2mmz.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-CS2cb_eZ.js +29 -0
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DMJ7zii9.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-Cs4MdYtv.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-B4RJRvYB.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-commit-horizontal-CysbcZxi.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-DMUaGAqV.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-B1h680n5.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-lzqtyFU8.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-B7B9V-bu.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-f874c610.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-Bz5TunQg.js +57 -0
- package/codeyam-cli/src/webserver/build/client/assets/rules-hEkvVw2-.js +97 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-CxXUmBSd.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DwFIBT09.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B6LgvRJg.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C1v1PQzo.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-aSv48UbS.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DYxHZQuP.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-mBRpZPiu.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-967OuJoF.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-DRTmerg9.js +257 -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/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/codeyam-power-rules-hook.sh +200 -0
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
- package/codeyam-cli/templates/codeyam:diagnose.md +650 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
- package/codeyam-cli/templates/codeyam:power-rules.md +447 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
- package/package.json +17 -16
- package/packages/ai/index.js +5 -4
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +99 -0
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +100 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +97 -6
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +945 -87
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +178 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1198 -82
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +16 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +86 -4
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +20 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +34 -3
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +111 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +5 -0
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +904 -84
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +186 -82
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +392 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1440 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +231 -4
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +26 -3
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +6 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +68 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +667 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +4 -0
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +15 -0
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +218 -50
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +10 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -7
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +209 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +458 -48
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +264 -78
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +96 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +372 -89
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +2 -2
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +6 -4
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
- package/codeyam-cli/templates/debug-command.md +0 -303
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -8,6 +8,51 @@ import * as fs from 'fs';
|
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
import ts from 'typescript';
|
|
10
10
|
import { applyServerOnlyMocks } from "./serverOnlyModules.js";
|
|
11
|
+
// Debug timing helper for tracking where time is spent
|
|
12
|
+
const DEBUG_TIMING = process.env.DEBUG_WRITE_SCENARIO === 'true';
|
|
13
|
+
let debugStartTime;
|
|
14
|
+
let debugLastTime;
|
|
15
|
+
// Timeout protection to prevent infinite hangs
|
|
16
|
+
const WRITE_SCENARIO_TIMEOUT_MS = parseInt(process.env.WRITE_SCENARIO_TIMEOUT_MS || '300000', // Default 5 minutes
|
|
17
|
+
10);
|
|
18
|
+
class WriteScenarioTimeoutError extends Error {
|
|
19
|
+
constructor(operation, timeoutMs) {
|
|
20
|
+
super(`WriteScenarioComponents timed out after ${timeoutMs}ms during: ${operation}`);
|
|
21
|
+
this.name = 'WriteScenarioTimeoutError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function withTimeout(operation, promise, timeoutMs = WRITE_SCENARIO_TIMEOUT_MS) {
|
|
25
|
+
let timeoutId;
|
|
26
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
27
|
+
timeoutId = setTimeout(() => {
|
|
28
|
+
reject(new WriteScenarioTimeoutError(operation, timeoutMs));
|
|
29
|
+
}, timeoutMs);
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
return await Promise.race([promise, timeoutPromise]);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
if (timeoutId)
|
|
36
|
+
clearTimeout(timeoutId);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function debugLog(message, extra) {
|
|
40
|
+
if (!DEBUG_TIMING)
|
|
41
|
+
return;
|
|
42
|
+
const now = Date.now();
|
|
43
|
+
if (!debugStartTime) {
|
|
44
|
+
debugStartTime = now;
|
|
45
|
+
debugLastTime = now;
|
|
46
|
+
}
|
|
47
|
+
const elapsed = now - debugStartTime;
|
|
48
|
+
const delta = now - debugLastTime;
|
|
49
|
+
debugLastTime = now;
|
|
50
|
+
console.log(`[WriteScenario +${elapsed}ms Δ${delta}ms] ${message}`, extra ? JSON.stringify(extra, null, 2) : '');
|
|
51
|
+
}
|
|
52
|
+
function resetDebugTiming() {
|
|
53
|
+
debugStartTime = 0;
|
|
54
|
+
debugLastTime = 0;
|
|
55
|
+
}
|
|
11
56
|
/**
|
|
12
57
|
* Find the end position of the last import/export-from statement using TypeScript AST.
|
|
13
58
|
* This is more reliable than regex for handling multiline imports, comments, etc.
|
|
@@ -17,7 +62,10 @@ import { applyServerOnlyMocks } from "./serverOnlyModules.js";
|
|
|
17
62
|
*/
|
|
18
63
|
function findEndOfImports(content) {
|
|
19
64
|
try {
|
|
20
|
-
|
|
65
|
+
// Use temp.tsx to enable JSX parsing - otherwise TypeScript may misparse
|
|
66
|
+
// JSX content containing the word "import" (e.g., "Entities that import this")
|
|
67
|
+
// as an import statement, causing mock code to be inserted in the wrong location.
|
|
68
|
+
const sourceFile = ts.createSourceFile('temp.tsx', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
21
69
|
let lastImportEnd = 0;
|
|
22
70
|
// Visit all top-level statements to find import/export declarations
|
|
23
71
|
for (const statement of sourceFile.statements) {
|
|
@@ -46,6 +94,106 @@ function findEndOfImports(content) {
|
|
|
46
94
|
function escapeRegExp(str) {
|
|
47
95
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
48
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Remove a named import from file content using TypeScript AST.
|
|
99
|
+
* Handles both regular imports (`EntityName`) and type-only imports (`type EntityName`).
|
|
100
|
+
*
|
|
101
|
+
* @param fileContent - The file content to modify
|
|
102
|
+
* @param entityName - The name of the entity to remove from imports
|
|
103
|
+
* @returns The modified file content with the entity removed from imports
|
|
104
|
+
*/
|
|
105
|
+
function removeNamedImportAst(fileContent, entityName) {
|
|
106
|
+
try {
|
|
107
|
+
const sourceFile = ts.createSourceFile('temp.tsx', fileContent, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
108
|
+
const replacements = [];
|
|
109
|
+
for (const statement of sourceFile.statements) {
|
|
110
|
+
if (!ts.isImportDeclaration(statement))
|
|
111
|
+
continue;
|
|
112
|
+
if (!statement.importClause?.namedBindings)
|
|
113
|
+
continue;
|
|
114
|
+
if (!ts.isNamedImports(statement.importClause.namedBindings))
|
|
115
|
+
continue;
|
|
116
|
+
const namedImports = statement.importClause.namedBindings;
|
|
117
|
+
const elements = namedImports.elements;
|
|
118
|
+
// Find the element that matches our entity name
|
|
119
|
+
const matchingIndex = elements.findIndex((el) => el.name.text === entityName);
|
|
120
|
+
if (matchingIndex === -1)
|
|
121
|
+
continue;
|
|
122
|
+
// Check if there's a default import (e.g., `import DefaultName, { NamedImport } from '...'`)
|
|
123
|
+
const hasDefaultImport = !!statement.importClause.name;
|
|
124
|
+
// If this is the only named import AND there's no default import, remove the entire statement
|
|
125
|
+
if (elements.length === 1 && !hasDefaultImport) {
|
|
126
|
+
// Find the end including any trailing newline
|
|
127
|
+
let end = statement.getEnd();
|
|
128
|
+
const afterStatement = fileContent.slice(end);
|
|
129
|
+
const trailingNewline = afterStatement.match(/^\r?\n/);
|
|
130
|
+
if (trailingNewline) {
|
|
131
|
+
end += trailingNewline[0].length;
|
|
132
|
+
}
|
|
133
|
+
replacements.push({
|
|
134
|
+
start: statement.getStart(sourceFile),
|
|
135
|
+
end,
|
|
136
|
+
replacement: '',
|
|
137
|
+
});
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
// Otherwise, rebuild the import without this element
|
|
141
|
+
const remainingElements = elements.filter((_, i) => i !== matchingIndex);
|
|
142
|
+
// Get the module specifier
|
|
143
|
+
const moduleSpecifier = statement.moduleSpecifier;
|
|
144
|
+
if (!ts.isStringLiteral(moduleSpecifier))
|
|
145
|
+
continue;
|
|
146
|
+
// Preserve import type modifier if present
|
|
147
|
+
const importTypePrefix = statement.importClause.isTypeOnly ? 'type ' : '';
|
|
148
|
+
// Get the default import name if present
|
|
149
|
+
const defaultImportName = statement.importClause.name?.text;
|
|
150
|
+
let newImport;
|
|
151
|
+
if (remainingElements.length === 0) {
|
|
152
|
+
// All named imports were removed, but there's a default import to preserve
|
|
153
|
+
// (we only get here when hasDefaultImport is true, because otherwise we'd have
|
|
154
|
+
// removed the whole statement at the elements.length === 1 check above)
|
|
155
|
+
newImport = `import ${defaultImportName} from ${moduleSpecifier.getText(sourceFile)};`;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// Build the new named imports string
|
|
159
|
+
const newNamedImports = remainingElements
|
|
160
|
+
.map((el) => {
|
|
161
|
+
const isTypeOnly = el.isTypeOnly;
|
|
162
|
+
const name = el.name.text;
|
|
163
|
+
const propertyName = el.propertyName?.text;
|
|
164
|
+
if (propertyName) {
|
|
165
|
+
return isTypeOnly
|
|
166
|
+
? `type ${propertyName} as ${name}`
|
|
167
|
+
: `${propertyName} as ${name}`;
|
|
168
|
+
}
|
|
169
|
+
return isTypeOnly ? `type ${name}` : name;
|
|
170
|
+
})
|
|
171
|
+
.join(', ');
|
|
172
|
+
// Build the new import statement, preserving default import if present
|
|
173
|
+
const defaultImportPrefix = defaultImportName
|
|
174
|
+
? `${defaultImportName}, `
|
|
175
|
+
: '';
|
|
176
|
+
newImport = `import ${importTypePrefix}${defaultImportPrefix}{ ${newNamedImports} } from ${moduleSpecifier.getText(sourceFile)};`;
|
|
177
|
+
}
|
|
178
|
+
replacements.push({
|
|
179
|
+
start: statement.getStart(sourceFile),
|
|
180
|
+
end: statement.getEnd(),
|
|
181
|
+
replacement: newImport,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
// Apply replacements in reverse order to preserve positions
|
|
185
|
+
let result = fileContent;
|
|
186
|
+
replacements.sort((a, b) => b.start - a.start);
|
|
187
|
+
for (const { start, end, replacement } of replacements) {
|
|
188
|
+
result = result.slice(0, start) + replacement + result.slice(end);
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
console.warn('[removeNamedImportAst] Failed to parse file:', error);
|
|
194
|
+
return fileContent; // Return original content on error
|
|
195
|
+
}
|
|
196
|
+
}
|
|
49
197
|
/**
|
|
50
198
|
* Map nested dist paths to src paths.
|
|
51
199
|
* Some build tools create nested structures like:
|
|
@@ -321,22 +469,37 @@ function stripServerOnlyImport(fileContent) {
|
|
|
321
469
|
* Excludes node_modules imports (bare specifiers like 'react', '@prisma/client').
|
|
322
470
|
*/
|
|
323
471
|
function extractInternalImportPaths(fileContent) {
|
|
472
|
+
// Always use AST parsing - regex with nested quantifiers can cause catastrophic
|
|
473
|
+
// backtracking that hangs on a single .exec() call (before iteration limits kick in)
|
|
474
|
+
return extractInternalImportPathsAst(fileContent);
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Extract internal import paths using TypeScript AST - more reliable for large files
|
|
478
|
+
*/
|
|
479
|
+
function extractInternalImportPathsAst(fileContent) {
|
|
324
480
|
const importPaths = [];
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
481
|
+
try {
|
|
482
|
+
// Use temp.tsx to enable JSX parsing for consistent handling of JSX files
|
|
483
|
+
const sourceFile = ts.createSourceFile('temp.tsx', fileContent, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
484
|
+
for (const statement of sourceFile.statements) {
|
|
485
|
+
if (ts.isImportDeclaration(statement) && statement.moduleSpecifier) {
|
|
486
|
+
const moduleSpecifier = statement.moduleSpecifier;
|
|
487
|
+
if (ts.isStringLiteral(moduleSpecifier)) {
|
|
488
|
+
const importPath = moduleSpecifier.text;
|
|
489
|
+
// Skip node_modules imports (bare specifiers)
|
|
490
|
+
if (importPath.startsWith('.') ||
|
|
491
|
+
importPath.startsWith('@/') ||
|
|
492
|
+
importPath.startsWith('~/') ||
|
|
493
|
+
importPath.startsWith('#')) {
|
|
494
|
+
importPaths.push(importPath);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
338
498
|
}
|
|
339
499
|
}
|
|
500
|
+
catch (error) {
|
|
501
|
+
console.warn('[extractInternalImportPathsAst] Failed to parse file:', error);
|
|
502
|
+
}
|
|
340
503
|
return importPaths;
|
|
341
504
|
}
|
|
342
505
|
/**
|
|
@@ -433,46 +596,97 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
|
|
|
433
596
|
}
|
|
434
597
|
// Check if we have multiple calls with different variable names
|
|
435
598
|
// This requires generating separate mock functions for each call site
|
|
436
|
-
|
|
437
|
-
|
|
599
|
+
//
|
|
600
|
+
// IMPORTANT: calls array may contain BOTH base hook calls (e.g., "useFetcher<Type>()")
|
|
601
|
+
// AND method chain usages (e.g., "useFetcher().functionCallReturnValue.submit(...)").
|
|
602
|
+
// We only want to count base hook calls for the length comparison with callVariableNames.
|
|
603
|
+
// A "base call" is one that ends with "()" possibly preceded by a type annotation,
|
|
604
|
+
// without any subsequent method chains like ".functionCallReturnValue" or ".submit(...)".
|
|
605
|
+
const baseHookCalls = importedExport.calls?.filter((call) => {
|
|
606
|
+
// Base hook calls match patterns like:
|
|
607
|
+
// - "useFetcher()"
|
|
608
|
+
// - "useFetcher<Type>()"
|
|
609
|
+
// - "useFetcher<{ complex: Type }>()"
|
|
610
|
+
// They end with "()" and don't have method chains after the call.
|
|
611
|
+
// Method chains contain ".functionCallReturnValue" or have property access after "()".
|
|
612
|
+
return (call.endsWith('()') &&
|
|
613
|
+
!call.includes('.functionCallReturnValue') &&
|
|
614
|
+
// Also exclude method chains like "hook().something" or "hook().method()"
|
|
615
|
+
!call.match(/\(\)\.[a-zA-Z]/));
|
|
616
|
+
});
|
|
617
|
+
// Determine if we can generate unique mock functions for multiple variables.
|
|
618
|
+
// We need:
|
|
619
|
+
// 1. Multiple variable names (callVariableNames.length > 1)
|
|
620
|
+
// 2. Base hook calls to match them (baseHookCalls.length > 0)
|
|
621
|
+
// Note: We use min(baseHookCalls.length, callVariableNames.length) for iteration
|
|
622
|
+
// to handle cases where data might be slightly out of sync (stale entries).
|
|
623
|
+
const hasMultipleCallsWithVariables = baseHookCalls &&
|
|
624
|
+
baseHookCalls.length > 1 &&
|
|
438
625
|
importedExport.callVariableNames &&
|
|
439
|
-
importedExport.callVariableNames.length
|
|
626
|
+
importedExport.callVariableNames.length > 1 &&
|
|
627
|
+
// Only proceed if we have at least as many base calls as variable names,
|
|
628
|
+
// OR they're close enough (within 1) to handle minor sync issues
|
|
629
|
+
Math.abs(baseHookCalls.length - importedExport.callVariableNames.length) <=
|
|
630
|
+
1;
|
|
440
631
|
let mockCode;
|
|
441
632
|
const variableMockCodes = [];
|
|
442
633
|
if (hasMultipleCallsWithVariables) {
|
|
443
634
|
// Generate separate mock functions for each variable-qualified call
|
|
444
|
-
//
|
|
445
|
-
//
|
|
635
|
+
// Look up canonical keys from dataForMocks and track variable names for function naming
|
|
636
|
+
// Get all call signature keys for this hook from dataForMocks
|
|
637
|
+
const dataForMocks = rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
|
|
638
|
+
// Match keys that start with the hook name (e.g., "useFetcher" matches "useFetcher<User>()")
|
|
639
|
+
const callSignatureKeysForHook = dataForMocks
|
|
640
|
+
? Object.keys(dataForMocks).filter((key) => {
|
|
641
|
+
const hookBaseName = importedExport.name.split(/[<(]/)[0];
|
|
642
|
+
const keyBaseName = key.split(/[<(]/)[0];
|
|
643
|
+
return keyBaseName === hookBaseName;
|
|
644
|
+
})
|
|
645
|
+
: [];
|
|
646
|
+
// Track variable name occurrences for unique function naming
|
|
446
647
|
const variableNameCounts = {};
|
|
447
|
-
|
|
648
|
+
// Use the minimum of both array lengths to handle slight mismatches
|
|
649
|
+
// (e.g., stale data from previous analysis runs)
|
|
650
|
+
const iterationLimit = Math.min(baseHookCalls.length, importedExport.callVariableNames.length);
|
|
651
|
+
for (let i = 0; i < iterationLimit; i++) {
|
|
448
652
|
const variableName = importedExport.callVariableNames[i];
|
|
449
653
|
if (!variableName)
|
|
450
654
|
continue;
|
|
451
655
|
// Calculate the occurrence index for this variable name
|
|
452
656
|
const occurrence = variableNameCounts[variableName] ?? 0;
|
|
453
657
|
variableNameCounts[variableName] = occurrence + 1;
|
|
454
|
-
//
|
|
455
|
-
// e.g., "fetcher[1] <- useFetcher" for the second usage of "fetcher"
|
|
658
|
+
// Build indexed variable name for function naming
|
|
456
659
|
const indexedVariableName = occurrence > 0 ? `${variableName}[${occurrence}]` : variableName;
|
|
457
|
-
//
|
|
458
|
-
//
|
|
459
|
-
const
|
|
460
|
-
|
|
660
|
+
// Use safe function name with underscores instead of brackets
|
|
661
|
+
// e.g., fetcher[1] -> fetcher_1
|
|
662
|
+
const safeFunctionName = indexedVariableName.replace(/\[(\d+)\]/g, '_$1');
|
|
663
|
+
// Compute unique mock function name for call site replacement
|
|
664
|
+
// e.g., useFetcher_entityDiffFetcher, useFetcher_reportFetcher
|
|
665
|
+
const mockFunctionName = `${importedExport.name}_${safeFunctionName}`;
|
|
666
|
+
// Use the call signature from baseHookCalls[i] as the data key
|
|
667
|
+
// This matches what's stored in dataForMocks
|
|
668
|
+
const callSignature = baseHookCalls[i];
|
|
669
|
+
// Generate mock code using the call signature directly
|
|
670
|
+
// This prevents "symbol already declared" errors when multiple calls exist
|
|
671
|
+
// Check if this is a package import that won't have scenario copies
|
|
672
|
+
const isPackageImportForMock = importPath?.startsWith('@');
|
|
673
|
+
const variableMockCode = constructMockCode(callSignature, // Use call signature format for data lookup
|
|
674
|
+
dependencySchemas, importedExport.entityType, undefined, // No need for separate canonical key
|
|
675
|
+
{
|
|
676
|
+
uniqueFunctionSuffix: safeFunctionName, // Use variable name for unique function naming
|
|
677
|
+
// For node_modules or package imports, skip spreading from __cyOriginal
|
|
678
|
+
// since those packages/files don't export *__cyOriginal variants
|
|
679
|
+
skipOriginalSpread: importedExport.isNodeModule || isPackageImportForMock,
|
|
680
|
+
});
|
|
461
681
|
if (variableMockCode) {
|
|
462
682
|
variableMockCodes.push(variableMockCode);
|
|
463
683
|
// Replace the call site with the variable-specific mock function
|
|
464
684
|
// e.g., useFetcher<BranchEntityDiffResult>() -> useFetcher_entityDiffFetcher()
|
|
465
685
|
// e.g., useFetcher() -> useFetcher_reportFetcher()
|
|
466
|
-
// For indexed variables: useFetcher() -> useFetcher_fetcher_1()
|
|
467
|
-
const callSignature = importedExport.calls[i];
|
|
468
686
|
// Escape special regex characters in the call signature
|
|
469
687
|
const escapedCallSignature = callSignature.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
470
688
|
// Create regex that matches the call (with optional whitespace variations)
|
|
471
689
|
const callRegex = new RegExp(escapedCallSignature.replace(/\s+/g, '\\s*'), 'g');
|
|
472
|
-
// Use safe function name with underscores instead of brackets
|
|
473
|
-
// e.g., fetcher[1] -> fetcher_1
|
|
474
|
-
const safeFunctionName = indexedVariableName.replace(/\[(\d+)\]/g, '_$1');
|
|
475
|
-
const mockFunctionName = `${importedExport.name}_${safeFunctionName}`;
|
|
476
690
|
fileContent = fileContent.replace(callRegex, `${mockFunctionName}()`);
|
|
477
691
|
}
|
|
478
692
|
}
|
|
@@ -487,66 +701,104 @@ function addMockToContent(fileContent, importedExport, fileAnalyses, rootAnalysi
|
|
|
487
701
|
? importedExport.callVariableNames[0]
|
|
488
702
|
: undefined;
|
|
489
703
|
if (singleCallVariableName) {
|
|
490
|
-
// For single variable assignments, use the
|
|
491
|
-
|
|
492
|
-
//
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
704
|
+
// For single variable assignments, use the call signature directly from dataForMocks
|
|
705
|
+
const dataForMocks = rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
|
|
706
|
+
// Find matching call signature key in dataForMocks
|
|
707
|
+
const hookBaseName = importedExport.name.split(/[<(]/)[0];
|
|
708
|
+
const callSignatureKey = dataForMocks
|
|
709
|
+
? Object.keys(dataForMocks).find((key) => {
|
|
710
|
+
// Split on ., <, or ( to get the true base name
|
|
711
|
+
// This handles both "useFlags()" -> "useFlags" and "trpc.useUtils()" -> "trpc"
|
|
712
|
+
const keyBaseName = key.split(/[.<(]/)[0];
|
|
713
|
+
return keyBaseName === hookBaseName;
|
|
714
|
+
})
|
|
715
|
+
: undefined;
|
|
716
|
+
// Use the call signature if found, otherwise construct it
|
|
717
|
+
const dataKey = callSignatureKey ??
|
|
718
|
+
importedExport.calls?.[0] ??
|
|
719
|
+
`${importedExport.name}()`;
|
|
720
|
+
// IMPORTANT: If the dataKey is a method chain (e.g., "trpc.useUtils()"), we should
|
|
721
|
+
// use the base name (e.g., "trpc") when calling constructMockCode. This ensures
|
|
722
|
+
// constructMockCode generates a complete nested mock from the schema without
|
|
723
|
+
// referencing __cyOriginal variables.
|
|
724
|
+
const dataKeyBaseName = dataKey.split(/[.<(]/)[0];
|
|
725
|
+
const isMethodChainDataKey = dataKeyBaseName === importedExport.name &&
|
|
726
|
+
dataKey !== importedExport.name &&
|
|
727
|
+
dataKey.includes('.');
|
|
728
|
+
const mockNameToUse = isMethodChainDataKey
|
|
729
|
+
? importedExport.name
|
|
730
|
+
: dataKey;
|
|
731
|
+
// Keep the original function name since there's only one call
|
|
732
|
+
// Check if this is a package import that won't have scenario copies
|
|
733
|
+
const isPackageImportForSingleCall = importPath?.startsWith('@');
|
|
734
|
+
mockCode = constructMockCode(mockNameToUse, dependencySchemas, importedExport.entityType, undefined, {
|
|
735
|
+
keepOriginalFunctionName: true,
|
|
736
|
+
// For node_modules or package imports, skip spreading from __cyOriginal
|
|
737
|
+
// since those packages/files don't export *__cyOriginal variants
|
|
738
|
+
skipOriginalSpread: importedExport.isNodeModule || isPackageImportForSingleCall,
|
|
739
|
+
});
|
|
496
740
|
// If constructMockCode didn't generate code, fall back to simple return
|
|
741
|
+
// IMPORTANT: We inline scenarios().data() inside the function rather than
|
|
742
|
+
// storing in a const - see comment in constructMockCode.ts for why.
|
|
497
743
|
if (!mockCode) {
|
|
498
|
-
mockCode = `
|
|
499
|
-
|
|
500
|
-
function ${importedExport.name}() {
|
|
501
|
-
return ${importedExport.name}ReturnValue;
|
|
744
|
+
mockCode = `function ${importedExport.name}(...args) {
|
|
745
|
+
return scenarios().data()?.["${dataKey}"];
|
|
502
746
|
}`;
|
|
503
747
|
}
|
|
504
748
|
}
|
|
505
749
|
else {
|
|
506
|
-
//
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
750
|
+
// Helper to find matching call signature key from dataForMocks
|
|
751
|
+
const hookBaseName = importedExport.name.split(/[<(]/)[0];
|
|
752
|
+
const findMatchingKey = (dataForMocks) => {
|
|
753
|
+
if (!dataForMocks)
|
|
754
|
+
return undefined;
|
|
755
|
+
return Object.keys(dataForMocks).find((key) => {
|
|
756
|
+
// Split on ., <, or ( to get the true base name
|
|
757
|
+
// This handles both "useFlags()" -> "useFlags" and "trpc.useUtils()" -> "trpc"
|
|
758
|
+
const keyBaseName = key.split(/[.<(]/)[0];
|
|
759
|
+
return keyBaseName === hookBaseName;
|
|
760
|
+
});
|
|
761
|
+
};
|
|
762
|
+
// Check rootAnalysis FIRST for matching keys.
|
|
763
|
+
// The mock DATA is generated from rootAnalysis, so the mock CODE must
|
|
764
|
+
// also use rootAnalysis keys to ensure the lookup succeeds.
|
|
765
|
+
let dataKey = findMatchingKey(rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks);
|
|
766
|
+
// If not found in rootAnalysis, fall back to fileAnalyses
|
|
767
|
+
if (!dataKey) {
|
|
768
|
+
for (const analysis of fileAnalyses) {
|
|
769
|
+
dataKey = findMatchingKey(analysis.metadata?.scenariosDataStructure?.dataForMocks);
|
|
770
|
+
if (dataKey)
|
|
519
771
|
break;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
// If not found in fileAnalyses, fall back to rootAnalysis
|
|
524
|
-
if (!variableQualifiedKey) {
|
|
525
|
-
const dataForMocks = rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
|
|
526
|
-
if (dataForMocks) {
|
|
527
|
-
variableQualifiedKey = Object.keys(dataForMocks).find((key) => {
|
|
528
|
-
const match = key.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*<-\s*(.+)$/);
|
|
529
|
-
return match && match[2] === importedExport.name;
|
|
530
|
-
});
|
|
531
772
|
}
|
|
532
773
|
}
|
|
533
|
-
if
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
774
|
+
// Use the data key if found, otherwise use call signature or function name.
|
|
775
|
+
// IMPORTANT: If the dataKey is a method chain (e.g., "trpc.useUtils()"), we should
|
|
776
|
+
// use the base name (e.g., "trpc") when calling constructMockCode. This ensures
|
|
777
|
+
// constructMockCode generates a complete nested mock from the schema without
|
|
778
|
+
// referencing __cyOriginal variables. The __cyOriginal pattern is only needed
|
|
779
|
+
// for partial mocking where we preserve some original methods, not for complete
|
|
780
|
+
// method-chain mocks where we provide all implementations.
|
|
781
|
+
const dataKeyBaseName = dataKey?.split(/[.<(]/)[0];
|
|
782
|
+
const isMethodChainDataKey = dataKey &&
|
|
783
|
+
dataKeyBaseName === importedExport.name &&
|
|
784
|
+
dataKey !== importedExport.name &&
|
|
785
|
+
dataKey.includes('.');
|
|
786
|
+
const mockNameToUse = isMethodChainDataKey
|
|
787
|
+
? importedExport.name
|
|
788
|
+
: (dataKey ?? importedExport.calls?.[0] ?? `${importedExport.name}()`);
|
|
789
|
+
mockCode = constructMockCode(mockNameToUse, dependencySchemas, importedExport.entityType, undefined, {
|
|
790
|
+
keepOriginalFunctionName: true,
|
|
791
|
+
// For node_modules or package imports, skip spreading from __cyOriginal
|
|
792
|
+
// since those packages/files don't export *__cyOriginal variants
|
|
793
|
+
skipOriginalSpread: importedExport.isNodeModule || importPath?.startsWith('@'),
|
|
794
|
+
});
|
|
795
|
+
// If constructMockCode didn't generate code, fall back to simple return
|
|
796
|
+
// IMPORTANT: We inline scenarios().data() inside the function rather than
|
|
797
|
+
// storing in a const - see comment in constructMockCode.ts for why.
|
|
798
|
+
if (!mockCode && dataKey) {
|
|
799
|
+
mockCode = `function ${importedExport.name}(...args) {
|
|
800
|
+
return scenarios().data()?.["${dataKey}"];
|
|
544
801
|
}`;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
else {
|
|
548
|
-
// Original behavior for calls without variable names
|
|
549
|
-
mockCode = constructMockCode(importedExport.name, dependencySchemas, importedExport.entityType);
|
|
550
802
|
}
|
|
551
803
|
}
|
|
552
804
|
}
|
|
@@ -565,8 +817,31 @@ function ${importedExport.name}() {
|
|
|
565
817
|
else {
|
|
566
818
|
// Escape regex special characters in importPath (e.g., brackets in [environmentId])
|
|
567
819
|
const escapedImportPath = importPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
568
|
-
|
|
569
|
-
|
|
820
|
+
// Use a simpler, more robust regex pattern that matches the fallback path.
|
|
821
|
+
// Key improvements:
|
|
822
|
+
// 1. Uses escapeRegExp(firstPart) to handle special characters in function names
|
|
823
|
+
// 2. Uses word boundaries (\b) to prevent partial matches
|
|
824
|
+
// 3. Handles comma BEFORE or AFTER the name: (?:,\s*|\s*,)?
|
|
825
|
+
// 4. Matches specific import path (escapedImportPath)
|
|
826
|
+
const importRegExp = new RegExp(`(import\\s*\\{[^}]*?)\\b${escapeRegExp(firstPart)}\\b(?:,\\s*|\\s*,)?((?:[^}]*\\}\\s*from\\s*['"]${escapedImportPath}['"];?))`, 'm');
|
|
827
|
+
// Check if any call signature has multiple parts (e.g., "logger.error(error)")
|
|
828
|
+
// If so, the mock code will spread from __cyOriginal, so we need to rename the import
|
|
829
|
+
// EXCEPT:
|
|
830
|
+
// 1. For node_module imports, the __cyOriginal pattern doesn't work because
|
|
831
|
+
// the original package doesn't export *__cyOriginal variants.
|
|
832
|
+
// 2. For package imports (starting with @), the __cyOriginal pattern doesn't work
|
|
833
|
+
// because scenario copies aren't created for package files - they keep the
|
|
834
|
+
// original import path which doesn't export *__cyOriginal.
|
|
835
|
+
const anyCallHasMultipleParts = importedExport.calls?.some((call) => {
|
|
836
|
+
const callParts = splitOutsideParenthesesAndArrays(call);
|
|
837
|
+
return callParts.length > 1;
|
|
838
|
+
});
|
|
839
|
+
// Package imports (starting with @) don't get scenario copies, so __cyOriginal won't exist
|
|
840
|
+
const isPackageImport = importPath.startsWith('@');
|
|
841
|
+
const shouldRenameToOriginal = !importedExport.isNodeModule &&
|
|
842
|
+
!isPackageImport &&
|
|
843
|
+
(importedExportNameParts.length > 1 || anyCallHasMultipleParts);
|
|
844
|
+
if (shouldRenameToOriginal) {
|
|
570
845
|
fileContent = fileContent.replace(importRegExp, `$1${firstPart}__cyOriginal$2`);
|
|
571
846
|
}
|
|
572
847
|
else {
|
|
@@ -587,7 +862,17 @@ function ${importedExport.name}() {
|
|
|
587
862
|
// This handles imports like: import { useEnvironment, otherThing } from "any/path"
|
|
588
863
|
// Removes useEnvironment but keeps otherThing
|
|
589
864
|
const namedImportRegExp = new RegExp(`(import\\s*\\{[^}]*?)\\b${escapeRegExp(firstPart)}\\b(?:,\\s*|\\s*,)?((?:[^}]*\\}\\s*from\\s*['"][^'"]*['"];?))`, 'm');
|
|
590
|
-
if (
|
|
865
|
+
// Check if any call signature has multiple parts (e.g., "logger.error(error)")
|
|
866
|
+
// If so, the mock code will spread from __cyOriginal, so we need to rename the import
|
|
867
|
+
// EXCEPT: For node_module imports, the __cyOriginal pattern doesn't work because
|
|
868
|
+
// the original package doesn't export *__cyOriginal variants.
|
|
869
|
+
const anyCallHasMultipleParts = importedExport.calls?.some((call) => {
|
|
870
|
+
const callParts = splitOutsideParenthesesAndArrays(call);
|
|
871
|
+
return callParts.length > 1;
|
|
872
|
+
});
|
|
873
|
+
const shouldRenameToOriginal = !importedExport.isNodeModule &&
|
|
874
|
+
(importedExportNameParts.length > 1 || anyCallHasMultipleParts);
|
|
875
|
+
if (shouldRenameToOriginal) {
|
|
591
876
|
// Rename the import instead of removing (for destructured access patterns)
|
|
592
877
|
fileContent = fileContent.replace(namedImportRegExp, `$1${firstPart}__cyOriginal$2`);
|
|
593
878
|
}
|
|
@@ -764,6 +1049,14 @@ function captureArgumentsForTesting(args) {
|
|
|
764
1049
|
}
|
|
765
1050
|
export default async function writeScenarioComponents({ project, file, entity, rootAnalysis, scenario, context, projectAnalyzer, framework, mocksDir, rootFile, namespaceMocks, writtenScenarioComponents = {}, fileStore, exportAsNamed, }) {
|
|
766
1051
|
var _a;
|
|
1052
|
+
// Reset debug timing for this invocation
|
|
1053
|
+
resetDebugTiming();
|
|
1054
|
+
debugLog('START writeScenarioComponents', {
|
|
1055
|
+
filePath: file.path,
|
|
1056
|
+
entityName: entity.name,
|
|
1057
|
+
scenarioName: scenario.name,
|
|
1058
|
+
isRootFile: !rootFile || rootFile === file,
|
|
1059
|
+
});
|
|
767
1060
|
// Capture arguments for testing if debug mode is enabled
|
|
768
1061
|
captureArgumentsForTesting({
|
|
769
1062
|
project,
|
|
@@ -907,7 +1200,23 @@ export default async function writeScenarioComponents({ project, file, entity, r
|
|
|
907
1200
|
return 1;
|
|
908
1201
|
return 0;
|
|
909
1202
|
});
|
|
1203
|
+
debugLog('Starting main importedExports loop', {
|
|
1204
|
+
count: sortedImportedExports.length,
|
|
1205
|
+
fileContentLength: fileContent.length,
|
|
1206
|
+
});
|
|
1207
|
+
let importedExportIndex = 0;
|
|
1208
|
+
const loopStartTime = Date.now();
|
|
1209
|
+
console.log(`[WriteScenario] Starting import loop for ${entity.name}: ${sortedImportedExports.length} imports`);
|
|
910
1210
|
for (const importedExport of sortedImportedExports) {
|
|
1211
|
+
importedExportIndex++;
|
|
1212
|
+
if (importedExportIndex % 5 === 0 || importedExportIndex === 1) {
|
|
1213
|
+
console.log(`[WriteScenario] ${entity.name} import ${importedExportIndex}/${sortedImportedExports.length}: ${importedExport.name} elapsed=${Date.now() - loopStartTime}ms`);
|
|
1214
|
+
debugLog(`Processing importedExport ${importedExportIndex}/${sortedImportedExports.length}`, {
|
|
1215
|
+
name: importedExport.name,
|
|
1216
|
+
filePath: importedExport.filePath,
|
|
1217
|
+
isMocked: importedExport.isMocked,
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
911
1220
|
// IMPORTANT: The import mapping keys may be either absolute or relative paths
|
|
912
1221
|
// depending on how they were created by the file analyzer. We try multiple formats.
|
|
913
1222
|
// Also need to normalize paths to handle /tmp vs /private/tmp on macOS
|
|
@@ -1034,7 +1343,13 @@ export default async function writeScenarioComponents({ project, file, entity, r
|
|
|
1034
1343
|
// e.g., if file has `export default X` but parent does `import { X } from '...'`
|
|
1035
1344
|
const needsNamedReExport = importedExport.resolvedIsDefault === true &&
|
|
1036
1345
|
importedExport.isDefault === false;
|
|
1037
|
-
|
|
1346
|
+
console.log(`[WriteScenario] RECURSE START: ${entity.name} -> ${importedExportEntity.name}`);
|
|
1347
|
+
const recurseStartTime = Date.now();
|
|
1348
|
+
debugLog(`Recursing into writeScenarioComponents for ${importedExportEntity.name}`, {
|
|
1349
|
+
entityName: importedExportEntity.name,
|
|
1350
|
+
filePath: fileNotMocked.path,
|
|
1351
|
+
});
|
|
1352
|
+
const { scenarioComponentPaths: newScenarioComponentPaths, writtenScenarioComponents: updatedWrittenScenarioComponents, } = await withTimeout(`recursive writeScenarioComponents for ${importedExportEntity.name}`, writeScenarioComponents({
|
|
1038
1353
|
project,
|
|
1039
1354
|
file: fileNotMocked,
|
|
1040
1355
|
entity: importedExportEntity,
|
|
@@ -1052,7 +1367,9 @@ export default async function writeScenarioComponents({ project, file, entity, r
|
|
|
1052
1367
|
exportAsNamed: needsNamedReExport
|
|
1053
1368
|
? importedExport.name
|
|
1054
1369
|
: undefined,
|
|
1055
|
-
});
|
|
1370
|
+
}), 180000);
|
|
1371
|
+
console.log(`[WriteScenario] RECURSE END: ${entity.name} -> ${importedExportEntity.name} took ${Date.now() - recurseStartTime}ms`);
|
|
1372
|
+
debugLog(`Completed recursive writeScenarioComponents for ${importedExportEntity.name}`);
|
|
1056
1373
|
writtenScenarioComponents = updatedWrittenScenarioComponents;
|
|
1057
1374
|
scenarioComponentPaths.push(...newScenarioComponentPaths);
|
|
1058
1375
|
}
|
|
@@ -1286,9 +1603,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1286
1603
|
: `import { ${entityImportName} } from '${path}';`;
|
|
1287
1604
|
// First, try to remove this entity from the already-rewritten grouped import
|
|
1288
1605
|
// This prevents duplicate/conflicting imports
|
|
1289
|
-
//
|
|
1290
|
-
// The global patterns used previously would also match type annotations like:
|
|
1291
|
-
// "param: MyType," in function signatures, corrupting the syntax.
|
|
1606
|
+
// Use AST-based removal to properly handle type-only imports like `type EntityName`
|
|
1292
1607
|
const escapedEntityName = escapeRegExp(entityImportName);
|
|
1293
1608
|
// For default imports: remove "DefaultName, " from "import DefaultName, { ... }"
|
|
1294
1609
|
// This handles the case where a default export is being split out
|
|
@@ -1296,27 +1611,12 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1296
1611
|
const defaultImportPattern = new RegExp(`(import\\s+)${escapedEntityName}\\s*,\\s*(\\{)`, 'gm');
|
|
1297
1612
|
fileContent = fileContent.replace(defaultImportPattern, '$1$2');
|
|
1298
1613
|
}
|
|
1299
|
-
//
|
|
1300
|
-
//
|
|
1301
|
-
//
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
let cleaned = namedImports
|
|
1306
|
-
.replace(new RegExp(`\\b${escapedEntityName}\\s*,\\s*`), '') // "EntityName, "
|
|
1307
|
-
.replace(new RegExp(`\\s*,\\s*${escapedEntityName}\\b`), '') // ", EntityName"
|
|
1308
|
-
.replace(new RegExp(`\\b${escapedEntityName}\\b`), ''); // "EntityName" (only one)
|
|
1309
|
-
// Clean up any double commas or leading/trailing commas
|
|
1310
|
-
cleaned = cleaned
|
|
1311
|
-
.replace(/,\s*,/g, ',')
|
|
1312
|
-
.replace(/^\s*,\s*/, '')
|
|
1313
|
-
.replace(/\s*,\s*$/, '');
|
|
1314
|
-
// If no imports left, remove the entire import statement
|
|
1315
|
-
if (cleaned.trim() === '') {
|
|
1316
|
-
return '';
|
|
1317
|
-
}
|
|
1318
|
-
return prefix + cleaned + suffix;
|
|
1319
|
-
});
|
|
1614
|
+
// Remove the named import using AST parsing
|
|
1615
|
+
// This properly handles:
|
|
1616
|
+
// - Regular imports: `import { EntityName } from '...'`
|
|
1617
|
+
// - Type-only imports: `import { type EntityName } from '...'`
|
|
1618
|
+
// - Mixed imports: `import { type EntityName, OtherName } from '...'`
|
|
1619
|
+
fileContent = removeNamedImportAst(fileContent, entityImportName);
|
|
1320
1620
|
// Add the new import at the beginning of fileContent
|
|
1321
1621
|
// Note: The header comment (// Scenario:) doesn't exist yet - it's prepended at writeFile time
|
|
1322
1622
|
// So prepending here puts the import right after the header in the final output
|
|
@@ -1330,17 +1630,30 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1330
1630
|
}
|
|
1331
1631
|
}
|
|
1332
1632
|
}
|
|
1633
|
+
// Track post-import-loop timing
|
|
1634
|
+
const postLoopStartTime = Date.now();
|
|
1635
|
+
console.log(`[WriteScenario] POST-LOOP START: ${entity.name}`);
|
|
1636
|
+
// Collect universal mocks BEFORE processing nodeModuleImports
|
|
1637
|
+
// This is needed to check if a node module import is handled by a universal mock
|
|
1638
|
+
const universalMocks = project.metadata?.universalMocks ?? [];
|
|
1639
|
+
const nodeModuleUniversalMocks = universalMocks.filter((mock) => mock.nodeModule && mock.content);
|
|
1640
|
+
// Create a set of import paths that have universal mocks for quick lookup
|
|
1641
|
+
const universalMockPaths = new Set(nodeModuleUniversalMocks.map((mock) => mock.filePath));
|
|
1333
1642
|
for (const nodeModuleImport of nodeModuleImports) {
|
|
1334
1643
|
if (!nodeModuleImport.isMocked)
|
|
1335
1644
|
continue;
|
|
1645
|
+
// Skip generating local mock functions for imports that have universal mocks.
|
|
1646
|
+
// Universal mocks provide the exports via rewritten import paths (handled below).
|
|
1647
|
+
// Generating a local mock function would cause "name defined multiple times" errors.
|
|
1648
|
+
if (universalMockPaths.has(nodeModuleImport.filePath)) {
|
|
1649
|
+
continue;
|
|
1650
|
+
}
|
|
1336
1651
|
fileContent = addMockToContent(fileContent, nodeModuleImport, fileAnalyses, rootAnalysis, relativeMocksDir, scenario.name, importMapping[nodeModuleImport.filePath] ?? nodeModuleImport.filePath);
|
|
1337
1652
|
}
|
|
1338
1653
|
// Rewrite node_module imports that have universal mocks
|
|
1339
1654
|
// Universal mocks create mock files at __codeyamMocks__/{safeFileName}.tsx
|
|
1340
1655
|
// We need to rewrite imports like `import { logger } from "@formbricks/logger"`
|
|
1341
1656
|
// to `import { logger } from "../__codeyamMocks__/_formbricks_logger.js"`
|
|
1342
|
-
const universalMocks = project.metadata?.universalMocks ?? [];
|
|
1343
|
-
const nodeModuleUniversalMocks = universalMocks.filter((mock) => mock.nodeModule && mock.content);
|
|
1344
1657
|
for (const universalMock of nodeModuleUniversalMocks) {
|
|
1345
1658
|
const originalPath = universalMock.filePath;
|
|
1346
1659
|
// Create the mock file name using the same safeFileName function as writeUniversalMocks
|
|
@@ -1353,6 +1666,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1353
1666
|
const importRegex = new RegExp(`(import\\s+(?:\\{[^}]*\\}|\\*\\s+as\\s+\\w+|\\w+)\\s+from\\s+)['"]${originalPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`, 'g');
|
|
1354
1667
|
fileContent = fileContent.replace(importRegex, `$1'${mockFileRelativePath}'`);
|
|
1355
1668
|
}
|
|
1669
|
+
console.log(`[WriteScenario] POST-LOOP ${entity.name}: node+universal mocks took ${Date.now() - postLoopStartTime}ms`);
|
|
1356
1670
|
if (rootAnalysis.entitySha === entity.sha &&
|
|
1357
1671
|
entity.metadata?.notExported &&
|
|
1358
1672
|
entity.name !== 'default') {
|
|
@@ -1388,20 +1702,31 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1388
1702
|
scenario,
|
|
1389
1703
|
});
|
|
1390
1704
|
}
|
|
1705
|
+
debugLog('Route path computed', { scenarioComponentPath });
|
|
1391
1706
|
// Strip <html> and <body> tags from root layout files for Next.js
|
|
1392
1707
|
// These tags cause hydration errors when the scenario layout is nested under the real root
|
|
1708
|
+
debugLog('Starting stripHtmlBodyTags');
|
|
1393
1709
|
fileContent = stripHtmlBodyTags(fileContent, file.path, framework);
|
|
1710
|
+
debugLog('Completed stripHtmlBodyTags');
|
|
1394
1711
|
// Strip "server-only" imports for Next.js
|
|
1395
1712
|
// These cause errors when the scenario component is rendered client-side
|
|
1713
|
+
debugLog('Starting stripServerOnlyImport');
|
|
1396
1714
|
fileContent = stripServerOnlyImport(fileContent);
|
|
1715
|
+
debugLog('Starting applyServerOnlyMocks');
|
|
1397
1716
|
fileContent = applyServerOnlyMocks(fileContent);
|
|
1717
|
+
debugLog('Completed server-only processing');
|
|
1398
1718
|
// Rewrite asset imports (CSS, images, fonts, etc.) to correct relative paths
|
|
1399
1719
|
// The original file path is relative to PROJECT_RELATIVE_PATH, the new path is scenarioComponentPath
|
|
1720
|
+
debugLog('Starting rewriteAssetImports');
|
|
1400
1721
|
fileContent = rewriteAssetImports(fileContent, `${PROJECT_RELATIVE_PATH}/${file.path}`, scenarioComponentPath);
|
|
1722
|
+
debugLog('Completed rewriteAssetImports');
|
|
1401
1723
|
// Rewrite relative TypeScript/JavaScript module imports to correct relative paths
|
|
1402
1724
|
// This handles cases where the file is moved (e.g., from [environmentId]/ to _environmentId_/)
|
|
1403
1725
|
// and relative imports like "./lib/organization" need to be rewritten
|
|
1726
|
+
debugLog('Starting rewriteRelativeModuleImports');
|
|
1404
1727
|
fileContent = rewriteRelativeModuleImports(fileContent, `${PROJECT_RELATIVE_PATH}/${file.path}`, scenarioComponentPath);
|
|
1728
|
+
debugLog('Completed rewriteRelativeModuleImports');
|
|
1729
|
+
console.log(`[WriteScenario] POST-LOOP ${entity.name}: transformations took ${Date.now() - postLoopStartTime}ms`);
|
|
1405
1730
|
/**
|
|
1406
1731
|
* Recursively process a file's imports to create transitive copies with server-only stripped.
|
|
1407
1732
|
* This handles chains of arbitrary depth: A -> B -> C -> D where each needs server-only removed.
|
|
@@ -1413,24 +1738,56 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1413
1738
|
* @param visitedPaths - Set of file paths currently being processed (for cycle detection)
|
|
1414
1739
|
* @returns The modified content with imports rewritten to point to transitive copies
|
|
1415
1740
|
*/
|
|
1416
|
-
async function processTransitiveImportsRecursively(content, sourceFilePath, targetFilePath, visitedPaths = new Set()) {
|
|
1741
|
+
async function processTransitiveImportsRecursively(content, sourceFilePath, targetFilePath, visitedPaths = new Set(), depth = 0, startTime = Date.now()) {
|
|
1742
|
+
// Global timeout for entire transitive processing
|
|
1743
|
+
const GLOBAL_TIMEOUT_MS = 180000; // 3 minutes max for all transitive processing (complex components need more time)
|
|
1744
|
+
const elapsed = Date.now() - startTime;
|
|
1745
|
+
if (elapsed > GLOBAL_TIMEOUT_MS) {
|
|
1746
|
+
throw new Error(`processTransitiveImportsRecursively exceeded ${GLOBAL_TIMEOUT_MS}ms (elapsed: ${elapsed}ms) at depth=${depth} for ${sourceFilePath}`);
|
|
1747
|
+
}
|
|
1417
1748
|
const importPaths = extractInternalImportPaths(content);
|
|
1749
|
+
// Always log to help debug timeout issues
|
|
1750
|
+
console.log(`[TransitiveImports] depth=${depth} file=${path.basename(sourceFilePath)} imports=${importPaths.length} visited=${visitedPaths.size} elapsed=${Date.now() - startTime}ms`);
|
|
1751
|
+
debugLog(`processTransitiveImportsRecursively depth=${depth}`, {
|
|
1752
|
+
sourceFilePath,
|
|
1753
|
+
importCount: importPaths.length,
|
|
1754
|
+
visitedCount: visitedPaths.size,
|
|
1755
|
+
});
|
|
1418
1756
|
let modifiedContent = content;
|
|
1419
|
-
|
|
1757
|
+
// Safety check: limit iterations to prevent infinite loops
|
|
1758
|
+
const MAX_IMPORTS_PER_FILE = 100;
|
|
1759
|
+
if (importPaths.length > MAX_IMPORTS_PER_FILE) {
|
|
1760
|
+
console.warn(`[WriteScenario] WARNING: File ${sourceFilePath} has ${importPaths.length} imports (> ${MAX_IMPORTS_PER_FILE}), limiting processing`);
|
|
1761
|
+
}
|
|
1762
|
+
let importIndex = 0;
|
|
1763
|
+
debugLog(`Starting import loop at depth=${depth}, ${importPaths.length} imports to process`);
|
|
1764
|
+
const slicedImports = importPaths.slice(0, MAX_IMPORTS_PER_FILE);
|
|
1765
|
+
for (const importPath of slicedImports) {
|
|
1766
|
+
if (!importPath) {
|
|
1767
|
+
continue;
|
|
1768
|
+
}
|
|
1769
|
+
importIndex++;
|
|
1770
|
+
debugLog(`[LOOP] depth=${depth} import ${importIndex}/${Math.min(importPaths.length, MAX_IMPORTS_PER_FILE)}: ${importPath}`);
|
|
1771
|
+
debugLog(`[LOOP] Calling resolveImportPath...`);
|
|
1420
1772
|
const resolvedPath = resolveImportPath(importPath, sourceFilePath, project);
|
|
1773
|
+
debugLog(`[LOOP] resolveImportPath returned: ${resolvedPath?.slice(0, 80) ?? 'null'}`);
|
|
1421
1774
|
if (!resolvedPath)
|
|
1422
1775
|
continue;
|
|
1776
|
+
debugLog(`[LOOP] Looking up importFile...`);
|
|
1423
1777
|
let importFile = fileStore
|
|
1424
1778
|
? fileStore.getByPath(resolvedPath)
|
|
1425
1779
|
: project.files?.find((f) => f.path === resolvedPath);
|
|
1780
|
+
debugLog(`[LOOP] importFile lookup result: ${importFile ? 'found' : 'not found'}`);
|
|
1426
1781
|
if (!importFile)
|
|
1427
1782
|
continue;
|
|
1428
1783
|
// Build the transitive file path (needed for import rewriting even if we skip creating)
|
|
1429
1784
|
const basePath = safeFolder(importFile.path.split('/').slice(0, -1).join('/'));
|
|
1430
1785
|
const extension = importFile.name.split('.').pop();
|
|
1431
1786
|
const isIndex = isIndexPath(importFile.path);
|
|
1432
|
-
|
|
1433
|
-
const
|
|
1787
|
+
// Limit pathHash length to prevent ENAMETOOLONG errors on macOS (255 char limit)
|
|
1788
|
+
const pathHash = safeFileName(importFile.path, { maxLength: 80 });
|
|
1789
|
+
const scenarioSlug = safeFileName(scenario.name, { maxLength: 60 });
|
|
1790
|
+
const transitiveFilePath = `${PROJECT_RELATIVE_PATH}/${basePath}/${pathHash}_${isIndex ? 'index_' : ''}transitive_${scenarioSlug}.${extension}`;
|
|
1434
1791
|
// Check if this is a circular import (we're already processing this file)
|
|
1435
1792
|
const isCircularImport = visitedPaths.has(resolvedPath);
|
|
1436
1793
|
// Check if already processed
|
|
@@ -1450,8 +1807,17 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1450
1807
|
// Strip server-only and mock server-only packages, then recursively process imports
|
|
1451
1808
|
let transitiveContent = stripServerOnlyImport(importFile.content);
|
|
1452
1809
|
transitiveContent = applyServerOnlyMocks(transitiveContent);
|
|
1453
|
-
|
|
1810
|
+
debugLog(`processTransitiveImportsRecursively depth=${depth} for ${importFile.path}`);
|
|
1811
|
+
debugLog(`Calling processTransitiveImportsRecursively depth=${depth + 1} for ${importFile.path}`);
|
|
1812
|
+
transitiveContent = await withTimeout(`processTransitiveImportsRecursively depth=${depth} for ${path.basename(importFile.path)}`, processTransitiveImportsRecursively(transitiveContent, importFile.path, transitiveFilePath, visitedPaths, depth + 1, startTime), 30000);
|
|
1813
|
+
debugLog(`withTimeout returned for depth=${depth}, transitiveContent length=${transitiveContent.length}`);
|
|
1814
|
+
debugLog(`Completed processTransitiveImportsRecursively depth=${depth} for ${importFile.path}`);
|
|
1815
|
+
debugLog(`Writing transitive file depth=${depth}`, {
|
|
1816
|
+
transitiveFilePath: path.basename(transitiveFilePath),
|
|
1817
|
+
contentLength: transitiveContent.length,
|
|
1818
|
+
});
|
|
1454
1819
|
await writeFile(transitiveFilePath, transitiveContent);
|
|
1820
|
+
debugLog(`Wrote transitive file depth=${depth}`);
|
|
1455
1821
|
scenarioComponentPaths.push(transitiveFilePath);
|
|
1456
1822
|
if (!writtenScenarioComponents[resolvedPath]) {
|
|
1457
1823
|
writtenScenarioComponents[resolvedPath] = [];
|
|
@@ -1461,22 +1827,64 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1461
1827
|
}
|
|
1462
1828
|
// ALWAYS rewrite the import to point to the transitive copy
|
|
1463
1829
|
// (even for circular imports or already-processed files)
|
|
1830
|
+
debugLog(`Rewriting import path depth=${depth}`, {
|
|
1831
|
+
importPath,
|
|
1832
|
+
resolvedPath,
|
|
1833
|
+
});
|
|
1464
1834
|
const relativePath = getRelativePath(targetFilePath, transitiveFilePath);
|
|
1465
1835
|
const relativePathWithoutExt = relativePath.replace(/\.(ts|tsx|js|jsx)$/, '');
|
|
1466
1836
|
const safeRelativePath = safeFolder(relativePathWithoutExt);
|
|
1467
1837
|
const escapedImportPath = importPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1468
|
-
|
|
1469
|
-
|
|
1838
|
+
debugLog(`Applying regex depth=${depth}`, {
|
|
1839
|
+
escapedImportPath,
|
|
1840
|
+
contentLength: modifiedContent.length,
|
|
1841
|
+
});
|
|
1842
|
+
// Quick check if the import path even exists in content
|
|
1843
|
+
const simpleCheck = modifiedContent.includes(importPath);
|
|
1844
|
+
debugLog(`Simple check: importPath "${importPath}" exists: ${simpleCheck}`);
|
|
1845
|
+
if (!simpleCheck) {
|
|
1846
|
+
debugLog(`Skipping regex - import path not found in content`);
|
|
1847
|
+
}
|
|
1848
|
+
else {
|
|
1849
|
+
const regexPattern = `(from\\s*["'])${escapedImportPath}(["'])`;
|
|
1850
|
+
debugLog(`Regex pattern: ${regexPattern.slice(0, 100)}`);
|
|
1851
|
+
const importRegex = new RegExp(regexPattern, 'g');
|
|
1852
|
+
debugLog(`About to call replace...`);
|
|
1853
|
+
// Timing for regex replace to detect slow operations
|
|
1854
|
+
const replaceStart = Date.now();
|
|
1855
|
+
modifiedContent = modifiedContent.replace(importRegex, `$1${safeRelativePath}$2`);
|
|
1856
|
+
const replaceTime = Date.now() - replaceStart;
|
|
1857
|
+
if (replaceTime > 100) {
|
|
1858
|
+
console.warn(`[WriteScenario] SLOW regex replace: ${replaceTime}ms for pattern ${regexPattern.slice(0, 50)} on ${modifiedContent.length} bytes`);
|
|
1859
|
+
}
|
|
1860
|
+
debugLog(`Regex applied depth=${depth} in ${replaceTime}ms`);
|
|
1861
|
+
}
|
|
1862
|
+
debugLog(`[LOOP END] depth=${depth} import ${importIndex} completed`);
|
|
1470
1863
|
}
|
|
1864
|
+
debugLog(`[LOOP DONE] Exiting import loop at depth=${depth}`);
|
|
1865
|
+
debugLog(`Returning from processTransitiveImportsRecursively depth=${depth}`);
|
|
1471
1866
|
return modifiedContent;
|
|
1472
1867
|
}
|
|
1868
|
+
console.log(`[WriteScenario] POST-LOOP ${entity.name}: before remaining imports ${Date.now() - postLoopStartTime}ms`);
|
|
1473
1869
|
// Process remaining internal imports that weren't in importedExports
|
|
1474
1870
|
// This handles transitive dependencies: when the file content includes code (e.g., from
|
|
1475
1871
|
// other functions in the same file) that imports from files with "server-only"
|
|
1872
|
+
debugLog('Extracting remaining import paths');
|
|
1476
1873
|
const remainingImportPaths = extractInternalImportPaths(fileContent);
|
|
1874
|
+
debugLog('Found remaining import paths', {
|
|
1875
|
+
count: remainingImportPaths.length,
|
|
1876
|
+
});
|
|
1477
1877
|
// Get all file paths that are in importedExports - these are handled by main processing
|
|
1478
1878
|
const importedExportFilePaths = new Set(allImportedExports.map((ie) => ie.resolvedFilePath || ie.filePath));
|
|
1879
|
+
debugLog('Starting remaining imports loop', {
|
|
1880
|
+
remainingCount: remainingImportPaths.length,
|
|
1881
|
+
importedExportCount: importedExportFilePaths.size,
|
|
1882
|
+
});
|
|
1883
|
+
let remainingImportIndex = 0;
|
|
1884
|
+
debugLog(`[REMAINING] Starting remaining imports loop, ${remainingImportPaths.length} imports`);
|
|
1479
1885
|
for (const importPath of remainingImportPaths) {
|
|
1886
|
+
remainingImportIndex++;
|
|
1887
|
+
debugLog(`[REMAINING LOOP] import ${remainingImportIndex}/${remainingImportPaths.length}: ${importPath}`);
|
|
1480
1888
|
// Resolve the import path to a project file path
|
|
1481
1889
|
const resolvedFilePath = resolveImportPath(importPath, file.path, project);
|
|
1482
1890
|
if (!resolvedFilePath) {
|
|
@@ -1515,8 +1923,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1515
1923
|
const targetFileBasePath = safeFolder(targetFile.path.split('/').slice(0, -1).join('/'));
|
|
1516
1924
|
const targetFileExtension = targetFile.name.split('.').pop();
|
|
1517
1925
|
const targetFileIsIndex = isIndexPath(targetFile.path);
|
|
1518
|
-
|
|
1519
|
-
const
|
|
1926
|
+
// Limit path hash length to prevent ENAMETOOLONG errors
|
|
1927
|
+
const filePathHash = safeFileName(targetFile.path, { maxLength: 80 });
|
|
1928
|
+
const targetScenarioSlug = safeFileName(scenario.name, { maxLength: 60 });
|
|
1929
|
+
const transformedFilePath = `${PROJECT_RELATIVE_PATH}/${targetFileBasePath}/${filePathHash}_${targetFileIsIndex ? 'index_' : ''}transitive_${targetScenarioSlug}.${targetFileExtension}`;
|
|
1520
1930
|
// Check if we've already processed this file as a transitive copy
|
|
1521
1931
|
// Note: __data_file_written__ is for entity-specific scenario files with different naming,
|
|
1522
1932
|
// but we still need transitive copies for server-only stripping. Data entity files may
|
|
@@ -1537,7 +1947,11 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1537
1947
|
// Recursively process this transitive file's imports
|
|
1538
1948
|
// This handles the nested case: service.ts → brevo.ts → constants.ts
|
|
1539
1949
|
const nestedImportPaths = extractInternalImportPaths(transformedContent);
|
|
1950
|
+
debugLog(`[NESTED] Processing ${nestedImportPaths.length} nested imports for ${targetFile.path}`);
|
|
1951
|
+
let nestedIndex = 0;
|
|
1540
1952
|
for (const nestedImportPath of nestedImportPaths) {
|
|
1953
|
+
nestedIndex++;
|
|
1954
|
+
debugLog(`[NESTED LOOP] import ${nestedIndex}/${nestedImportPaths.length}: ${nestedImportPath}`);
|
|
1541
1955
|
const nestedResolvedPath = resolveImportPath(nestedImportPath, targetFile.path, project);
|
|
1542
1956
|
if (!nestedResolvedPath)
|
|
1543
1957
|
continue;
|
|
@@ -1551,8 +1965,12 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1551
1965
|
const nestedBasePath = safeFolder(nestedFile.path.split('/').slice(0, -1).join('/'));
|
|
1552
1966
|
const nestedExtension = nestedFile.name.split('.').pop();
|
|
1553
1967
|
const nestedIsIndex = isIndexPath(nestedFile.path);
|
|
1554
|
-
|
|
1555
|
-
const
|
|
1968
|
+
// Limit path hash length to prevent ENAMETOOLONG errors
|
|
1969
|
+
const nestedPathHash = safeFileName(nestedFile.path, { maxLength: 80 });
|
|
1970
|
+
const nestedScenarioSlug = safeFileName(scenario.name, {
|
|
1971
|
+
maxLength: 60,
|
|
1972
|
+
});
|
|
1973
|
+
const nestedTransformedPath = `${PROJECT_RELATIVE_PATH}/${nestedBasePath}/${nestedPathHash}_${nestedIsIndex ? 'index_' : ''}transitive_${nestedScenarioSlug}.${nestedExtension}`;
|
|
1556
1974
|
// Check if already processed as a transitive file (we can rewrite to point to it)
|
|
1557
1975
|
// Note: __data_file_written__ is for entity-specific scenario files with different naming,
|
|
1558
1976
|
// but we still need transitive copies for server-only stripping in the import chain
|
|
@@ -1568,7 +1986,9 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1568
1986
|
// This handles chains of any depth: A -> B -> C -> D
|
|
1569
1987
|
let nestedContent = stripServerOnlyImport(nestedFile.content);
|
|
1570
1988
|
nestedContent = applyServerOnlyMocks(nestedContent);
|
|
1571
|
-
|
|
1989
|
+
debugLog(`processTransitiveImportsRecursively (nested) for ${nestedFile.path}`);
|
|
1990
|
+
nestedContent = await withTimeout(`processTransitiveImportsRecursively (nested) for ${path.basename(nestedFile.path)}`, processTransitiveImportsRecursively(nestedContent, nestedFile.path, nestedTransformedPath), 30000);
|
|
1991
|
+
debugLog(`Completed processTransitiveImportsRecursively (nested) for ${nestedFile.path}`);
|
|
1572
1992
|
await writeFile(nestedTransformedPath, nestedContent);
|
|
1573
1993
|
scenarioComponentPaths.push(nestedTransformedPath);
|
|
1574
1994
|
// Mark as written
|
|
@@ -1616,6 +2036,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1616
2036
|
const importRegex = new RegExp(`(from\\s*["'])${escapedImportPath}(["'])`, 'g');
|
|
1617
2037
|
fileContent = fileContent.replace(importRegex, `$1${safeRelativePath}$2`);
|
|
1618
2038
|
}
|
|
2039
|
+
console.log(`[WriteScenario] POST-LOOP ${entity.name}: remaining imports loop took ${Date.now() - postLoopStartTime}ms`);
|
|
1619
2040
|
const scenarioComponentComment = `// This file is auto-generated by CodeYam. Do not edit this file manually.
|
|
1620
2041
|
// This file contains content for a scenario component:
|
|
1621
2042
|
// Analyses being written: ${JSON.stringify(fileAnalyses?.map((a) => ({ id: a.id, entityName: a.entityName })))}
|
|
@@ -1639,8 +2060,14 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1639
2060
|
else {
|
|
1640
2061
|
finalContent = `${scenarioComponentComment}\n\n${fileContent}`;
|
|
1641
2062
|
}
|
|
2063
|
+
debugLog('About to write final scenario file', {
|
|
2064
|
+
scenarioComponentPath,
|
|
2065
|
+
contentLength: finalContent.length,
|
|
2066
|
+
});
|
|
1642
2067
|
await writeFile(scenarioComponentPath, finalContent);
|
|
2068
|
+
debugLog('Successfully wrote scenario file');
|
|
1643
2069
|
scenarioComponentPaths.push(scenarioComponentPath);
|
|
2070
|
+
console.log(`[WriteScenario] POST-LOOP ${entity.name}: COMPLETE total=${Date.now() - postLoopStartTime}ms`);
|
|
1644
2071
|
return { scenarioComponentPaths, writtenScenarioComponents };
|
|
1645
2072
|
}
|
|
1646
2073
|
//# sourceMappingURL=writeScenarioComponents.js.map
|