@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.62d4615
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 +16 -12
- package/analyzer-template/packages/ai/index.ts +20 -5
- package/analyzer-template/packages/ai/package.json +3 -3
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +214 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +205 -10
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- 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 +1518 -125
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +318 -5
- 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 +2301 -348
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +7 -2
- 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/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +93 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +422 -86
- 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 +63 -2
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1394 -92
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +578 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2267 -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 +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
- 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 +824 -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 +127 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- 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/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +522 -272
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +34 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- 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/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -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 +625 -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 +550 -137
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -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 +917 -130
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- 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/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +12 -5
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- 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.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +10 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- 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/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.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/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.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/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.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/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.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/ProjectMetadata.d.ts +3 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.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 +199 -3
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.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/package.json +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/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- 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/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.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/ProjectMetadata.d.ts +3 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.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 +199 -3
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.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 +57 -26
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- 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 +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1268 -167
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +81 -9
- 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 +61 -15
- package/analyzer-template/project/startScenarioCapture.ts +79 -41
- package/analyzer-template/project/writeMockDataTsx.ts +405 -65
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +862 -183
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +31 -23
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- 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 +7 -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 +7 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +1126 -126
- 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/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.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/loadReadyToBeCaptured.js +19 -8
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.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/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.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 +73 -36
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +65 -10
- 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 +53 -15
- 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 +354 -54
- 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 +624 -127
- 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 +31 -21
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +9 -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 +42 -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/memory.js +264 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- 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 +29 -15
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +18 -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 +76 -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 +249 -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/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +128 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +285 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +83 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +96 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +33 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +6 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +78 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- 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 +104 -3
- 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/CopyButton-CA3JxPb7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-B86KKU7e.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BqY8gDAW.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-ClaLpuOo.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-BDhPilK7.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-VeqEBv9v.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-Bs7Nn1Jr.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-Bm3PmcCz.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-C6PKeMYR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-Gq3Ocjo6.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BNLaXBHR.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-B3TDXxnk.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DD1r_QU0.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DfKzxuoe.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-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.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-TJp6ofnp.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-JE9ZIoBl.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-CXhHQYrI.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-Ca9fAY46.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-C5lqplTC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-n38keI1k.js +23 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DGgZjdFg.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-38yPijoD.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-BSHEfydn.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-DCPhhSMo.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-Dk8wkAS7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-DXnyr8uP.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-Bh6jH0cL.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-CcsFv748.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-ChN9-fAY.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-BUvfJMNR.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-CTqLEAGU.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-d4e77269.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-DCHBwHou.js +76 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-D6oziHts.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-B8VUL8nl.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-B2X7lJgQ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CPoAg7Zo.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BZz2NjYa.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DNwUduNu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CpZgwliL.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-Bv9JFvUO.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-C0KrUQp-.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-C2h1v1XD.js +260 -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-memory-hook.sh +199 -0
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
- package/codeyam-cli/templates/codeyam:diagnose.md +803 -0
- package/codeyam-cli/templates/codeyam:memory.md +404 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +13 -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/codeyam-cli/templates/rule-notification-hook.py +54 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +428 -0
- package/codeyam-cli/templates/rules-instructions.md +123 -0
- package/package.json +22 -19
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +167 -13
- 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 +154 -9
- 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 +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.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 +1157 -103
- 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 +1816 -216
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +7 -2
- 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/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +83 -1
- 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/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +355 -77
- 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 +50 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1109 -85
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +400 -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 +1646 -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 +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +88 -46
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
- 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 +677 -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 +98 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.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/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +268 -52
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +24 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.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/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- 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/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.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/getImportedExports.js +11 -7
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -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 +483 -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 +404 -85
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -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 +768 -117
- 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/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- 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 +10 -3
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- 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/loadAnalyses.js +45 -2
- package/packages/database/src/lib/loadAnalyses.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.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/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.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
|
@@ -27,6 +27,67 @@ import ts from 'typescript';
|
|
|
27
27
|
import { LazyFileStore } from './LazyFileStore';
|
|
28
28
|
import { applyServerOnlyMocks } from './serverOnlyModules';
|
|
29
29
|
|
|
30
|
+
// Debug timing helper for tracking where time is spent
|
|
31
|
+
const DEBUG_TIMING = process.env.DEBUG_WRITE_SCENARIO === 'true';
|
|
32
|
+
let debugStartTime: number;
|
|
33
|
+
let debugLastTime: number;
|
|
34
|
+
|
|
35
|
+
// Timeout protection to prevent infinite hangs
|
|
36
|
+
const WRITE_SCENARIO_TIMEOUT_MS = parseInt(
|
|
37
|
+
process.env.WRITE_SCENARIO_TIMEOUT_MS || '300000', // Default 5 minutes
|
|
38
|
+
10,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
class WriteScenarioTimeoutError extends Error {
|
|
42
|
+
constructor(operation: string, timeoutMs: number) {
|
|
43
|
+
super(
|
|
44
|
+
`WriteScenarioComponents timed out after ${timeoutMs}ms during: ${operation}`,
|
|
45
|
+
);
|
|
46
|
+
this.name = 'WriteScenarioTimeoutError';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function withTimeout<T>(
|
|
51
|
+
operation: string,
|
|
52
|
+
promise: Promise<T>,
|
|
53
|
+
timeoutMs: number = WRITE_SCENARIO_TIMEOUT_MS,
|
|
54
|
+
): Promise<T> {
|
|
55
|
+
let timeoutId: NodeJS.Timeout | undefined;
|
|
56
|
+
|
|
57
|
+
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
58
|
+
timeoutId = setTimeout(() => {
|
|
59
|
+
reject(new WriteScenarioTimeoutError(operation, timeoutMs));
|
|
60
|
+
}, timeoutMs);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
return await Promise.race([promise, timeoutPromise]);
|
|
65
|
+
} finally {
|
|
66
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function debugLog(message: string, extra?: Record<string, unknown>): void {
|
|
71
|
+
if (!DEBUG_TIMING) return;
|
|
72
|
+
const now = Date.now();
|
|
73
|
+
if (!debugStartTime) {
|
|
74
|
+
debugStartTime = now;
|
|
75
|
+
debugLastTime = now;
|
|
76
|
+
}
|
|
77
|
+
const elapsed = now - debugStartTime;
|
|
78
|
+
const delta = now - debugLastTime;
|
|
79
|
+
debugLastTime = now;
|
|
80
|
+
console.log(
|
|
81
|
+
`[WriteScenario +${elapsed}ms Δ${delta}ms] ${message}`,
|
|
82
|
+
extra ? JSON.stringify(extra, null, 2) : '',
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function resetDebugTiming(): void {
|
|
87
|
+
debugStartTime = 0;
|
|
88
|
+
debugLastTime = 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
30
91
|
/**
|
|
31
92
|
* Find the end position of the last import/export-from statement using TypeScript AST.
|
|
32
93
|
* This is more reliable than regex for handling multiline imports, comments, etc.
|
|
@@ -36,11 +97,15 @@ import { applyServerOnlyMocks } from './serverOnlyModules';
|
|
|
36
97
|
*/
|
|
37
98
|
function findEndOfImports(content: string): number {
|
|
38
99
|
try {
|
|
100
|
+
// Use temp.tsx to enable JSX parsing - otherwise TypeScript may misparse
|
|
101
|
+
// JSX content containing the word "import" (e.g., "Entities that import this")
|
|
102
|
+
// as an import statement, causing mock code to be inserted in the wrong location.
|
|
39
103
|
const sourceFile = ts.createSourceFile(
|
|
40
|
-
'temp.
|
|
104
|
+
'temp.tsx',
|
|
41
105
|
content,
|
|
42
106
|
ts.ScriptTarget.Latest,
|
|
43
107
|
true,
|
|
108
|
+
ts.ScriptKind.TSX,
|
|
44
109
|
);
|
|
45
110
|
|
|
46
111
|
let lastImportEnd = 0;
|
|
@@ -75,6 +140,125 @@ function escapeRegExp(str: string): string {
|
|
|
75
140
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
76
141
|
}
|
|
77
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Remove a named import from file content using TypeScript AST.
|
|
145
|
+
* Handles both regular imports (`EntityName`) and type-only imports (`type EntityName`).
|
|
146
|
+
*
|
|
147
|
+
* @param fileContent - The file content to modify
|
|
148
|
+
* @param entityName - The name of the entity to remove from imports
|
|
149
|
+
* @returns The modified file content with the entity removed from imports
|
|
150
|
+
*/
|
|
151
|
+
function removeNamedImportAst(fileContent: string, entityName: string): string {
|
|
152
|
+
try {
|
|
153
|
+
const sourceFile = ts.createSourceFile(
|
|
154
|
+
'temp.tsx',
|
|
155
|
+
fileContent,
|
|
156
|
+
ts.ScriptTarget.Latest,
|
|
157
|
+
true,
|
|
158
|
+
ts.ScriptKind.TSX,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const replacements: { start: number; end: number; replacement: string }[] =
|
|
162
|
+
[];
|
|
163
|
+
|
|
164
|
+
for (const statement of sourceFile.statements) {
|
|
165
|
+
if (!ts.isImportDeclaration(statement)) continue;
|
|
166
|
+
if (!statement.importClause?.namedBindings) continue;
|
|
167
|
+
if (!ts.isNamedImports(statement.importClause.namedBindings)) continue;
|
|
168
|
+
|
|
169
|
+
const namedImports = statement.importClause.namedBindings;
|
|
170
|
+
const elements = namedImports.elements;
|
|
171
|
+
|
|
172
|
+
// Find the element that matches our entity name
|
|
173
|
+
const matchingIndex = elements.findIndex(
|
|
174
|
+
(el) => el.name.text === entityName,
|
|
175
|
+
);
|
|
176
|
+
if (matchingIndex === -1) continue;
|
|
177
|
+
|
|
178
|
+
// Check if there's a default import (e.g., `import DefaultName, { NamedImport } from '...'`)
|
|
179
|
+
const hasDefaultImport = !!statement.importClause.name;
|
|
180
|
+
|
|
181
|
+
// If this is the only named import AND there's no default import, remove the entire statement
|
|
182
|
+
if (elements.length === 1 && !hasDefaultImport) {
|
|
183
|
+
// Find the end including any trailing newline
|
|
184
|
+
let end = statement.getEnd();
|
|
185
|
+
const afterStatement = fileContent.slice(end);
|
|
186
|
+
const trailingNewline = afterStatement.match(/^\r?\n/);
|
|
187
|
+
if (trailingNewline) {
|
|
188
|
+
end += trailingNewline[0].length;
|
|
189
|
+
}
|
|
190
|
+
replacements.push({
|
|
191
|
+
start: statement.getStart(sourceFile),
|
|
192
|
+
end,
|
|
193
|
+
replacement: '',
|
|
194
|
+
});
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Otherwise, rebuild the import without this element
|
|
199
|
+
const remainingElements = elements.filter((_, i) => i !== matchingIndex);
|
|
200
|
+
|
|
201
|
+
// Get the module specifier
|
|
202
|
+
const moduleSpecifier = statement.moduleSpecifier;
|
|
203
|
+
if (!ts.isStringLiteral(moduleSpecifier)) continue;
|
|
204
|
+
|
|
205
|
+
// Preserve import type modifier if present
|
|
206
|
+
const importTypePrefix = statement.importClause.isTypeOnly ? 'type ' : '';
|
|
207
|
+
|
|
208
|
+
// Get the default import name if present
|
|
209
|
+
const defaultImportName = statement.importClause.name?.text;
|
|
210
|
+
|
|
211
|
+
let newImport: string;
|
|
212
|
+
|
|
213
|
+
if (remainingElements.length === 0) {
|
|
214
|
+
// All named imports were removed, but there's a default import to preserve
|
|
215
|
+
// (we only get here when hasDefaultImport is true, because otherwise we'd have
|
|
216
|
+
// removed the whole statement at the elements.length === 1 check above)
|
|
217
|
+
newImport = `import ${defaultImportName} from ${moduleSpecifier.getText(sourceFile)};`;
|
|
218
|
+
} else {
|
|
219
|
+
// Build the new named imports string
|
|
220
|
+
const newNamedImports = remainingElements
|
|
221
|
+
.map((el) => {
|
|
222
|
+
const isTypeOnly = el.isTypeOnly;
|
|
223
|
+
const name = el.name.text;
|
|
224
|
+
const propertyName = el.propertyName?.text;
|
|
225
|
+
if (propertyName) {
|
|
226
|
+
return isTypeOnly
|
|
227
|
+
? `type ${propertyName} as ${name}`
|
|
228
|
+
: `${propertyName} as ${name}`;
|
|
229
|
+
}
|
|
230
|
+
return isTypeOnly ? `type ${name}` : name;
|
|
231
|
+
})
|
|
232
|
+
.join(', ');
|
|
233
|
+
|
|
234
|
+
// Build the new import statement, preserving default import if present
|
|
235
|
+
const defaultImportPrefix = defaultImportName
|
|
236
|
+
? `${defaultImportName}, `
|
|
237
|
+
: '';
|
|
238
|
+
newImport = `import ${importTypePrefix}${defaultImportPrefix}{ ${newNamedImports} } from ${moduleSpecifier.getText(sourceFile)};`;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
replacements.push({
|
|
242
|
+
start: statement.getStart(sourceFile),
|
|
243
|
+
end: statement.getEnd(),
|
|
244
|
+
replacement: newImport,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Apply replacements in reverse order to preserve positions
|
|
249
|
+
let result = fileContent;
|
|
250
|
+
replacements.sort((a, b) => b.start - a.start);
|
|
251
|
+
for (const { start, end, replacement } of replacements) {
|
|
252
|
+
result = result.slice(0, start) + replacement + result.slice(end);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return result;
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.warn('[removeNamedImportAst] Failed to parse file:', error);
|
|
258
|
+
return fileContent; // Return original content on error
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
78
262
|
/**
|
|
79
263
|
* Map nested dist paths to src paths.
|
|
80
264
|
* Some build tools create nested structures like:
|
|
@@ -518,27 +702,49 @@ function stripServerOnlyImport(fileContent: string): string {
|
|
|
518
702
|
* Excludes node_modules imports (bare specifiers like 'react', '@prisma/client').
|
|
519
703
|
*/
|
|
520
704
|
function extractInternalImportPaths(fileContent: string): string[] {
|
|
705
|
+
// Always use AST parsing - regex with nested quantifiers can cause catastrophic
|
|
706
|
+
// backtracking that hangs on a single .exec() call (before iteration limits kick in)
|
|
707
|
+
return extractInternalImportPathsAst(fileContent);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Extract internal import paths using TypeScript AST - more reliable for large files
|
|
712
|
+
*/
|
|
713
|
+
function extractInternalImportPathsAst(fileContent: string): string[] {
|
|
521
714
|
const importPaths: string[] = [];
|
|
522
715
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
716
|
+
try {
|
|
717
|
+
// Use temp.tsx to enable JSX parsing for consistent handling of JSX files
|
|
718
|
+
const sourceFile = ts.createSourceFile(
|
|
719
|
+
'temp.tsx',
|
|
720
|
+
fileContent,
|
|
721
|
+
ts.ScriptTarget.Latest,
|
|
722
|
+
true,
|
|
723
|
+
ts.ScriptKind.TSX,
|
|
724
|
+
);
|
|
725
|
+
|
|
726
|
+
for (const statement of sourceFile.statements) {
|
|
727
|
+
if (ts.isImportDeclaration(statement) && statement.moduleSpecifier) {
|
|
728
|
+
const moduleSpecifier = statement.moduleSpecifier;
|
|
729
|
+
if (ts.isStringLiteral(moduleSpecifier)) {
|
|
730
|
+
const importPath = moduleSpecifier.text;
|
|
731
|
+
// Skip node_modules imports (bare specifiers)
|
|
732
|
+
if (
|
|
733
|
+
importPath.startsWith('.') ||
|
|
734
|
+
importPath.startsWith('@/') ||
|
|
735
|
+
importPath.startsWith('~/') ||
|
|
736
|
+
importPath.startsWith('#')
|
|
737
|
+
) {
|
|
738
|
+
importPaths.push(importPath);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
541
742
|
}
|
|
743
|
+
} catch (error) {
|
|
744
|
+
console.warn(
|
|
745
|
+
'[extractInternalImportPathsAst] Failed to parse file:',
|
|
746
|
+
error,
|
|
747
|
+
);
|
|
542
748
|
}
|
|
543
749
|
|
|
544
750
|
return importPaths;
|
|
@@ -664,22 +870,72 @@ function addMockToContent(
|
|
|
664
870
|
|
|
665
871
|
// Check if we have multiple calls with different variable names
|
|
666
872
|
// This requires generating separate mock functions for each call site
|
|
873
|
+
//
|
|
874
|
+
// IMPORTANT: calls array may contain BOTH base hook calls (e.g., "useFetcher<Type>()")
|
|
875
|
+
// AND method chain usages (e.g., "useFetcher().functionCallReturnValue.submit(...)").
|
|
876
|
+
// We only want to count base hook calls for the length comparison with callVariableNames.
|
|
877
|
+
// A "base call" is one that ends with "()" possibly preceded by a type annotation,
|
|
878
|
+
// without any subsequent method chains like ".functionCallReturnValue" or ".submit(...)".
|
|
879
|
+
const baseHookCalls = importedExport.calls?.filter((call) => {
|
|
880
|
+
// Base hook calls match patterns like:
|
|
881
|
+
// - "useFetcher()"
|
|
882
|
+
// - "useFetcher<Type>()"
|
|
883
|
+
// - "useFetcher<{ complex: Type }>()"
|
|
884
|
+
// They end with "()" and don't have method chains after the call.
|
|
885
|
+
// Method chains contain ".functionCallReturnValue" or have property access after "()".
|
|
886
|
+
return (
|
|
887
|
+
call.endsWith('()') &&
|
|
888
|
+
!call.includes('.functionCallReturnValue') &&
|
|
889
|
+
// Also exclude method chains like "hook().something" or "hook().method()"
|
|
890
|
+
!call.match(/\(\)\.[a-zA-Z]/)
|
|
891
|
+
);
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
// Determine if we can generate unique mock functions for multiple variables.
|
|
895
|
+
// We need:
|
|
896
|
+
// 1. Multiple variable names (callVariableNames.length > 1)
|
|
897
|
+
// 2. Base hook calls to match them (baseHookCalls.length > 0)
|
|
898
|
+
// Note: We use min(baseHookCalls.length, callVariableNames.length) for iteration
|
|
899
|
+
// to handle cases where data might be slightly out of sync (stale entries).
|
|
667
900
|
const hasMultipleCallsWithVariables =
|
|
668
|
-
|
|
669
|
-
|
|
901
|
+
baseHookCalls &&
|
|
902
|
+
baseHookCalls.length > 1 &&
|
|
670
903
|
importedExport.callVariableNames &&
|
|
671
|
-
importedExport.callVariableNames.length
|
|
904
|
+
importedExport.callVariableNames.length > 1 &&
|
|
905
|
+
// Only proceed if we have at least as many base calls as variable names,
|
|
906
|
+
// OR they're close enough (within 1) to handle minor sync issues
|
|
907
|
+
Math.abs(baseHookCalls.length - importedExport.callVariableNames.length) <=
|
|
908
|
+
1;
|
|
672
909
|
|
|
673
910
|
let mockCode: string | undefined;
|
|
674
911
|
const variableMockCodes: string[] = [];
|
|
675
912
|
|
|
676
913
|
if (hasMultipleCallsWithVariables) {
|
|
677
914
|
// Generate separate mock functions for each variable-qualified call
|
|
678
|
-
//
|
|
679
|
-
|
|
915
|
+
// Look up canonical keys from dataForMocks and track variable names for function naming
|
|
916
|
+
|
|
917
|
+
// Get all call signature keys for this hook from dataForMocks
|
|
918
|
+
const dataForMocks =
|
|
919
|
+
rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
|
|
920
|
+
// Match keys that start with the hook name (e.g., "useFetcher" matches "useFetcher<User>()")
|
|
921
|
+
const callSignatureKeysForHook = dataForMocks
|
|
922
|
+
? Object.keys(dataForMocks).filter((key) => {
|
|
923
|
+
const hookBaseName = importedExport.name.split(/[<(]/)[0];
|
|
924
|
+
const keyBaseName = key.split(/[<(]/)[0];
|
|
925
|
+
return keyBaseName === hookBaseName;
|
|
926
|
+
})
|
|
927
|
+
: [];
|
|
928
|
+
|
|
929
|
+
// Track variable name occurrences for unique function naming
|
|
680
930
|
const variableNameCounts: Record<string, number> = {};
|
|
681
931
|
|
|
682
|
-
|
|
932
|
+
// Use the minimum of both array lengths to handle slight mismatches
|
|
933
|
+
// (e.g., stale data from previous analysis runs)
|
|
934
|
+
const iterationLimit = Math.min(
|
|
935
|
+
baseHookCalls!.length,
|
|
936
|
+
importedExport.callVariableNames!.length,
|
|
937
|
+
);
|
|
938
|
+
for (let i = 0; i < iterationLimit; i++) {
|
|
683
939
|
const variableName = importedExport.callVariableNames![i];
|
|
684
940
|
if (!variableName) continue;
|
|
685
941
|
|
|
@@ -687,18 +943,37 @@ function addMockToContent(
|
|
|
687
943
|
const occurrence = variableNameCounts[variableName] ?? 0;
|
|
688
944
|
variableNameCounts[variableName] = occurrence + 1;
|
|
689
945
|
|
|
690
|
-
//
|
|
691
|
-
// e.g., "fetcher[1] <- useFetcher" for the second usage of "fetcher"
|
|
946
|
+
// Build indexed variable name for function naming
|
|
692
947
|
const indexedVariableName =
|
|
693
948
|
occurrence > 0 ? `${variableName}[${occurrence}]` : variableName;
|
|
694
949
|
|
|
695
|
-
//
|
|
696
|
-
//
|
|
697
|
-
const
|
|
950
|
+
// Use safe function name with underscores instead of brackets
|
|
951
|
+
// e.g., fetcher[1] -> fetcher_1
|
|
952
|
+
const safeFunctionName = indexedVariableName.replace(/\[(\d+)\]/g, '_$1');
|
|
953
|
+
// Compute unique mock function name for call site replacement
|
|
954
|
+
// e.g., useFetcher_entityDiffFetcher, useFetcher_reportFetcher
|
|
955
|
+
const mockFunctionName = `${importedExport.name}_${safeFunctionName}`;
|
|
956
|
+
|
|
957
|
+
// Use the call signature from baseHookCalls[i] as the data key
|
|
958
|
+
// This matches what's stored in dataForMocks
|
|
959
|
+
const callSignature = baseHookCalls![i];
|
|
960
|
+
|
|
961
|
+
// Generate mock code using the call signature directly
|
|
962
|
+
// This prevents "symbol already declared" errors when multiple calls exist
|
|
963
|
+
// Check if this is a package import that won't have scenario copies
|
|
964
|
+
const isPackageImportForMock = importPath?.startsWith('@');
|
|
698
965
|
const variableMockCode = constructMockCode(
|
|
699
|
-
|
|
966
|
+
callSignature, // Use call signature format for data lookup
|
|
700
967
|
dependencySchemas,
|
|
701
968
|
importedExport.entityType,
|
|
969
|
+
undefined, // No need for separate canonical key
|
|
970
|
+
{
|
|
971
|
+
uniqueFunctionSuffix: safeFunctionName, // Use variable name for unique function naming
|
|
972
|
+
// For node_modules or package imports, skip spreading from __cyOriginal
|
|
973
|
+
// since those packages/files don't export *__cyOriginal variants
|
|
974
|
+
skipOriginalSpread:
|
|
975
|
+
importedExport.isNodeModule || isPackageImportForMock,
|
|
976
|
+
},
|
|
702
977
|
);
|
|
703
978
|
|
|
704
979
|
if (variableMockCode) {
|
|
@@ -707,25 +982,25 @@ function addMockToContent(
|
|
|
707
982
|
// Replace the call site with the variable-specific mock function
|
|
708
983
|
// e.g., useFetcher<BranchEntityDiffResult>() -> useFetcher_entityDiffFetcher()
|
|
709
984
|
// e.g., useFetcher() -> useFetcher_reportFetcher()
|
|
710
|
-
// For indexed variables: useFetcher() -> useFetcher_fetcher_1()
|
|
711
|
-
const callSignature = importedExport.calls![i];
|
|
712
985
|
// Escape special regex characters in the call signature
|
|
713
986
|
const escapedCallSignature = callSignature.replace(
|
|
714
987
|
/[.*+?^${}()|[\]\\]/g,
|
|
715
988
|
'\\$&',
|
|
716
989
|
);
|
|
717
|
-
// Create regex that matches the call (with optional whitespace variations)
|
|
990
|
+
// Create regex that matches the call (with optional whitespace variations).
|
|
991
|
+
// TypeScript formatters commonly break type parameters across lines, e.g.:
|
|
992
|
+
// useLoaderData<
|
|
993
|
+
// typeof loader
|
|
994
|
+
// >()
|
|
995
|
+
// So we allow optional whitespace around < and > delimiters, not just
|
|
996
|
+
// where whitespace already exists in the call signature string.
|
|
718
997
|
const callRegex = new RegExp(
|
|
719
|
-
escapedCallSignature
|
|
720
|
-
|
|
998
|
+
escapedCallSignature
|
|
999
|
+
.replace(/\s+/g, '\\s*')
|
|
1000
|
+
.replace(/</g, '\\s*<\\s*')
|
|
1001
|
+
.replace(/>/g, '\\s*>\\s*'),
|
|
1002
|
+
'gs',
|
|
721
1003
|
);
|
|
722
|
-
// Use safe function name with underscores instead of brackets
|
|
723
|
-
// e.g., fetcher[1] -> fetcher_1
|
|
724
|
-
const safeFunctionName = indexedVariableName.replace(
|
|
725
|
-
/\[(\d+)\]/g,
|
|
726
|
-
'_$1',
|
|
727
|
-
);
|
|
728
|
-
const mockFunctionName = `${importedExport.name}_${safeFunctionName}`;
|
|
729
1004
|
fileContent = fileContent.replace(callRegex, `${mockFunctionName}()`);
|
|
730
1005
|
}
|
|
731
1006
|
}
|
|
@@ -741,83 +1016,172 @@ function addMockToContent(
|
|
|
741
1016
|
: undefined;
|
|
742
1017
|
|
|
743
1018
|
if (singleCallVariableName) {
|
|
744
|
-
// For single variable assignments, use the
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
//
|
|
1019
|
+
// For single variable assignments, use the call signature directly from dataForMocks
|
|
1020
|
+
const dataForMocks =
|
|
1021
|
+
rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks;
|
|
1022
|
+
|
|
1023
|
+
// Find matching call signature key in dataForMocks
|
|
1024
|
+
// IMPORTANT: First try exact match with type parameters (e.g., "useLoaderData<LoaderData>()")
|
|
1025
|
+
// to avoid picking the wrong variant (e.g., "useLoaderData<typeof loader>()" which may
|
|
1026
|
+
// have different properties). Fall back to base name matching only if exact match fails.
|
|
1027
|
+
const hookBaseName = importedExport.name.split(/[<(]/)[0];
|
|
1028
|
+
const expectedKey = importedExport.calls?.[0];
|
|
1029
|
+
let callSignatureKey: string | undefined;
|
|
1030
|
+
|
|
1031
|
+
if (dataForMocks) {
|
|
1032
|
+
const keys = Object.keys(dataForMocks);
|
|
1033
|
+
|
|
1034
|
+
// First try exact match with the expected call signature
|
|
1035
|
+
if (expectedKey && keys.includes(expectedKey)) {
|
|
1036
|
+
callSignatureKey = expectedKey;
|
|
1037
|
+
} else {
|
|
1038
|
+
// Fall back to base name matching
|
|
1039
|
+
callSignatureKey = keys.find((key) => {
|
|
1040
|
+
// Split on ., <, or ( to get the true base name
|
|
1041
|
+
// This handles both "useFlags()" -> "useFlags" and "trpc.useUtils()" -> "trpc"
|
|
1042
|
+
const keyBaseName = key.split(/[.<(]/)[0];
|
|
1043
|
+
return keyBaseName === hookBaseName;
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// Use the call signature if found, otherwise construct it
|
|
1049
|
+
const dataKey =
|
|
1050
|
+
callSignatureKey ??
|
|
1051
|
+
importedExport.calls?.[0] ??
|
|
1052
|
+
`${importedExport.name}()`;
|
|
1053
|
+
|
|
1054
|
+
// IMPORTANT: If the dataKey is a method chain (e.g., "trpc.useUtils()"), we should
|
|
1055
|
+
// use the base name (e.g., "trpc") when calling constructMockCode. This ensures
|
|
1056
|
+
// constructMockCode generates a complete nested mock from the schema without
|
|
1057
|
+
// referencing __cyOriginal variables.
|
|
1058
|
+
const dataKeyBaseName = dataKey.split(/[.<(]/)[0];
|
|
1059
|
+
const isMethodChainDataKey =
|
|
1060
|
+
dataKeyBaseName === importedExport.name &&
|
|
1061
|
+
dataKey !== importedExport.name &&
|
|
1062
|
+
dataKey.includes('.');
|
|
1063
|
+
const mockNameToUse = isMethodChainDataKey
|
|
1064
|
+
? importedExport.name
|
|
1065
|
+
: dataKey;
|
|
1066
|
+
|
|
1067
|
+
// Keep the original function name since there's only one call
|
|
1068
|
+
// Check if this is a package import that won't have scenario copies
|
|
1069
|
+
const isPackageImportForSingleCall = importPath?.startsWith('@');
|
|
749
1070
|
mockCode = constructMockCode(
|
|
750
|
-
|
|
1071
|
+
mockNameToUse,
|
|
751
1072
|
dependencySchemas,
|
|
752
1073
|
importedExport.entityType,
|
|
753
|
-
|
|
1074
|
+
undefined,
|
|
1075
|
+
{
|
|
1076
|
+
keepOriginalFunctionName: true,
|
|
1077
|
+
// For node_modules or package imports, skip spreading from __cyOriginal
|
|
1078
|
+
// since those packages/files don't export *__cyOriginal variants
|
|
1079
|
+
skipOriginalSpread:
|
|
1080
|
+
importedExport.isNodeModule || isPackageImportForSingleCall,
|
|
1081
|
+
},
|
|
754
1082
|
);
|
|
755
1083
|
// If constructMockCode didn't generate code, fall back to simple return
|
|
1084
|
+
// IMPORTANT: We inline scenarios().data() inside the function rather than
|
|
1085
|
+
// storing in a const - see comment in constructMockCode.ts for why.
|
|
756
1086
|
if (!mockCode) {
|
|
757
|
-
mockCode =
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
1087
|
+
mockCode = `// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)
|
|
1088
|
+
const _${importedExport.name}Ref = {
|
|
1089
|
+
current: null,
|
|
1090
|
+
};
|
|
1091
|
+
function ${importedExport.name}(...args) {
|
|
1092
|
+
if (!_${importedExport.name}Ref.current) {
|
|
1093
|
+
_${importedExport.name}Ref.current = scenarios().data()?.["${dataKey}"];
|
|
1094
|
+
}
|
|
1095
|
+
return _${importedExport.name}Ref.current;
|
|
761
1096
|
}`;
|
|
762
1097
|
}
|
|
763
1098
|
} else {
|
|
764
|
-
//
|
|
765
|
-
//
|
|
766
|
-
//
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
if (variableQualifiedKey) {
|
|
779
|
-
break;
|
|
780
|
-
}
|
|
1099
|
+
// Helper to find matching call signature key from dataForMocks
|
|
1100
|
+
// IMPORTANT: First try exact match with type parameters (e.g., "useLoaderData<LoaderData>()")
|
|
1101
|
+
// to avoid picking the wrong variant. Fall back to base name matching only if needed.
|
|
1102
|
+
const hookBaseName = importedExport.name.split(/[<(]/)[0];
|
|
1103
|
+
const expectedKey = importedExport.calls?.[0];
|
|
1104
|
+
const findMatchingKey = (
|
|
1105
|
+
dataForMocks: Record<string, unknown> | undefined,
|
|
1106
|
+
): string | undefined => {
|
|
1107
|
+
if (!dataForMocks) return undefined;
|
|
1108
|
+
const keys = Object.keys(dataForMocks);
|
|
1109
|
+
|
|
1110
|
+
// First try exact match with the expected call signature
|
|
1111
|
+
if (expectedKey && keys.includes(expectedKey)) {
|
|
1112
|
+
return expectedKey;
|
|
781
1113
|
}
|
|
782
|
-
}
|
|
783
1114
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1115
|
+
// Fall back to base name matching
|
|
1116
|
+
return keys.find((key) => {
|
|
1117
|
+
// Split on ., <, or ( to get the true base name
|
|
1118
|
+
// This handles both "useFlags()" -> "useFlags" and "trpc.useUtils()" -> "trpc"
|
|
1119
|
+
const keyBaseName = key.split(/[.<(]/)[0];
|
|
1120
|
+
return keyBaseName === hookBaseName;
|
|
1121
|
+
});
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// Check rootAnalysis FIRST for matching keys.
|
|
1125
|
+
// The mock DATA is generated from rootAnalysis, so the mock CODE must
|
|
1126
|
+
// also use rootAnalysis keys to ensure the lookup succeeds.
|
|
1127
|
+
let dataKey = findMatchingKey(
|
|
1128
|
+
rootAnalysis.metadata?.scenariosDataStructure?.dataForMocks,
|
|
1129
|
+
);
|
|
1130
|
+
|
|
1131
|
+
// If not found in rootAnalysis, fall back to fileAnalyses
|
|
1132
|
+
if (!dataKey) {
|
|
1133
|
+
for (const analysis of fileAnalyses) {
|
|
1134
|
+
dataKey = findMatchingKey(
|
|
1135
|
+
analysis.metadata?.scenariosDataStructure?.dataForMocks,
|
|
1136
|
+
);
|
|
1137
|
+
if (dataKey) break;
|
|
793
1138
|
}
|
|
794
1139
|
}
|
|
795
1140
|
|
|
796
|
-
if
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
1141
|
+
// Use the data key if found, otherwise use call signature or function name.
|
|
1142
|
+
// IMPORTANT: If the dataKey is a method chain (e.g., "trpc.useUtils()"), we should
|
|
1143
|
+
// use the base name (e.g., "trpc") when calling constructMockCode. This ensures
|
|
1144
|
+
// constructMockCode generates a complete nested mock from the schema without
|
|
1145
|
+
// referencing __cyOriginal variables. The __cyOriginal pattern is only needed
|
|
1146
|
+
// for partial mocking where we preserve some original methods, not for complete
|
|
1147
|
+
// method-chain mocks where we provide all implementations.
|
|
1148
|
+
const dataKeyBaseName = dataKey?.split(/[.<(]/)[0];
|
|
1149
|
+
const isMethodChainDataKey =
|
|
1150
|
+
dataKey &&
|
|
1151
|
+
dataKeyBaseName === importedExport.name &&
|
|
1152
|
+
dataKey !== importedExport.name &&
|
|
1153
|
+
dataKey.includes('.');
|
|
1154
|
+
const mockNameToUse = isMethodChainDataKey
|
|
1155
|
+
? importedExport.name
|
|
1156
|
+
: (dataKey ?? importedExport.calls?.[0] ?? `${importedExport.name}()`);
|
|
809
1157
|
|
|
810
|
-
|
|
811
|
-
|
|
1158
|
+
mockCode = constructMockCode(
|
|
1159
|
+
mockNameToUse,
|
|
1160
|
+
dependencySchemas,
|
|
1161
|
+
importedExport.entityType,
|
|
1162
|
+
undefined,
|
|
1163
|
+
{
|
|
1164
|
+
keepOriginalFunctionName: true,
|
|
1165
|
+
// For node_modules or package imports, skip spreading from __cyOriginal
|
|
1166
|
+
// since those packages/files don't export *__cyOriginal variants
|
|
1167
|
+
skipOriginalSpread:
|
|
1168
|
+
importedExport.isNodeModule || importPath?.startsWith('@'),
|
|
1169
|
+
},
|
|
1170
|
+
);
|
|
1171
|
+
// If constructMockCode didn't generate code, fall back to simple return
|
|
1172
|
+
// IMPORTANT: We inline scenarios().data() inside the function rather than
|
|
1173
|
+
// storing in a const - see comment in constructMockCode.ts for why.
|
|
1174
|
+
if (!mockCode && dataKey) {
|
|
1175
|
+
mockCode = `// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)
|
|
1176
|
+
const _${importedExport.name}Ref = {
|
|
1177
|
+
current: null,
|
|
1178
|
+
};
|
|
1179
|
+
function ${importedExport.name}(...args) {
|
|
1180
|
+
if (!_${importedExport.name}Ref.current) {
|
|
1181
|
+
_${importedExport.name}Ref.current = scenarios().data()?.["${dataKey}"];
|
|
1182
|
+
}
|
|
1183
|
+
return _${importedExport.name}Ref.current;
|
|
812
1184
|
}`;
|
|
813
|
-
}
|
|
814
|
-
} else {
|
|
815
|
-
// Original behavior for calls without variable names
|
|
816
|
-
mockCode = constructMockCode(
|
|
817
|
-
importedExport.name,
|
|
818
|
-
dependencySchemas,
|
|
819
|
-
importedExport.entityType,
|
|
820
|
-
);
|
|
821
1185
|
}
|
|
822
1186
|
}
|
|
823
1187
|
}
|
|
@@ -848,12 +1212,39 @@ function ${importedExport.name}() {
|
|
|
848
1212
|
/[.*+?^${}()|[\]\\]/g,
|
|
849
1213
|
'\\$&',
|
|
850
1214
|
);
|
|
1215
|
+
// Use a simpler, more robust regex pattern that matches the fallback path.
|
|
1216
|
+
// Key improvements:
|
|
1217
|
+
// 1. Uses escapeRegExp(firstPart) to handle special characters in function names
|
|
1218
|
+
// 2. Uses word boundaries (\b) to prevent partial matches
|
|
1219
|
+
// 3. Handles comma BEFORE or AFTER the name: (?:,\s*|\s*,)?
|
|
1220
|
+
// 4. Matches specific import path (escapedImportPath)
|
|
851
1221
|
const importRegExp = new RegExp(
|
|
852
|
-
`(import
|
|
1222
|
+
`(import\\s*\\{[^}]*?)\\b${escapeRegExp(firstPart)}\\b(?:,\\s*|\\s*,)?((?:[^}]*\\}\\s*from\\s*['"]${escapedImportPath}['"];?))`,
|
|
853
1223
|
'm',
|
|
854
1224
|
);
|
|
855
1225
|
|
|
856
|
-
if (
|
|
1226
|
+
// Check if any call signature has multiple parts (e.g., "logger.error(error)")
|
|
1227
|
+
// If so, the mock code will spread from __cyOriginal, so we need to rename the import
|
|
1228
|
+
// EXCEPT:
|
|
1229
|
+
// 1. For node_module imports, the __cyOriginal pattern doesn't work because
|
|
1230
|
+
// the original package doesn't export *__cyOriginal variants.
|
|
1231
|
+
// 2. For package imports (starting with @), the __cyOriginal pattern doesn't work
|
|
1232
|
+
// because scenario copies aren't created for package files - they keep the
|
|
1233
|
+
// original import path which doesn't export *__cyOriginal.
|
|
1234
|
+
const anyCallHasMultipleParts = importedExport.calls?.some((call) => {
|
|
1235
|
+
const callParts = splitOutsideParenthesesAndArrays(call);
|
|
1236
|
+
return callParts.length > 1;
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
// Package imports (starting with @) don't get scenario copies, so __cyOriginal won't exist
|
|
1240
|
+
const isPackageImport = importPath.startsWith('@');
|
|
1241
|
+
|
|
1242
|
+
const shouldRenameToOriginal =
|
|
1243
|
+
!importedExport.isNodeModule &&
|
|
1244
|
+
!isPackageImport &&
|
|
1245
|
+
(importedExportNameParts.length > 1 || anyCallHasMultipleParts);
|
|
1246
|
+
|
|
1247
|
+
if (shouldRenameToOriginal) {
|
|
857
1248
|
fileContent = fileContent.replace(
|
|
858
1249
|
importRegExp,
|
|
859
1250
|
`$1${firstPart}__cyOriginal$2`,
|
|
@@ -862,6 +1253,21 @@ function ${importedExport.name}() {
|
|
|
862
1253
|
fileContent = fileContent.replace(importRegExp, '$1$2');
|
|
863
1254
|
}
|
|
864
1255
|
|
|
1256
|
+
// Also handle namespace imports (import * as foo from '...')
|
|
1257
|
+
// These need to be renamed to foo__cyOriginal when the mock code spreads from the original.
|
|
1258
|
+
// Note: We match any path (not just escapedImportPath) because the import path may have
|
|
1259
|
+
// been rewritten by transitive import handling before this code runs.
|
|
1260
|
+
if (shouldRenameToOriginal) {
|
|
1261
|
+
const namespaceImportRegExp = new RegExp(
|
|
1262
|
+
`(import\\s+\\*\\s+as\\s+)${escapeRegExp(firstPart)}(\\s+from\\s+['"][^'"]*['"])`,
|
|
1263
|
+
'm',
|
|
1264
|
+
);
|
|
1265
|
+
fileContent = fileContent.replace(
|
|
1266
|
+
namespaceImportRegExp,
|
|
1267
|
+
`$1${firstPart}__cyOriginal$2`,
|
|
1268
|
+
);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
865
1271
|
// Remove empty imports entirely to avoid partial commenting issues with multiline imports
|
|
866
1272
|
// This handles both single-line and multiline empty imports
|
|
867
1273
|
fileContent = fileContent.replace(
|
|
@@ -886,7 +1292,20 @@ function ${importedExport.name}() {
|
|
|
886
1292
|
'm',
|
|
887
1293
|
);
|
|
888
1294
|
|
|
889
|
-
if (
|
|
1295
|
+
// Check if any call signature has multiple parts (e.g., "logger.error(error)")
|
|
1296
|
+
// If so, the mock code will spread from __cyOriginal, so we need to rename the import
|
|
1297
|
+
// EXCEPT: For node_module imports, the __cyOriginal pattern doesn't work because
|
|
1298
|
+
// the original package doesn't export *__cyOriginal variants.
|
|
1299
|
+
const anyCallHasMultipleParts = importedExport.calls?.some((call) => {
|
|
1300
|
+
const callParts = splitOutsideParenthesesAndArrays(call);
|
|
1301
|
+
return callParts.length > 1;
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
const shouldRenameToOriginal =
|
|
1305
|
+
!importedExport.isNodeModule &&
|
|
1306
|
+
(importedExportNameParts.length > 1 || anyCallHasMultipleParts);
|
|
1307
|
+
|
|
1308
|
+
if (shouldRenameToOriginal) {
|
|
890
1309
|
// Rename the import instead of removing (for destructured access patterns)
|
|
891
1310
|
fileContent = fileContent.replace(
|
|
892
1311
|
namedImportRegExp,
|
|
@@ -1108,6 +1527,15 @@ export default async function writeScenarioComponents({
|
|
|
1108
1527
|
scenarioComponentPaths: string[];
|
|
1109
1528
|
writtenScenarioComponents: { [key: string]: string[] };
|
|
1110
1529
|
}> {
|
|
1530
|
+
// Reset debug timing for this invocation
|
|
1531
|
+
resetDebugTiming();
|
|
1532
|
+
debugLog('START writeScenarioComponents', {
|
|
1533
|
+
filePath: file.path,
|
|
1534
|
+
entityName: entity.name,
|
|
1535
|
+
scenarioName: scenario.name,
|
|
1536
|
+
isRootFile: !rootFile || rootFile === file,
|
|
1537
|
+
});
|
|
1538
|
+
|
|
1111
1539
|
// Capture arguments for testing if debug mode is enabled
|
|
1112
1540
|
captureArgumentsForTesting({
|
|
1113
1541
|
project,
|
|
@@ -1327,7 +1755,31 @@ export default async function writeScenarioComponents({
|
|
|
1327
1755
|
return 0;
|
|
1328
1756
|
});
|
|
1329
1757
|
|
|
1758
|
+
debugLog('Starting main importedExports loop', {
|
|
1759
|
+
count: sortedImportedExports.length,
|
|
1760
|
+
fileContentLength: fileContent.length,
|
|
1761
|
+
});
|
|
1762
|
+
|
|
1763
|
+
let importedExportIndex = 0;
|
|
1764
|
+
const loopStartTime = Date.now();
|
|
1765
|
+
console.log(
|
|
1766
|
+
`[WriteScenario] Starting import loop for ${entity.name}: ${sortedImportedExports.length} imports`,
|
|
1767
|
+
);
|
|
1330
1768
|
for (const importedExport of sortedImportedExports) {
|
|
1769
|
+
importedExportIndex++;
|
|
1770
|
+
if (importedExportIndex % 5 === 0 || importedExportIndex === 1) {
|
|
1771
|
+
console.log(
|
|
1772
|
+
`[WriteScenario] ${entity.name} import ${importedExportIndex}/${sortedImportedExports.length}: ${importedExport.name} elapsed=${Date.now() - loopStartTime}ms`,
|
|
1773
|
+
);
|
|
1774
|
+
debugLog(
|
|
1775
|
+
`Processing importedExport ${importedExportIndex}/${sortedImportedExports.length}`,
|
|
1776
|
+
{
|
|
1777
|
+
name: importedExport.name,
|
|
1778
|
+
filePath: importedExport.filePath,
|
|
1779
|
+
isMocked: importedExport.isMocked,
|
|
1780
|
+
},
|
|
1781
|
+
);
|
|
1782
|
+
}
|
|
1331
1783
|
// IMPORTANT: The import mapping keys may be either absolute or relative paths
|
|
1332
1784
|
// depending on how they were created by the file analyzer. We try multiple formats.
|
|
1333
1785
|
// Also need to normalize paths to handle /tmp vs /private/tmp on macOS
|
|
@@ -1506,28 +1958,49 @@ export default async function writeScenarioComponents({
|
|
|
1506
1958
|
importedExport.resolvedIsDefault === true &&
|
|
1507
1959
|
importedExport.isDefault === false;
|
|
1508
1960
|
|
|
1961
|
+
console.log(
|
|
1962
|
+
`[WriteScenario] RECURSE START: ${entity.name} -> ${importedExportEntity.name}`,
|
|
1963
|
+
);
|
|
1964
|
+
const recurseStartTime = Date.now();
|
|
1965
|
+
debugLog(
|
|
1966
|
+
`Recursing into writeScenarioComponents for ${importedExportEntity.name}`,
|
|
1967
|
+
{
|
|
1968
|
+
entityName: importedExportEntity.name,
|
|
1969
|
+
filePath: fileNotMocked.path,
|
|
1970
|
+
},
|
|
1971
|
+
);
|
|
1509
1972
|
const {
|
|
1510
1973
|
scenarioComponentPaths: newScenarioComponentPaths,
|
|
1511
1974
|
writtenScenarioComponents: updatedWrittenScenarioComponents,
|
|
1512
|
-
} = await
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
:
|
|
1530
|
-
|
|
1975
|
+
} = await withTimeout(
|
|
1976
|
+
`recursive writeScenarioComponents for ${importedExportEntity.name}`,
|
|
1977
|
+
writeScenarioComponents({
|
|
1978
|
+
project,
|
|
1979
|
+
file: fileNotMocked,
|
|
1980
|
+
entity: importedExportEntity,
|
|
1981
|
+
rootAnalysis,
|
|
1982
|
+
scenario,
|
|
1983
|
+
context,
|
|
1984
|
+
projectAnalyzer,
|
|
1985
|
+
framework,
|
|
1986
|
+
mocksDir,
|
|
1987
|
+
rootFile,
|
|
1988
|
+
namespaceMocks,
|
|
1989
|
+
writtenScenarioComponents,
|
|
1990
|
+
fileStore,
|
|
1991
|
+
// Pass the import name so we can add `export { default as Name };`
|
|
1992
|
+
exportAsNamed: needsNamedReExport
|
|
1993
|
+
? importedExport.name
|
|
1994
|
+
: undefined,
|
|
1995
|
+
}),
|
|
1996
|
+
180000, // 3 minute timeout for recursive calls (complex components need more time)
|
|
1997
|
+
);
|
|
1998
|
+
console.log(
|
|
1999
|
+
`[WriteScenario] RECURSE END: ${entity.name} -> ${importedExportEntity.name} took ${Date.now() - recurseStartTime}ms`,
|
|
2000
|
+
);
|
|
2001
|
+
debugLog(
|
|
2002
|
+
`Completed recursive writeScenarioComponents for ${importedExportEntity.name}`,
|
|
2003
|
+
);
|
|
1531
2004
|
writtenScenarioComponents = updatedWrittenScenarioComponents;
|
|
1532
2005
|
scenarioComponentPaths.push(...newScenarioComponentPaths);
|
|
1533
2006
|
}
|
|
@@ -1831,9 +2304,7 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1831
2304
|
|
|
1832
2305
|
// First, try to remove this entity from the already-rewritten grouped import
|
|
1833
2306
|
// This prevents duplicate/conflicting imports
|
|
1834
|
-
//
|
|
1835
|
-
// The global patterns used previously would also match type annotations like:
|
|
1836
|
-
// "param: MyType," in function signatures, corrupting the syntax.
|
|
2307
|
+
// Use AST-based removal to properly handle type-only imports like `type EntityName`
|
|
1837
2308
|
const escapedEntityName = escapeRegExp(entityImportName);
|
|
1838
2309
|
|
|
1839
2310
|
// For default imports: remove "DefaultName, " from "import DefaultName, { ... }"
|
|
@@ -1846,33 +2317,12 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1846
2317
|
fileContent = fileContent.replace(defaultImportPattern, '$1$2');
|
|
1847
2318
|
}
|
|
1848
2319
|
|
|
1849
|
-
//
|
|
1850
|
-
//
|
|
1851
|
-
//
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
);
|
|
1856
|
-
fileContent = fileContent.replace(
|
|
1857
|
-
importWithEntityPattern,
|
|
1858
|
-
(match, prefix, namedImports, suffix) => {
|
|
1859
|
-
// Remove the entity name from the named imports
|
|
1860
|
-
let cleaned = namedImports
|
|
1861
|
-
.replace(new RegExp(`\\b${escapedEntityName}\\s*,\\s*`), '') // "EntityName, "
|
|
1862
|
-
.replace(new RegExp(`\\s*,\\s*${escapedEntityName}\\b`), '') // ", EntityName"
|
|
1863
|
-
.replace(new RegExp(`\\b${escapedEntityName}\\b`), ''); // "EntityName" (only one)
|
|
1864
|
-
// Clean up any double commas or leading/trailing commas
|
|
1865
|
-
cleaned = cleaned
|
|
1866
|
-
.replace(/,\s*,/g, ',')
|
|
1867
|
-
.replace(/^\s*,\s*/, '')
|
|
1868
|
-
.replace(/\s*,\s*$/, '');
|
|
1869
|
-
// If no imports left, remove the entire import statement
|
|
1870
|
-
if (cleaned.trim() === '') {
|
|
1871
|
-
return '';
|
|
1872
|
-
}
|
|
1873
|
-
return prefix + cleaned + suffix;
|
|
1874
|
-
},
|
|
1875
|
-
);
|
|
2320
|
+
// Remove the named import using AST parsing
|
|
2321
|
+
// This properly handles:
|
|
2322
|
+
// - Regular imports: `import { EntityName } from '...'`
|
|
2323
|
+
// - Type-only imports: `import { type EntityName } from '...'`
|
|
2324
|
+
// - Mixed imports: `import { type EntityName, OtherName } from '...'`
|
|
2325
|
+
fileContent = removeNamedImportAst(fileContent, entityImportName);
|
|
1876
2326
|
|
|
1877
2327
|
// Add the new import at the beginning of fileContent
|
|
1878
2328
|
// Note: The header comment (// Scenario:) doesn't exist yet - it's prepended at writeFile time
|
|
@@ -1888,9 +2338,32 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1888
2338
|
}
|
|
1889
2339
|
}
|
|
1890
2340
|
|
|
2341
|
+
// Track post-import-loop timing
|
|
2342
|
+
const postLoopStartTime = Date.now();
|
|
2343
|
+
console.log(`[WriteScenario] POST-LOOP START: ${entity.name}`);
|
|
2344
|
+
|
|
2345
|
+
// Collect universal mocks BEFORE processing nodeModuleImports
|
|
2346
|
+
// This is needed to check if a node module import is handled by a universal mock
|
|
2347
|
+
const universalMocks = project.metadata?.universalMocks ?? [];
|
|
2348
|
+
const nodeModuleUniversalMocks = universalMocks.filter(
|
|
2349
|
+
(mock) => mock.nodeModule && mock.content,
|
|
2350
|
+
);
|
|
2351
|
+
|
|
2352
|
+
// Create a set of import paths that have universal mocks for quick lookup
|
|
2353
|
+
const universalMockPaths = new Set(
|
|
2354
|
+
nodeModuleUniversalMocks.map((mock) => mock.filePath),
|
|
2355
|
+
);
|
|
2356
|
+
|
|
1891
2357
|
for (const nodeModuleImport of nodeModuleImports) {
|
|
1892
2358
|
if (!nodeModuleImport.isMocked) continue;
|
|
1893
2359
|
|
|
2360
|
+
// Skip generating local mock functions for imports that have universal mocks.
|
|
2361
|
+
// Universal mocks provide the exports via rewritten import paths (handled below).
|
|
2362
|
+
// Generating a local mock function would cause "name defined multiple times" errors.
|
|
2363
|
+
if (universalMockPaths.has(nodeModuleImport.filePath)) {
|
|
2364
|
+
continue;
|
|
2365
|
+
}
|
|
2366
|
+
|
|
1894
2367
|
fileContent = addMockToContent(
|
|
1895
2368
|
fileContent,
|
|
1896
2369
|
nodeModuleImport,
|
|
@@ -1906,10 +2379,6 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1906
2379
|
// Universal mocks create mock files at __codeyamMocks__/{safeFileName}.tsx
|
|
1907
2380
|
// We need to rewrite imports like `import { logger } from "@formbricks/logger"`
|
|
1908
2381
|
// to `import { logger } from "../__codeyamMocks__/_formbricks_logger"`
|
|
1909
|
-
const universalMocks = project.metadata?.universalMocks ?? [];
|
|
1910
|
-
const nodeModuleUniversalMocks = universalMocks.filter(
|
|
1911
|
-
(mock) => mock.nodeModule && mock.content,
|
|
1912
|
-
);
|
|
1913
2382
|
|
|
1914
2383
|
for (const universalMock of nodeModuleUniversalMocks) {
|
|
1915
2384
|
const originalPath = universalMock.filePath;
|
|
@@ -1932,6 +2401,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1932
2401
|
);
|
|
1933
2402
|
}
|
|
1934
2403
|
|
|
2404
|
+
console.log(
|
|
2405
|
+
`[WriteScenario] POST-LOOP ${entity.name}: node+universal mocks took ${Date.now() - postLoopStartTime}ms`,
|
|
2406
|
+
);
|
|
2407
|
+
|
|
1935
2408
|
if (
|
|
1936
2409
|
rootAnalysis.entitySha === entity.sha &&
|
|
1937
2410
|
entity.metadata?.notExported &&
|
|
@@ -1973,31 +2446,46 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
1973
2446
|
});
|
|
1974
2447
|
}
|
|
1975
2448
|
|
|
2449
|
+
debugLog('Route path computed', { scenarioComponentPath });
|
|
2450
|
+
|
|
1976
2451
|
// Strip <html> and <body> tags from root layout files for Next.js
|
|
1977
2452
|
// These tags cause hydration errors when the scenario layout is nested under the real root
|
|
2453
|
+
debugLog('Starting stripHtmlBodyTags');
|
|
1978
2454
|
fileContent = stripHtmlBodyTags(fileContent, file.path, framework);
|
|
2455
|
+
debugLog('Completed stripHtmlBodyTags');
|
|
1979
2456
|
|
|
1980
2457
|
// Strip "server-only" imports for Next.js
|
|
1981
2458
|
// These cause errors when the scenario component is rendered client-side
|
|
2459
|
+
debugLog('Starting stripServerOnlyImport');
|
|
1982
2460
|
fileContent = stripServerOnlyImport(fileContent);
|
|
2461
|
+
debugLog('Starting applyServerOnlyMocks');
|
|
1983
2462
|
fileContent = applyServerOnlyMocks(fileContent);
|
|
2463
|
+
debugLog('Completed server-only processing');
|
|
1984
2464
|
|
|
1985
2465
|
// Rewrite asset imports (CSS, images, fonts, etc.) to correct relative paths
|
|
1986
2466
|
// The original file path is relative to PROJECT_RELATIVE_PATH, the new path is scenarioComponentPath
|
|
2467
|
+
debugLog('Starting rewriteAssetImports');
|
|
1987
2468
|
fileContent = rewriteAssetImports(
|
|
1988
2469
|
fileContent,
|
|
1989
2470
|
`${PROJECT_RELATIVE_PATH}/${file.path}`,
|
|
1990
2471
|
scenarioComponentPath,
|
|
1991
2472
|
);
|
|
2473
|
+
debugLog('Completed rewriteAssetImports');
|
|
1992
2474
|
|
|
1993
2475
|
// Rewrite relative TypeScript/JavaScript module imports to correct relative paths
|
|
1994
2476
|
// This handles cases where the file is moved (e.g., from [environmentId]/ to _environmentId_/)
|
|
1995
2477
|
// and relative imports like "./lib/organization" need to be rewritten
|
|
2478
|
+
debugLog('Starting rewriteRelativeModuleImports');
|
|
1996
2479
|
fileContent = rewriteRelativeModuleImports(
|
|
1997
2480
|
fileContent,
|
|
1998
2481
|
`${PROJECT_RELATIVE_PATH}/${file.path}`,
|
|
1999
2482
|
scenarioComponentPath,
|
|
2000
2483
|
);
|
|
2484
|
+
debugLog('Completed rewriteRelativeModuleImports');
|
|
2485
|
+
|
|
2486
|
+
console.log(
|
|
2487
|
+
`[WriteScenario] POST-LOOP ${entity.name}: transformations took ${Date.now() - postLoopStartTime}ms`,
|
|
2488
|
+
);
|
|
2001
2489
|
|
|
2002
2490
|
/**
|
|
2003
2491
|
* Recursively process a file's imports to create transitive copies with server-only stripped.
|
|
@@ -2015,21 +2503,69 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2015
2503
|
sourceFilePath: string,
|
|
2016
2504
|
targetFilePath: string,
|
|
2017
2505
|
visitedPaths: Set<string> = new Set(),
|
|
2506
|
+
depth: number = 0,
|
|
2507
|
+
startTime: number = Date.now(),
|
|
2018
2508
|
): Promise<string> {
|
|
2509
|
+
// Global timeout for entire transitive processing
|
|
2510
|
+
const GLOBAL_TIMEOUT_MS = 180000; // 3 minutes max for all transitive processing (complex components need more time)
|
|
2511
|
+
const elapsed = Date.now() - startTime;
|
|
2512
|
+
if (elapsed > GLOBAL_TIMEOUT_MS) {
|
|
2513
|
+
throw new Error(
|
|
2514
|
+
`processTransitiveImportsRecursively exceeded ${GLOBAL_TIMEOUT_MS}ms (elapsed: ${elapsed}ms) at depth=${depth} for ${sourceFilePath}`,
|
|
2515
|
+
);
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2019
2518
|
const importPaths = extractInternalImportPaths(content);
|
|
2519
|
+
// Always log to help debug timeout issues
|
|
2520
|
+
console.log(
|
|
2521
|
+
`[TransitiveImports] depth=${depth} file=${path.basename(sourceFilePath)} imports=${importPaths.length} visited=${visitedPaths.size} elapsed=${Date.now() - startTime}ms`,
|
|
2522
|
+
);
|
|
2523
|
+
debugLog(`processTransitiveImportsRecursively depth=${depth}`, {
|
|
2524
|
+
sourceFilePath,
|
|
2525
|
+
importCount: importPaths.length,
|
|
2526
|
+
visitedCount: visitedPaths.size,
|
|
2527
|
+
});
|
|
2020
2528
|
let modifiedContent = content;
|
|
2021
2529
|
|
|
2022
|
-
|
|
2530
|
+
// Safety check: limit iterations to prevent infinite loops
|
|
2531
|
+
const MAX_IMPORTS_PER_FILE = 100;
|
|
2532
|
+
if (importPaths.length > MAX_IMPORTS_PER_FILE) {
|
|
2533
|
+
console.warn(
|
|
2534
|
+
`[WriteScenario] WARNING: File ${sourceFilePath} has ${importPaths.length} imports (> ${MAX_IMPORTS_PER_FILE}), limiting processing`,
|
|
2535
|
+
);
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
let importIndex = 0;
|
|
2539
|
+
debugLog(
|
|
2540
|
+
`Starting import loop at depth=${depth}, ${importPaths.length} imports to process`,
|
|
2541
|
+
);
|
|
2542
|
+
const slicedImports = importPaths.slice(0, MAX_IMPORTS_PER_FILE);
|
|
2543
|
+
for (const importPath of slicedImports) {
|
|
2544
|
+
if (!importPath) {
|
|
2545
|
+
continue;
|
|
2546
|
+
}
|
|
2547
|
+
importIndex++;
|
|
2548
|
+
debugLog(
|
|
2549
|
+
`[LOOP] depth=${depth} import ${importIndex}/${Math.min(importPaths.length, MAX_IMPORTS_PER_FILE)}: ${importPath}`,
|
|
2550
|
+
);
|
|
2551
|
+
debugLog(`[LOOP] Calling resolveImportPath...`);
|
|
2023
2552
|
const resolvedPath = resolveImportPath(
|
|
2024
2553
|
importPath,
|
|
2025
2554
|
sourceFilePath,
|
|
2026
2555
|
project,
|
|
2027
2556
|
);
|
|
2557
|
+
debugLog(
|
|
2558
|
+
`[LOOP] resolveImportPath returned: ${resolvedPath?.slice(0, 80) ?? 'null'}`,
|
|
2559
|
+
);
|
|
2028
2560
|
if (!resolvedPath) continue;
|
|
2029
2561
|
|
|
2562
|
+
debugLog(`[LOOP] Looking up importFile...`);
|
|
2030
2563
|
let importFile = fileStore
|
|
2031
2564
|
? fileStore.getByPath(resolvedPath)
|
|
2032
2565
|
: project.files?.find((f) => f.path === resolvedPath);
|
|
2566
|
+
debugLog(
|
|
2567
|
+
`[LOOP] importFile lookup result: ${importFile ? 'found' : 'not found'}`,
|
|
2568
|
+
);
|
|
2033
2569
|
if (!importFile) continue;
|
|
2034
2570
|
|
|
2035
2571
|
// Build the transitive file path (needed for import rewriting even if we skip creating)
|
|
@@ -2038,8 +2574,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2038
2574
|
);
|
|
2039
2575
|
const extension = importFile.name.split('.').pop();
|
|
2040
2576
|
const isIndex = isIndexPath(importFile.path);
|
|
2041
|
-
|
|
2042
|
-
const
|
|
2577
|
+
// Limit pathHash length to prevent ENAMETOOLONG errors on macOS (255 char limit)
|
|
2578
|
+
const pathHash = safeFileName(importFile.path, { maxLength: 80 });
|
|
2579
|
+
const scenarioSlug = safeFileName(scenario.name, { maxLength: 60 });
|
|
2580
|
+
const transitiveFilePath = `${PROJECT_RELATIVE_PATH}/${basePath}/${pathHash}_${isIndex ? 'index_' : ''}transitive_${scenarioSlug}.${extension}`;
|
|
2043
2581
|
|
|
2044
2582
|
// Check if this is a circular import (we're already processing this file)
|
|
2045
2583
|
const isCircularImport = visitedPaths.has(resolvedPath);
|
|
@@ -2064,14 +2602,37 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2064
2602
|
// Strip server-only and mock server-only packages, then recursively process imports
|
|
2065
2603
|
let transitiveContent = stripServerOnlyImport(importFile.content);
|
|
2066
2604
|
transitiveContent = applyServerOnlyMocks(transitiveContent);
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2605
|
+
debugLog(
|
|
2606
|
+
`processTransitiveImportsRecursively depth=${depth} for ${importFile.path}`,
|
|
2607
|
+
);
|
|
2608
|
+
debugLog(
|
|
2609
|
+
`Calling processTransitiveImportsRecursively depth=${depth + 1} for ${importFile.path}`,
|
|
2610
|
+
);
|
|
2611
|
+
transitiveContent = await withTimeout(
|
|
2612
|
+
`processTransitiveImportsRecursively depth=${depth} for ${path.basename(importFile.path)}`,
|
|
2613
|
+
processTransitiveImportsRecursively(
|
|
2614
|
+
transitiveContent,
|
|
2615
|
+
importFile.path,
|
|
2616
|
+
transitiveFilePath,
|
|
2617
|
+
visitedPaths,
|
|
2618
|
+
depth + 1,
|
|
2619
|
+
startTime, // Pass through the original start time
|
|
2620
|
+
),
|
|
2621
|
+
30000, // 30 second timeout per transitive import
|
|
2622
|
+
);
|
|
2623
|
+
debugLog(
|
|
2624
|
+
`withTimeout returned for depth=${depth}, transitiveContent length=${transitiveContent.length}`,
|
|
2625
|
+
);
|
|
2626
|
+
debugLog(
|
|
2627
|
+
`Completed processTransitiveImportsRecursively depth=${depth} for ${importFile.path}`,
|
|
2072
2628
|
);
|
|
2073
2629
|
|
|
2630
|
+
debugLog(`Writing transitive file depth=${depth}`, {
|
|
2631
|
+
transitiveFilePath: path.basename(transitiveFilePath),
|
|
2632
|
+
contentLength: transitiveContent.length,
|
|
2633
|
+
});
|
|
2074
2634
|
await writeFile(transitiveFilePath, transitiveContent);
|
|
2635
|
+
debugLog(`Wrote transitive file depth=${depth}`);
|
|
2075
2636
|
scenarioComponentPaths.push(transitiveFilePath);
|
|
2076
2637
|
|
|
2077
2638
|
if (!writtenScenarioComponents[resolvedPath]) {
|
|
@@ -2085,6 +2646,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2085
2646
|
|
|
2086
2647
|
// ALWAYS rewrite the import to point to the transitive copy
|
|
2087
2648
|
// (even for circular imports or already-processed files)
|
|
2649
|
+
debugLog(`Rewriting import path depth=${depth}`, {
|
|
2650
|
+
importPath,
|
|
2651
|
+
resolvedPath,
|
|
2652
|
+
});
|
|
2088
2653
|
const relativePath = getRelativePath(targetFilePath, transitiveFilePath);
|
|
2089
2654
|
const relativePathWithoutExt = relativePath.replace(
|
|
2090
2655
|
/\.(ts|tsx|js|jsx)$/,
|
|
@@ -2095,30 +2660,79 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2095
2660
|
/[.*+?^${}()|[\]\\]/g,
|
|
2096
2661
|
'\\$&',
|
|
2097
2662
|
);
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
);
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2663
|
+
debugLog(`Applying regex depth=${depth}`, {
|
|
2664
|
+
escapedImportPath,
|
|
2665
|
+
contentLength: modifiedContent.length,
|
|
2666
|
+
});
|
|
2667
|
+
// Quick check if the import path even exists in content
|
|
2668
|
+
const simpleCheck = modifiedContent.includes(importPath);
|
|
2669
|
+
debugLog(
|
|
2670
|
+
`Simple check: importPath "${importPath}" exists: ${simpleCheck}`,
|
|
2105
2671
|
);
|
|
2672
|
+
if (!simpleCheck) {
|
|
2673
|
+
debugLog(`Skipping regex - import path not found in content`);
|
|
2674
|
+
} else {
|
|
2675
|
+
const regexPattern = `(from\\s*["'])${escapedImportPath}(["'])`;
|
|
2676
|
+
debugLog(`Regex pattern: ${regexPattern.slice(0, 100)}`);
|
|
2677
|
+
const importRegex = new RegExp(regexPattern, 'g');
|
|
2678
|
+
debugLog(`About to call replace...`);
|
|
2679
|
+
|
|
2680
|
+
// Timing for regex replace to detect slow operations
|
|
2681
|
+
const replaceStart = Date.now();
|
|
2682
|
+
modifiedContent = modifiedContent.replace(
|
|
2683
|
+
importRegex,
|
|
2684
|
+
`$1${safeRelativePath}$2`,
|
|
2685
|
+
);
|
|
2686
|
+
const replaceTime = Date.now() - replaceStart;
|
|
2687
|
+
if (replaceTime > 100) {
|
|
2688
|
+
console.warn(
|
|
2689
|
+
`[WriteScenario] SLOW regex replace: ${replaceTime}ms for pattern ${regexPattern.slice(0, 50)} on ${modifiedContent.length} bytes`,
|
|
2690
|
+
);
|
|
2691
|
+
}
|
|
2692
|
+
debugLog(`Regex applied depth=${depth} in ${replaceTime}ms`);
|
|
2693
|
+
}
|
|
2694
|
+
debugLog(`[LOOP END] depth=${depth} import ${importIndex} completed`);
|
|
2106
2695
|
}
|
|
2107
2696
|
|
|
2697
|
+
debugLog(`[LOOP DONE] Exiting import loop at depth=${depth}`);
|
|
2698
|
+
debugLog(
|
|
2699
|
+
`Returning from processTransitiveImportsRecursively depth=${depth}`,
|
|
2700
|
+
);
|
|
2108
2701
|
return modifiedContent;
|
|
2109
2702
|
}
|
|
2110
2703
|
|
|
2704
|
+
console.log(
|
|
2705
|
+
`[WriteScenario] POST-LOOP ${entity.name}: before remaining imports ${Date.now() - postLoopStartTime}ms`,
|
|
2706
|
+
);
|
|
2707
|
+
|
|
2111
2708
|
// Process remaining internal imports that weren't in importedExports
|
|
2112
2709
|
// This handles transitive dependencies: when the file content includes code (e.g., from
|
|
2113
2710
|
// other functions in the same file) that imports from files with "server-only"
|
|
2711
|
+
debugLog('Extracting remaining import paths');
|
|
2114
2712
|
const remainingImportPaths = extractInternalImportPaths(fileContent);
|
|
2713
|
+
debugLog('Found remaining import paths', {
|
|
2714
|
+
count: remainingImportPaths.length,
|
|
2715
|
+
});
|
|
2115
2716
|
|
|
2116
2717
|
// Get all file paths that are in importedExports - these are handled by main processing
|
|
2117
2718
|
const importedExportFilePaths = new Set(
|
|
2118
2719
|
allImportedExports.map((ie) => ie.resolvedFilePath || ie.filePath),
|
|
2119
2720
|
);
|
|
2120
2721
|
|
|
2722
|
+
debugLog('Starting remaining imports loop', {
|
|
2723
|
+
remainingCount: remainingImportPaths.length,
|
|
2724
|
+
importedExportCount: importedExportFilePaths.size,
|
|
2725
|
+
});
|
|
2726
|
+
|
|
2727
|
+
let remainingImportIndex = 0;
|
|
2728
|
+
debugLog(
|
|
2729
|
+
`[REMAINING] Starting remaining imports loop, ${remainingImportPaths.length} imports`,
|
|
2730
|
+
);
|
|
2121
2731
|
for (const importPath of remainingImportPaths) {
|
|
2732
|
+
remainingImportIndex++;
|
|
2733
|
+
debugLog(
|
|
2734
|
+
`[REMAINING LOOP] import ${remainingImportIndex}/${remainingImportPaths.length}: ${importPath}`,
|
|
2735
|
+
);
|
|
2122
2736
|
// Resolve the import path to a project file path
|
|
2123
2737
|
const resolvedFilePath = resolveImportPath(importPath, file.path, project);
|
|
2124
2738
|
|
|
@@ -2166,8 +2780,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2166
2780
|
);
|
|
2167
2781
|
const targetFileExtension = targetFile.name.split('.').pop();
|
|
2168
2782
|
const targetFileIsIndex = isIndexPath(targetFile.path);
|
|
2169
|
-
|
|
2170
|
-
const
|
|
2783
|
+
// Limit path hash length to prevent ENAMETOOLONG errors
|
|
2784
|
+
const filePathHash = safeFileName(targetFile.path, { maxLength: 80 });
|
|
2785
|
+
const targetScenarioSlug = safeFileName(scenario.name, { maxLength: 60 });
|
|
2786
|
+
const transformedFilePath = `${PROJECT_RELATIVE_PATH}/${targetFileBasePath}/${filePathHash}_${targetFileIsIndex ? 'index_' : ''}transitive_${targetScenarioSlug}.${targetFileExtension}`;
|
|
2171
2787
|
|
|
2172
2788
|
// Check if we've already processed this file as a transitive copy
|
|
2173
2789
|
// Note: __data_file_written__ is for entity-specific scenario files with different naming,
|
|
@@ -2194,7 +2810,15 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2194
2810
|
// Recursively process this transitive file's imports
|
|
2195
2811
|
// This handles the nested case: service.ts → brevo.ts → constants.ts
|
|
2196
2812
|
const nestedImportPaths = extractInternalImportPaths(transformedContent);
|
|
2813
|
+
debugLog(
|
|
2814
|
+
`[NESTED] Processing ${nestedImportPaths.length} nested imports for ${targetFile.path}`,
|
|
2815
|
+
);
|
|
2816
|
+
let nestedIndex = 0;
|
|
2197
2817
|
for (const nestedImportPath of nestedImportPaths) {
|
|
2818
|
+
nestedIndex++;
|
|
2819
|
+
debugLog(
|
|
2820
|
+
`[NESTED LOOP] import ${nestedIndex}/${nestedImportPaths.length}: ${nestedImportPath}`,
|
|
2821
|
+
);
|
|
2198
2822
|
const nestedResolvedPath = resolveImportPath(
|
|
2199
2823
|
nestedImportPath,
|
|
2200
2824
|
targetFile.path,
|
|
@@ -2214,8 +2838,12 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2214
2838
|
);
|
|
2215
2839
|
const nestedExtension = nestedFile.name.split('.').pop();
|
|
2216
2840
|
const nestedIsIndex = isIndexPath(nestedFile.path);
|
|
2217
|
-
|
|
2218
|
-
const
|
|
2841
|
+
// Limit path hash length to prevent ENAMETOOLONG errors
|
|
2842
|
+
const nestedPathHash = safeFileName(nestedFile.path, { maxLength: 80 });
|
|
2843
|
+
const nestedScenarioSlug = safeFileName(scenario.name, {
|
|
2844
|
+
maxLength: 60,
|
|
2845
|
+
});
|
|
2846
|
+
const nestedTransformedPath = `${PROJECT_RELATIVE_PATH}/${nestedBasePath}/${nestedPathHash}_${nestedIsIndex ? 'index_' : ''}transitive_${nestedScenarioSlug}.${nestedExtension}`;
|
|
2219
2847
|
|
|
2220
2848
|
// Check if already processed as a transitive file (we can rewrite to point to it)
|
|
2221
2849
|
// Note: __data_file_written__ is for entity-specific scenario files with different naming,
|
|
@@ -2235,10 +2863,20 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2235
2863
|
// This handles chains of any depth: A -> B -> C -> D
|
|
2236
2864
|
let nestedContent = stripServerOnlyImport(nestedFile.content);
|
|
2237
2865
|
nestedContent = applyServerOnlyMocks(nestedContent);
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2866
|
+
debugLog(
|
|
2867
|
+
`processTransitiveImportsRecursively (nested) for ${nestedFile.path}`,
|
|
2868
|
+
);
|
|
2869
|
+
nestedContent = await withTimeout(
|
|
2870
|
+
`processTransitiveImportsRecursively (nested) for ${path.basename(nestedFile.path)}`,
|
|
2871
|
+
processTransitiveImportsRecursively(
|
|
2872
|
+
nestedContent,
|
|
2873
|
+
nestedFile.path,
|
|
2874
|
+
nestedTransformedPath,
|
|
2875
|
+
),
|
|
2876
|
+
30000, // 30 second timeout per nested transitive import
|
|
2877
|
+
);
|
|
2878
|
+
debugLog(
|
|
2879
|
+
`Completed processTransitiveImportsRecursively (nested) for ${nestedFile.path}`,
|
|
2242
2880
|
);
|
|
2243
2881
|
|
|
2244
2882
|
await writeFile(nestedTransformedPath, nestedContent);
|
|
@@ -2326,6 +2964,10 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2326
2964
|
fileContent = fileContent.replace(importRegex, `$1${safeRelativePath}$2`);
|
|
2327
2965
|
}
|
|
2328
2966
|
|
|
2967
|
+
console.log(
|
|
2968
|
+
`[WriteScenario] POST-LOOP ${entity.name}: remaining imports loop took ${Date.now() - postLoopStartTime}ms`,
|
|
2969
|
+
);
|
|
2970
|
+
|
|
2329
2971
|
const scenarioComponentComment = `// This file is auto-generated by CodeYam. Do not edit this file manually.
|
|
2330
2972
|
// This file contains content for a scenario component:
|
|
2331
2973
|
// Analyses being written: ${JSON.stringify(fileAnalyses?.map((a) => ({ id: a.id, entityName: a.entityName })))}
|
|
@@ -2337,6 +2979,34 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2337
2979
|
// Scenario: ${scenario.id} - ${scenario.name}
|
|
2338
2980
|
`;
|
|
2339
2981
|
|
|
2982
|
+
// Final pass: Rename any namespace imports (import * as X from '...') that have
|
|
2983
|
+
// corresponding mock code using ...X__cyOriginal spread pattern.
|
|
2984
|
+
// This handles cases where:
|
|
2985
|
+
// 1. The import path was rewritten by transitive import handling
|
|
2986
|
+
// 2. The import wasn't caught by the earlier renaming logic
|
|
2987
|
+
// We scan for all __cyOriginal references in the mock code and ensure the imports are renamed.
|
|
2988
|
+
const cyOriginalReferences = fileContent.match(/\.\.\.(\w+)__cyOriginal/g);
|
|
2989
|
+
if (cyOriginalReferences) {
|
|
2990
|
+
const uniqueNames = [
|
|
2991
|
+
...new Set(
|
|
2992
|
+
cyOriginalReferences.map((ref) =>
|
|
2993
|
+
ref.replace('...', '').replace('__cyOriginal', ''),
|
|
2994
|
+
),
|
|
2995
|
+
),
|
|
2996
|
+
];
|
|
2997
|
+
for (const name of uniqueNames) {
|
|
2998
|
+
// Match namespace imports for this name that haven't been renamed yet
|
|
2999
|
+
const namespaceImportRegex = new RegExp(
|
|
3000
|
+
`(import\\s+\\*\\s+as\\s+)${escapeRegExp(name)}(\\s+from\\s+['"][^'"]*['"])`,
|
|
3001
|
+
'g',
|
|
3002
|
+
);
|
|
3003
|
+
fileContent = fileContent.replace(
|
|
3004
|
+
namespaceImportRegex,
|
|
3005
|
+
`$1${name}__cyOriginal$2`,
|
|
3006
|
+
);
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
|
|
2340
3010
|
// Use the directive that was extracted at the beginning of processing
|
|
2341
3011
|
// This ensures it stays at the very top even after imports are prepended
|
|
2342
3012
|
// NOTE: We only preserve "use client" directives, NOT "use server" directives.
|
|
@@ -2350,8 +3020,17 @@ ${exportKeyword}const ${functionName} = new Proxy(() => scenarios().data()?.["${
|
|
|
2350
3020
|
finalContent = `${scenarioComponentComment}\n\n${fileContent}`;
|
|
2351
3021
|
}
|
|
2352
3022
|
|
|
3023
|
+
debugLog('About to write final scenario file', {
|
|
3024
|
+
scenarioComponentPath,
|
|
3025
|
+
contentLength: finalContent.length,
|
|
3026
|
+
});
|
|
2353
3027
|
await writeFile(scenarioComponentPath, finalContent);
|
|
3028
|
+
debugLog('Successfully wrote scenario file');
|
|
2354
3029
|
scenarioComponentPaths.push(scenarioComponentPath);
|
|
2355
3030
|
|
|
3031
|
+
console.log(
|
|
3032
|
+
`[WriteScenario] POST-LOOP ${entity.name}: COMPLETE total=${Date.now() - postLoopStartTime}ms`,
|
|
3033
|
+
);
|
|
3034
|
+
|
|
2356
3035
|
return { scenarioComponentPaths, writtenScenarioComponents };
|
|
2357
3036
|
}
|