@codeyam/codeyam-cli 0.1.0-staging.76566f9 → 0.1.0-staging.78c1cad
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 +32 -29
- package/analyzer-template/packages/ai/index.ts +21 -5
- package/analyzer-template/packages/ai/package.json +4 -4
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +226 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +217 -13
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +316 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/nodeToSource.ts +19 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/paths.ts +11 -4
- package/analyzer-template/packages/ai/src/lib/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 +15 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1229 -30
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +265 -6
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +247 -66
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2041 -328
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.ts +10 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +296 -35
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +10 -2
- 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 +70 -9
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +129 -20
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.ts +62 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +140 -14
- 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 +393 -90
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.ts +35 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -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 +33 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +86 -142
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +59 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1461 -67
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +200 -196
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +677 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2484 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +5 -5
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -142
- 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 +110 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -89
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +11 -11
- 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 +122 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
- package/analyzer-template/packages/analyze/index.ts +6 -1
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +132 -33
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/getNodeType.ts +1 -0
- 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 +492 -282
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +47 -37
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +25 -6
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +13 -14
- package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts +21 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +115 -20
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +35 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +15 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeNextRoute.ts +8 -3
- 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 +1352 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +201 -46
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +304 -66
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +579 -29
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +166 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -3
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1839 -844
- 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/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 +10 -10
- 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/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/index.ts +1 -0
- package/analyzer-template/packages/database/package.json +4 -4
- package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +22 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +17 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +164 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +38 -15
- 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 +58 -19
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -9
- package/analyzer-template/packages/database/src/lib/loadEntity.ts +19 -8
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +5 -6
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +96 -152
- package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatus.ts +58 -42
- package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.ts +81 -65
- package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
- 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 +221 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +33 -5
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/index.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/index.js +1 -0
- package/analyzer-template/packages/github/dist/database/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +4 -0
- 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 +16 -1
- 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/tables/analysesTable.d.ts +1 -18
- 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 +17 -1
- 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.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +29 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +149 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
- 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/labsRequestsTable.d.ts +23 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +7 -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 +15 -1
- 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 +45 -14
- 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 -10
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts +4 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js +5 -5
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/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 +5 -5
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.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 +76 -89
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js +41 -30
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.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 +217 -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 +33 -5
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.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 +3 -4
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js +0 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js +2 -0
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +71 -27
- 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 +8 -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 +19 -54
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- 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/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 +2 -2
- 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 +3 -6
- package/analyzer-template/packages/types/src/enums/ProjectFramework.ts +2 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +87 -27
- 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 +8 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +19 -77
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +181 -5
- 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/package.json +1 -1
- package/analyzer-template/packages/utils/dist/types/index.d.ts +3 -4
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js +0 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js +2 -0
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +71 -27
- 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 +8 -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 +19 -54
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- 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/fs/rsyncCopy.d.ts +3 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +120 -4
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.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/fs/rsyncCopy.ts +148 -3
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +57 -26
- package/analyzer-template/playwright/captureFromUrl.ts +89 -82
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -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 +30 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1149 -130
- 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 +18 -7
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +85 -10
- package/analyzer-template/project/reconcileMockDataKeys.ts +246 -1
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/runMultiScenarioServer.ts +26 -3
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +54 -15
- package/analyzer-template/project/startScenarioCapture.ts +15 -0
- package/analyzer-template/project/writeClientLogRoute.ts +125 -0
- package/analyzer-template/project/writeMockDataTsx.ts +315 -11
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +420 -57
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +23 -13
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +14 -1
- package/background/src/lib/local/createLocalAnalyzer.js +2 -30
- 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 +24 -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 +1002 -88
- 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 +7 -5
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +69 -11
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +206 -1
- 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 +23 -3
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +49 -15
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +12 -0
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeClientLogRoute.js +110 -0
- package/background/src/lib/virtualized/project/writeClientLogRoute.js.map +1 -0
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +267 -8
- 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 +326 -51
- 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 +23 -13
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +386 -9
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
- package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
- package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
- package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
- package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
- package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
- package/codeyam-cli/src/cli.js +62 -23
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js +47 -0
- package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js +71 -0
- package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.designSystem.test.js +30 -0
- package/codeyam-cli/src/commands/__tests__/editor.designSystem.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js +51 -0
- package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +56 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +101 -47
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +22 -10
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +176 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +37 -23
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +43 -35
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/editor.js +5923 -0
- package/codeyam-cli/src/commands/editor.js.map +1 -0
- package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js +23 -0
- package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js.map +1 -0
- package/codeyam-cli/src/commands/editorIsolateArgs.js +25 -0
- package/codeyam-cli/src/commands/editorIsolateArgs.js.map +1 -0
- package/codeyam-cli/src/commands/init.js +148 -292
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +278 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +31 -18
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/report.js +46 -1
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- 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/telemetry.js +37 -0
- package/codeyam-cli/src/commands/telemetry.js.map +1 -0
- package/codeyam-cli/src/commands/test-startup.js +3 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +14 -2
- package/codeyam-cli/src/commands/verify.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/data/designSystems.js +27 -0
- package/codeyam-cli/src/data/designSystems.js.map +1 -0
- package/codeyam-cli/src/data/techStacks.js +77 -0
- package/codeyam-cli/src/data/techStacks.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +173 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js +46 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js +134 -0
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js +181 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +4024 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js +76 -0
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
- package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js +137 -0
- package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js +100 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +304 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +194 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +381 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js +67 -0
- package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
- package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +542 -0
- package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +594 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js +435 -0
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorMockState.test.js +270 -0
- package/codeyam-cli/src/utils/__tests__/editorMockState.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +217 -0
- package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +361 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +153 -0
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +291 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +1768 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +329 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js +143 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js +66 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js +53 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +2121 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/git.editor.test.js +134 -0
- package/codeyam-cli/src/utils/__tests__/git.editor.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js +177 -0
- package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +122 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js +302 -0
- package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +185 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +129 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js +9 -0
- package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/project.test.js +65 -0
- package/codeyam-cli/src/utils/__tests__/project.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js +127 -0
- package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js +118 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +284 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js +121 -0
- package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +672 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js +84 -0
- package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/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 +175 -82
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/telemetry.test.js +159 -0
- package/codeyam-cli/src/utils/__tests__/telemetry.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +51 -0
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/testRunner.test.js +216 -0
- package/codeyam-cli/src/utils/__tests__/testRunner.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +148 -0
- package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -0
- package/codeyam-cli/src/utils/analysisRunner.js +67 -22
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +26 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js +100 -0
- package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
- package/codeyam-cli/src/utils/backgroundServer.js +203 -30
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/buildFlags.js +4 -0
- package/codeyam-cli/src/utils/buildFlags.js.map +1 -0
- package/codeyam-cli/src/utils/database.js +128 -7
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/devModeEvents.js +40 -0
- package/codeyam-cli/src/utils/devModeEvents.js.map +1 -0
- package/codeyam-cli/src/utils/devServerState.js +71 -0
- package/codeyam-cli/src/utils/devServerState.js.map +1 -0
- package/codeyam-cli/src/utils/editorApi.js +95 -0
- package/codeyam-cli/src/utils/editorApi.js.map +1 -0
- package/codeyam-cli/src/utils/editorAudit.js +844 -0
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -0
- package/codeyam-cli/src/utils/editorBroadcastViewport.js +26 -0
- package/codeyam-cli/src/utils/editorBroadcastViewport.js.map +1 -0
- package/codeyam-cli/src/utils/editorCapture.js +102 -0
- package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js +67 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js.map +1 -0
- package/codeyam-cli/src/utils/editorDevServer.js +197 -0
- package/codeyam-cli/src/utils/editorDevServer.js.map +1 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js +50 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/editorEntityHelpers.js +144 -0
- package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorGuard.js +36 -0
- package/codeyam-cli/src/utils/editorGuard.js.map +1 -0
- package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
- package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
- package/codeyam-cli/src/utils/editorJournal.js +225 -0
- package/codeyam-cli/src/utils/editorJournal.js.map +1 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js +152 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorMigration.js +224 -0
- package/codeyam-cli/src/utils/editorMigration.js.map +1 -0
- package/codeyam-cli/src/utils/editorMockState.js +248 -0
- package/codeyam-cli/src/utils/editorMockState.js.map +1 -0
- package/codeyam-cli/src/utils/editorPreloadHelpers.js +135 -0
- package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorPreview.js +139 -0
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -0
- package/codeyam-cli/src/utils/editorRecapture.js +109 -0
- package/codeyam-cli/src/utils/editorRecapture.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js +134 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarios.js +677 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js +462 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
- package/codeyam-cli/src/utils/editorShouldRevalidate.js +21 -0
- package/codeyam-cli/src/utils/editorShouldRevalidate.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js +394 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +227 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
- package/codeyam-cli/src/utils/fileMetadata.js +5 -0
- package/codeyam-cli/src/utils/fileMetadata.js.map +1 -1
- package/codeyam-cli/src/utils/fileWatcher.js +63 -9
- package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +4 -3
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +182 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/glossaryAdd.js +74 -0
- package/codeyam-cli/src/utils/glossaryAdd.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +134 -39
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/interactiveSyncWatcher.js +126 -0
- package/codeyam-cli/src/utils/interactiveSyncWatcher.js.map +1 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/manualEntityAnalysis.js +196 -0
- package/codeyam-cli/src/utils/manualEntityAnalysis.js.map +1 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
- package/codeyam-cli/src/utils/parseRegisterArg.js +31 -0
- package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
- package/codeyam-cli/src/utils/pathIgnoring.js +19 -7
- package/codeyam-cli/src/utils/pathIgnoring.js.map +1 -1
- package/codeyam-cli/src/utils/progress.js +8 -1
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/project.js +15 -5
- package/codeyam-cli/src/utils/project.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js +11 -11
- package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js +159 -0
- package/codeyam-cli/src/utils/queue/__tests__/job.interactiveStart.test.js.map +1 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +22 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/heartbeat.js +13 -5
- package/codeyam-cli/src/utils/queue/heartbeat.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +214 -7
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +7 -0
- 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/registerScenarioResult.js +52 -0
- package/codeyam-cli/src/utils/registerScenarioResult.js.map +1 -0
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/routePatternMatching.js +129 -0
- package/codeyam-cli/src/utils/routePatternMatching.js.map +1 -0
- package/codeyam-cli/src/utils/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 +229 -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 +74 -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 +376 -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 +113 -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 +116 -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 +44 -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__/parser.test.js +83 -0
- package/codeyam-cli/src/utils/rules/__tests__/parser.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js +118 -0
- package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js +72 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.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/__tests__/sourceFiles.test.js +76 -0
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +7 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +93 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +49 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.js +65 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.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/sourceFiles.js +43 -0
- package/codeyam-cli/src/utils/rules/sourceFiles.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/scenarioCoverage.js +77 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
- package/codeyam-cli/src/utils/scenarioMarkers.js +134 -0
- package/codeyam-cli/src/utils/scenarioMarkers.js.map +1 -0
- package/codeyam-cli/src/utils/scenariosManifest.js +313 -0
- package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
- package/codeyam-cli/src/utils/screenshotHash.js +26 -0
- package/codeyam-cli/src/utils/screenshotHash.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +94 -12
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +96 -45
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js +175 -0
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -0
- package/codeyam-cli/src/utils/slugUtils.js +25 -0
- package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
- package/codeyam-cli/src/utils/syncMocksMiddleware.js +7 -26
- package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/telemetry.js +106 -0
- package/codeyam-cli/src/utils/telemetry.js.map +1 -0
- package/codeyam-cli/src/utils/telemetryMiddleware.js +22 -0
- package/codeyam-cli/src/utils/telemetryMiddleware.js.map +1 -0
- package/codeyam-cli/src/utils/testResultCache.js +53 -0
- package/codeyam-cli/src/utils/testResultCache.js.map +1 -0
- package/codeyam-cli/src/utils/testResultCache.server.js +81 -0
- package/codeyam-cli/src/utils/testResultCache.server.js.map +1 -0
- package/codeyam-cli/src/utils/testResultCache.server.test.js +187 -0
- package/codeyam-cli/src/utils/testResultCache.server.test.js.map +1 -0
- package/codeyam-cli/src/utils/testResultCache.test.js +230 -0
- package/codeyam-cli/src/utils/testResultCache.test.js.map +1 -0
- package/codeyam-cli/src/utils/testRunner.js +350 -0
- package/codeyam-cli/src/utils/testRunner.js.map +1 -0
- package/codeyam-cli/src/utils/transcriptPruning.js +67 -0
- package/codeyam-cli/src/utils/transcriptPruning.js.map +1 -0
- package/codeyam-cli/src/utils/versionInfo.js +67 -15
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/webappDetection.js +38 -3
- package/codeyam-cli/src/utils/webappDetection.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/__tests__/api.interactive-switch-scenario.test.js +98 -0
- package/codeyam-cli/src/webserver/__tests__/api.interactive-switch-scenario.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js +35 -0
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +107 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js +66 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +647 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +315 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js +135 -0
- package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js +86 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +129 -50
- 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/app/lib/git.js +397 -0
- package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
- package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js +34 -0
- package/codeyam-cli/src/webserver/app/routes/api.interactive-switch-scenario.js.map +1 -0
- package/codeyam-cli/src/webserver/app/types/editor.js +8 -0
- package/codeyam-cli/src/webserver/app/types/editor.js.map +1 -0
- package/codeyam-cli/src/webserver/backgroundServer.js +186 -37
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +51 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CLe80MMu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-Crt_KN_U.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CQgyEGV-.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CD7lGABo.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-CgTNOhnu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DtYTSPL2.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-D3s1MFkb.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-D1CdlbrV.js → LoadingDots-By5zI316.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-wDPcZNKx.js → LogViewer-CM5zg40N.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/MiniClaudeChat-CQENLSrF.js +36 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-C2PLkej3.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DanvyBPb.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CefgqbCr.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bc8BG-Lw.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CK7-NaPZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-BA_Ry-rs.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/_index-C1YkzTAV.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-yH46LLUz.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-web-links-CHx25PAe.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-Bg3e7q4S.js +22 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-capture-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-client-errors-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-commit-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-dev-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-entity-status-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-entry-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-image._-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-screenshot-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-update-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-load-commit-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-recapture-stale-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-refresh-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-register-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-rename-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-scenario-data-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-seed-state-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-data-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-image._-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-prompt-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenarios-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-schema-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-switch-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-test-results-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-verify-routes-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.interactive-switch-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-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.rule-path-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-CL-lMgHh.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BYimnrHg.js → chevron-down-GmAjGS9-.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-BAdwhyCx.js +43 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CaVsIRxt.js → circle-check-DFcQkN5j.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/copy-C6iF61Xs.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-4ImjHTVC.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-Coe5NhbS.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-DoA97ML3.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CRepiabR.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor._tab-Gbk_i5Js.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-CRxPi2BB.js +96 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-CluPkvXJ.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-Dt-SjPsw.js → entity._sha._-DYJRGiDI.js} +14 -13
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-wdiwx5-Z.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-BrkN-40Y.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DxfhekTZ.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CfLCUi9S.js → entity._sha_.edit._scenarioId-CRXJWmpB.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DKJyZfAY.js → entry.client-SuW9syRS.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-Daa96Fr1.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-D-xGrg29.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-Bq_fbXP5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-BsGHu8WX.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-BosqDOlH.js → index-Bp1l4hSv.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-CzNNiTkw.js → index-CWV9XZiG.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/index-DE3jI_dv.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-B_IX45ih.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CNp9QFCX.js → loader-circle-De-7qQ2u.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/manifest-9032538f.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-Cx2xEx7s.js +101 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-CFxEKL1u.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-dKFRTYcy.js +80 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-DDGjYAMJ.js → search-BdBb5aqc.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/settings-DdE-Untf.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DSCdE99u.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-CrplD4b1.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CBc5dE1s.js → triangle-alert-DqJ0j69l.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DhXHbEjP.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-D9QZKaLJ.js +2 -0
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-Cy5Qg_UR.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useToast-5HR2j9ZE.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/xterm-BqvuqXEL.js +27 -0
- package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-B6HnVI5u.js +16 -0
- package/codeyam-cli/src/webserver/build/server/assets/index-rV_xLS1u.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/init-BdWDvetv.js +10 -0
- package/codeyam-cli/src/webserver/build/server/assets/progress-CHTtrxFG.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-B_jdq5dT.js +689 -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 +39 -5
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/editorProxy.js +1028 -0
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -0
- package/codeyam-cli/src/webserver/idleDetector.js +130 -0
- package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js +28 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js.map +1 -0
- package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +414 -0
- package/codeyam-cli/src/webserver/scripts/journalCapture.ts +283 -0
- package/codeyam-cli/src/webserver/server.js +414 -26
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +952 -0
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -0
- package/codeyam-cli/templates/__tests__/editor-step-hook.prompt-capture.test.ts +118 -0
- package/codeyam-cli/templates/chrome-extension-react/EXTENSION_SETUP.md +75 -0
- package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
- package/codeyam-cli/templates/chrome-extension-react/gitignore +15 -0
- package/codeyam-cli/templates/chrome-extension-react/index.html +12 -0
- package/codeyam-cli/templates/chrome-extension-react/package.json +27 -0
- package/codeyam-cli/templates/chrome-extension-react/popup.html +12 -0
- package/codeyam-cli/templates/chrome-extension-react/public/manifest.json +15 -0
- package/codeyam-cli/templates/chrome-extension-react/src/background/service-worker.ts +7 -0
- package/codeyam-cli/templates/chrome-extension-react/src/globals.css +6 -0
- package/codeyam-cli/templates/chrome-extension-react/src/lib/storage.ts +37 -0
- package/codeyam-cli/templates/chrome-extension-react/src/popup/App.tsx +12 -0
- package/codeyam-cli/templates/chrome-extension-react/src/popup/main.tsx +10 -0
- package/codeyam-cli/templates/chrome-extension-react/tsconfig.json +24 -0
- package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +41 -0
- package/codeyam-cli/templates/codeyam-editor-claude.md +149 -0
- package/codeyam-cli/templates/codeyam-editor-reference.md +216 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/commands/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/design-systems/clean-dashboard-design-system.md +255 -0
- package/codeyam-cli/templates/design-systems/editorial-design-system.md +267 -0
- package/codeyam-cli/templates/design-systems/mono-brutalist-design-system.md +256 -0
- package/codeyam-cli/templates/design-systems/neo-brutalist-design-system.md +294 -0
- package/codeyam-cli/templates/editor-step-hook.py +368 -0
- package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +203 -0
- package/codeyam-cli/templates/expo-react-native/README.md +41 -0
- package/codeyam-cli/templates/expo-react-native/__tests__/.gitkeep +0 -0
- package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +13 -0
- package/codeyam-cli/templates/expo-react-native/app/index.tsx +36 -0
- package/codeyam-cli/templates/expo-react-native/app.json +18 -0
- package/codeyam-cli/templates/expo-react-native/babel.config.js +9 -0
- package/codeyam-cli/templates/expo-react-native/gitignore +12 -0
- package/codeyam-cli/templates/expo-react-native/global.css +10 -0
- package/codeyam-cli/templates/expo-react-native/lib/storage.ts +32 -0
- package/codeyam-cli/templates/expo-react-native/lib/theme.ts +73 -0
- package/codeyam-cli/templates/expo-react-native/metro.config.js +6 -0
- package/codeyam-cli/templates/expo-react-native/nativewind-env.d.ts +1 -0
- package/codeyam-cli/templates/expo-react-native/package.json +48 -0
- package/codeyam-cli/templates/expo-react-native/tailwind.config.js +10 -0
- package/codeyam-cli/templates/expo-react-native/tsconfig.json +10 -0
- package/codeyam-cli/templates/hooks/staleness-check.sh +43 -0
- package/codeyam-cli/templates/isolation-route/expo-router.tsx.template +54 -0
- package/codeyam-cli/templates/isolation-route/next-app.tsx.template +80 -0
- package/codeyam-cli/templates/isolation-route/next-pages.tsx.template +79 -0
- package/codeyam-cli/templates/isolation-route/vite-react.tsx.template +78 -0
- package/codeyam-cli/templates/msw/browser-setup.ts.template +47 -0
- package/codeyam-cli/templates/msw/handler-router.ts.template +47 -0
- package/codeyam-cli/templates/msw/server-setup.ts.template +52 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_PATTERNS.md +308 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_UPGRADE.md +304 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +126 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/FEATURE_PATTERNS.md +37 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/api/todos/route.ts +17 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/globals.css +26 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/layout.tsx +34 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +24 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/page.tsx +10 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/env +4 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/eslint.config.mjs +11 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +64 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/next.config.ts +14 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +39 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/postcss.config.mjs +7 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/schema.prisma +27 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +40 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma.config.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +140 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/tsconfig.json +34 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/SUPABASE_SETUP.md +104 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/api/todos/route.ts +17 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/globals.css +26 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/layout.tsx +34 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/prisma.ts +20 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/supabase.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/page.tsx +10 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/env +9 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/eslint.config.mjs +11 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/gitignore +40 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/next.config.ts +11 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +37 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/postcss.config.mjs +7 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/schema.prisma +27 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/seed.ts +39 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma.config.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/tsconfig.json +34 -0
- package/codeyam-cli/templates/prompts/conversation-guidance.txt +44 -0
- package/codeyam-cli/templates/prompts/conversation-prompt.txt +28 -0
- package/codeyam-cli/templates/prompts/interruption-prompt.txt +31 -0
- package/codeyam-cli/templates/prompts/stale-rules-prompt.txt +24 -0
- package/codeyam-cli/templates/rule-notification-hook.py +83 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +647 -0
- package/codeyam-cli/templates/rules-instructions.md +78 -0
- package/codeyam-cli/templates/seed-adapters/supabase.ts +291 -0
- package/codeyam-cli/templates/{codeyam-debug-skill.md → skills/codeyam-debug/SKILL.md} +48 -4
- package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +237 -0
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +244 -0
- package/codeyam-cli/templates/skills/codeyam-memory/SKILL.md +611 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/deprecated-prompt.md +100 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/misleading-api-prompt.md +117 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/analyze-prompt.md +46 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
- package/codeyam-cli/templates/skills/codeyam-new-rule/SKILL.md +11 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → skills/codeyam-setup/SKILL.md} +13 -1
- package/codeyam-cli/templates/{codeyam-sim-skill.md → skills/codeyam-sim/SKILL.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → skills/codeyam-test/SKILL.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → skills/codeyam-verify/SKILL.md} +1 -1
- package/package.json +35 -24
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +179 -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 +160 -13
- 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 +237 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/nodeToSource.js +16 -0
- package/packages/ai/src/lib/astScopes/nodeToSource.js.map +1 -1
- package/packages/ai/src/lib/astScopes/paths.js +12 -3
- package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
- package/packages/ai/src/lib/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 +7 -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 +944 -30
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.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 +188 -38
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1627 -199
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js +9 -2
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +230 -23
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +7 -1
- 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 -7
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +111 -14
- 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/coercePrimitivesToArraysBySchema.js +54 -0
- package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +122 -12
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- 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 +333 -81
- 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/dataStructure/helpers/stripNullableMarkers.js +34 -0
- package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +130 -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 +21 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +78 -120
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +47 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1156 -62
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +177 -163
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +484 -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 +1807 -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/guessScenarioDataFromDescription.js +2 -2
- 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/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.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/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -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 -100
- 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 +83 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -70
- 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 +9 -9
- 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 +94 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +2 -1
- 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 +109 -30
- 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/index.js +4 -2
- package/packages/analyze/src/lib/asts/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/getNodeType.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/getNodeType.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 +220 -57
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +37 -27
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +14 -2
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +11 -8
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +14 -0
- package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +75 -21
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +22 -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 +10 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeNextRoute.js +5 -1
- package/packages/analyze/src/lib/files/analyzeNextRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/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 +907 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +170 -40
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- 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 +253 -42
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.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 +381 -26
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +104 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -3
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +1478 -672
- 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/index.js +1 -0
- package/packages/database/index.js.map +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +16 -1
- 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.map +1 -1
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +149 -0
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- 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 +15 -1
- 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 +45 -14
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -10
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntity.js +5 -5
- package/packages/database/src/lib/loadEntity.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +5 -5
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/database/src/lib/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +76 -89
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/database/src/lib/updateFreshAnalysisStatus.js +41 -30
- package/packages/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
- package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
- package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.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 +217 -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 +33 -5
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.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 +0 -1
- package/packages/types/index.js.map +1 -1
- package/packages/types/src/enums/ProjectFramework.js +2 -0
- package/packages/types/src/enums/ProjectFramework.js.map +1 -1
- package/packages/types/src/types/Scenario.js +1 -21
- package/packages/types/src/types/Scenario.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +120 -4
- package/packages/utils/src/lib/fs/rsyncCopy.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/npm-post-install.cjs +34 -0
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -409
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -288
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -495
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -120
- 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/src/commands/detect-universal-mocks.js +0 -118
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +0 -1
- package/codeyam-cli/src/commands/list.js +0 -31
- package/codeyam-cli/src/commands/list.js.map +0 -1
- package/codeyam-cli/src/commands/webapp-info.js +0 -146
- package/codeyam-cli/src/commands/webapp-info.js.map +0 -1
- package/codeyam-cli/src/utils/universal-mocks.js +0 -152
- package/codeyam-cli/src/utils/universal-mocks.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CzGX-miz.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CBQPrpT0.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BfmDgXxG.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-6J7zDUD5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CVP_WGQ3.js +0 -32
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CgUsG7ib.js +0 -21
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DAtOlaWE.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-D62Lxxmv.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/globals-C9s7Lhdl.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-0d27da29.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-B_wIKCIf.js +0 -56
- package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-BqPPNjAl.js +0 -2
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useToast-DWHcCcl1.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CU58-Ttc.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-D35o2uae.js +0 -175
- package/codeyam-cli/templates/codeyam-stop-hook.sh +0 -284
- package/codeyam-cli/templates/debug-codeyam.md +0 -625
- 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 -298
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -226
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -408
- 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 -77
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- package/scripts/finalize-analyzer.cjs +0 -81
- /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/{api.link-scenario-value-l0sNRNKZ.js → api.agent-transcripts-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-key-attributes-l0sNRNKZ.js → api.dev-mode-events-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-valid-values-l0sNRNKZ.js → api.editor-audit-l0sNRNKZ.js} +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
package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from '~codeyam/ai';
|
|
5
5
|
import { cleanKnownObjectFunctionsFromMapping } from '~codeyam/ai';
|
|
6
6
|
import { DataStructure, Entity, ReadonlyAnalysis } from '~codeyam/types';
|
|
7
|
+
import { transformationTracer } from './TransformationTracer';
|
|
7
8
|
|
|
8
9
|
export interface DataStructureInfo {
|
|
9
10
|
signatureSchema: { [key: string]: string };
|
|
@@ -40,6 +41,96 @@ function getTypeParameter(functionName: string): string | null {
|
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Check if a schema path contains a Set/Map collection method call.
|
|
46
|
+
* Paths like `.has(articleId)`, `.delete(articleId)`, `.add(articleId)` represent
|
|
47
|
+
* membership checks on Sets/Maps, not meaningful data flow for schema generation.
|
|
48
|
+
* These create massive combinatorial explosions when every filter field (filterRatings,
|
|
49
|
+
* filterPublications, filterAuthors, etc.) × every method (has, delete, add) gets
|
|
50
|
+
* tracked as a separate equivalency.
|
|
51
|
+
*/
|
|
52
|
+
const COLLECTION_METHOD_PATTERN = /\.(?:has|delete|add|clear|get|set)\(/;
|
|
53
|
+
function isCollectionMethodPath(path: string): boolean {
|
|
54
|
+
return COLLECTION_METHOD_PATTERN.test(path);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Check if a path contains an inline object literal inside a function call argument.
|
|
59
|
+
* e.g., setUndoEntry({ label: '...', undo: () => {} }) has '{' inside '(' ')'.
|
|
60
|
+
* These paths are call-site snapshots where the source code text was captured
|
|
61
|
+
* as the path. They don't represent schema structure and are very expensive to
|
|
62
|
+
* parse (avg 319 chars). They account for ~55% of equivalencies in complex entities.
|
|
63
|
+
*/
|
|
64
|
+
const INLINE_OBJECT_ARG_PATTERN = /\([^)]*\{[^}]*:/;
|
|
65
|
+
function hasInlineObjectArg(path: string): boolean {
|
|
66
|
+
// Match function calls containing object literals with key-value pairs.
|
|
67
|
+
// Pattern: open paren, then { with a : inside before closing }.
|
|
68
|
+
// e.g., setUndoEntry({ label: '...' }) matches
|
|
69
|
+
// e.g., find(item) does NOT match
|
|
70
|
+
// e.g., fn({a:1, b:2}) matches
|
|
71
|
+
return INLINE_OBJECT_ARG_PATTERN.test(path);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Primitive types that should not have child paths
|
|
75
|
+
const PRIMITIVE_TYPES = new Set([
|
|
76
|
+
'number',
|
|
77
|
+
'string',
|
|
78
|
+
'boolean',
|
|
79
|
+
'null',
|
|
80
|
+
'undefined',
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
// Check if a type string represents a primitive type
|
|
84
|
+
// Handles union types like "string | undefined" or "number | null"
|
|
85
|
+
// Also handles string literal unions like "'suggestion' | 'warning' | 'tip'"
|
|
86
|
+
function isPrimitiveType(typeStr: string): boolean {
|
|
87
|
+
if (PRIMITIVE_TYPES.has(typeStr)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
// Check union types - if ALL parts of the union are primitives, it's primitive
|
|
91
|
+
// e.g., "string | undefined" -> ["string", "undefined"] -> both are primitive -> true
|
|
92
|
+
// e.g., "object | null" -> ["object", "null"] -> object is not primitive -> false
|
|
93
|
+
// e.g., "'suggestion' | 'warning'" -> string literal union -> true
|
|
94
|
+
if (typeStr.includes('|')) {
|
|
95
|
+
const parts = typeStr.split('|').map((p) => p.trim());
|
|
96
|
+
return parts.every(
|
|
97
|
+
(part) =>
|
|
98
|
+
PRIMITIVE_TYPES.has(part) ||
|
|
99
|
+
// String literal values like 'suggestion', 'warning' are primitives
|
|
100
|
+
(part.startsWith("'") && part.endsWith("'")),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Extract signature index from a path like "signature[0]" or "signature[0].foo"
|
|
107
|
+
// Returns the index number or undefined if not a signature path
|
|
108
|
+
function extractSignatureIndex(path: string): number | undefined {
|
|
109
|
+
const match = path.match(/^signature\[(\d+)\]/);
|
|
110
|
+
return match ? parseInt(match[1], 10) : undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Check if a new schema path would go through a primitive type
|
|
114
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', then
|
|
115
|
+
// 'entities[].scenarioCount.sha' would go through a primitive and should be rejected
|
|
116
|
+
function wouldGoThroughPrimitive(
|
|
117
|
+
newPath: string,
|
|
118
|
+
schema: { [key: string]: string },
|
|
119
|
+
): boolean {
|
|
120
|
+
const pathParts = splitOutsideParenthesesAndArrays(newPath);
|
|
121
|
+
|
|
122
|
+
// Check each prefix of the path (excluding the full path itself)
|
|
123
|
+
for (let i = 1; i < pathParts.length; i++) {
|
|
124
|
+
const prefixPath = joinParenthesesAndArrays(pathParts.slice(0, i));
|
|
125
|
+
const prefixType = schema[prefixPath];
|
|
126
|
+
if (prefixType && isPrimitiveType(prefixType)) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
43
134
|
// Check if schemaPathPart matches or is a function call variant of pathPart
|
|
44
135
|
// e.g., 'isEntityBeingAnalyzed(entity.sha)' matches 'isEntityBeingAnalyzed'
|
|
45
136
|
function pathPartMatches(pathPart: string, schemaPathPart: string): boolean {
|
|
@@ -56,21 +147,56 @@ function pathPartMatches(pathPart: string, schemaPathPart: string): boolean {
|
|
|
56
147
|
function bestValueFromOptions(options: Array<string | undefined>) {
|
|
57
148
|
options = options.filter(Boolean) as string[];
|
|
58
149
|
|
|
59
|
-
const known = options.
|
|
60
|
-
if (known)
|
|
150
|
+
const known = options.filter((o) => !o.includes('unknown'));
|
|
151
|
+
if (known.length > 0) {
|
|
152
|
+
// Among known values, prefer string literal unions over bare primitives.
|
|
153
|
+
// e.g., "'draft' | 'inProgress' | 'paused' | 'completed'" is more specific than "string".
|
|
154
|
+
// This handles cases where a dependency schema has a bare type like "string" but the
|
|
155
|
+
// child entity's analysis has the actual literal union from TypeScript type resolution.
|
|
156
|
+
if (known.length > 1 && known.some((o) => PRIMITIVE_TYPES.has(o))) {
|
|
157
|
+
const literalUnion = known.find(
|
|
158
|
+
(o) => !PRIMITIVE_TYPES.has(o) && o.includes("'"),
|
|
159
|
+
);
|
|
160
|
+
if (literalUnion) {
|
|
161
|
+
return literalUnion;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return known[0];
|
|
165
|
+
}
|
|
61
166
|
|
|
62
167
|
const notUnknown = options.find((o) => o !== 'unknown');
|
|
63
|
-
if (notUnknown)
|
|
168
|
+
if (notUnknown) {
|
|
169
|
+
return notUnknown;
|
|
170
|
+
}
|
|
64
171
|
|
|
65
172
|
return options[0] ?? 'unknown';
|
|
66
173
|
}
|
|
67
174
|
|
|
175
|
+
/** Timeout (ms) for the merge operation. Throws DataStructureTimeoutError if exceeded.
|
|
176
|
+
* All successful merges complete in <300ms. Anything exceeding 2s is pathological. */
|
|
177
|
+
const MERGE_TIMEOUT_MS = 2_000;
|
|
178
|
+
|
|
179
|
+
/** Cap for schema size during postfix application and dep copy.
|
|
180
|
+
* Successful merges produce <3K ret keys. Beyond 5K, further entries
|
|
181
|
+
* are cross-products of unrelated equivalencies — noise, not signal. */
|
|
182
|
+
const SCHEMA_KEY_CAP = 5_000;
|
|
183
|
+
|
|
184
|
+
export class DataStructureTimeoutError extends Error {
|
|
185
|
+
constructor(entityName: string, elapsedMs: number) {
|
|
186
|
+
super(
|
|
187
|
+
`Data structure merge timed out for ${entityName} after ${Math.round(elapsedMs / 1000)}s (limit: ${MERGE_TIMEOUT_MS / 1000}s)`,
|
|
188
|
+
);
|
|
189
|
+
this.name = 'DataStructureTimeoutError';
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
68
193
|
export default function mergeInDependentDataStructure({
|
|
69
194
|
importedExports,
|
|
70
195
|
dependentAnalyses,
|
|
71
196
|
rootScopeName,
|
|
72
197
|
dataStructure,
|
|
73
198
|
dependencySchemas,
|
|
199
|
+
timeoutMs = MERGE_TIMEOUT_MS,
|
|
74
200
|
}: {
|
|
75
201
|
importedExports: Pick<
|
|
76
202
|
Entity['metadata']['importedExports'][0],
|
|
@@ -92,7 +218,23 @@ export default function mergeInDependentDataStructure({
|
|
|
92
218
|
[name: string]: DataStructureInfo;
|
|
93
219
|
};
|
|
94
220
|
};
|
|
221
|
+
/** Override the default timeout (ms). Set to 0 to disable. */
|
|
222
|
+
timeoutMs?: number;
|
|
95
223
|
}) {
|
|
224
|
+
const mergeStartTime = Date.now();
|
|
225
|
+
const mergeDeadline = timeoutMs > 0 ? mergeStartTime + timeoutMs : 0;
|
|
226
|
+
|
|
227
|
+
/** Call in hot loops. Throws DataStructureTimeoutError if deadline exceeded.
|
|
228
|
+
* Date.now() is ~20ns — negligible vs the ms-scale string ops in each iteration. */
|
|
229
|
+
const checkDeadline = () => {
|
|
230
|
+
if (!mergeDeadline) return;
|
|
231
|
+
if (Date.now() > mergeDeadline) {
|
|
232
|
+
throw new DataStructureTimeoutError(
|
|
233
|
+
rootScopeName,
|
|
234
|
+
Date.now() - mergeStartTime,
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
96
238
|
const mergedDataStructure: Omit<
|
|
97
239
|
DataStructure,
|
|
98
240
|
'equivalentSignatureVariables'
|
|
@@ -105,1012 +247,1865 @@ export default function mergeInDependentDataStructure({
|
|
|
105
247
|
environmentVariables: [...(dataStructure.environmentVariables || [])],
|
|
106
248
|
};
|
|
107
249
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
250
|
+
try {
|
|
251
|
+
// Build a set of functions that have multiple DIFFERENT type parameters.
|
|
252
|
+
// For these functions, we must NOT normalize paths to avoid merging different schemas.
|
|
253
|
+
// e.g., if we have both useFetcher<{ data: UserData }>() and useFetcher<{ data: ConfigData }>(),
|
|
254
|
+
// they must stay separate and not both become 'returnValue'.
|
|
255
|
+
const functionsWithMultipleTypeParams = new Set<string>();
|
|
256
|
+
const typeParamsByFunction: Record<string, Set<string>> = {};
|
|
257
|
+
|
|
258
|
+
// Helper to scan a schema for type parameters
|
|
259
|
+
const scanSchemaForTypeParams = (schema: { [key: string]: string }) => {
|
|
260
|
+
for (const schemaPath of Object.keys(schema ?? {})) {
|
|
261
|
+
const parts = splitOutsideParenthesesAndArrays(schemaPath);
|
|
262
|
+
if (parts.length > 0) {
|
|
263
|
+
const firstPart = parts[0];
|
|
264
|
+
const typeParam = getTypeParameter(firstPart);
|
|
265
|
+
if (typeParam) {
|
|
266
|
+
const baseName = cleanFunctionName(firstPart);
|
|
267
|
+
typeParamsByFunction[baseName] ||= new Set();
|
|
268
|
+
typeParamsByFunction[baseName].add(typeParam);
|
|
269
|
+
if (typeParamsByFunction[baseName].size > 1) {
|
|
270
|
+
functionsWithMultipleTypeParams.add(baseName);
|
|
271
|
+
}
|
|
128
272
|
}
|
|
129
273
|
}
|
|
130
274
|
}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
275
|
+
};
|
|
133
276
|
|
|
134
|
-
|
|
135
|
-
|
|
277
|
+
// Scan the root entity's schema
|
|
278
|
+
scanSchemaForTypeParams(dataStructure.returnValueSchema);
|
|
136
279
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
280
|
+
// Also scan all dependency schemas for type parameters
|
|
281
|
+
for (const filePath of Object.keys(dependencySchemas ?? {})) {
|
|
282
|
+
for (const name of Object.keys(dependencySchemas[filePath] ?? {})) {
|
|
283
|
+
scanSchemaForTypeParams(
|
|
284
|
+
dependencySchemas[filePath][name]?.returnValueSchema,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
143
287
|
}
|
|
144
|
-
}
|
|
145
288
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
);
|
|
159
|
-
|
|
289
|
+
let equivalentSchemaPaths: {
|
|
290
|
+
equivalentRoots: {
|
|
291
|
+
schemaRootPath: string;
|
|
292
|
+
function?: { filePath?: string; name: string };
|
|
293
|
+
postfix?: string;
|
|
294
|
+
}[];
|
|
295
|
+
equivalentPostfixes: Record<string, string>;
|
|
296
|
+
}[] = [];
|
|
297
|
+
|
|
298
|
+
// O(1) index for findOrCreateEquivalentSchemaPathsEntry.
|
|
299
|
+
// Maps "(rootPath)::(normalizedFuncName)" → the entry containing that root.
|
|
300
|
+
// This replaces the O(E) linear search that was causing O(E²) gather performance.
|
|
301
|
+
const espIndex = new Map<string, (typeof equivalentSchemaPaths)[0]>();
|
|
302
|
+
const espIndexKey = (path: string, functionName: string | undefined) => {
|
|
303
|
+
const normalized = cleanFunctionName(functionName);
|
|
304
|
+
const funcKey =
|
|
305
|
+
normalized === rootScopeName ? '__self__' : normalized || '__self__';
|
|
306
|
+
return `${path}::${funcKey}`;
|
|
307
|
+
};
|
|
308
|
+
const updateEspIndex = (entry: (typeof equivalentSchemaPaths)[0]) => {
|
|
309
|
+
for (const root of entry.equivalentRoots) {
|
|
310
|
+
const funcName = root.function?.name ?? rootScopeName;
|
|
311
|
+
espIndex.set(espIndexKey(root.schemaRootPath, funcName), entry);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
160
314
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
315
|
+
// Pre-build a lookup map from cleaned function name to dependency for O(1) lookups.
|
|
316
|
+
// This avoids O(n) linear search in findRelevantDependency which was causing O(n²) performance.
|
|
317
|
+
const dependencyByCleanedName = new Map<
|
|
318
|
+
string,
|
|
319
|
+
(typeof importedExports)[0]
|
|
320
|
+
>();
|
|
321
|
+
for (const dep of importedExports) {
|
|
322
|
+
const cleanedName = cleanFunctionName(dep.name);
|
|
323
|
+
if (!dependencyByCleanedName.has(cleanedName)) {
|
|
324
|
+
dependencyByCleanedName.set(cleanedName, dep);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
164
327
|
|
|
165
|
-
|
|
166
|
-
|
|
328
|
+
const findRelevantDependency = (functionName: any) => {
|
|
329
|
+
return dependencyByCleanedName.get(cleanFunctionName(functionName));
|
|
330
|
+
};
|
|
167
331
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
332
|
+
const findRelevantDependentDataStructure = (functionName: any) => {
|
|
333
|
+
const dependency = findRelevantDependency(functionName);
|
|
334
|
+
if (!dependency) return;
|
|
171
335
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (!dependentAnalysis?.metadata?.mergedDataStructure) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
336
|
+
return dependencySchemas?.[dependency.filePath]?.[dependency.name];
|
|
337
|
+
};
|
|
177
338
|
|
|
178
|
-
|
|
179
|
-
|
|
339
|
+
const findRelevantDependentAnalysisDataStructure = (functionName: any) => {
|
|
340
|
+
const dependency = findRelevantDependency(functionName);
|
|
341
|
+
if (!dependency) return;
|
|
342
|
+
|
|
343
|
+
const dependentAnalysis =
|
|
344
|
+
dependentAnalyses[dependency.filePath]?.[dependency.name];
|
|
345
|
+
if (!dependentAnalysis?.metadata?.mergedDataStructure) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
180
348
|
|
|
181
|
-
|
|
182
|
-
filePath?: string;
|
|
183
|
-
name: string;
|
|
184
|
-
}) => {
|
|
185
|
-
const { filePath, name } = dependency;
|
|
186
|
-
mergedDataStructure.dependencySchemas[filePath] ||= {};
|
|
187
|
-
mergedDataStructure.dependencySchemas[filePath][name] ||= {
|
|
188
|
-
signatureSchema: {},
|
|
189
|
-
returnValueSchema: {},
|
|
349
|
+
return dependentAnalysis.metadata.mergedDataStructure;
|
|
190
350
|
};
|
|
191
351
|
|
|
192
|
-
|
|
193
|
-
|
|
352
|
+
const findOrCreateDependentSchemas = (dependency: {
|
|
353
|
+
filePath?: string;
|
|
354
|
+
name: string;
|
|
355
|
+
}) => {
|
|
356
|
+
const { filePath, name } = dependency;
|
|
357
|
+
mergedDataStructure.dependencySchemas[filePath] ||= {};
|
|
358
|
+
mergedDataStructure.dependencySchemas[filePath][name] ||= {
|
|
359
|
+
signatureSchema: {},
|
|
360
|
+
returnValueSchema: {},
|
|
361
|
+
};
|
|
194
362
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
363
|
+
return mergedDataStructure.dependencySchemas[filePath][name];
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const cleanSchema = (
|
|
367
|
+
schema: { [key: string]: string },
|
|
368
|
+
context?: Record<string, any>,
|
|
369
|
+
) => {
|
|
370
|
+
transformationTracer.traceSchemaTransform(
|
|
371
|
+
rootScopeName,
|
|
372
|
+
'cleanKnownObjectFunctionsFromMapping',
|
|
373
|
+
schema,
|
|
374
|
+
cleanKnownObjectFunctionsFromMapping,
|
|
375
|
+
context,
|
|
376
|
+
);
|
|
377
|
+
};
|
|
198
378
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
379
|
+
// Cache translatePath results — the same path is often translated multiple times
|
|
380
|
+
// (once per equivalency entry that references it). Avoids redundant
|
|
381
|
+
// splitOutsideParenthesesAndArrays calls on long paths.
|
|
382
|
+
const translatePathCache = new Map<string, string>();
|
|
383
|
+
|
|
384
|
+
const translatePath = (path: string, dependencyName: string) => {
|
|
385
|
+
const cacheKey = `${dependencyName}\0${path}`;
|
|
386
|
+
const cached = translatePathCache.get(cacheKey);
|
|
387
|
+
if (cached !== undefined) return cached;
|
|
388
|
+
|
|
389
|
+
let result = path;
|
|
390
|
+
if (path.startsWith(dependencyName)) {
|
|
391
|
+
const pathParts = splitOutsideParenthesesAndArrays(path);
|
|
392
|
+
if (pathParts.length > 1) {
|
|
393
|
+
if (pathParts[1].startsWith('functionCallReturnValue')) {
|
|
394
|
+
// Check if this function has multiple DIFFERENT type parameters.
|
|
395
|
+
// If so, DON'T normalize to returnValue - keep the full path to avoid
|
|
396
|
+
// merging different type-parameterized variants together.
|
|
397
|
+
const baseName = cleanFunctionName(pathParts[0]);
|
|
398
|
+
if (!functionsWithMultipleTypeParams.has(baseName)) {
|
|
399
|
+
// functionCallReturnValue immediately follows - normalize to returnValue
|
|
400
|
+
result = joinParenthesesAndArrays([
|
|
401
|
+
'returnValue',
|
|
402
|
+
...pathParts.slice(2),
|
|
403
|
+
]);
|
|
404
|
+
}
|
|
405
|
+
} else if (
|
|
406
|
+
pathParts[0].endsWith(')') &&
|
|
407
|
+
pathParts[1].startsWith('signature[')
|
|
408
|
+
) {
|
|
409
|
+
// Hook-style with signature access
|
|
410
|
+
result = joinParenthesesAndArrays(pathParts.slice(1));
|
|
212
411
|
}
|
|
213
|
-
// functionCallReturnValue immediately follows - normalize to returnValue
|
|
214
|
-
// e.g., useAuth().functionCallReturnValue.user -> returnValue.user
|
|
215
|
-
return joinParenthesesAndArrays([
|
|
216
|
-
'returnValue',
|
|
217
|
-
...pathParts.slice(2),
|
|
218
|
-
]);
|
|
219
|
-
} else if (
|
|
220
|
-
pathParts[0].endsWith(')') &&
|
|
221
|
-
pathParts[1].startsWith('signature[')
|
|
222
|
-
) {
|
|
223
|
-
// Hook-style with signature access (e.g., BranchChangesTab().signature[0]...)
|
|
224
|
-
// Strip the function name for signature equivalency matching
|
|
225
|
-
return joinParenthesesAndArrays(pathParts.slice(1));
|
|
226
412
|
}
|
|
227
|
-
// For all other cases (object-style APIs like getSupabase().auth and
|
|
228
|
-
// direct object references like supabase.from), preserve the path as-is.
|
|
229
|
-
// The prefix must be kept for proper schema lookups in constructMockCode
|
|
230
|
-
// and gatherDataForMocks.
|
|
231
413
|
}
|
|
232
|
-
}
|
|
233
|
-
return path;
|
|
234
|
-
};
|
|
235
414
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
allPaths: { path: string; functionName?: string }[],
|
|
415
|
+
translatePathCache.set(cacheKey, result);
|
|
416
|
+
return result;
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
const gatherAllEquivalentSchemaPaths = (
|
|
420
|
+
functionName: string,
|
|
421
|
+
sourceAndUsageEquivalencies: Pick<
|
|
422
|
+
DataStructure,
|
|
423
|
+
'sourceEquivalencies' | 'usageEquivalencies'
|
|
424
|
+
>,
|
|
425
|
+
dataStructure?: Pick<
|
|
426
|
+
DataStructure,
|
|
427
|
+
'signatureSchema' | 'returnValueSchema'
|
|
428
|
+
>,
|
|
251
429
|
) => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
let equivalentSchemaPathsEntry:
|
|
267
|
-
| (typeof equivalentSchemaPaths)[0]
|
|
268
|
-
| undefined;
|
|
269
|
-
for (const pathInfo of allPaths) {
|
|
270
|
-
if (!equivalentSchemaPathsEntry) {
|
|
271
|
-
equivalentSchemaPathsEntry = equivalentSchemaPaths.find((esp) =>
|
|
272
|
-
esp.equivalentRoots.some(
|
|
273
|
-
(er) =>
|
|
274
|
-
er.schemaRootPath === pathInfo.path &&
|
|
275
|
-
(er.function?.name ===
|
|
276
|
-
cleanFunctionName(pathInfo.functionName) ||
|
|
277
|
-
(!er.function &&
|
|
278
|
-
cleanFunctionName(pathInfo.functionName) ===
|
|
279
|
-
rootScopeName)),
|
|
280
|
-
),
|
|
281
|
-
);
|
|
430
|
+
checkDeadline();
|
|
431
|
+
if (!sourceAndUsageEquivalencies) return;
|
|
432
|
+
|
|
433
|
+
// Pre-computed normalized schema index cache.
|
|
434
|
+
// Avoids repeated splitOutsideParenthesesAndArrays calls and function-name
|
|
435
|
+
// normalization for the same schema paths across multiple equivalency iterations.
|
|
436
|
+
// The normalization depends on `functionName` (constant per gatherAllEquivalentSchemaPaths call),
|
|
437
|
+
// so this cache is scoped to this call.
|
|
438
|
+
type NormalizedEntry = { path: string; parts: string[] };
|
|
439
|
+
const normalizedSchemaCache = new Map<
|
|
440
|
+
object,
|
|
441
|
+
{
|
|
442
|
+
byFirstPart: Map<string, NormalizedEntry[]>;
|
|
282
443
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
444
|
+
>();
|
|
445
|
+
const getSchemaIndex = (
|
|
446
|
+
schema: Record<string, string> | undefined,
|
|
447
|
+
): { byFirstPart: Map<string, NormalizedEntry[]> } => {
|
|
448
|
+
if (!schema) return { byFirstPart: new Map() };
|
|
449
|
+
const cached = normalizedSchemaCache.get(schema);
|
|
450
|
+
if (cached) return cached;
|
|
451
|
+
const byFirstPart = new Map<string, NormalizedEntry[]>();
|
|
452
|
+
for (const path in schema) {
|
|
453
|
+
checkDeadline();
|
|
454
|
+
let parts = splitOutsideParenthesesAndArrays(path);
|
|
455
|
+
if (parts[0].startsWith(functionName)) {
|
|
456
|
+
const baseName = cleanFunctionName(parts[0]);
|
|
457
|
+
if (!functionsWithMultipleTypeParams.has(baseName)) {
|
|
458
|
+
parts =
|
|
459
|
+
parts[1] === 'functionCallReturnValue'
|
|
460
|
+
? ['returnValue', ...parts.slice(2)]
|
|
461
|
+
: parts.slice(1);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const entry: NormalizedEntry = { path, parts };
|
|
465
|
+
// Index by the base of the first part (before any function call args)
|
|
466
|
+
const firstPart = parts[0] ?? '';
|
|
467
|
+
const parenIdx = firstPart.indexOf('(');
|
|
468
|
+
const firstPartBase =
|
|
469
|
+
parenIdx >= 0 ? firstPart.slice(0, parenIdx) : firstPart;
|
|
470
|
+
let bucket = byFirstPart.get(firstPartBase);
|
|
471
|
+
if (!bucket) {
|
|
472
|
+
bucket = [];
|
|
473
|
+
byFirstPart.set(firstPartBase, bucket);
|
|
474
|
+
}
|
|
475
|
+
bucket.push(entry);
|
|
476
|
+
}
|
|
477
|
+
const result = { byFirstPart };
|
|
478
|
+
normalizedSchemaCache.set(schema, result);
|
|
479
|
+
return result;
|
|
480
|
+
};
|
|
307
481
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
equivalentRoot.schemaRootPath.startsWith('signature[')
|
|
338
|
-
? dataStructure?.signatureSchema
|
|
339
|
-
: dataStructure?.returnValueSchema,
|
|
340
|
-
);
|
|
482
|
+
const findOrCreateEquivalentSchemaPathsEntry = (
|
|
483
|
+
allPaths: { path: string; functionName?: string }[],
|
|
484
|
+
) => {
|
|
485
|
+
const equivalentRoots = allPaths
|
|
486
|
+
.filter(
|
|
487
|
+
(p) =>
|
|
488
|
+
p.functionName === rootScopeName ||
|
|
489
|
+
!!findRelevantDependency(p.functionName),
|
|
490
|
+
)
|
|
491
|
+
.map((p) => ({
|
|
492
|
+
schemaRootPath: p.path,
|
|
493
|
+
function:
|
|
494
|
+
p.functionName === rootScopeName
|
|
495
|
+
? undefined
|
|
496
|
+
: findRelevantDependency(p.functionName),
|
|
497
|
+
}));
|
|
498
|
+
|
|
499
|
+
let equivalentSchemaPathsEntry:
|
|
500
|
+
| (typeof equivalentSchemaPaths)[0]
|
|
501
|
+
| undefined;
|
|
502
|
+
|
|
503
|
+
// Collect the signature indices from the new roots we want to add
|
|
504
|
+
const newRootSignatureIndices = new Set<number>();
|
|
505
|
+
for (const root of equivalentRoots) {
|
|
506
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
507
|
+
if (idx !== undefined) {
|
|
508
|
+
newRootSignatureIndices.add(idx);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
341
511
|
|
|
342
|
-
|
|
343
|
-
|
|
512
|
+
// Use espIndex Map for O(1) lookup instead of O(E) linear search.
|
|
513
|
+
// Falls back to linear search only when Map hit has a signature index conflict.
|
|
514
|
+
for (const pathInfo of allPaths) {
|
|
515
|
+
checkDeadline();
|
|
516
|
+
if (equivalentSchemaPathsEntry) break;
|
|
517
|
+
const candidate = espIndex.get(
|
|
518
|
+
espIndexKey(pathInfo.path, pathInfo.functionName),
|
|
344
519
|
);
|
|
520
|
+
if (!candidate) continue;
|
|
521
|
+
|
|
522
|
+
// Verify no signature index conflict with the candidate entry
|
|
523
|
+
if (newRootSignatureIndices.size > 0) {
|
|
524
|
+
const existingIndicesByFunction = new Map<string, Set<number>>();
|
|
525
|
+
for (const er of candidate.equivalentRoots) {
|
|
526
|
+
const funcKey = er.function
|
|
527
|
+
? `${er.function.name}::${er.function.filePath}`
|
|
528
|
+
: '__self__';
|
|
529
|
+
const idx = extractSignatureIndex(er.schemaRootPath);
|
|
530
|
+
if (idx !== undefined) {
|
|
531
|
+
if (!existingIndicesByFunction.has(funcKey)) {
|
|
532
|
+
existingIndicesByFunction.set(funcKey, new Set());
|
|
533
|
+
}
|
|
534
|
+
existingIndicesByFunction.get(funcKey)!.add(idx);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
345
537
|
|
|
346
|
-
|
|
347
|
-
for (const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
538
|
+
let hasConflict = false;
|
|
539
|
+
for (const newRoot of equivalentRoots) {
|
|
540
|
+
const funcKey = newRoot.function
|
|
541
|
+
? `${newRoot.function.name}::${newRoot.function.filePath}`
|
|
542
|
+
: '__self__';
|
|
543
|
+
const newIdx = extractSignatureIndex(newRoot.schemaRootPath);
|
|
544
|
+
if (newIdx !== undefined) {
|
|
545
|
+
const existingIndices = existingIndicesByFunction.get(funcKey);
|
|
546
|
+
if (existingIndices && existingIndices.size > 0) {
|
|
547
|
+
if (!existingIndices.has(newIdx)) {
|
|
548
|
+
hasConflict = true;
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
359
551
|
}
|
|
360
552
|
}
|
|
553
|
+
}
|
|
361
554
|
|
|
362
|
-
|
|
555
|
+
if (hasConflict) continue;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
equivalentSchemaPathsEntry = candidate;
|
|
559
|
+
}
|
|
363
560
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
561
|
+
if (!equivalentSchemaPathsEntry) {
|
|
562
|
+
// Before creating a new entry, filter out roots that have conflicting
|
|
563
|
+
// signature indices from the same function. An entry should never contain
|
|
564
|
+
// roots with different signature indices from the same function.
|
|
565
|
+
// This prevents the bug where signature[1], signature[2], signature[4]
|
|
566
|
+
// all get merged together due to incorrect sourceEquivalencies.
|
|
567
|
+
let filteredRoots = equivalentRoots;
|
|
568
|
+
if (newRootSignatureIndices.size > 1) {
|
|
569
|
+
// There are multiple signature indices - we need to filter to keep only
|
|
570
|
+
// one consistent set. We'll keep the roots that match the PRIMARY index
|
|
571
|
+
// (the first signature index we encounter from self, or the lowest index).
|
|
572
|
+
|
|
573
|
+
// First, determine the primary index - prefer the self root's index
|
|
574
|
+
let primaryIndex: number | undefined;
|
|
575
|
+
for (const root of equivalentRoots) {
|
|
576
|
+
if (!root.function) {
|
|
577
|
+
// This is a self root
|
|
578
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
579
|
+
if (idx !== undefined) {
|
|
580
|
+
primaryIndex = idx;
|
|
370
581
|
break;
|
|
371
582
|
}
|
|
372
|
-
|
|
373
|
-
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
// If no self root has a signature index, use the lowest index
|
|
586
|
+
if (primaryIndex === undefined) {
|
|
587
|
+
primaryIndex = Math.min(...newRootSignatureIndices);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Filter roots: keep if no signature index OR signature index matches primary
|
|
591
|
+
filteredRoots = equivalentRoots.filter((root) => {
|
|
592
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
593
|
+
return idx === undefined || idx === primaryIndex;
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
equivalentSchemaPathsEntry = {
|
|
598
|
+
equivalentRoots: filteredRoots,
|
|
599
|
+
equivalentPostfixes: {},
|
|
600
|
+
};
|
|
601
|
+
equivalentSchemaPaths.push(equivalentSchemaPathsEntry);
|
|
602
|
+
} else {
|
|
603
|
+
equivalentSchemaPathsEntry.equivalentRoots.push(...equivalentRoots);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// Deduplicate roots using a Set for O(n) instead of O(n²)
|
|
607
|
+
const seenRoots = new Set<string>();
|
|
608
|
+
equivalentSchemaPathsEntry.equivalentRoots =
|
|
609
|
+
equivalentSchemaPathsEntry.equivalentRoots.filter((er) => {
|
|
610
|
+
const key = er.schemaRootPath + '::' + (er.function?.name ?? '');
|
|
611
|
+
if (seenRoots.has(key)) return false;
|
|
612
|
+
seenRoots.add(key);
|
|
613
|
+
return true;
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
// Keep the espIndex in sync after adding/deduplicating roots
|
|
617
|
+
updateEspIndex(equivalentSchemaPathsEntry);
|
|
618
|
+
|
|
619
|
+
return equivalentSchemaPathsEntry;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
// Helper to extract function name from a path that starts with a function call.
|
|
623
|
+
// e.g., 'ScenarioViewer().signature[0].scenario' -> 'ScenarioViewer'
|
|
624
|
+
// Returns undefined if the path doesn't start with a function call or the function isn't a dependency.
|
|
625
|
+
const extractFunctionNameFromPath = (
|
|
626
|
+
path: string,
|
|
627
|
+
): string | undefined => {
|
|
628
|
+
const parts = splitOutsideParenthesesAndArrays(path);
|
|
629
|
+
if (parts.length > 0 && parts[0].endsWith(')')) {
|
|
630
|
+
// Extract the function name without the () suffix and type params
|
|
631
|
+
const funcCallPart = parts[0];
|
|
632
|
+
const funcName = cleanFunctionName(funcCallPart.replace(/\(\)$/, ''));
|
|
633
|
+
// Check if this function is a dependency
|
|
634
|
+
if (findRelevantDependency(funcName)) {
|
|
635
|
+
return funcName;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return undefined;
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
const allEquivalencies = [
|
|
642
|
+
sourceAndUsageEquivalencies.usageEquivalencies,
|
|
643
|
+
sourceAndUsageEquivalencies.sourceEquivalencies,
|
|
644
|
+
].filter(Boolean);
|
|
645
|
+
|
|
646
|
+
// Global dedup across ALL equivalency entries. The same (scope, targetPath)
|
|
647
|
+
// pair often appears in 30-50 different source entries (e.g., every variable
|
|
648
|
+
// that flows through loadView references the same 50 target paths).
|
|
649
|
+
// Processing these redundantly accounts for 96% of work in the gather phase.
|
|
650
|
+
const globalSeenTargets = new Set<string>();
|
|
651
|
+
|
|
652
|
+
for (const equivalencies of allEquivalencies) {
|
|
653
|
+
const schemaPathEntries = Object.entries(equivalencies);
|
|
654
|
+
for (const [schemaPath, usages] of schemaPathEntries) {
|
|
655
|
+
checkDeadline();
|
|
656
|
+
|
|
657
|
+
// Skip equivalency entries whose source path is a Set/Map membership operation.
|
|
658
|
+
// Patterns like `.has(articleId)`, `.delete(articleId)`, `.add(articleId)` on
|
|
659
|
+
// Sets/Maps represent membership checks, not meaningful data flow for schema generation.
|
|
660
|
+
// In the Margo LibraryPage case, these account for 74% of all equivalency targets
|
|
661
|
+
// (19,444 of 26,340) and cause a combinatorial explosion in the merge.
|
|
662
|
+
if (isCollectionMethodPath(schemaPath)) continue;
|
|
663
|
+
|
|
664
|
+
// Skip paths with inline object literals in function call arguments.
|
|
665
|
+
// These are call-site snapshots (e.g., setUndoEntry({ label: '...', undo: ... }))
|
|
666
|
+
// that embed source code text as path strings. They're expensive to parse
|
|
667
|
+
// and don't contribute useful schema information.
|
|
668
|
+
if (hasInlineObjectArg(schemaPath)) continue;
|
|
669
|
+
|
|
670
|
+
// First, check if the raw schemaPath starts with a function call to a dependency.
|
|
671
|
+
// If so, use that dependency name for translation (so translatePath can strip the prefix).
|
|
672
|
+
const extractedFuncName = extractFunctionNameFromPath(schemaPath);
|
|
673
|
+
const effectiveFunctionName = extractedFuncName || functionName;
|
|
674
|
+
const translatedPath = translatePath(
|
|
675
|
+
schemaPath,
|
|
676
|
+
effectiveFunctionName,
|
|
677
|
+
);
|
|
678
|
+
|
|
679
|
+
const allPathsRaw: { path: string; functionName?: string }[] = [
|
|
680
|
+
{ path: translatedPath, functionName: effectiveFunctionName },
|
|
681
|
+
...usages
|
|
682
|
+
.filter((u) => !isCollectionMethodPath(u.schemaPath))
|
|
683
|
+
.map((u) => ({
|
|
684
|
+
path: translatePath(u.schemaPath, u.scopeNodeName),
|
|
685
|
+
functionName: u.scopeNodeName,
|
|
686
|
+
})),
|
|
687
|
+
].filter((pathInfo) => !pathInfo.path.includes('.map('));
|
|
688
|
+
|
|
689
|
+
// Deduplicate by translated path + function name, both within this entry
|
|
690
|
+
// AND across all entries. The same target path appears in 30-50 different
|
|
691
|
+
// source entries (every variable flowing through loadView references the same
|
|
692
|
+
// 50 target paths). Without global dedup, we process 5,533 targets instead of 217.
|
|
693
|
+
const allPaths = allPathsRaw.filter((p) => {
|
|
694
|
+
const key = `${p.functionName ?? ''}::${p.path}`;
|
|
695
|
+
if (globalSeenTargets.has(key)) return false;
|
|
696
|
+
globalSeenTargets.add(key);
|
|
697
|
+
return true;
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
// Fix 38: Derive base paths from property access paths.
|
|
701
|
+
// When we have equivalent paths like:
|
|
702
|
+
// Parent: signature[0].scenarios[].name
|
|
703
|
+
// Child: signature[0].selectedScenario.name
|
|
704
|
+
// We want to derive the base paths by finding the common suffix:
|
|
705
|
+
// Common suffix: .name
|
|
706
|
+
// Parent base: signature[0].scenarios[]
|
|
707
|
+
// Child base: signature[0].selectedScenario
|
|
708
|
+
// This allows the merge to find nested child schema fields under the base prop.
|
|
709
|
+
|
|
710
|
+
// Find child signature paths (paths from child components)
|
|
711
|
+
const childPaths = allPaths.filter(
|
|
712
|
+
(p) =>
|
|
713
|
+
p.functionName &&
|
|
714
|
+
p.functionName !== rootScopeName &&
|
|
715
|
+
p.functionName !== effectiveFunctionName,
|
|
716
|
+
);
|
|
717
|
+
// Find parent paths (paths from this component)
|
|
718
|
+
const parentPaths = allPaths.filter(
|
|
719
|
+
(p) =>
|
|
720
|
+
!p.functionName ||
|
|
721
|
+
p.functionName === rootScopeName ||
|
|
722
|
+
p.functionName === effectiveFunctionName,
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
const derivedBasePaths: { path: string; functionName?: string }[] =
|
|
726
|
+
[];
|
|
727
|
+
const allPathSet = new Set(allPaths.map((p) => p.path));
|
|
728
|
+
const derivedBasePathSet = new Set<string>();
|
|
729
|
+
|
|
730
|
+
// For each child path, find its equivalent parent path and derive bases
|
|
731
|
+
for (const childPathInfo of childPaths) {
|
|
732
|
+
checkDeadline();
|
|
733
|
+
const childParts = splitOutsideParenthesesAndArrays(
|
|
734
|
+
childPathInfo.path,
|
|
735
|
+
);
|
|
736
|
+
|
|
737
|
+
// Look for a parent path that shares a common suffix with this child path
|
|
738
|
+
for (const parentPathInfo of parentPaths) {
|
|
739
|
+
const parentParts = splitOutsideParenthesesAndArrays(
|
|
740
|
+
parentPathInfo.path,
|
|
741
|
+
);
|
|
742
|
+
|
|
743
|
+
// Find the common suffix (from the end)
|
|
744
|
+
let commonSuffixLength = 0;
|
|
745
|
+
const minLen = Math.min(childParts.length, parentParts.length);
|
|
746
|
+
for (let i = 1; i <= minLen; i++) {
|
|
374
747
|
if (
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
schemaPathParts[i].startsWith(pathParts[i] + '(')
|
|
748
|
+
childParts[childParts.length - i] ===
|
|
749
|
+
parentParts[parentParts.length - i]
|
|
378
750
|
) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
751
|
+
commonSuffixLength = i;
|
|
752
|
+
} else {
|
|
753
|
+
break;
|
|
382
754
|
}
|
|
383
755
|
}
|
|
384
756
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
757
|
+
// If there's a common suffix and both paths have more parts than the suffix
|
|
758
|
+
if (
|
|
759
|
+
commonSuffixLength > 0 &&
|
|
760
|
+
childParts.length > commonSuffixLength &&
|
|
761
|
+
parentParts.length > commonSuffixLength
|
|
762
|
+
) {
|
|
763
|
+
const childBaseParts = childParts.slice(
|
|
764
|
+
0,
|
|
765
|
+
childParts.length - commonSuffixLength,
|
|
766
|
+
);
|
|
767
|
+
const parentBaseParts = parentParts.slice(
|
|
768
|
+
0,
|
|
769
|
+
parentParts.length - commonSuffixLength,
|
|
770
|
+
);
|
|
771
|
+
|
|
772
|
+
// Only derive if BOTH paths look like signature paths.
|
|
773
|
+
// This ensures we're handling JSX child-to-parent prop mappings,
|
|
774
|
+
// not other complex equivalencies like function call returns.
|
|
775
|
+
const isChildSignaturePath =
|
|
776
|
+
childBaseParts[0]?.startsWith('signature[') ||
|
|
777
|
+
(childBaseParts[0]?.endsWith(')') &&
|
|
778
|
+
childBaseParts[1]?.startsWith('signature['));
|
|
779
|
+
const isParentSignaturePath =
|
|
780
|
+
parentBaseParts[0]?.startsWith('signature[');
|
|
781
|
+
|
|
782
|
+
if (isChildSignaturePath && isParentSignaturePath) {
|
|
783
|
+
const childBase = joinParenthesesAndArrays(childBaseParts);
|
|
784
|
+
const parentBase = joinParenthesesAndArrays(parentBaseParts);
|
|
785
|
+
|
|
786
|
+
// Only derive if:
|
|
787
|
+
// 1. Parent has array iteration (e.g., scenarios[]) and child does NOT
|
|
788
|
+
// 2. Bases are different
|
|
789
|
+
// 3. Child base is NOT just "signature[N]" (too generic - every component has this)
|
|
790
|
+
// We only want specific prop paths like "signature[0].selectedScenario"
|
|
791
|
+
// This targets array-to-object mappings like scenarios[] -> selectedScenario
|
|
792
|
+
const parentHasArrayIterator = parentBase.includes('[]');
|
|
793
|
+
const childHasArrayIterator = childBase.includes('[]');
|
|
794
|
+
|
|
795
|
+
// Skip if child base is just the generic signature marker (e.g., "signature[0]")
|
|
796
|
+
const childBaseIsGenericSignature = /^signature\[\d+\]$/.test(
|
|
797
|
+
childBase,
|
|
798
|
+
);
|
|
410
799
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
800
|
+
if (
|
|
801
|
+
childBase !== parentBase &&
|
|
802
|
+
parentHasArrayIterator &&
|
|
803
|
+
!childHasArrayIterator &&
|
|
804
|
+
!childBaseIsGenericSignature
|
|
805
|
+
) {
|
|
806
|
+
// Add child base if not already present (O(1) Set lookup)
|
|
807
|
+
if (
|
|
808
|
+
!allPathSet.has(childBase) &&
|
|
809
|
+
!derivedBasePathSet.has(childBase)
|
|
810
|
+
) {
|
|
811
|
+
derivedBasePaths.push({
|
|
812
|
+
path: childBase,
|
|
813
|
+
functionName: childPathInfo.functionName,
|
|
814
|
+
});
|
|
815
|
+
derivedBasePathSet.add(childBase);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// Add parent base if not already present (O(1) Set lookup)
|
|
819
|
+
if (
|
|
820
|
+
!allPathSet.has(parentBase) &&
|
|
821
|
+
!derivedBasePathSet.has(parentBase)
|
|
822
|
+
) {
|
|
823
|
+
derivedBasePaths.push({
|
|
824
|
+
path: parentBase,
|
|
825
|
+
functionName: parentPathInfo.functionName,
|
|
826
|
+
});
|
|
827
|
+
derivedBasePathSet.add(parentBase);
|
|
828
|
+
}
|
|
423
829
|
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
allPaths.push(...derivedBasePaths);
|
|
836
|
+
|
|
837
|
+
const entry = findOrCreateEquivalentSchemaPathsEntry(allPaths);
|
|
838
|
+
|
|
839
|
+
// Trace equivalency gathering - helps debug why paths may not be connected
|
|
840
|
+
if (allPaths.length > 1) {
|
|
841
|
+
transformationTracer.operation(rootScopeName, {
|
|
842
|
+
operation: 'gatherEquivalency',
|
|
843
|
+
stage: 'gathering',
|
|
844
|
+
path: translatedPath,
|
|
845
|
+
context: {
|
|
846
|
+
sourceFunction: functionName,
|
|
847
|
+
equivalentPaths: allPaths.map((p) => ({
|
|
848
|
+
path: p.path,
|
|
849
|
+
function: p.functionName,
|
|
850
|
+
})),
|
|
851
|
+
equivalentRoots: entry.equivalentRoots.map((r) => ({
|
|
852
|
+
path: r.schemaRootPath,
|
|
853
|
+
function: r.function?.name,
|
|
854
|
+
})),
|
|
855
|
+
},
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
for (const equivalentRoot of entry.equivalentRoots) {
|
|
859
|
+
checkDeadline();
|
|
860
|
+
const dataStructures =
|
|
861
|
+
equivalentRoot.function &&
|
|
862
|
+
equivalentRoot.function.name !== rootScopeName
|
|
863
|
+
? [
|
|
864
|
+
findRelevantDependentDataStructure(
|
|
865
|
+
equivalentRoot.function.name,
|
|
866
|
+
),
|
|
867
|
+
findRelevantDependentAnalysisDataStructure(
|
|
868
|
+
equivalentRoot.function.name,
|
|
869
|
+
),
|
|
870
|
+
]
|
|
871
|
+
: [dataStructure];
|
|
872
|
+
|
|
873
|
+
// Determine if this is a signature schema path.
|
|
874
|
+
// The path might be 'signature[0]...' directly, or 'FuncName().signature[0]...' if it has a function prefix.
|
|
875
|
+
const schemaRootParts = splitOutsideParenthesesAndArrays(
|
|
876
|
+
equivalentRoot.schemaRootPath,
|
|
877
|
+
);
|
|
878
|
+
const isSignaturePath =
|
|
879
|
+
equivalentRoot.schemaRootPath.startsWith('signature[') ||
|
|
880
|
+
(schemaRootParts[0]?.endsWith(')') &&
|
|
881
|
+
schemaRootParts[1]?.startsWith('signature['));
|
|
882
|
+
|
|
883
|
+
const schemas = dataStructures.map((dataStructure) =>
|
|
884
|
+
isSignaturePath
|
|
885
|
+
? dataStructure?.signatureSchema
|
|
886
|
+
: dataStructure?.returnValueSchema,
|
|
887
|
+
);
|
|
429
888
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
889
|
+
let pathParts = splitOutsideParenthesesAndArrays(
|
|
890
|
+
equivalentRoot.schemaRootPath,
|
|
891
|
+
);
|
|
892
|
+
|
|
893
|
+
// Fix: When processing a child component's schema, the schemaRootPath has the function
|
|
894
|
+
// prefix (e.g., 'ScenarioViewer().signature[0].scenario'), but the child's schema paths
|
|
895
|
+
// don't have that prefix (e.g., 'signature[0].scenario.metadata.screenshotPaths').
|
|
896
|
+
// Strip the function prefix from pathParts so they can match.
|
|
897
|
+
if (
|
|
898
|
+
equivalentRoot.function &&
|
|
899
|
+
pathParts[0].endsWith(')') &&
|
|
900
|
+
pathParts[1]?.startsWith('signature[')
|
|
901
|
+
) {
|
|
902
|
+
pathParts = pathParts.slice(1);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
for (const schema of schemas) {
|
|
906
|
+
// Use pre-computed index to only iterate schema entries whose
|
|
907
|
+
// normalized first part matches pathParts[0], instead of all entries.
|
|
908
|
+
const schemaIndex = getSchemaIndex(schema);
|
|
909
|
+
const lookupPart = pathParts[0] ?? '';
|
|
910
|
+
const lookupParenIdx = lookupPart.indexOf('(');
|
|
911
|
+
const lookupBase =
|
|
912
|
+
lookupParenIdx >= 0
|
|
913
|
+
? lookupPart.slice(0, lookupParenIdx)
|
|
914
|
+
: lookupPart;
|
|
915
|
+
const candidates = schemaIndex.byFirstPart.get(lookupBase) || [];
|
|
916
|
+
for (const {
|
|
917
|
+
path: schemaPath,
|
|
918
|
+
parts: schemaPathParts,
|
|
919
|
+
} of candidates) {
|
|
920
|
+
checkDeadline();
|
|
921
|
+
if (schemaPathParts.length < pathParts.length) continue;
|
|
922
|
+
|
|
923
|
+
// Check if all path parts match (allowing function call variants)
|
|
924
|
+
let allMatch = true;
|
|
925
|
+
let matchedUpToIndex = pathParts.length;
|
|
926
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
927
|
+
if (!pathPartMatches(pathParts[i], schemaPathParts[i])) {
|
|
928
|
+
allMatch = false;
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
// If the last pathPart matched a function call variant,
|
|
932
|
+
// we need to include it in the postfix calculation
|
|
933
|
+
if (
|
|
934
|
+
i === pathParts.length - 1 &&
|
|
935
|
+
schemaPathParts[i] !== pathParts[i] &&
|
|
936
|
+
schemaPathParts[i].startsWith(pathParts[i] + '(')
|
|
937
|
+
) {
|
|
938
|
+
// The schemaPathPart is a function call variant (e.g., 'isEntityBeingAnalyzed(entity.sha)')
|
|
939
|
+
// We want to include this as part of the postfix
|
|
940
|
+
matchedUpToIndex = i;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
if (allMatch) {
|
|
945
|
+
// When we matched a function call variant at the end (e.g., 'foo' matched 'foo(args)'),
|
|
946
|
+
// the base itself should be marked as a function, and the function call details
|
|
947
|
+
// should be included as sub-paths
|
|
948
|
+
if (matchedUpToIndex < pathParts.length) {
|
|
949
|
+
// This is a function call variant match at the last position
|
|
950
|
+
// Mark the base as a function (empty postfix = the base path itself)
|
|
951
|
+
entry.equivalentPostfixes[''] = bestValueFromOptions([
|
|
952
|
+
entry.equivalentPostfixes[''],
|
|
953
|
+
'function',
|
|
954
|
+
]);
|
|
955
|
+
|
|
956
|
+
// Also capture the function call and any remaining parts
|
|
957
|
+
// e.g., 'isEntityBeingAnalyzed(entity.sha)' or 'isEntityBeingAnalyzed(entity.sha).functionCallReturnValue'
|
|
958
|
+
const funcCallPart = schemaPathParts[matchedUpToIndex];
|
|
959
|
+
const baseName = pathParts[matchedUpToIndex]; // e.g., 'isEntityBeingAnalyzed'
|
|
960
|
+
const argsMatch = funcCallPart.match(/\(.*\)$/);
|
|
961
|
+
|
|
962
|
+
if (argsMatch) {
|
|
963
|
+
// Create postfix using just the args portion: (entity.sha) instead of isEntityBeingAnalyzed(entity.sha)
|
|
964
|
+
// This avoids duplicating the base name in the final path
|
|
965
|
+
const argsPortion = argsMatch[0]; // e.g., '(entity.sha)'
|
|
966
|
+
const remainingParts = schemaPathParts.slice(
|
|
967
|
+
matchedUpToIndex + 1,
|
|
968
|
+
);
|
|
969
|
+
|
|
970
|
+
// Build the postfix as: (args).remaining.parts
|
|
971
|
+
const funcPostfix = joinParenthesesAndArrays([
|
|
972
|
+
argsPortion,
|
|
973
|
+
...remainingParts,
|
|
974
|
+
]);
|
|
975
|
+
entry.equivalentPostfixes[funcPostfix] = entry
|
|
976
|
+
.equivalentPostfixes[funcPostfix]
|
|
977
|
+
? bestValueFromOptions([
|
|
978
|
+
entry.equivalentPostfixes[funcPostfix],
|
|
979
|
+
schema[schemaPath],
|
|
980
|
+
])
|
|
981
|
+
: schema[schemaPath];
|
|
982
|
+
}
|
|
983
|
+
} else {
|
|
984
|
+
// Regular exact match - use the standard postfix logic
|
|
985
|
+
const postfix = joinParenthesesAndArrays(
|
|
986
|
+
schemaPathParts.slice(matchedUpToIndex),
|
|
987
|
+
);
|
|
988
|
+
|
|
989
|
+
const previousValue = entry.equivalentPostfixes[postfix];
|
|
990
|
+
const newValue = schema[schemaPath];
|
|
991
|
+
entry.equivalentPostfixes[postfix] = previousValue
|
|
992
|
+
? bestValueFromOptions([previousValue, newValue])
|
|
993
|
+
: newValue;
|
|
994
|
+
|
|
995
|
+
// Trace postfix gathering - shows where type info comes from
|
|
996
|
+
if (entry.equivalentPostfixes[postfix] !== previousValue) {
|
|
997
|
+
transformationTracer.operation(rootScopeName, {
|
|
998
|
+
operation: 'gatherPostfix',
|
|
999
|
+
stage: 'gathering',
|
|
1000
|
+
path: postfix || '(root)',
|
|
1001
|
+
before: previousValue,
|
|
1002
|
+
after: entry.equivalentPostfixes[postfix],
|
|
1003
|
+
context: {
|
|
1004
|
+
sourceSchemaPath: schemaPath,
|
|
1005
|
+
sourceFunction:
|
|
1006
|
+
equivalentRoot.function?.name || rootScopeName,
|
|
1007
|
+
equivalentRootPath: equivalentRoot.schemaRootPath,
|
|
1008
|
+
rawValue: newValue,
|
|
1009
|
+
},
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
437
1013
|
}
|
|
438
1014
|
}
|
|
439
1015
|
}
|
|
440
1016
|
}
|
|
441
1017
|
}
|
|
442
1018
|
}
|
|
443
|
-
}
|
|
444
1019
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
1020
|
+
if (Object.keys(dataStructure?.returnValueSchema ?? {}).length > 0) {
|
|
1021
|
+
// Find all paths that contain functionCallReturnValue and extract unique base paths
|
|
1022
|
+
// For each path containing functionCallReturnValue, find the FIRST occurrence and use
|
|
1023
|
+
// that as a base path. This handles nested cases like:
|
|
1024
|
+
// X().functionCallReturnValue.A.B.Y().functionCallReturnValue
|
|
1025
|
+
// where we want both X().functionCallReturnValue and Y().functionCallReturnValue as bases
|
|
1026
|
+
const allBasePaths = new Set<string>();
|
|
1027
|
+
for (const path of Object.keys(dataStructure.returnValueSchema)) {
|
|
1028
|
+
checkDeadline();
|
|
1029
|
+
const parts = splitOutsideParenthesesAndArrays(path);
|
|
1030
|
+
// Find all positions of functionCallReturnValue and create base paths for each
|
|
1031
|
+
for (let i = 0; i < parts.length; i++) {
|
|
1032
|
+
if (parts[i] === 'functionCallReturnValue') {
|
|
1033
|
+
const basePath = joinParenthesesAndArrays(parts.slice(0, i + 1));
|
|
1034
|
+
allBasePaths.add(basePath);
|
|
1035
|
+
}
|
|
459
1036
|
}
|
|
460
1037
|
}
|
|
461
|
-
}
|
|
462
1038
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
1039
|
+
// Sort by length so shorter paths are processed first
|
|
1040
|
+
const sortedBasePaths = [...allBasePaths].sort(
|
|
1041
|
+
(a, b) => a.length - b.length,
|
|
1042
|
+
);
|
|
467
1043
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
1044
|
+
for (const basePath of sortedBasePaths) {
|
|
1045
|
+
const translatedBasePath = translatePath(basePath, functionName);
|
|
1046
|
+
const entry = findOrCreateEquivalentSchemaPathsEntry([
|
|
1047
|
+
{ path: translatedBasePath, functionName: functionName },
|
|
1048
|
+
]);
|
|
1049
|
+
const newRoot = {
|
|
1050
|
+
schemaRootPath: translatedBasePath,
|
|
1051
|
+
function: findRelevantDependency(functionName),
|
|
1052
|
+
};
|
|
1053
|
+
entry.equivalentRoots.push(newRoot);
|
|
1054
|
+
// Update index for the newly added root
|
|
1055
|
+
const newRootFuncName = newRoot.function?.name ?? rootScopeName;
|
|
1056
|
+
espIndex.set(
|
|
1057
|
+
espIndexKey(newRoot.schemaRootPath, newRootFuncName),
|
|
1058
|
+
entry,
|
|
1059
|
+
);
|
|
477
1060
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
1061
|
+
const basePathParts = splitOutsideParenthesesAndArrays(basePath);
|
|
1062
|
+
for (const schemaPath in dataStructure.returnValueSchema) {
|
|
1063
|
+
checkDeadline();
|
|
1064
|
+
const schemaPathParts =
|
|
1065
|
+
splitOutsideParenthesesAndArrays(schemaPath);
|
|
1066
|
+
if (schemaPathParts.length < basePathParts.length) continue;
|
|
1067
|
+
|
|
1068
|
+
// Check if this schemaPath actually starts with this basePath
|
|
1069
|
+
// (not just has the same length prefix)
|
|
1070
|
+
const prefixParts = schemaPathParts.slice(0, basePathParts.length);
|
|
1071
|
+
if (
|
|
1072
|
+
joinParenthesesAndArrays(prefixParts) !==
|
|
1073
|
+
joinParenthesesAndArrays(basePathParts)
|
|
1074
|
+
) {
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
482
1077
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
1078
|
+
const postfix = joinParenthesesAndArrays(
|
|
1079
|
+
schemaPathParts.slice(basePathParts.length),
|
|
1080
|
+
);
|
|
1081
|
+
const newValue = entry.equivalentPostfixes[postfix]
|
|
1082
|
+
? bestValueFromOptions([
|
|
1083
|
+
entry.equivalentPostfixes[postfix],
|
|
1084
|
+
dataStructure.returnValueSchema[schemaPath],
|
|
1085
|
+
])
|
|
1086
|
+
: dataStructure.returnValueSchema[schemaPath];
|
|
1087
|
+
|
|
1088
|
+
entry.equivalentPostfixes[postfix] = newValue;
|
|
491
1089
|
}
|
|
492
|
-
|
|
493
|
-
const postfix = joinParenthesesAndArrays(
|
|
494
|
-
schemaPathParts.slice(basePathParts.length),
|
|
495
|
-
);
|
|
496
|
-
entry.equivalentPostfixes[postfix] = entry.equivalentPostfixes[
|
|
497
|
-
postfix
|
|
498
|
-
]
|
|
499
|
-
? bestValueFromOptions([
|
|
500
|
-
entry.equivalentPostfixes[postfix],
|
|
501
|
-
dataStructure.returnValueSchema[schemaPath],
|
|
502
|
-
])
|
|
503
|
-
: dataStructure.returnValueSchema[schemaPath];
|
|
504
1090
|
}
|
|
505
1091
|
}
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
const mergeAllEquivalentSchemaPaths = () => {
|
|
510
|
-
const mergedEquivalentSchemaPaths: typeof equivalentSchemaPaths = [];
|
|
1092
|
+
};
|
|
511
1093
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
1094
|
+
const mergeAllEquivalentSchemaPaths = () => {
|
|
1095
|
+
const mergedEquivalentSchemaPaths: typeof equivalentSchemaPaths = [];
|
|
1096
|
+
|
|
1097
|
+
// Pre-pass: Connect entries with array/array-element relationships.
|
|
1098
|
+
// This handles cases like:
|
|
1099
|
+
// - Entry A has root 'surveys' (array)
|
|
1100
|
+
// - Entry B has root 'surveys[]' (array element)
|
|
1101
|
+
// These need to be connected so Entry B's field postfixes flow to Entry A.
|
|
1102
|
+
// We do this before the main merge to ensure the connection happens regardless
|
|
1103
|
+
// of processing order.
|
|
1104
|
+
for (const esp of equivalentSchemaPaths) {
|
|
1105
|
+
checkDeadline();
|
|
1106
|
+
for (const root of esp.equivalentRoots) {
|
|
1107
|
+
if (root.schemaRootPath.endsWith('[]')) {
|
|
1108
|
+
// Find a matching parent entry with the base array path
|
|
1109
|
+
const baseArrayPath = root.schemaRootPath.slice(0, -2);
|
|
1110
|
+
const parentEntry = equivalentSchemaPaths.find(
|
|
1111
|
+
(other) =>
|
|
1112
|
+
other !== esp &&
|
|
1113
|
+
other.equivalentRoots.some(
|
|
1114
|
+
(otherRoot) =>
|
|
1115
|
+
otherRoot.schemaRootPath === baseArrayPath &&
|
|
1116
|
+
otherRoot.function?.name === root.function?.name &&
|
|
1117
|
+
otherRoot.function?.filePath === root.function?.filePath,
|
|
1118
|
+
),
|
|
1119
|
+
);
|
|
1120
|
+
if (parentEntry) {
|
|
1121
|
+
// Add transformed postfixes from child (array element) to parent (array)
|
|
1122
|
+
// so they can be applied with [] prefix to parent paths
|
|
1123
|
+
for (const [postfixPath, postfixValue] of Object.entries(
|
|
1124
|
+
esp.equivalentPostfixes,
|
|
1125
|
+
)) {
|
|
1126
|
+
checkDeadline();
|
|
1127
|
+
const transformedPostfix = joinParenthesesAndArrays(
|
|
1128
|
+
['[]', postfixPath].filter(Boolean),
|
|
1129
|
+
);
|
|
1130
|
+
if (!(transformedPostfix in parentEntry.equivalentPostfixes)) {
|
|
1131
|
+
parentEntry.equivalentPostfixes[transformedPostfix] =
|
|
1132
|
+
postfixValue;
|
|
1133
|
+
}
|
|
546
1134
|
}
|
|
547
1135
|
}
|
|
548
1136
|
}
|
|
549
1137
|
}
|
|
550
1138
|
}
|
|
551
|
-
}
|
|
552
1139
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
1140
|
+
const findEquivalentSchemaPathEntry = (
|
|
1141
|
+
schemaSubPath: string,
|
|
1142
|
+
equivalentRootFunction: (typeof equivalentSchemaPaths)[0]['equivalentRoots'][0]['function'],
|
|
1143
|
+
) => {
|
|
1144
|
+
let postfix: string | undefined;
|
|
1145
|
+
|
|
1146
|
+
// Get the signature index we're looking for (if any)
|
|
1147
|
+
const lookingForSignatureIndex = extractSignatureIndex(schemaSubPath);
|
|
1148
|
+
|
|
1149
|
+
const equivalentEntry = mergedEquivalentSchemaPaths.find((esp) =>
|
|
1150
|
+
esp.equivalentRoots.some((er) => {
|
|
1151
|
+
if (
|
|
1152
|
+
(schemaSubPath.startsWith('returnValue') ||
|
|
1153
|
+
schemaSubPath.startsWith('signature[')) &&
|
|
1154
|
+
(er.function?.name !== equivalentRootFunction?.name ||
|
|
1155
|
+
er.function?.filePath !== equivalentRootFunction?.filePath)
|
|
1156
|
+
) {
|
|
1157
|
+
return false;
|
|
1158
|
+
}
|
|
568
1159
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
1160
|
+
if (schemaSubPath === er.schemaRootPath) {
|
|
1161
|
+
// Additional check: if we're looking for a signature path, make sure
|
|
1162
|
+
// the entry doesn't already have DIFFERENT signature indices.
|
|
1163
|
+
// This prevents entries with signature[1], signature[2], signature[4]
|
|
1164
|
+
// from all being merged together.
|
|
1165
|
+
if (lookingForSignatureIndex !== undefined) {
|
|
1166
|
+
const hasConflictingSignatureIndex = esp.equivalentRoots.some(
|
|
1167
|
+
(otherRoot) => {
|
|
1168
|
+
// Only check roots from the same function
|
|
1169
|
+
if (
|
|
1170
|
+
otherRoot.function?.name !==
|
|
1171
|
+
equivalentRootFunction?.name ||
|
|
1172
|
+
otherRoot.function?.filePath !==
|
|
1173
|
+
equivalentRootFunction?.filePath
|
|
1174
|
+
) {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
const otherIndex = extractSignatureIndex(
|
|
1178
|
+
otherRoot.schemaRootPath,
|
|
1179
|
+
);
|
|
1180
|
+
return (
|
|
1181
|
+
otherIndex !== undefined &&
|
|
1182
|
+
otherIndex !== lookingForSignatureIndex
|
|
1183
|
+
);
|
|
1184
|
+
},
|
|
1185
|
+
);
|
|
1186
|
+
if (hasConflictingSignatureIndex) {
|
|
1187
|
+
return false;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
573
1190
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
1191
|
+
postfix = er.postfix;
|
|
1192
|
+
return true;
|
|
1193
|
+
}
|
|
577
1194
|
|
|
578
|
-
|
|
579
|
-
|
|
1195
|
+
return false;
|
|
1196
|
+
}),
|
|
1197
|
+
);
|
|
580
1198
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
Math.max(
|
|
584
|
-
...a.equivalentRoots.map(
|
|
585
|
-
(er) => splitOutsideParenthesesAndArrays(er.schemaRootPath).length,
|
|
586
|
-
),
|
|
587
|
-
) -
|
|
588
|
-
Math.max(
|
|
589
|
-
...b.equivalentRoots.map(
|
|
590
|
-
(er) => splitOutsideParenthesesAndArrays(er.schemaRootPath).length,
|
|
591
|
-
),
|
|
592
|
-
),
|
|
593
|
-
);
|
|
1199
|
+
return { equivalentEntry, postfix };
|
|
1200
|
+
};
|
|
594
1201
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
)
|
|
1202
|
+
const sortedEquivalentSchemaPaths = equivalentSchemaPaths.sort(
|
|
1203
|
+
(a, b) =>
|
|
1204
|
+
Math.max(
|
|
1205
|
+
...a.equivalentRoots.map(
|
|
1206
|
+
(er) =>
|
|
1207
|
+
splitOutsideParenthesesAndArrays(er.schemaRootPath).length,
|
|
1208
|
+
),
|
|
1209
|
+
) -
|
|
1210
|
+
Math.max(
|
|
1211
|
+
...b.equivalentRoots.map(
|
|
1212
|
+
(er) =>
|
|
1213
|
+
splitOutsideParenthesesAndArrays(er.schemaRootPath).length,
|
|
1214
|
+
),
|
|
1215
|
+
),
|
|
1216
|
+
);
|
|
609
1217
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
1218
|
+
for (const esp of sortedEquivalentSchemaPaths) {
|
|
1219
|
+
checkDeadline();
|
|
1220
|
+
if (esp.equivalentRoots.length === 0) continue;
|
|
1221
|
+
let bestCandidateLength: number | undefined;
|
|
1222
|
+
let bestCandidate: (typeof equivalentSchemaPaths)[0] | undefined;
|
|
1223
|
+
let postfix: string | undefined;
|
|
1224
|
+
for (const equivalentRoot of esp.equivalentRoots) {
|
|
1225
|
+
const rootSchemaPath = equivalentRoot.schemaRootPath;
|
|
1226
|
+
const schemaPathParts =
|
|
1227
|
+
splitOutsideParenthesesAndArrays(rootSchemaPath);
|
|
1228
|
+
|
|
1229
|
+
for (let i = 0; i < schemaPathParts.length; i++) {
|
|
1230
|
+
const subPath = joinParenthesesAndArrays(
|
|
1231
|
+
schemaPathParts.slice(0, i + 1),
|
|
622
1232
|
);
|
|
1233
|
+
|
|
1234
|
+
const { equivalentEntry, postfix: equivalentEntryPostfix } =
|
|
1235
|
+
findEquivalentSchemaPathEntry(subPath, equivalentRoot.function);
|
|
1236
|
+
if (
|
|
1237
|
+
equivalentEntry &&
|
|
1238
|
+
(!bestCandidateLength || bestCandidateLength > i + 1)
|
|
1239
|
+
) {
|
|
1240
|
+
bestCandidate = equivalentEntry;
|
|
1241
|
+
bestCandidateLength = i + 1;
|
|
1242
|
+
postfix = joinParenthesesAndArrays(
|
|
1243
|
+
[
|
|
1244
|
+
equivalentEntryPostfix,
|
|
1245
|
+
...schemaPathParts.slice(i + 1),
|
|
1246
|
+
].filter(Boolean),
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
623
1249
|
}
|
|
624
1250
|
}
|
|
625
|
-
}
|
|
626
1251
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
1252
|
+
if (bestCandidate) {
|
|
1253
|
+
for (const root of esp.equivalentRoots) {
|
|
1254
|
+
if (postfix.length > 0) {
|
|
1255
|
+
root.postfix = postfix;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
bestCandidate.equivalentRoots.push(root);
|
|
631
1259
|
}
|
|
632
1260
|
|
|
633
|
-
|
|
1261
|
+
const postfixesToMerge =
|
|
1262
|
+
postfix.length > 0
|
|
1263
|
+
? Object.keys(esp.equivalentPostfixes).reduce(
|
|
1264
|
+
(acc, postfixPath) => {
|
|
1265
|
+
const fullPath = joinParenthesesAndArrays([
|
|
1266
|
+
postfix,
|
|
1267
|
+
postfixPath,
|
|
1268
|
+
]);
|
|
1269
|
+
acc[fullPath] = esp.equivalentPostfixes[postfixPath];
|
|
1270
|
+
return acc;
|
|
1271
|
+
},
|
|
1272
|
+
{} as Record<string, string>,
|
|
1273
|
+
)
|
|
1274
|
+
: esp.equivalentPostfixes;
|
|
1275
|
+
|
|
1276
|
+
bestCandidate.equivalentPostfixes = {
|
|
1277
|
+
...bestCandidate.equivalentPostfixes,
|
|
1278
|
+
...postfixesToMerge,
|
|
1279
|
+
};
|
|
1280
|
+
} else {
|
|
1281
|
+
mergedEquivalentSchemaPaths.push(esp);
|
|
634
1282
|
}
|
|
1283
|
+
}
|
|
635
1284
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
? Object.keys(esp.equivalentPostfixes).reduce(
|
|
639
|
-
(acc, postfixPath) => {
|
|
640
|
-
const fullPath = joinParenthesesAndArrays([
|
|
641
|
-
postfix,
|
|
642
|
-
postfixPath,
|
|
643
|
-
]);
|
|
644
|
-
acc[fullPath] = esp.equivalentPostfixes[postfixPath];
|
|
645
|
-
return acc;
|
|
646
|
-
},
|
|
647
|
-
{} as Record<string, string>,
|
|
648
|
-
)
|
|
649
|
-
: esp.equivalentPostfixes;
|
|
1285
|
+
return mergedEquivalentSchemaPaths;
|
|
1286
|
+
};
|
|
650
1287
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
mergedEquivalentSchemaPaths.push(esp);
|
|
1288
|
+
// Build a lookup of mocked dependencies to skip their internal implementation
|
|
1289
|
+
const mockedDependencies = new Set<string>();
|
|
1290
|
+
for (const dep of importedExports) {
|
|
1291
|
+
if (dep.isMocked) {
|
|
1292
|
+
mockedDependencies.add(`${dep.filePath}::${dep.name}`);
|
|
657
1293
|
}
|
|
658
1294
|
}
|
|
659
1295
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
1296
|
+
gatherAllEquivalentSchemaPaths(rootScopeName, dataStructure);
|
|
1297
|
+
|
|
1298
|
+
// Process dependencySchemas for all dependencies (including mocked ones)
|
|
1299
|
+
// dependencySchemas contains usage information (how dependencies are called),
|
|
1300
|
+
// not internal implementation, so we want this for mocked dependencies too
|
|
1301
|
+
for (const dependency of importedExports) {
|
|
1302
|
+
checkDeadline();
|
|
1303
|
+
const dependentDataStructure =
|
|
1304
|
+
dependencySchemas?.[dependency.filePath]?.[dependency.name];
|
|
1305
|
+
if (!dependentDataStructure) continue;
|
|
1306
|
+
gatherAllEquivalentSchemaPaths(
|
|
1307
|
+
dependency.name,
|
|
1308
|
+
dependentDataStructure,
|
|
1309
|
+
dependentDataStructure,
|
|
1310
|
+
);
|
|
668
1311
|
}
|
|
669
|
-
}
|
|
670
1312
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
const dependentDataStructure =
|
|
678
|
-
dependencySchemas?.[dependency.filePath]?.[dependency.name];
|
|
679
|
-
if (!dependentDataStructure) continue;
|
|
680
|
-
gatherAllEquivalentSchemaPaths(
|
|
681
|
-
dependency.name,
|
|
682
|
-
dependentDataStructure,
|
|
683
|
-
dependentDataStructure,
|
|
684
|
-
);
|
|
685
|
-
}
|
|
1313
|
+
for (const filePath in dependentAnalyses) {
|
|
1314
|
+
for (const name in dependentAnalyses[filePath]) {
|
|
1315
|
+
// Skip mocked dependencies - we don't want to merge in their internal implementation
|
|
1316
|
+
if (mockedDependencies.has(`${filePath}::${name}`)) {
|
|
1317
|
+
continue;
|
|
1318
|
+
}
|
|
686
1319
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
// Skip mocked dependencies - we don't want to merge in their internal implementation
|
|
690
|
-
if (mockedDependencies.has(`${filePath}::${name}`)) {
|
|
691
|
-
continue;
|
|
692
|
-
}
|
|
1320
|
+
const childMergedDataStructure =
|
|
1321
|
+
dependentAnalyses[filePath][name].metadata?.mergedDataStructure || {};
|
|
693
1322
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
gatherAllEquivalentSchemaPaths(name, mergedDataStructure);
|
|
1323
|
+
gatherAllEquivalentSchemaPaths(name, childMergedDataStructure as any);
|
|
1324
|
+
}
|
|
697
1325
|
}
|
|
698
|
-
}
|
|
699
1326
|
|
|
700
|
-
|
|
1327
|
+
const gatherElapsed = Date.now() - mergeStartTime;
|
|
701
1328
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
| {
|
|
706
|
-
signatureSchema: { [key: string]: string };
|
|
707
|
-
returnValueSchema: { [key: string]: string };
|
|
708
|
-
}
|
|
709
|
-
| undefined;
|
|
1329
|
+
equivalentSchemaPaths = mergeAllEquivalentSchemaPaths();
|
|
1330
|
+
|
|
1331
|
+
const mergeEspElapsed = Date.now() - mergeStartTime;
|
|
710
1332
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
1333
|
+
// Collect schemas that need cleaning — batch the calls for the end instead of
|
|
1334
|
+
// calling cleanSchema inside the inner root loop (which was O(roots * schemaSize)).
|
|
1335
|
+
const schemasToClean = new Set<{ [key: string]: string }>();
|
|
1336
|
+
|
|
1337
|
+
for (const esp of equivalentSchemaPaths) {
|
|
1338
|
+
checkDeadline();
|
|
1339
|
+
// Pre-compute which postfixes have children to avoid O(n²) lookups in the inner loop.
|
|
1340
|
+
// A postfix "has children" if there are other postfixes that extend it.
|
|
1341
|
+
const postfixesWithChildren = new Set<string>();
|
|
1342
|
+
const postfixKeys = Object.keys(esp.equivalentPostfixes);
|
|
1343
|
+
|
|
1344
|
+
// Pre-parse ALL postfix paths once. These parsed parts are reused in:
|
|
1345
|
+
// 1. The children detection loop below
|
|
1346
|
+
// 2. The inner postfix application loop (lines that split postfixPath and equivalentRoot.postfix)
|
|
1347
|
+
// This eliminates thousands of redundant splitOutsideParenthesesAndArrays calls.
|
|
1348
|
+
const postfixPartsCache = new Map<string, string[]>();
|
|
1349
|
+
for (const postfixPath of postfixKeys) {
|
|
1350
|
+
if (!postfixPath) continue;
|
|
1351
|
+
postfixPartsCache.set(
|
|
1352
|
+
postfixPath,
|
|
1353
|
+
splitOutsideParenthesesAndArrays(postfixPath),
|
|
1354
|
+
);
|
|
715
1355
|
}
|
|
716
1356
|
|
|
717
|
-
|
|
1357
|
+
// Check for empty postfix having children (any other postfixes exist)
|
|
1358
|
+
if (postfixKeys.length > 1 && '' in esp.equivalentPostfixes) {
|
|
1359
|
+
postfixesWithChildren.add('');
|
|
1360
|
+
}
|
|
718
1361
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
1362
|
+
// Check for array element postfixes having children using a prefix set.
|
|
1363
|
+
// This avoids O(n²) scans across large postfix lists.
|
|
1364
|
+
// e.g., 'currentEntities[]' has children if a path like 'currentEntities[].sha' exists.
|
|
1365
|
+
const postfixPrefixSet = new Set<string>();
|
|
1366
|
+
for (const postfixPath of postfixKeys) {
|
|
1367
|
+
if (!postfixPath) continue;
|
|
1368
|
+
const parts = postfixPartsCache.get(postfixPath)!;
|
|
1369
|
+
for (let i = 1; i < parts.length; i++) {
|
|
1370
|
+
postfixPrefixSet.add(joinParenthesesAndArrays(parts.slice(0, i)));
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
for (const postfixPath of postfixKeys) {
|
|
1374
|
+
if (postfixPath.endsWith('[]') && postfixPrefixSet.has(postfixPath)) {
|
|
1375
|
+
postfixesWithChildren.add(postfixPath);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
722
1378
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
)
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
1379
|
+
// Deduplicate equivalentRoots that would write to the same schema paths.
|
|
1380
|
+
// Roots with the same (function, schemaRootPath, postfix) are redundant.
|
|
1381
|
+
const seenRootKeys = new Set<string>();
|
|
1382
|
+
const uniqueRoots = esp.equivalentRoots.filter((root) => {
|
|
1383
|
+
const key = `${root.function?.filePath ?? ''}::${root.function?.name ?? ''}::${root.schemaRootPath}::${root.postfix ?? ''}`;
|
|
1384
|
+
if (seenRootKeys.has(key)) return false;
|
|
1385
|
+
seenRootKeys.add(key);
|
|
1386
|
+
return true;
|
|
1387
|
+
});
|
|
1388
|
+
|
|
1389
|
+
for (const equivalentRoot of uniqueRoots) {
|
|
1390
|
+
checkDeadline();
|
|
1391
|
+
let merged:
|
|
1392
|
+
| {
|
|
1393
|
+
signatureSchema: { [key: string]: string };
|
|
1394
|
+
returnValueSchema: { [key: string]: string };
|
|
1395
|
+
}
|
|
1396
|
+
| undefined;
|
|
1397
|
+
|
|
1398
|
+
if (equivalentRoot.function) {
|
|
1399
|
+
merged = findOrCreateDependentSchemas(equivalentRoot.function);
|
|
1400
|
+
} else {
|
|
1401
|
+
merged = mergedDataStructure;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
if (!merged) continue;
|
|
1405
|
+
|
|
1406
|
+
const schema = equivalentRoot.schemaRootPath.startsWith('signature[')
|
|
1407
|
+
? merged.signatureSchema
|
|
1408
|
+
: merged.returnValueSchema;
|
|
1409
|
+
|
|
1410
|
+
// Skip if this schema has already grown past the cap
|
|
1411
|
+
if (Object.keys(schema).length > SCHEMA_KEY_CAP) continue;
|
|
1412
|
+
|
|
1413
|
+
for (const [postfixPath, postfixValue] of Object.entries(
|
|
1414
|
+
esp.equivalentPostfixes,
|
|
1415
|
+
)) {
|
|
1416
|
+
checkDeadline();
|
|
1417
|
+
let relevantPostfix = postfixPath;
|
|
1418
|
+
if (equivalentRoot.postfix) {
|
|
1419
|
+
// Check if postfixPath starts with equivalentRoot.postfix at a path boundary.
|
|
1420
|
+
// Must ensure exact path part match - "entityCode" should NOT match "entity" prefix.
|
|
1421
|
+
// Valid: "entity.foo" starts with "entity" (boundary at '.')
|
|
1422
|
+
// Valid: "entity[0]" starts with "entity" (boundary at '[')
|
|
1423
|
+
// Invalid: "entityCode" starts with "entity" (no boundary, different property)
|
|
1424
|
+
if (!postfixPath.startsWith(equivalentRoot.postfix)) {
|
|
1425
|
+
continue;
|
|
1426
|
+
}
|
|
1427
|
+
// Additional check: ensure the match is at a path boundary
|
|
1428
|
+
const nextChar = postfixPath[equivalentRoot.postfix.length];
|
|
1429
|
+
if (
|
|
1430
|
+
nextChar !== undefined &&
|
|
1431
|
+
nextChar !== '.' &&
|
|
1432
|
+
nextChar !== '['
|
|
1433
|
+
) {
|
|
1434
|
+
// The postfixPath continues with more characters that aren't a path separator.
|
|
1435
|
+
// This means "entity" matched "entityCode" which is wrong - they're different properties.
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
const postFixPathParts =
|
|
1440
|
+
postfixPartsCache.get(postfixPath) ??
|
|
1441
|
+
splitOutsideParenthesesAndArrays(postfixPath);
|
|
1442
|
+
// Cache equivalentRoot.postfix parts — same root reused across all postfixes
|
|
1443
|
+
if (!postfixPartsCache.has(equivalentRoot.postfix)) {
|
|
1444
|
+
postfixPartsCache.set(
|
|
1445
|
+
equivalentRoot.postfix,
|
|
1446
|
+
splitOutsideParenthesesAndArrays(equivalentRoot.postfix),
|
|
1447
|
+
);
|
|
1448
|
+
}
|
|
1449
|
+
const equivalentRootPostFixParts = postfixPartsCache.get(
|
|
1450
|
+
equivalentRoot.postfix,
|
|
1451
|
+
)!;
|
|
1452
|
+
relevantPostfix = joinParenthesesAndArrays(
|
|
1453
|
+
postFixPathParts.slice(equivalentRootPostFixParts.length),
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
const newSchemaPath = joinParenthesesAndArrays([
|
|
1458
|
+
equivalentRoot.schemaRootPath,
|
|
1459
|
+
relevantPostfix,
|
|
1460
|
+
]);
|
|
1461
|
+
|
|
1462
|
+
// Skip paths that would go through a primitive type
|
|
1463
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', skip 'entities[].scenarioCount.sha'
|
|
1464
|
+
if (wouldGoThroughPrimitive(newSchemaPath, schema)) {
|
|
1465
|
+
transformationTracer.operation(rootScopeName, {
|
|
1466
|
+
operation: 'skipPrimitivePath',
|
|
1467
|
+
stage: 'merged',
|
|
1468
|
+
path: newSchemaPath,
|
|
1469
|
+
context: {
|
|
1470
|
+
reason: 'would go through primitive type',
|
|
1471
|
+
postfixValue,
|
|
1472
|
+
},
|
|
1473
|
+
});
|
|
729
1474
|
continue;
|
|
730
1475
|
}
|
|
731
1476
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
1477
|
+
// Skip setting primitive type when there are child postfixes that indicate structure.
|
|
1478
|
+
// This prevents downgrading an object/array element to a primitive type.
|
|
1479
|
+
// Uses pre-computed postfixesWithChildren Set for O(1) lookup instead of O(n) iteration.
|
|
1480
|
+
const hasChildPostfixes =
|
|
1481
|
+
(relevantPostfix === '' || relevantPostfix.endsWith('[]')) &&
|
|
1482
|
+
postfixesWithChildren.has(postfixPath);
|
|
1483
|
+
if (PRIMITIVE_TYPES.has(postfixValue) && hasChildPostfixes) {
|
|
1484
|
+
continue;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
// Don't overwrite a more specific type with a less specific one
|
|
1488
|
+
// This can happen when nested roots share entries with their parent roots
|
|
1489
|
+
const existingType = schema[newSchemaPath];
|
|
1490
|
+
if (existingType) {
|
|
1491
|
+
// Don't overwrite a primitive type with 'object' or 'array'
|
|
1492
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', don't overwrite with 'object'
|
|
1493
|
+
if (
|
|
1494
|
+
PRIMITIVE_TYPES.has(existingType) &&
|
|
1495
|
+
(postfixValue === 'object' || postfixValue === 'array')
|
|
1496
|
+
) {
|
|
1497
|
+
transformationTracer.operation(rootScopeName, {
|
|
1498
|
+
operation: 'skipTypeDowngrade',
|
|
1499
|
+
stage: 'merged',
|
|
1500
|
+
path: newSchemaPath,
|
|
1501
|
+
context: {
|
|
1502
|
+
reason: 'would overwrite primitive with object/array',
|
|
1503
|
+
existingType,
|
|
1504
|
+
newType: postfixValue,
|
|
1505
|
+
},
|
|
1506
|
+
});
|
|
1507
|
+
continue;
|
|
1508
|
+
}
|
|
1509
|
+
// Don't overwrite a complex/union type with a primitive
|
|
1510
|
+
// e.g., if schema has 'scenarios[]': 'Scenario | null', don't overwrite with 'string'
|
|
1511
|
+
if (
|
|
1512
|
+
!PRIMITIVE_TYPES.has(existingType) &&
|
|
1513
|
+
PRIMITIVE_TYPES.has(postfixValue)
|
|
1514
|
+
) {
|
|
1515
|
+
transformationTracer.operation(rootScopeName, {
|
|
1516
|
+
operation: 'skipTypeDowngrade',
|
|
1517
|
+
stage: 'merged',
|
|
1518
|
+
path: newSchemaPath,
|
|
1519
|
+
context: {
|
|
1520
|
+
reason: 'would overwrite complex type with primitive',
|
|
1521
|
+
existingType,
|
|
1522
|
+
newType: postfixValue,
|
|
1523
|
+
},
|
|
1524
|
+
});
|
|
1525
|
+
continue;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
741
1528
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
1529
|
+
// Log the successful postfix merge
|
|
1530
|
+
transformationTracer.operation(rootScopeName, {
|
|
1531
|
+
operation: 'mergePostfix',
|
|
1532
|
+
stage: 'merged',
|
|
1533
|
+
path: newSchemaPath,
|
|
1534
|
+
before: existingType,
|
|
1535
|
+
after: postfixValue,
|
|
1536
|
+
context: {
|
|
1537
|
+
schemaRootPath: equivalentRoot.schemaRootPath,
|
|
1538
|
+
postfix: relevantPostfix,
|
|
1539
|
+
dependency: equivalentRoot.function?.name,
|
|
1540
|
+
},
|
|
1541
|
+
});
|
|
1542
|
+
schema[newSchemaPath] = postfixValue;
|
|
1543
|
+
}
|
|
746
1544
|
|
|
747
|
-
schema
|
|
1545
|
+
schemasToClean.add(schema);
|
|
748
1546
|
}
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
const postfixElapsed = Date.now() - mergeStartTime;
|
|
749
1550
|
|
|
750
|
-
|
|
1551
|
+
// Batch-clean all modified schemas once (instead of once per root per ESP entry)
|
|
1552
|
+
for (const schema of schemasToClean) {
|
|
1553
|
+
cleanSchema(schema, { stage: 'afterMergePostfix' });
|
|
751
1554
|
}
|
|
752
|
-
}
|
|
753
1555
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
originalSchema
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
1556
|
+
const cleanElapsed = Date.now() - mergeStartTime;
|
|
1557
|
+
|
|
1558
|
+
// Propagate equivalency-derived attributes to generic function call variants.
|
|
1559
|
+
// When attributes are traced via equivalencies (e.g., fileComparisons from buildDataMap.signature[2]),
|
|
1560
|
+
// they get written to non-generic paths (returnValue.data.x or funcName().functionCallReturnValue.data.x).
|
|
1561
|
+
// If the ORIGINAL input schema has generic variants (funcName<T>().functionCallReturnValue.data),
|
|
1562
|
+
// we need to copy the attributes to those paths too.
|
|
1563
|
+
for (const filePath in mergedDataStructure.dependencySchemas) {
|
|
1564
|
+
for (const depName in mergedDataStructure.dependencySchemas[filePath]) {
|
|
1565
|
+
const depSchema =
|
|
1566
|
+
mergedDataStructure.dependencySchemas[filePath][depName];
|
|
1567
|
+
const returnValueSchema = depSchema.returnValueSchema;
|
|
1568
|
+
|
|
1569
|
+
// Look at the ORIGINAL input dependencySchemas for generic variants,
|
|
1570
|
+
// since the merged schema may have lost them during equivalency processing
|
|
1571
|
+
const originalSchema = dependencySchemas?.[filePath]?.[depName];
|
|
1572
|
+
const schemaToSearchForGenericVariants =
|
|
1573
|
+
originalSchema?.returnValueSchema || returnValueSchema;
|
|
1574
|
+
|
|
1575
|
+
// Find all unique generic variants of this function
|
|
1576
|
+
// e.g., useFetcher<BranchEntityDiffResult>() from useFetcher<BranchEntityDiffResult>().functionCallReturnValue.data
|
|
1577
|
+
const genericVariants = new Set<string>();
|
|
1578
|
+
const genericRegex = new RegExp(
|
|
1579
|
+
`^${depName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}<[^>]+>\\(\\)`,
|
|
1580
|
+
);
|
|
777
1581
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
1582
|
+
for (const path in schemaToSearchForGenericVariants) {
|
|
1583
|
+
checkDeadline();
|
|
1584
|
+
const match = path.match(genericRegex);
|
|
1585
|
+
if (match) {
|
|
1586
|
+
genericVariants.add(match[0]);
|
|
1587
|
+
}
|
|
782
1588
|
}
|
|
783
|
-
}
|
|
784
1589
|
|
|
785
|
-
|
|
1590
|
+
if (genericVariants.size === 0) continue;
|
|
786
1591
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
1592
|
+
// For each returnValue. path or non-generic function call path,
|
|
1593
|
+
// create corresponding paths for each generic variant
|
|
1594
|
+
const pathsToAdd: [string, string][] = [];
|
|
790
1595
|
|
|
791
|
-
|
|
792
|
-
|
|
1596
|
+
for (const path in returnValueSchema) {
|
|
1597
|
+
checkDeadline();
|
|
1598
|
+
const value = returnValueSchema[path];
|
|
793
1599
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
1600
|
+
// Handle returnValue. paths
|
|
1601
|
+
if (path.startsWith('returnValue.')) {
|
|
1602
|
+
const suffix = path.slice('returnValue.'.length);
|
|
1603
|
+
for (const genericVariant of genericVariants) {
|
|
1604
|
+
const genericPath = `${genericVariant}.functionCallReturnValue.${suffix}`;
|
|
1605
|
+
if (!(genericPath in returnValueSchema)) {
|
|
1606
|
+
pathsToAdd.push([genericPath, value]);
|
|
1607
|
+
}
|
|
801
1608
|
}
|
|
802
1609
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
1610
|
+
// Handle non-generic function call paths like depName().functionCallReturnValue.x
|
|
1611
|
+
else if (path.startsWith(`${depName}().functionCallReturnValue.`)) {
|
|
1612
|
+
const suffix = path.slice(
|
|
1613
|
+
`${depName}().functionCallReturnValue.`.length,
|
|
1614
|
+
);
|
|
1615
|
+
for (const genericVariant of genericVariants) {
|
|
1616
|
+
const genericPath = `${genericVariant}.functionCallReturnValue.${suffix}`;
|
|
1617
|
+
if (!(genericPath in returnValueSchema)) {
|
|
1618
|
+
pathsToAdd.push([genericPath, value]);
|
|
1619
|
+
}
|
|
813
1620
|
}
|
|
814
1621
|
}
|
|
815
1622
|
}
|
|
816
|
-
}
|
|
817
1623
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
1624
|
+
// Add the new generic variant paths
|
|
1625
|
+
for (const [path, value] of pathsToAdd) {
|
|
1626
|
+
returnValueSchema[path] = value;
|
|
1627
|
+
}
|
|
821
1628
|
}
|
|
822
1629
|
}
|
|
823
|
-
}
|
|
824
1630
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
for (const [path, value] of pathsToNormalize) {
|
|
854
|
-
delete depSchema.returnValueSchema[path];
|
|
855
|
-
let normalizedPath: string;
|
|
856
|
-
if (path === 'returnValue') {
|
|
857
|
-
normalizedPath = `${dependency.name}().functionCallReturnValue`;
|
|
858
|
-
} else if (path.startsWith('returnValue.')) {
|
|
859
|
-
normalizedPath = path.replace(
|
|
860
|
-
/^returnValue\./,
|
|
861
|
-
`${dependency.name}().functionCallReturnValue.`,
|
|
862
|
-
);
|
|
863
|
-
} else {
|
|
864
|
-
// path.startsWith('returnValue[')
|
|
865
|
-
// e.g., returnValue[] -> getOptions().functionCallReturnValue[]
|
|
866
|
-
// e.g., returnValue[].label -> getOptions().functionCallReturnValue[].label
|
|
867
|
-
normalizedPath = path.replace(
|
|
868
|
-
/^returnValue/,
|
|
869
|
-
`${dependency.name}().functionCallReturnValue`,
|
|
870
|
-
);
|
|
1631
|
+
// For mocked dependencies: copy paths from dependencySchemas (usage info) and normalize
|
|
1632
|
+
// returnValue. paths that were created by equivalency processing.
|
|
1633
|
+
// This ensures all paths use the consistent functionName().functionCallReturnValue. format.
|
|
1634
|
+
for (const dependency of importedExports) {
|
|
1635
|
+
if (!dependency.isMocked) continue;
|
|
1636
|
+
|
|
1637
|
+
const srcSchema =
|
|
1638
|
+
dependencySchemas?.[dependency.filePath]?.[dependency.name];
|
|
1639
|
+
if (!srcSchema?.returnValueSchema) continue;
|
|
1640
|
+
|
|
1641
|
+
const depSchema = findOrCreateDependentSchemas({
|
|
1642
|
+
filePath: dependency.filePath,
|
|
1643
|
+
name: dependency.name,
|
|
1644
|
+
});
|
|
1645
|
+
|
|
1646
|
+
// First, normalize any returnValue paths that were written by equivalency processing
|
|
1647
|
+
// to the standard functionName().functionCallReturnValue format.
|
|
1648
|
+
// This includes both returnValue. (dot) and returnValue[ (array) paths.
|
|
1649
|
+
const pathsToNormalize: [string, string][] = [];
|
|
1650
|
+
for (const path in depSchema.returnValueSchema) {
|
|
1651
|
+
checkDeadline();
|
|
1652
|
+
if (
|
|
1653
|
+
path === 'returnValue' ||
|
|
1654
|
+
path.startsWith('returnValue.') ||
|
|
1655
|
+
path.startsWith('returnValue[')
|
|
1656
|
+
) {
|
|
1657
|
+
pathsToNormalize.push([path, depSchema.returnValueSchema[path]]);
|
|
1658
|
+
}
|
|
871
1659
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1660
|
+
for (const [path, value] of pathsToNormalize) {
|
|
1661
|
+
delete depSchema.returnValueSchema[path];
|
|
1662
|
+
let normalizedPath: string;
|
|
1663
|
+
if (path === 'returnValue') {
|
|
1664
|
+
normalizedPath = `${dependency.name}().functionCallReturnValue`;
|
|
1665
|
+
} else if (path.startsWith('returnValue.')) {
|
|
1666
|
+
normalizedPath = path.replace(
|
|
1667
|
+
/^returnValue\./,
|
|
1668
|
+
`${dependency.name}().functionCallReturnValue.`,
|
|
1669
|
+
);
|
|
1670
|
+
} else {
|
|
1671
|
+
// path.startsWith('returnValue[')
|
|
1672
|
+
// e.g., returnValue[] -> getOptions().functionCallReturnValue[]
|
|
1673
|
+
// e.g., returnValue[].label -> getOptions().functionCallReturnValue[].label
|
|
1674
|
+
normalizedPath = path.replace(
|
|
1675
|
+
/^returnValue/,
|
|
1676
|
+
`${dependency.name}().functionCallReturnValue`,
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1679
|
+
transformationTracer.operation(rootScopeName, {
|
|
1680
|
+
operation: 'normalizeReturnValuePath',
|
|
1681
|
+
stage: 'merged',
|
|
1682
|
+
path: normalizedPath,
|
|
1683
|
+
before: path,
|
|
1684
|
+
after: normalizedPath,
|
|
1685
|
+
context: { dependency: dependency.name, value },
|
|
1686
|
+
});
|
|
895
1687
|
depSchema.returnValueSchema[normalizedPath] = value;
|
|
896
|
-
continue;
|
|
897
1688
|
}
|
|
898
1689
|
|
|
899
|
-
//
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1690
|
+
// Now copy paths from the source schema (dependencySchemas)
|
|
1691
|
+
for (const path in srcSchema.returnValueSchema) {
|
|
1692
|
+
checkDeadline();
|
|
1693
|
+
const value = srcSchema.returnValueSchema[path];
|
|
1694
|
+
|
|
1695
|
+
// Normalize paths starting with 'returnValue' to use the standard format:
|
|
1696
|
+
// 'returnValue.foo' -> 'dependencyName().functionCallReturnValue.foo'
|
|
1697
|
+
// This ensures consistency across the codebase and allows constructMockCode
|
|
1698
|
+
// and gatherDataForMocks to work correctly.
|
|
1699
|
+
if (path === 'returnValue' || path.startsWith('returnValue.')) {
|
|
1700
|
+
// Convert 'returnValue' -> 'name().functionCallReturnValue'
|
|
1701
|
+
// Convert 'returnValue.foo' -> 'name().functionCallReturnValue.foo'
|
|
1702
|
+
const normalizedPath =
|
|
1703
|
+
path === 'returnValue'
|
|
1704
|
+
? `${dependency.name}().functionCallReturnValue`
|
|
1705
|
+
: path.replace(
|
|
1706
|
+
/^returnValue\./,
|
|
1707
|
+
`${dependency.name}().functionCallReturnValue.`,
|
|
1708
|
+
);
|
|
1709
|
+
|
|
1710
|
+
// Always write srcSchema values - they take precedence over equivalency-derived values
|
|
1711
|
+
depSchema.returnValueSchema[normalizedPath] = value;
|
|
1712
|
+
continue;
|
|
1713
|
+
}
|
|
907
1714
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
// Skip paths starting with 'returnValue' - they were already handled above
|
|
914
|
-
if (
|
|
915
|
-
['function', 'async-function'].includes(value) &&
|
|
916
|
-
path.endsWith(')') &&
|
|
917
|
-
!path.startsWith('returnValue')
|
|
918
|
-
) {
|
|
919
|
-
if (!(path in depSchema.returnValueSchema)) {
|
|
1715
|
+
// Copy paths containing functionCallReturnValue (return value structures)
|
|
1716
|
+
// These are needed for constructMockCode to build the proper mock data hierarchy
|
|
1717
|
+
// Example: supabase.auth.getSession().functionCallReturnValue.data.session
|
|
1718
|
+
if (path.includes('.functionCallReturnValue')) {
|
|
1719
|
+
// Always write srcSchema values - they take precedence over equivalency-derived values
|
|
920
1720
|
depSchema.returnValueSchema[path] = value;
|
|
1721
|
+
continue;
|
|
921
1722
|
}
|
|
922
|
-
}
|
|
923
1723
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
// EXCEPTION: For function-style dependencies like getSupabase(), skip intermediate object
|
|
931
|
-
// paths like 'getSupabase().auth' that are just property access after a function call.
|
|
932
|
-
// These aren't needed because constructMockCode can infer the structure from the actual
|
|
933
|
-
// function call paths like 'getSupabase().auth.getUser()'. We only need object paths
|
|
934
|
-
// for object-style dependencies like 'supabase.auth' where the dependency itself is an object.
|
|
935
|
-
if (value === 'object' && !path.startsWith('returnValue')) {
|
|
936
|
-
// Check if this is a function-style dependency (path starts with name() or name<T>())
|
|
937
|
-
const isFunctionStyleDependency =
|
|
938
|
-
path.startsWith(`${dependency.name}()`) ||
|
|
939
|
-
path.match(new RegExp(`^${dependency.name}<[^>]+>\\(\\)`));
|
|
940
|
-
|
|
941
|
-
// For function-style dependencies, skip intermediate object paths
|
|
942
|
-
// Only keep object paths that are within functionCallReturnValue
|
|
1724
|
+
// Copy function-typed paths that end with () (are function calls)
|
|
1725
|
+
// These include:
|
|
1726
|
+
// - Function stubs without functionCallReturnValue (like onAuthStateChange)
|
|
1727
|
+
// - Function markers with async-function type (like getSession(): async-function)
|
|
1728
|
+
// which are needed for constructMockCode to know to generate async functions
|
|
1729
|
+
// Skip paths starting with 'returnValue' - they were already handled above
|
|
943
1730
|
if (
|
|
944
|
-
|
|
945
|
-
|
|
1731
|
+
['function', 'async-function'].includes(value) &&
|
|
1732
|
+
path.endsWith(')') &&
|
|
1733
|
+
!path.startsWith('returnValue')
|
|
946
1734
|
) {
|
|
947
|
-
|
|
1735
|
+
if (!(path in depSchema.returnValueSchema)) {
|
|
1736
|
+
depSchema.returnValueSchema[path] = value;
|
|
1737
|
+
}
|
|
948
1738
|
}
|
|
949
1739
|
|
|
950
|
-
|
|
951
|
-
|
|
1740
|
+
// Copy object-typed paths for chained API access patterns (like trpc.customer.getCustomersByOrg)
|
|
1741
|
+
// These intermediate paths are needed for constructMockCode to build the nested mock structure.
|
|
1742
|
+
// Example: for trpc.customer.getCustomersByOrg.useQuery().functionCallReturnValue.data,
|
|
1743
|
+
// we need 'trpc', 'trpc.customer', 'trpc.customer.getCustomersByOrg' all typed as 'object'.
|
|
1744
|
+
// Skip paths starting with 'returnValue' - they were already handled above
|
|
1745
|
+
//
|
|
1746
|
+
// EXCEPTION: For function-style dependencies like getSupabase(), skip intermediate object
|
|
1747
|
+
// paths like 'getSupabase().auth' that are just property access after a function call.
|
|
1748
|
+
// These aren't needed because constructMockCode can infer the structure from the actual
|
|
1749
|
+
// function call paths like 'getSupabase().auth.getUser()'. We only need object paths
|
|
1750
|
+
// for object-style dependencies like 'supabase.auth' where the dependency itself is an object.
|
|
1751
|
+
if (value === 'object' && !path.startsWith('returnValue')) {
|
|
1752
|
+
// Check if this is a function-style dependency (path starts with name() or name<T>())
|
|
1753
|
+
const isFunctionStyleDependency =
|
|
1754
|
+
path.startsWith(`${dependency.name}()`) ||
|
|
1755
|
+
path.match(new RegExp(`^${dependency.name}<[^>]+>\\(\\)`));
|
|
1756
|
+
|
|
1757
|
+
// For function-style dependencies, skip intermediate object paths
|
|
1758
|
+
// Only keep object paths that are within functionCallReturnValue
|
|
1759
|
+
if (
|
|
1760
|
+
isFunctionStyleDependency &&
|
|
1761
|
+
!path.includes('.functionCallReturnValue')
|
|
1762
|
+
) {
|
|
1763
|
+
continue;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
if (!(path in depSchema.returnValueSchema)) {
|
|
1767
|
+
depSchema.returnValueSchema[path] = value;
|
|
1768
|
+
}
|
|
952
1769
|
}
|
|
953
1770
|
}
|
|
954
|
-
}
|
|
955
1771
|
|
|
956
|
-
|
|
957
|
-
|
|
1772
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1773
|
+
stage: 'afterMockedDependencyMerge',
|
|
1774
|
+
dependency: dependency.name,
|
|
1775
|
+
});
|
|
958
1776
|
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
if (!srcSchema) continue;
|
|
973
|
-
|
|
974
|
-
// Skip mocked dependencies - they were already processed above with path normalization
|
|
975
|
-
if (mockedDependencies.has(`${filePath}::${name}`)) {
|
|
976
|
-
continue;
|
|
977
|
-
}
|
|
1777
|
+
// Pull signature requirements from downstream functions into the mocked return value.
|
|
1778
|
+
// When a mocked function's return flows into another function's signature (via usageEquivalencies),
|
|
1779
|
+
// we need to include that function's signature requirements in the mock.
|
|
1780
|
+
//
|
|
1781
|
+
// Example: fromE5() returns a currency object that flows to calculateTotalPrice(price, quantity).
|
|
1782
|
+
// calculateTotalPrice's signatureSchema shows signature[0].multiply() is required.
|
|
1783
|
+
// We need to add multiply() to fromE5's mock return value.
|
|
1784
|
+
const usageEquivalencies = srcSchema.usageEquivalencies ?? {};
|
|
1785
|
+
for (const [returnPath, equivalencies] of Object.entries(
|
|
1786
|
+
usageEquivalencies,
|
|
1787
|
+
)) {
|
|
1788
|
+
// Only process return value paths (functionCallReturnValue)
|
|
1789
|
+
if (!returnPath.includes('.functionCallReturnValue')) continue;
|
|
978
1790
|
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1791
|
+
for (const equiv of equivalencies) {
|
|
1792
|
+
// Check if this equivalency points to a signature path
|
|
1793
|
+
const signatureMatch = equiv.schemaPath.match(
|
|
1794
|
+
/\.signature\[(\d+)\]$/,
|
|
1795
|
+
);
|
|
1796
|
+
if (!signatureMatch) continue;
|
|
1797
|
+
|
|
1798
|
+
const targetFunctionName = cleanFunctionName(equiv.scopeNodeName);
|
|
1799
|
+
const signatureIndex = signatureMatch[1];
|
|
1800
|
+
|
|
1801
|
+
// Look up the target function's analysis to get its signature requirements
|
|
1802
|
+
// First try dependentAnalyses, then dependencySchemas
|
|
1803
|
+
let targetSignatureSchema: Record<string, string> | undefined;
|
|
1804
|
+
|
|
1805
|
+
// Check dependentAnalyses first (has the full merged analysis)
|
|
1806
|
+
for (const depFilePath in dependentAnalyses) {
|
|
1807
|
+
const analysis =
|
|
1808
|
+
dependentAnalyses[depFilePath]?.[targetFunctionName];
|
|
1809
|
+
if (analysis?.metadata?.mergedDataStructure?.signatureSchema) {
|
|
1810
|
+
targetSignatureSchema =
|
|
1811
|
+
analysis.metadata.mergedDataStructure.signatureSchema;
|
|
1812
|
+
break;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
982
1815
|
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1816
|
+
// Fallback to dependencySchemas if not found
|
|
1817
|
+
if (!targetSignatureSchema) {
|
|
1818
|
+
for (const depFilePath in dependencySchemas) {
|
|
1819
|
+
const schema =
|
|
1820
|
+
dependencySchemas[depFilePath]?.[targetFunctionName];
|
|
1821
|
+
if (schema?.signatureSchema) {
|
|
1822
|
+
targetSignatureSchema = schema.signatureSchema;
|
|
1823
|
+
break;
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
992
1827
|
|
|
993
|
-
|
|
994
|
-
// from the copied schema. Without this, method call paths on primitives like
|
|
995
|
-
// "projectSlug.replace(...)" would cause convertDotNotation to create nested
|
|
996
|
-
// object structures instead of preserving the primitive type.
|
|
997
|
-
cleanSchema(depSchema.returnValueSchema);
|
|
998
|
-
}
|
|
1828
|
+
if (!targetSignatureSchema) continue;
|
|
999
1829
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
// Find all unique type-parameterized call signatures in the schema
|
|
1008
|
-
const typeParamVariants = new Set<string>();
|
|
1009
|
-
for (const path of Object.keys(srcSchema.returnValueSchema)) {
|
|
1010
|
-
const parts = splitOutsideParenthesesAndArrays(path);
|
|
1011
|
-
if (
|
|
1012
|
-
parts.length > 0 &&
|
|
1013
|
-
parts[0].includes('<') &&
|
|
1014
|
-
parts[0].endsWith(')')
|
|
1015
|
-
) {
|
|
1016
|
-
typeParamVariants.add(parts[0]);
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1830
|
+
// Find all paths in the target's signatureSchema that extend from signature[N]
|
|
1831
|
+
// e.g., signature[0].multiply(quantity) -> .multiply(quantity)
|
|
1832
|
+
const signaturePrefix = `signature[${signatureIndex}]`;
|
|
1833
|
+
for (const [sigPath, sigType] of Object.entries(
|
|
1834
|
+
targetSignatureSchema,
|
|
1835
|
+
)) {
|
|
1836
|
+
if (!sigPath.startsWith(signaturePrefix)) continue;
|
|
1019
1837
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
const variantSchema = findOrCreateDependentSchemas({
|
|
1023
|
-
filePath,
|
|
1024
|
-
name: variant,
|
|
1025
|
-
});
|
|
1838
|
+
// Skip the base signature[N] path itself - we only want the method/property extensions
|
|
1839
|
+
if (sigPath === signaturePrefix) continue;
|
|
1026
1840
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1841
|
+
// Extract the suffix after signature[N] (e.g., ".multiply(quantity)")
|
|
1842
|
+
const suffix = sigPath.slice(signaturePrefix.length);
|
|
1843
|
+
|
|
1844
|
+
// Build the path for the mocked return value
|
|
1845
|
+
// e.g., fromE5(priceE5).functionCallReturnValue.multiply(quantity)
|
|
1846
|
+
const returnValuePath = returnPath + suffix;
|
|
1847
|
+
|
|
1848
|
+
// Add to the mocked dependency's return value schema if not already present
|
|
1849
|
+
if (!(returnValuePath in depSchema.returnValueSchema)) {
|
|
1850
|
+
depSchema.returnValueSchema[returnValuePath] = sigType;
|
|
1032
1851
|
}
|
|
1033
1852
|
}
|
|
1034
|
-
cleanSchema(variantSchema.returnValueSchema);
|
|
1035
1853
|
}
|
|
1036
1854
|
}
|
|
1855
|
+
|
|
1856
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1857
|
+
stage: 'afterSignatureRequirementsMerge',
|
|
1858
|
+
dependency: dependency.name,
|
|
1859
|
+
});
|
|
1037
1860
|
}
|
|
1038
|
-
}
|
|
1039
1861
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1862
|
+
// Process the input dependencySchemas FIRST (before child dependentAnalyses).
|
|
1863
|
+
// This ensures the parent entity's direct usage of dependencies takes precedence.
|
|
1864
|
+
// When both parent and child use the same dependency (e.g., useLoaderData),
|
|
1865
|
+
// the parent's schema paths are preserved, and child's paths are merged in later.
|
|
1866
|
+
//
|
|
1867
|
+
// Some dependencies (like .d.ts type declaration files) may not have:
|
|
1868
|
+
// - Equivalencies with the root scope
|
|
1869
|
+
// - A dependent analysis (they're just type declarations)
|
|
1870
|
+
// - Be marked as mocked
|
|
1871
|
+
// Without this, their schemas would be lost entirely.
|
|
1872
|
+
for (const filePath in dependencySchemas) {
|
|
1873
|
+
for (const name in dependencySchemas[filePath]) {
|
|
1874
|
+
const srcSchema = dependencySchemas[filePath][name];
|
|
1875
|
+
if (!srcSchema) continue;
|
|
1876
|
+
|
|
1877
|
+
// Skip mocked dependencies - they were already processed above with path normalization
|
|
1878
|
+
if (mockedDependencies.has(`${filePath}::${name}`)) {
|
|
1879
|
+
continue;
|
|
1880
|
+
}
|
|
1048
1881
|
|
|
1049
|
-
|
|
1882
|
+
// Check if this dependency was already processed by equivalencies
|
|
1883
|
+
const existingSchema =
|
|
1884
|
+
mergedDataStructure.dependencySchemas[filePath]?.[name];
|
|
1050
1885
|
|
|
1051
|
-
|
|
1886
|
+
// Only add if no existing schema (equivalencies didn't process it)
|
|
1887
|
+
if (!existingSchema) {
|
|
1888
|
+
const depSchema = findOrCreateDependentSchemas({ filePath, name });
|
|
1889
|
+
for (const path in srcSchema.returnValueSchema) {
|
|
1890
|
+
checkDeadline();
|
|
1891
|
+
depSchema.returnValueSchema[path] =
|
|
1892
|
+
srcSchema.returnValueSchema[path];
|
|
1893
|
+
}
|
|
1894
|
+
for (const path in srcSchema.signatureSchema) {
|
|
1895
|
+
checkDeadline();
|
|
1896
|
+
depSchema.signatureSchema[path] = srcSchema.signatureSchema[path];
|
|
1897
|
+
}
|
|
1052
1898
|
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1899
|
+
// Clean known object functions (like String.prototype.replace, Array.prototype.map)
|
|
1900
|
+
// from the copied schema. Without this, method call paths on primitives like
|
|
1901
|
+
// "projectSlug.replace(...)" would cause convertDotNotation to create nested
|
|
1902
|
+
// object structures instead of preserving the primitive type.
|
|
1903
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1904
|
+
stage: 'afterDependencySchemaCopy',
|
|
1905
|
+
filePath,
|
|
1906
|
+
dependency: name,
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1058
1909
|
|
|
1059
|
-
//
|
|
1060
|
-
//
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1910
|
+
// TYPE REFINEMENT: Check if dependentAnalyses has a more specific type for this dependency.
|
|
1911
|
+
// When a parent passes `entity.filePath` (string | undefined) to a child component
|
|
1912
|
+
// that requires `filePath: string`, we should use the child's more specific type.
|
|
1913
|
+
// This prevents mock data from having undefined values for required props.
|
|
1914
|
+
//
|
|
1915
|
+
// This runs REGARDLESS of whether equivalencies already processed the schema,
|
|
1916
|
+
// because equivalencies copy the parent's type (string | undefined), not the child's
|
|
1917
|
+
// required type (string).
|
|
1918
|
+
const depSchema = findOrCreateDependentSchemas({ filePath, name });
|
|
1919
|
+
const childAnalysis = dependentAnalyses[filePath]?.[name];
|
|
1920
|
+
const childSignatureSchema =
|
|
1921
|
+
childAnalysis?.metadata?.mergedDataStructure?.signatureSchema;
|
|
1922
|
+
|
|
1923
|
+
if (childSignatureSchema) {
|
|
1924
|
+
for (const path in depSchema.signatureSchema) {
|
|
1925
|
+
checkDeadline();
|
|
1926
|
+
const parentType = depSchema.signatureSchema[path];
|
|
1927
|
+
const childType = childSignatureSchema[path];
|
|
1928
|
+
|
|
1929
|
+
if (parentType && childType) {
|
|
1930
|
+
// Check if parent has optional type and child has required type
|
|
1931
|
+
const parentIsOptional =
|
|
1932
|
+
parentType.includes('| undefined') ||
|
|
1933
|
+
parentType.includes('| null');
|
|
1934
|
+
const childIsOptional =
|
|
1935
|
+
childType.includes('| undefined') ||
|
|
1936
|
+
childType.includes('| null');
|
|
1937
|
+
|
|
1938
|
+
// If child requires a more specific type (not optional), use it
|
|
1939
|
+
if (parentIsOptional && !childIsOptional) {
|
|
1940
|
+
depSchema.signatureSchema[path] = childType;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1066
1943
|
}
|
|
1067
1944
|
}
|
|
1068
1945
|
|
|
1069
|
-
//
|
|
1070
|
-
for
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1946
|
+
// For functions with multiple different type parameters, also create separate entries
|
|
1947
|
+
// for each type-parameterized variant. This allows gatherDataForMocks to look up
|
|
1948
|
+
// the specific schema for each call signature.
|
|
1949
|
+
// This runs regardless of whether the base entry already existed, since we need
|
|
1950
|
+
// the separate variant entries for proper schema lookup.
|
|
1951
|
+
const baseName = cleanFunctionName(name);
|
|
1952
|
+
if (functionsWithMultipleTypeParams.has(baseName)) {
|
|
1953
|
+
// Find all unique type-parameterized call signatures in the schema
|
|
1954
|
+
const typeParamVariants = new Set<string>();
|
|
1955
|
+
for (const path of Object.keys(srcSchema.returnValueSchema)) {
|
|
1956
|
+
const parts = splitOutsideParenthesesAndArrays(path);
|
|
1957
|
+
if (
|
|
1958
|
+
parts.length > 0 &&
|
|
1959
|
+
parts[0].includes('<') &&
|
|
1960
|
+
parts[0].endsWith(')')
|
|
1961
|
+
) {
|
|
1962
|
+
typeParamVariants.add(parts[0]);
|
|
1963
|
+
}
|
|
1075
1964
|
}
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
1965
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
depFilePath
|
|
1085
|
-
]) {
|
|
1086
|
-
const nestedDepSchema =
|
|
1087
|
-
dependentMergedDataStructure.dependencySchemas[depFilePath][
|
|
1088
|
-
depName
|
|
1089
|
-
];
|
|
1090
|
-
const targetDepSchema = findOrCreateDependentSchemas({
|
|
1091
|
-
filePath: depFilePath,
|
|
1092
|
-
name: depName,
|
|
1966
|
+
// Create a separate entry for each type-parameterized variant
|
|
1967
|
+
for (const variant of typeParamVariants) {
|
|
1968
|
+
const variantSchema = findOrCreateDependentSchemas({
|
|
1969
|
+
filePath,
|
|
1970
|
+
name: variant,
|
|
1093
1971
|
});
|
|
1094
1972
|
|
|
1095
|
-
//
|
|
1096
|
-
for (const path in
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1973
|
+
// Copy only paths that belong to this variant
|
|
1974
|
+
for (const path in srcSchema.returnValueSchema) {
|
|
1975
|
+
checkDeadline();
|
|
1976
|
+
if (path.startsWith(variant)) {
|
|
1977
|
+
variantSchema.returnValueSchema[path] =
|
|
1978
|
+
srcSchema.returnValueSchema[path];
|
|
1100
1979
|
}
|
|
1101
1980
|
}
|
|
1981
|
+
cleanSchema(variantSchema.returnValueSchema, {
|
|
1982
|
+
stage: 'afterTypeVariantCopy',
|
|
1983
|
+
filePath,
|
|
1984
|
+
dependency: name,
|
|
1985
|
+
variant,
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
// Ensure ALL dependencies from dependentAnalyses are included in dependencySchemas,
|
|
1993
|
+
// even if they have no equivalencies with the root scope.
|
|
1994
|
+
// This preserves nested functionCallReturnValue paths that would otherwise be lost.
|
|
1995
|
+
// EXCEPT: Skip mocked dependencies - we don't want their internal implementation details.
|
|
1996
|
+
for (const filePath in dependentAnalyses) {
|
|
1997
|
+
for (const name in dependentAnalyses[filePath]) {
|
|
1998
|
+
checkDeadline();
|
|
1999
|
+
const dependentMergedDataStructure =
|
|
2000
|
+
dependentAnalyses[filePath][name].metadata?.mergedDataStructure;
|
|
2001
|
+
|
|
2002
|
+
if (!dependentMergedDataStructure) continue;
|
|
2003
|
+
|
|
2004
|
+
const isMocked = mockedDependencies.has(`${filePath}::${name}`);
|
|
2005
|
+
|
|
2006
|
+
// For mocked dependencies: ONLY copy nested dependencySchemas (skip internal implementation)
|
|
2007
|
+
// For non-mocked dependencies: copy everything (signature, returnValue, and nested dependencySchemas)
|
|
2008
|
+
if (!isMocked) {
|
|
2009
|
+
// Create the dependency schema entry if it doesn't exist
|
|
2010
|
+
const depSchema = findOrCreateDependentSchemas({ filePath, name });
|
|
2011
|
+
|
|
2012
|
+
// Copy over paths from the dependent's returnValueSchema.
|
|
2013
|
+
// Only add paths that don't already exist (don't overwrite values set by equivalencies).
|
|
2014
|
+
// Skip if either source or target exceeds the cap — copying 2,531 paths from
|
|
2015
|
+
// ArticleTable with translatePath on each takes ~1.5s for one entity.
|
|
2016
|
+
const srcRetSize = Object.keys(
|
|
2017
|
+
dependentMergedDataStructure.returnValueSchema || {},
|
|
2018
|
+
).length;
|
|
2019
|
+
if (
|
|
2020
|
+
srcRetSize > SCHEMA_KEY_CAP ||
|
|
2021
|
+
Object.keys(depSchema.returnValueSchema).length > SCHEMA_KEY_CAP
|
|
2022
|
+
)
|
|
2023
|
+
continue;
|
|
2024
|
+
for (const path in dependentMergedDataStructure.returnValueSchema) {
|
|
2025
|
+
// Fast path: only call translatePath when the path starts with the
|
|
2026
|
+
// dependency name (e.g., "ArticleTable().functionCallReturnValue.x").
|
|
2027
|
+
// Most paths start with "returnValue" or "signature" and don't need translation.
|
|
2028
|
+
const translatedPath = path.startsWith(name)
|
|
2029
|
+
? translatePath(path, name)
|
|
2030
|
+
: path;
|
|
2031
|
+
if (!(translatedPath in depSchema.returnValueSchema)) {
|
|
2032
|
+
depSchema.returnValueSchema[translatedPath] =
|
|
2033
|
+
dependentMergedDataStructure.returnValueSchema[path];
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
// Copy over signature schema as well
|
|
2038
|
+
for (const path in dependentMergedDataStructure.signatureSchema) {
|
|
2039
|
+
const translatedPath = path.startsWith(name)
|
|
2040
|
+
? translatePath(path, name)
|
|
2041
|
+
: path;
|
|
2042
|
+
if (!(translatedPath in depSchema.signatureSchema)) {
|
|
2043
|
+
depSchema.signatureSchema[translatedPath] =
|
|
2044
|
+
dependentMergedDataStructure.signatureSchema[path];
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
1102
2048
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
2049
|
+
// Copy nested dependencySchemas for ALL entities (including mocked ones)
|
|
2050
|
+
// This represents what dependencies THIS entity uses, not its internal implementation
|
|
2051
|
+
if (dependentMergedDataStructure.dependencySchemas) {
|
|
2052
|
+
for (const depFilePath in dependentMergedDataStructure.dependencySchemas) {
|
|
2053
|
+
for (const depName in dependentMergedDataStructure
|
|
2054
|
+
.dependencySchemas[depFilePath]) {
|
|
2055
|
+
const nestedDepSchema =
|
|
2056
|
+
dependentMergedDataStructure.dependencySchemas[depFilePath][
|
|
2057
|
+
depName
|
|
2058
|
+
];
|
|
2059
|
+
const targetDepSchema = findOrCreateDependentSchemas({
|
|
2060
|
+
filePath: depFilePath,
|
|
2061
|
+
name: depName,
|
|
2062
|
+
});
|
|
2063
|
+
|
|
2064
|
+
// Merge in the nested dependency schemas
|
|
2065
|
+
for (const path in nestedDepSchema.returnValueSchema) {
|
|
2066
|
+
checkDeadline();
|
|
2067
|
+
if (!(path in targetDepSchema.returnValueSchema)) {
|
|
2068
|
+
const value = nestedDepSchema.returnValueSchema[path];
|
|
2069
|
+
targetDepSchema.returnValueSchema[path] = value;
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
for (const path in nestedDepSchema.signatureSchema) {
|
|
2074
|
+
checkDeadline();
|
|
2075
|
+
if (!(path in targetDepSchema.signatureSchema)) {
|
|
2076
|
+
targetDepSchema.signatureSchema[path] =
|
|
2077
|
+
nestedDepSchema.signatureSchema[path];
|
|
2078
|
+
}
|
|
1107
2079
|
}
|
|
1108
2080
|
}
|
|
1109
2081
|
}
|
|
1110
2082
|
}
|
|
1111
2083
|
}
|
|
1112
2084
|
}
|
|
1113
|
-
}
|
|
1114
2085
|
|
|
1115
|
-
|
|
2086
|
+
const totalElapsed = Date.now() - mergeStartTime;
|
|
2087
|
+
const retKeys = Object.keys(mergedDataStructure.returnValueSchema).length;
|
|
2088
|
+
|
|
2089
|
+
// Only log phase breakdown for slow merges (>2s)
|
|
2090
|
+
if (totalElapsed > 2000) {
|
|
2091
|
+
console.log(
|
|
2092
|
+
`CodeYam Log Level 2: ${rootScopeName} merge phases: gather=${gatherElapsed}ms mergeESP=${mergeEspElapsed - gatherElapsed}ms postfix=${postfixElapsed - mergeEspElapsed}ms clean=${cleanElapsed - postfixElapsed}ms depCopy=${totalElapsed - cleanElapsed}ms total=${totalElapsed}ms ret=${retKeys}`,
|
|
2093
|
+
);
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
return mergedDataStructure;
|
|
2097
|
+
} catch (error) {
|
|
2098
|
+
if (error instanceof DataStructureTimeoutError) {
|
|
2099
|
+
// Return partial results instead of propagating the timeout.
|
|
2100
|
+
// By this point, mergedDataStructure has valid data from completed phases
|
|
2101
|
+
// (gather + mergeESP complete in <1s, postfix/clean/depCopy may be partial).
|
|
2102
|
+
const retKeys = Object.keys(mergedDataStructure.returnValueSchema).length;
|
|
2103
|
+
console.log(
|
|
2104
|
+
`CodeYam Log Level 1: ${rootScopeName} merge timed out — returning partial results (${retKeys} ret keys, ${Math.round((Date.now() - mergeStartTime) / 1000)}s)`,
|
|
2105
|
+
);
|
|
2106
|
+
(mergedDataStructure as any).timedOut = true;
|
|
2107
|
+
return mergedDataStructure;
|
|
2108
|
+
}
|
|
2109
|
+
throw error;
|
|
2110
|
+
}
|
|
1116
2111
|
}
|