@codeyam/codeyam-cli 0.1.0-staging.dd216e0 → 0.1.0-staging.e090cb3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +16 -13
- package/analyzer-template/packages/ai/index.ts +21 -5
- package/analyzer-template/packages/ai/package.json +3 -3
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +226 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +205 -10
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1507 -117
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +324 -5
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2227 -350
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +7 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +296 -35
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +120 -76
- 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 +54 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +149 -11
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +396 -88
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +174 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +59 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1421 -92
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +614 -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/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/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 +17 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +110 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +532 -275
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +34 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +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 +620 -49
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +380 -45
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +876 -123
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +3 -3
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/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 +18 -5
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
- package/analyzer-template/packages/database/src/lib/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 +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
- package/analyzer-template/packages/database/src/lib/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 +7 -14
- 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 +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/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 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +13 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/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 +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/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 +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +5 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/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/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +57 -26
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1199 -167
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +18 -7
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +81 -9
- package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +51 -15
- package/analyzer-template/project/startScenarioCapture.ts +6 -0
- package/analyzer-template/project/writeMockDataTsx.ts +403 -61
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +395 -98
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +31 -23
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +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 +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +1060 -125
- 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 +65 -10
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +47 -15
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +7 -0
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +350 -50
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +303 -83
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +31 -21
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +9 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +3 -1
- 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 +30 -34
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +49 -257
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +264 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +31 -18
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/report.js +72 -24
- 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/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/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 +128 -82
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +29 -15
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +16 -2
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +76 -37
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +138 -18
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +25 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.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 +230 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +378 -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 +115 -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__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +6 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +83 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +37 -10
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -42
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/versionInfo.js +25 -19
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +88 -23
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +26 -5
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +40 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-B86KKU7e.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-CMjhlvyu.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BqY8gDAW.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-ClaLpuOo.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-BDhPilK7.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-DXN1aCbt.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-BmEO4Lqa.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CI1VaB3F.js → LogViewer-Bm3PmcCz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-CgMEzchJ.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DQddU4F4.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CBui0id_.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-Dt7eySG0.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-B3TDXxnk.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BtBFH820.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-CN61MOMa.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.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.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-ITTv_xL3.js → chevron-down-TJp6ofnp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-JE9ZIoBl.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-mMM0RzI0.js → circle-check-CXhHQYrI.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-en9_3LGg.js → createLucideIcon-Ca9fAY46.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-C0epRiVn.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-DBgKdrTR.js → entity._sha._-BVnB8a9L.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DGgZjdFg.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-Sf59Z2Pa.js → entity._sha_.edit._scenarioId-38yPijoD.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-BvGka1gZ.js → entry.client-BSHEfydn.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-_IuKNgFH.js → fileTableUtils-DCPhhSMo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-0N0YJQv7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{git-8zM4ebXo.js → git-DXnyr8uP.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/globals-CKT08Djd.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-DFbRIdR_.js → index-CcsFv748.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-CkpJhcNC.js → index-ChN9-fAY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-BLJ7HxOC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-DEtRABV3.js → loader-circle-CTqLEAGU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-b171b9d3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CCQd4aZA.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-CHhiHoo_.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-Clp3R4kH.js → search-B8VUL8nl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BejnUJ6R.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CPoAg7Zo.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CUVskfkL.js → triangle-alert-BZz2NjYa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DNwUduNu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-CHT-Bzx5.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CpZgwliL.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-BCR_pi3-.js → useToast-Bv9JFvUO.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-8Fv-lH1-.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Akn3iYFP.js +257 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam-debug.md} +48 -4
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/codeyam-memory.md +392 -0
- package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam-setup.md} +151 -4
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam-sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam-test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam-verify.md} +1 -1
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
- package/codeyam-cli/templates/rules-instructions.md +132 -0
- package/package.json +14 -11
- 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 +154 -9
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +1137 -96
- 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 +178 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1741 -208
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +7 -2
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +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 +77 -55
- 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 +52 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +133 -11
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +334 -79
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +126 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +47 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1128 -85
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +414 -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/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/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 +16 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +83 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +94 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +268 -52
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +24 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +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 +480 -46
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +268 -51
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +738 -111
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/database/src/lib/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 +13 -3
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/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 +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/database/src/lib/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 +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -76
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js +0 -7
- package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-DpUOH11S.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Cxs_KUEt.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D_gPUolj.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-MbTu_hOR.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-Diqfd5nO.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/_index-D0tNX0Y7.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CV8R8fpo.js +0 -32
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-Tv-88Jsz.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Cw7TE00E.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DUOKD0lj.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-DMW0hD4L.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-D3y4cv7l.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-18ff0544.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-BuQ6JiJU.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/settings-DzIyX7wI.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-BKNqbrwU.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-By4FnEmE.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CzKXayO4.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CHRMAMo8.js +0 -166
- package/codeyam-cli/templates/debug-codeyam.md +0 -576
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/{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
|
@@ -79,15 +79,29 @@
|
|
|
79
79
|
* - `helpers/README.md` - Overview of the helper module architecture
|
|
80
80
|
*/
|
|
81
81
|
import fillInSchemaGapsAndUnknowns from "./helpers/fillInSchemaGapsAndUnknowns.js";
|
|
82
|
+
import { clearCleanKnownObjectFunctionsCache } from "./helpers/cleanKnownObjectFunctions.js";
|
|
83
|
+
import { clearCleanNonObjectFunctionsCache } from "./helpers/cleanNonObjectFunctions.js";
|
|
84
|
+
/**
|
|
85
|
+
* Patterns that indicate recursive type structures in schema paths.
|
|
86
|
+
* Used by hasExcessivePatternRepetition() to detect exponential path blowup.
|
|
87
|
+
*/
|
|
88
|
+
const RECURSIVE_PATH_PATTERNS = [
|
|
89
|
+
/\.attributes\.properties\[\]/g, // TypeScript AST JSX nodes
|
|
90
|
+
/\.children\[\]/g, // Tree structures
|
|
91
|
+
/\.elements\[\]/g, // Array-like structures
|
|
92
|
+
/\.members\[\]/g, // Class/interface members
|
|
93
|
+
/\.properties\[\]/g, // Object properties
|
|
94
|
+
/\.items\[\]/g, // Generic items arrays
|
|
95
|
+
];
|
|
82
96
|
import ensureSchemaConsistency from "./helpers/ensureSchemaConsistency.js";
|
|
83
97
|
import cleanPath from "./helpers/cleanPath.js";
|
|
84
98
|
import { PathManager } from "./helpers/PathManager.js";
|
|
85
|
-
import { uniqueId,
|
|
99
|
+
import { uniqueId, uniqueScopeAndPaths, uniqueScopeVariables, } from "./helpers/uniqueIdUtils.js";
|
|
86
100
|
import selectBestValue from "./helpers/selectBestValue.js";
|
|
87
101
|
import { VisitedTracker } from "./helpers/VisitedTracker.js";
|
|
88
102
|
import { DebugTracer } from "./helpers/DebugTracer.js";
|
|
89
103
|
import { BatchSchemaProcessor } from "./helpers/BatchSchemaProcessor.js";
|
|
90
|
-
import {
|
|
104
|
+
import { ROOT_SCOPE_NAME, ScopeTreeManager, } from "./helpers/ScopeTreeManager.js";
|
|
91
105
|
import cleanScopeNodeName from "./helpers/cleanScopeNodeName.js";
|
|
92
106
|
import getFunctionCallRoot from "./helpers/getFunctionCallRoot.js";
|
|
93
107
|
import cleanPathOfNonTransformingFunctions from "./helpers/cleanPathOfNonTransformingFunctions.js";
|
|
@@ -108,6 +122,17 @@ export function resetScopeDataStructureMetrics() {
|
|
|
108
122
|
followEquivalenciesEarlyExitPhase1Count = 0;
|
|
109
123
|
followEquivalenciesWithWorkCount = 0;
|
|
110
124
|
addEquivalencyCallCount = 0;
|
|
125
|
+
// Clear module-level caches to prevent unbounded memory growth across entities
|
|
126
|
+
const knownObjectCache = clearCleanKnownObjectFunctionsCache();
|
|
127
|
+
const nonObjectCache = clearCleanNonObjectFunctionsCache();
|
|
128
|
+
if (knownObjectCache.count > 0 || nonObjectCache.count > 0) {
|
|
129
|
+
const totalBytes = knownObjectCache.estimatedBytes + nonObjectCache.estimatedBytes;
|
|
130
|
+
console.log('CodeYam: Cleared analysis caches', {
|
|
131
|
+
knownObjectCache: `${knownObjectCache.count} entries, ${(knownObjectCache.estimatedBytes / 1024).toFixed(1)}KB`,
|
|
132
|
+
nonObjectCache: `${nonObjectCache.count} entries, ${(nonObjectCache.estimatedBytes / 1024).toFixed(1)}KB`,
|
|
133
|
+
totalKB: `${(totalBytes / 1024).toFixed(1)}KB`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
111
136
|
}
|
|
112
137
|
// Performance: Pre-computed Sets for equivalency reason filtering (O(1) vs O(n))
|
|
113
138
|
const ALLOWED_EQUIVALENCY_REASONS = new Set([
|
|
@@ -156,6 +181,7 @@ const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
|
156
181
|
'transformed non-object function equivalency - implicit parent equivalency - rerouted via useCallback',
|
|
157
182
|
'transformed non-object function equivalency - Array.from() equivalency',
|
|
158
183
|
'Spread operator equivalency key update: Explicit array deconstruction equivalency value',
|
|
184
|
+
// 'transformed non-object function equivalency - Explicit array deconstruction equivalency value',
|
|
159
185
|
]);
|
|
160
186
|
export class ScopeDataStructure {
|
|
161
187
|
// Getter for backward compatibility - returns the tree structure
|
|
@@ -176,6 +202,26 @@ export class ScopeDataStructure {
|
|
|
176
202
|
* Maps local variable path to array of usages.
|
|
177
203
|
*/
|
|
178
204
|
this.rawConditionalUsages = {};
|
|
205
|
+
/**
|
|
206
|
+
* Conditional effects collected during AST analysis.
|
|
207
|
+
* Tracks what setter calls happen inside conditionals (if, switch, ternary).
|
|
208
|
+
*/
|
|
209
|
+
this.rawConditionalEffects = [];
|
|
210
|
+
/**
|
|
211
|
+
* Compound conditionals collected during AST analysis.
|
|
212
|
+
* Groups conditions that must all be true together (e.g., a && b && c).
|
|
213
|
+
*/
|
|
214
|
+
this.rawCompoundConditionals = [];
|
|
215
|
+
/**
|
|
216
|
+
* Gating conditions for child component boundaries.
|
|
217
|
+
* Maps child component name to the conditions that must be true for it to render.
|
|
218
|
+
*/
|
|
219
|
+
this.rawChildBoundaryGatingConditions = {};
|
|
220
|
+
/**
|
|
221
|
+
* JSX rendering usages collected during AST analysis.
|
|
222
|
+
* Tracks arrays rendered via .map() and strings interpolated in JSX.
|
|
223
|
+
*/
|
|
224
|
+
this.rawJsxRenderingUsages = [];
|
|
179
225
|
this.lastAddToSchemaId = 0;
|
|
180
226
|
this.lastEquivalencyId = 0;
|
|
181
227
|
this.lastEquivalencyDatabaseId = 0;
|
|
@@ -430,6 +476,10 @@ export class ScopeDataStructure {
|
|
|
430
476
|
}
|
|
431
477
|
return;
|
|
432
478
|
}
|
|
479
|
+
// PERF: Early exit for paths with repeated function-call signature patterns
|
|
480
|
+
if (this.hasExcessivePatternRepetition(path)) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
433
483
|
// Update chain metadata for database tracking
|
|
434
484
|
if (equivalencyValueChain.length > 0) {
|
|
435
485
|
equivalencyValueChain[equivalencyValueChain.length - 1].addToSchemaId =
|
|
@@ -599,7 +649,6 @@ export class ScopeDataStructure {
|
|
|
599
649
|
}
|
|
600
650
|
addEquivalency(path, equivalentPath, equivalentScopeName, scopeNode, equivalencyReason, equivalencyValueChain, traceId) {
|
|
601
651
|
var _a;
|
|
602
|
-
// DEBUG: Detect infinite loops
|
|
603
652
|
addEquivalencyCallCount++;
|
|
604
653
|
if (addEquivalencyCallCount > 50000) {
|
|
605
654
|
console.error('INFINITE LOOP DETECTED in addEquivalency', {
|
|
@@ -794,6 +843,19 @@ export class ScopeDataStructure {
|
|
|
794
843
|
const searchKey = getFunctionCallRoot(functionCallInfo.callSignature);
|
|
795
844
|
const existingFunctionCall = this.getExternalFunctionCallsIndex().get(searchKey);
|
|
796
845
|
if (existingFunctionCall) {
|
|
846
|
+
// Preserve per-call schemas BEFORE merging to enable per-variable mock data.
|
|
847
|
+
// This is critical for hooks like useFetcher<UserData>() vs useFetcher<ReportData>()
|
|
848
|
+
// where each call returns different typed data.
|
|
849
|
+
if (!existingFunctionCall.perCallSignatureSchemas) {
|
|
850
|
+
// First merge - save the existing call's schema
|
|
851
|
+
existingFunctionCall.perCallSignatureSchemas = {
|
|
852
|
+
[existingFunctionCall.callSignature]: {
|
|
853
|
+
...existingFunctionCall.schema,
|
|
854
|
+
},
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
// Save the new call's schema before it gets merged
|
|
858
|
+
existingFunctionCall.perCallSignatureSchemas[functionCallInfo.callSignature] = { ...functionCallInfo.schema };
|
|
797
859
|
// Merge schemas using selectBestValue to preserve specific types like 'null'
|
|
798
860
|
// over generic types like 'unknown'. This ensures ref variables detected
|
|
799
861
|
// earlier (marked as 'null') aren't overwritten by later 'unknown' values.
|
|
@@ -900,9 +962,26 @@ export class ScopeDataStructure {
|
|
|
900
962
|
const remainingKey = remainingSchemaPathParts.join('|');
|
|
901
963
|
const equivalentSchemaPath = equivalentSchemaPathMap.get(remainingKey);
|
|
902
964
|
if (equivalentSchemaPath) {
|
|
965
|
+
// Skip propagation when there's a structural mismatch:
|
|
966
|
+
// - schemaPath ends with [] (array element, represents an object)
|
|
967
|
+
// - equivalentSchemaPath doesn't end with [] (non-array prop, usually a scalar)
|
|
968
|
+
// This prevents incorrectly typing array elements as strings when they're
|
|
969
|
+
// equivalent to scalar props like JSX keys (e.g., workouts[] ↔ Card().key)
|
|
970
|
+
const schemaPathEndsWithArray = schemaPath.endsWith('[]');
|
|
971
|
+
const equivalentEndsWithArray = equivalentSchemaPath.endsWith('[]');
|
|
972
|
+
if (schemaPathEndsWithArray !== equivalentEndsWithArray) {
|
|
973
|
+
// Don't propagate between array element paths and non-array paths
|
|
974
|
+
continue;
|
|
975
|
+
}
|
|
903
976
|
const value1 = scopeNode.schema[schemaPath];
|
|
904
977
|
const value2 = equivalentScopeNode.schema[equivalentSchemaPath];
|
|
905
978
|
const bestValue = selectBestValue(value1, value2);
|
|
979
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
980
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
981
|
+
if (this.hasExcessivePatternRepetition(schemaPath) ||
|
|
982
|
+
this.hasExcessivePatternRepetition(equivalentSchemaPath)) {
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
906
985
|
scopeNode.schema[schemaPath] = bestValue;
|
|
907
986
|
equivalentScopeNode.schema[equivalentSchemaPath] = bestValue;
|
|
908
987
|
}
|
|
@@ -914,6 +993,10 @@ export class ScopeDataStructure {
|
|
|
914
993
|
equivalentPath,
|
|
915
994
|
...remainingSchemaPathParts,
|
|
916
995
|
]);
|
|
996
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
997
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
998
|
+
continue;
|
|
999
|
+
}
|
|
917
1000
|
equivalentScopeNode.schema[newEquivalentPath] =
|
|
918
1001
|
scopeNode.schema[schemaPath];
|
|
919
1002
|
}
|
|
@@ -970,26 +1053,103 @@ export class ScopeDataStructure {
|
|
|
970
1053
|
isValidPath(path) {
|
|
971
1054
|
return this.pathManager.isValidPath(path);
|
|
972
1055
|
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Detects if a path contains excessive repetition of the same pattern.
|
|
1058
|
+
*
|
|
1059
|
+
* This prevents exponential blowup when analyzing recursive type structures.
|
|
1060
|
+
* For example, TypeScript AST nodes have `.attributes.properties[]` where each
|
|
1061
|
+
* property is also a node with `.attributes.properties[]`. Without this check,
|
|
1062
|
+
* paths like `signature[0].attributes.properties[].attributes.properties[].attributes.properties[]...`
|
|
1063
|
+
* would be generated exponentially.
|
|
1064
|
+
*
|
|
1065
|
+
* Two detection strategies:
|
|
1066
|
+
* 1. Known patterns: Check RECURSIVE_PATH_PATTERNS for common recursive structures
|
|
1067
|
+
* 2. Generic detection: For longer paths, detect any 2-3 part segment that repeats
|
|
1068
|
+
*
|
|
1069
|
+
* @param path - The schema path to check
|
|
1070
|
+
* @param maxRepetitions - Maximum allowed repetitions of any pattern (default: 2)
|
|
1071
|
+
* @returns true if the path has excessive repetition
|
|
1072
|
+
*/
|
|
1073
|
+
hasExcessivePatternRepetition(path, maxRepetitions = 2) {
|
|
1074
|
+
// Check known recursive patterns
|
|
1075
|
+
for (const pattern of RECURSIVE_PATH_PATTERNS) {
|
|
1076
|
+
const matches = path.match(pattern);
|
|
1077
|
+
if (matches && matches.length > maxRepetitions) {
|
|
1078
|
+
return true;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
// Check for repeated function calls that indicate recursive type expansion.
|
|
1082
|
+
// E.g., localeCompare(b[])...localeCompare(b[]) means string.localeCompare
|
|
1083
|
+
// returns a type that again has localeCompare, causing infinite expansion.
|
|
1084
|
+
// We extract all function call patterns like "funcName(args)" and check if
|
|
1085
|
+
// the same normalized call appears more than once.
|
|
1086
|
+
const funcCallPattern = /(?:^|\.)[^.([]+\([^)]*\)/g;
|
|
1087
|
+
const funcCallMatches = path.match(funcCallPattern);
|
|
1088
|
+
if (funcCallMatches && funcCallMatches.length > 1) {
|
|
1089
|
+
const seen = new Set();
|
|
1090
|
+
for (const match of funcCallMatches) {
|
|
1091
|
+
// Strip leading dot and normalize array indices
|
|
1092
|
+
const normalized = match.replace(/^\./, '').replace(/\[\d+\]/g, '[]');
|
|
1093
|
+
if (seen.has(normalized))
|
|
1094
|
+
return true;
|
|
1095
|
+
seen.add(normalized);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
// For longer paths, detect any repeated multi-part segments we haven't explicitly listed
|
|
1099
|
+
const pathParts = this.splitPath(path);
|
|
1100
|
+
if (pathParts.length <= 6) {
|
|
1101
|
+
return false;
|
|
1102
|
+
}
|
|
1103
|
+
// Check for repeated sequences of 2-3 consecutive parts
|
|
1104
|
+
for (let segmentLength = 2; segmentLength <= 3; segmentLength++) {
|
|
1105
|
+
const seen = new Map();
|
|
1106
|
+
for (let i = 0; i <= pathParts.length - segmentLength; i++) {
|
|
1107
|
+
const segment = pathParts.slice(i, i + segmentLength).join('.');
|
|
1108
|
+
const normalizedSegment = segment.replace(/\[\d+\]/g, '[]');
|
|
1109
|
+
const count = (seen.get(normalizedSegment) || 0) + 1;
|
|
1110
|
+
seen.set(normalizedSegment, count);
|
|
1111
|
+
if (count > maxRepetitions) {
|
|
1112
|
+
return true;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
973
1118
|
addToTree(pathParts) {
|
|
974
1119
|
this.scopeTreeManager.addPath(pathParts);
|
|
975
1120
|
}
|
|
976
1121
|
setInstantiatedVariables(scopeNode) {
|
|
977
1122
|
let instantiatedVariables = scopeNode.analysis?.instantiatedVariables ?? [];
|
|
978
|
-
for (const [path,
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1123
|
+
for (const [path, rawEquivalentPath] of Object.entries(scopeNode.analysis.isolatedEquivalentVariables ?? {})) {
|
|
1124
|
+
// Normalize to array for consistent handling (supports both string and string[])
|
|
1125
|
+
const equivalentPaths = Array.isArray(rawEquivalentPath)
|
|
1126
|
+
? rawEquivalentPath
|
|
1127
|
+
: rawEquivalentPath
|
|
1128
|
+
? [rawEquivalentPath]
|
|
1129
|
+
: [];
|
|
1130
|
+
for (const equivalentPath of equivalentPaths) {
|
|
1131
|
+
if (typeof equivalentPath !== 'string') {
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
if (equivalentPath.startsWith('signature[')) {
|
|
1135
|
+
const equivalentPathParts = this.splitPath(equivalentPath);
|
|
1136
|
+
instantiatedVariables.push(equivalentPathParts[0]);
|
|
1137
|
+
instantiatedVariables.push(path);
|
|
1138
|
+
}
|
|
986
1139
|
}
|
|
987
1140
|
const duplicateInstantiated = instantiatedVariables.find((v) => path.split('::cyDuplicateKey')[0] === v.split('::cyDuplicateKey')[0]);
|
|
988
1141
|
if (duplicateInstantiated) {
|
|
989
1142
|
instantiatedVariables.push(path);
|
|
990
1143
|
}
|
|
991
1144
|
}
|
|
992
|
-
|
|
1145
|
+
const instantiatedSeen = new Set();
|
|
1146
|
+
instantiatedVariables = instantiatedVariables.filter((varName) => {
|
|
1147
|
+
if (instantiatedSeen.has(varName)) {
|
|
1148
|
+
return false;
|
|
1149
|
+
}
|
|
1150
|
+
instantiatedSeen.add(varName);
|
|
1151
|
+
return true;
|
|
1152
|
+
});
|
|
993
1153
|
scopeNode.instantiatedVariables = instantiatedVariables;
|
|
994
1154
|
if (!scopeNode.tree || scopeNode.tree.length === 0) {
|
|
995
1155
|
return;
|
|
@@ -1001,125 +1161,156 @@ export class ScopeDataStructure {
|
|
|
1001
1161
|
const parentInstantiatedVariables = [
|
|
1002
1162
|
...(parentScopeNode.parentInstantiatedVariables ?? []),
|
|
1003
1163
|
...parentScopeNode.instantiatedVariables.filter((v) => !v.startsWith('signature[') && !v.startsWith('returnValue')),
|
|
1004
|
-
].filter((varName
|
|
1005
|
-
|
|
1006
|
-
|
|
1164
|
+
].filter((varName) => !instantiatedSeen.has(varName));
|
|
1165
|
+
const parentInstantiatedSeen = new Set();
|
|
1166
|
+
const dedupedParentInstantiatedVariables = parentInstantiatedVariables.filter((varName) => {
|
|
1167
|
+
if (parentInstantiatedSeen.has(varName)) {
|
|
1168
|
+
return false;
|
|
1169
|
+
}
|
|
1170
|
+
parentInstantiatedSeen.add(varName);
|
|
1171
|
+
return true;
|
|
1172
|
+
});
|
|
1173
|
+
scopeNode.parentInstantiatedVariables = dedupedParentInstantiatedVariables;
|
|
1007
1174
|
}
|
|
1008
1175
|
trackFunctionCalls(scopeNode) {
|
|
1009
1176
|
this.captureFunctionCalls(scopeNode);
|
|
1010
1177
|
this.checkExternalFunctionCalls();
|
|
1011
1178
|
}
|
|
1012
1179
|
determineEquivalenciesAndBuildSchema(scopeNode) {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
if (Object.keys(isolatedEquivalentVariables || {}).some((k) => k.includes('Fetcher') || k.includes('fetcher'))) {
|
|
1016
|
-
console.log('CodeYam DEBUG determineEquivalenciesAndBuildSchema:', JSON.stringify({
|
|
1017
|
-
scopeNodeName: scopeNode.name,
|
|
1018
|
-
fetcherEquivalencies: Object.entries(isolatedEquivalentVariables || {})
|
|
1019
|
-
.filter(([k, v]) => k.includes('Fetcher') ||
|
|
1020
|
-
k.includes('fetcher') ||
|
|
1021
|
-
String(v).includes('Fetcher') ||
|
|
1022
|
-
String(v).includes('fetcher'))
|
|
1023
|
-
.reduce((acc, [k, v]) => {
|
|
1024
|
-
acc[k] = v;
|
|
1025
|
-
return acc;
|
|
1026
|
-
}, {}),
|
|
1027
|
-
}, null, 2));
|
|
1180
|
+
if (!scopeNode.analysis) {
|
|
1181
|
+
return;
|
|
1028
1182
|
}
|
|
1183
|
+
const { isolatedStructure, isolatedEquivalentVariables } = scopeNode.analysis;
|
|
1184
|
+
// Flatten isolatedEquivalentVariables values for allPaths (handles both string and string[])
|
|
1185
|
+
const flattenedEquivValues = Object.values(isolatedEquivalentVariables || {}).flatMap((v) => (Array.isArray(v) ? v : [v]));
|
|
1029
1186
|
const allPaths = Array.from(new Set([
|
|
1030
1187
|
...Object.keys(isolatedStructure || {}),
|
|
1031
1188
|
...Object.keys(isolatedEquivalentVariables || {}),
|
|
1032
|
-
...
|
|
1189
|
+
...flattenedEquivValues,
|
|
1033
1190
|
]));
|
|
1034
1191
|
for (let path in isolatedEquivalentVariables) {
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1192
|
+
const rawEquivalentValue = isolatedEquivalentVariables?.[path];
|
|
1193
|
+
// Normalize to array for consistent handling
|
|
1194
|
+
const equivalentValues = Array.isArray(rawEquivalentValue)
|
|
1195
|
+
? rawEquivalentValue
|
|
1196
|
+
: [rawEquivalentValue];
|
|
1197
|
+
for (let equivalentValue of equivalentValues) {
|
|
1198
|
+
if (equivalentValue && this.isValidPath(equivalentValue)) {
|
|
1199
|
+
// IMPORTANT: DO NOT strip ::cyDuplicateKey:: markers from equivalencies.
|
|
1200
|
+
// These markers are critical for distinguishing variable reassignments.
|
|
1201
|
+
// For example, with:
|
|
1202
|
+
// let fetcher = useFetcher<ConfigData>();
|
|
1203
|
+
// const configData = fetcher.data?.data;
|
|
1204
|
+
// fetcher = useFetcher<SettingsData>();
|
|
1205
|
+
// const settingsData = fetcher.data?.data;
|
|
1206
|
+
//
|
|
1207
|
+
// mergeStatements creates:
|
|
1208
|
+
// fetcher → useFetcher<ConfigData>()...
|
|
1209
|
+
// fetcher::cyDuplicateKey1:: → useFetcher<SettingsData>()...
|
|
1210
|
+
// configData → fetcher.data.data
|
|
1211
|
+
// settingsData → fetcher::cyDuplicateKey1::.data.data
|
|
1212
|
+
//
|
|
1213
|
+
// If we strip ::cyDuplicateKey::, settingsData would incorrectly trace
|
|
1214
|
+
// to useFetcher<ConfigData>() instead of useFetcher<SettingsData>().
|
|
1215
|
+
path = cleanPath(path, allPaths);
|
|
1216
|
+
equivalentValue = cleanPath(equivalentValue, allPaths);
|
|
1217
|
+
this.addEquivalency(path, equivalentValue, scopeNode.name, scopeNode, 'original equivalency');
|
|
1218
|
+
// Propagate equivalencies involving parent-scope variables to those parent scopes.
|
|
1219
|
+
// This handles patterns like: collected.push({...entity}) where 'collected' is defined
|
|
1220
|
+
// in a parent scope. The equivalency collected[] -> push().signature[0] needs to be
|
|
1221
|
+
// visible when tracing from the parent scope.
|
|
1222
|
+
const rootVariable = this.extractRootVariable(path);
|
|
1223
|
+
const equivalentRootVariable = this.extractRootVariable(equivalentValue);
|
|
1224
|
+
// Skip propagation for self-referential reassignment patterns like:
|
|
1225
|
+
// x = x.method().functionCallReturnValue
|
|
1226
|
+
// where the path IS the variable itself (not a sub-path like x[] or x.prop).
|
|
1227
|
+
// These create circular references since both sides reference the same variable.
|
|
1228
|
+
//
|
|
1229
|
+
// But DO propagate for patterns like collected[] -> collected.push(...).signature[0]
|
|
1230
|
+
// where the path has additional segments beyond the root variable.
|
|
1231
|
+
const pathIsJustRootVariable = path === rootVariable;
|
|
1232
|
+
const isSelfReferentialReassignment = pathIsJustRootVariable && rootVariable === equivalentRootVariable;
|
|
1233
|
+
if (rootVariable &&
|
|
1234
|
+
!isSelfReferentialReassignment &&
|
|
1235
|
+
scopeNode.parentInstantiatedVariables?.includes(rootVariable)) {
|
|
1236
|
+
// Find the parent scope where this variable is defined
|
|
1237
|
+
for (const parentScopeName of scopeNode.tree || []) {
|
|
1238
|
+
const parentScope = this.scopeNodes[parentScopeName];
|
|
1239
|
+
if (parentScope?.instantiatedVariables?.includes(rootVariable)) {
|
|
1240
|
+
// Add the equivalency to the parent scope as well
|
|
1241
|
+
this.addEquivalency(path, equivalentValue, scopeNode.name, // The equivalent path's scope remains the child scope
|
|
1242
|
+
parentScope, // But store it in the parent scope's equivalencies
|
|
1243
|
+
'propagated parent-variable equivalency');
|
|
1244
|
+
break;
|
|
1245
|
+
}
|
|
1067
1246
|
}
|
|
1068
1247
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1248
|
+
// Propagate sub-property equivalencies when the equivalentValue is a simple variable
|
|
1249
|
+
// that has sub-properties defined in the isolatedEquivalentVariables.
|
|
1250
|
+
// This handles cases like: dataItem={{ structure: completeDataStructure }}
|
|
1251
|
+
// where completeDataStructure has sub-properties like completeDataStructure['Function Arguments']
|
|
1252
|
+
// We need to propagate these to create: dataItem.structure['Function Arguments'] equivalencies
|
|
1253
|
+
const isSimpleVariable = !equivalentValue.startsWith('signature[') &&
|
|
1254
|
+
!equivalentValue.includes('functionCallReturnValue') &&
|
|
1255
|
+
!equivalentValue.includes('.') &&
|
|
1256
|
+
!equivalentValue.includes('[');
|
|
1257
|
+
if (isSimpleVariable) {
|
|
1258
|
+
// Look in current scope and all parent scopes for sub-properties
|
|
1259
|
+
const scopesToCheck = [scopeNode.name, ...scopeNode.tree];
|
|
1260
|
+
for (const scopeName of scopesToCheck) {
|
|
1261
|
+
const checkScope = this.scopeNodes[scopeName];
|
|
1262
|
+
if (!checkScope?.analysis?.isolatedEquivalentVariables)
|
|
1263
|
+
continue;
|
|
1264
|
+
for (const [subPath, rawSubValue] of Object.entries(checkScope.analysis.isolatedEquivalentVariables)) {
|
|
1265
|
+
// Normalize to array for consistent handling
|
|
1266
|
+
const subValues = Array.isArray(rawSubValue)
|
|
1267
|
+
? rawSubValue
|
|
1268
|
+
: rawSubValue
|
|
1269
|
+
? [rawSubValue]
|
|
1270
|
+
: [];
|
|
1271
|
+
// Check if this is a sub-property of the equivalentValue variable
|
|
1272
|
+
// e.g., completeDataStructure['Function Arguments'] or completeDataStructure.foo
|
|
1273
|
+
const matchesDot = subPath.startsWith(equivalentValue + '.');
|
|
1274
|
+
const matchesBracket = subPath.startsWith(equivalentValue + '[');
|
|
1275
|
+
if (matchesDot || matchesBracket) {
|
|
1276
|
+
const subPropertyPath = subPath.substring(equivalentValue.length);
|
|
1277
|
+
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
1278
|
+
for (const subValue of subValues) {
|
|
1279
|
+
if (typeof subValue !== 'string')
|
|
1280
|
+
continue;
|
|
1281
|
+
const newEquivalentValue = cleanPath(subValue.replace(/::cyDuplicateKey\d+::/g, ''), allPaths);
|
|
1282
|
+
if (newEquivalentValue &&
|
|
1283
|
+
this.isValidPath(newEquivalentValue)) {
|
|
1284
|
+
this.addEquivalency(newPath, newEquivalentValue, checkScope.name, // Use the scope where the sub-property was found
|
|
1285
|
+
scopeNode, 'propagated sub-property equivalency');
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
// Also check if equivalentValue itself maps to a functionCallReturnValue
|
|
1290
|
+
// e.g., result = useMemo(...).functionCallReturnValue
|
|
1291
|
+
for (const subValue of subValues) {
|
|
1292
|
+
if (subPath === equivalentValue &&
|
|
1293
|
+
typeof subValue === 'string' &&
|
|
1294
|
+
subValue.endsWith('.functionCallReturnValue')) {
|
|
1295
|
+
this.propagateFunctionCallReturnSubProperties(path, subValue, scopeNode, allPaths);
|
|
1296
|
+
}
|
|
1099
1297
|
}
|
|
1100
|
-
}
|
|
1101
|
-
// Also check if equivalentValue itself maps to a functionCallReturnValue
|
|
1102
|
-
// e.g., result = useMemo(...).functionCallReturnValue
|
|
1103
|
-
if (subPath === equivalentValue &&
|
|
1104
|
-
typeof subValue === 'string' &&
|
|
1105
|
-
subValue.endsWith('.functionCallReturnValue')) {
|
|
1106
|
-
this.propagateFunctionCallReturnSubProperties(path, subValue, scopeNode, allPaths);
|
|
1107
1298
|
}
|
|
1108
1299
|
}
|
|
1109
1300
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1301
|
+
// Handle function call return values by propagating returnValue.* sub-properties
|
|
1302
|
+
// from the callback scope to the usage path
|
|
1303
|
+
if (equivalentValue.endsWith('.functionCallReturnValue')) {
|
|
1304
|
+
this.propagateFunctionCallReturnSubProperties(path, equivalentValue, scopeNode, allPaths);
|
|
1305
|
+
// Track which variable receives the return value of each function call
|
|
1306
|
+
// This enables generating separate mock data for each call site
|
|
1307
|
+
this.trackReceivingVariable(path, equivalentValue);
|
|
1308
|
+
}
|
|
1309
|
+
// Also track variables that receive destructured properties from function call return values
|
|
1310
|
+
// e.g., "userData" -> "db.query('users').functionCallReturnValue.data"
|
|
1311
|
+
if (equivalentValue.includes('.functionCallReturnValue.')) {
|
|
1312
|
+
this.trackReceivingVariable(path, equivalentValue);
|
|
1313
|
+
}
|
|
1123
1314
|
}
|
|
1124
1315
|
}
|
|
1125
1316
|
}
|
|
@@ -1127,7 +1318,7 @@ export class ScopeDataStructure {
|
|
|
1127
1318
|
// This eliminates deep call stacks and improves deduplication
|
|
1128
1319
|
this.batchProcessor = new BatchSchemaProcessor();
|
|
1129
1320
|
this.batchQueuedSet = new Set();
|
|
1130
|
-
for (const key of
|
|
1321
|
+
for (const key of allPaths) {
|
|
1131
1322
|
let value = isolatedStructure[key] ?? 'unknown';
|
|
1132
1323
|
if (['null', 'undefined'].includes(value)) {
|
|
1133
1324
|
value = 'unknown';
|
|
@@ -1161,7 +1352,14 @@ export class ScopeDataStructure {
|
|
|
1161
1352
|
processBatchQueue() {
|
|
1162
1353
|
if (!this.batchProcessor)
|
|
1163
1354
|
return;
|
|
1355
|
+
let iterations = 0;
|
|
1164
1356
|
while (this.batchProcessor.hasWork()) {
|
|
1357
|
+
iterations++;
|
|
1358
|
+
// Safety: detect potential infinite loops
|
|
1359
|
+
if (iterations > 100000) {
|
|
1360
|
+
console.error(`[ScopeDataStructure] processBatchQueue exceeded 100k iterations, possible infinite loop!`);
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1165
1363
|
const item = this.batchProcessor.getNextWork();
|
|
1166
1364
|
if (!item)
|
|
1167
1365
|
break;
|
|
@@ -1208,18 +1406,6 @@ export class ScopeDataStructure {
|
|
|
1208
1406
|
// Find the FunctionCallInfo that matches this call signature
|
|
1209
1407
|
const searchKey = getFunctionCallRoot(callSignature);
|
|
1210
1408
|
const functionCallInfo = this.getExternalFunctionCallsIndex().get(searchKey);
|
|
1211
|
-
// DEBUG: Track useFetcher calls
|
|
1212
|
-
if (searchKey === 'useFetcher' || callSignature.includes('useFetcher')) {
|
|
1213
|
-
console.log('CodeYam DEBUG trackReceivingVariable:', JSON.stringify({
|
|
1214
|
-
receivingVariable,
|
|
1215
|
-
equivalentValue,
|
|
1216
|
-
callSignature,
|
|
1217
|
-
searchKey,
|
|
1218
|
-
foundFunctionCallInfo: !!functionCallInfo,
|
|
1219
|
-
existingRecvVars: functionCallInfo?.receivingVariableNames,
|
|
1220
|
-
existingCallSigToVar: functionCallInfo?.callSignatureToVariable,
|
|
1221
|
-
}, null, 2));
|
|
1222
|
-
}
|
|
1223
1409
|
if (!functionCallInfo) {
|
|
1224
1410
|
return;
|
|
1225
1411
|
}
|
|
@@ -1268,8 +1454,15 @@ export class ScopeDataStructure {
|
|
|
1268
1454
|
const checkScope = this.scopeNodes[scopeName];
|
|
1269
1455
|
if (!checkScope?.analysis?.isolatedEquivalentVariables)
|
|
1270
1456
|
continue;
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1457
|
+
const rawFunctionRef = checkScope.analysis.isolatedEquivalentVariables[functionName];
|
|
1458
|
+
// Normalize to array and find first string ending with 'F'
|
|
1459
|
+
const functionRefs = Array.isArray(rawFunctionRef)
|
|
1460
|
+
? rawFunctionRef
|
|
1461
|
+
: rawFunctionRef
|
|
1462
|
+
? [rawFunctionRef]
|
|
1463
|
+
: [];
|
|
1464
|
+
const functionRef = functionRefs.find((r) => typeof r === 'string' && r.endsWith('F'));
|
|
1465
|
+
if (typeof functionRef === 'string') {
|
|
1273
1466
|
callbackScopeName = functionRef.slice(0, -1);
|
|
1274
1467
|
break;
|
|
1275
1468
|
}
|
|
@@ -1292,22 +1485,32 @@ export class ScopeDataStructure {
|
|
|
1292
1485
|
if (!callbackScope.analysis?.isolatedEquivalentVariables)
|
|
1293
1486
|
return;
|
|
1294
1487
|
const isolatedVars = callbackScope.analysis.isolatedEquivalentVariables;
|
|
1488
|
+
// Get the first returnValue equivalency (normalize array to single value for these checks)
|
|
1489
|
+
const rawReturnValue = isolatedVars.returnValue;
|
|
1490
|
+
const firstReturnValue = Array.isArray(rawReturnValue)
|
|
1491
|
+
? rawReturnValue[0]
|
|
1492
|
+
: rawReturnValue;
|
|
1295
1493
|
// First, check if returnValue is an alias to another variable (e.g., returnValue = intermediate)
|
|
1296
1494
|
// If so, we need to look for that variable's sub-properties too
|
|
1297
|
-
const returnValueAlias = typeof
|
|
1298
|
-
|
|
1299
|
-
? isolatedVars.returnValue
|
|
1495
|
+
const returnValueAlias = typeof firstReturnValue === 'string' && !firstReturnValue.includes('.')
|
|
1496
|
+
? firstReturnValue
|
|
1300
1497
|
: undefined;
|
|
1301
1498
|
// Pattern 3: Object.keys(X).reduce() - the reduce result has the same sub-properties as X
|
|
1302
1499
|
// When returnValue = "Object.keys(source).reduce(...).functionCallReturnValue", look for source.* sub-properties
|
|
1303
1500
|
let reduceSourceVar;
|
|
1304
|
-
if (typeof
|
|
1305
|
-
const reduceMatch =
|
|
1501
|
+
if (typeof firstReturnValue === 'string') {
|
|
1502
|
+
const reduceMatch = firstReturnValue.match(/^Object\.keys\((\w+)\)\.reduce\(.*\)\.functionCallReturnValue$/);
|
|
1306
1503
|
if (reduceMatch) {
|
|
1307
1504
|
reduceSourceVar = reduceMatch[1];
|
|
1308
1505
|
}
|
|
1309
1506
|
}
|
|
1310
|
-
for (const [subPath,
|
|
1507
|
+
for (const [subPath, rawSubValue] of Object.entries(isolatedVars)) {
|
|
1508
|
+
// Normalize to array for consistent handling
|
|
1509
|
+
const subValues = Array.isArray(rawSubValue)
|
|
1510
|
+
? rawSubValue
|
|
1511
|
+
: rawSubValue
|
|
1512
|
+
? [rawSubValue]
|
|
1513
|
+
: [];
|
|
1311
1514
|
// Check for direct returnValue.* sub-properties
|
|
1312
1515
|
const isReturnValueSub = subPath.startsWith('returnValue.') ||
|
|
1313
1516
|
subPath.startsWith('returnValue[');
|
|
@@ -1319,33 +1522,36 @@ export class ScopeDataStructure {
|
|
|
1319
1522
|
const isReduceSourceSub = reduceSourceVar &&
|
|
1320
1523
|
(subPath.startsWith(reduceSourceVar + '.') ||
|
|
1321
1524
|
subPath.startsWith(reduceSourceVar + '['));
|
|
1322
|
-
if (
|
|
1323
|
-
(!isReturnValueSub && !isAliasSub && !isReduceSourceSub))
|
|
1324
|
-
continue;
|
|
1325
|
-
// Convert alias/reduceSource paths to returnValue paths
|
|
1326
|
-
let effectiveSubPath = subPath;
|
|
1327
|
-
if (isAliasSub && !isReturnValueSub) {
|
|
1328
|
-
// Replace the alias prefix with returnValue
|
|
1329
|
-
effectiveSubPath =
|
|
1330
|
-
'returnValue' + subPath.substring(returnValueAlias.length);
|
|
1331
|
-
}
|
|
1332
|
-
else if (isReduceSourceSub && !isReturnValueSub && !isAliasSub) {
|
|
1333
|
-
// Replace the reduce source prefix with returnValue
|
|
1334
|
-
effectiveSubPath =
|
|
1335
|
-
'returnValue' + subPath.substring(reduceSourceVar.length);
|
|
1336
|
-
}
|
|
1337
|
-
const subPropertyPath = effectiveSubPath.substring('returnValue'.length);
|
|
1338
|
-
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
1339
|
-
let newEquivalentValue = cleanPath(subValue.replace(/::cyDuplicateKey\d+::/g, ''), allPaths);
|
|
1340
|
-
// Resolve variable references through parent scope equivalencies
|
|
1341
|
-
const resolved = this.resolveVariableThroughParentScopes(newEquivalentValue, callbackScope, allPaths);
|
|
1342
|
-
newEquivalentValue = resolved.resolvedPath;
|
|
1343
|
-
const equivalentScopeName = resolved.scopeName;
|
|
1344
|
-
if (!newEquivalentValue || !this.isValidPath(newEquivalentValue))
|
|
1525
|
+
if (!isReturnValueSub && !isAliasSub && !isReduceSourceSub)
|
|
1345
1526
|
continue;
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1527
|
+
for (const subValue of subValues) {
|
|
1528
|
+
if (typeof subValue !== 'string')
|
|
1529
|
+
continue;
|
|
1530
|
+
// Convert alias/reduceSource paths to returnValue paths
|
|
1531
|
+
let effectiveSubPath = subPath;
|
|
1532
|
+
if (isAliasSub && !isReturnValueSub) {
|
|
1533
|
+
// Replace the alias prefix with returnValue
|
|
1534
|
+
effectiveSubPath =
|
|
1535
|
+
'returnValue' + subPath.substring(returnValueAlias.length);
|
|
1536
|
+
}
|
|
1537
|
+
else if (isReduceSourceSub && !isReturnValueSub && !isAliasSub) {
|
|
1538
|
+
// Replace the reduce source prefix with returnValue
|
|
1539
|
+
effectiveSubPath =
|
|
1540
|
+
'returnValue' + subPath.substring(reduceSourceVar.length);
|
|
1541
|
+
}
|
|
1542
|
+
const subPropertyPath = effectiveSubPath.substring('returnValue'.length);
|
|
1543
|
+
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
1544
|
+
let newEquivalentValue = cleanPath(subValue.replace(/::cyDuplicateKey\d+::/g, ''), allPaths);
|
|
1545
|
+
// Resolve variable references through parent scope equivalencies
|
|
1546
|
+
const resolved = this.resolveVariableThroughParentScopes(newEquivalentValue, callbackScope, allPaths);
|
|
1547
|
+
newEquivalentValue = resolved.resolvedPath;
|
|
1548
|
+
const equivalentScopeName = resolved.scopeName;
|
|
1549
|
+
if (!newEquivalentValue || !this.isValidPath(newEquivalentValue))
|
|
1550
|
+
continue;
|
|
1551
|
+
this.addEquivalency(newPath, newEquivalentValue, equivalentScopeName, scopeNode, 'propagated function call return sub-property equivalency');
|
|
1552
|
+
// Ensure the database entry has the usage path
|
|
1553
|
+
this.addUsageToEquivalencyDatabaseEntry(newPath, newEquivalentValue, equivalentScopeName, scopeNode.name);
|
|
1554
|
+
}
|
|
1349
1555
|
}
|
|
1350
1556
|
}
|
|
1351
1557
|
/**
|
|
@@ -1377,7 +1583,14 @@ export class ScopeDataStructure {
|
|
|
1377
1583
|
const parentScope = this.scopeNodes[parentScopeName];
|
|
1378
1584
|
if (!parentScope?.analysis?.isolatedEquivalentVariables)
|
|
1379
1585
|
continue;
|
|
1380
|
-
const
|
|
1586
|
+
const rawRootEquiv = parentScope.analysis.isolatedEquivalentVariables[rootVar];
|
|
1587
|
+
// Normalize to array and use first string value
|
|
1588
|
+
const rootEquivs = Array.isArray(rawRootEquiv)
|
|
1589
|
+
? rawRootEquiv
|
|
1590
|
+
: rawRootEquiv
|
|
1591
|
+
? [rawRootEquiv]
|
|
1592
|
+
: [];
|
|
1593
|
+
const rootEquiv = rootEquivs.find((r) => typeof r === 'string');
|
|
1381
1594
|
if (typeof rootEquiv === 'string') {
|
|
1382
1595
|
return {
|
|
1383
1596
|
resolvedPath: cleanPath(rootEquiv + restOfPath, allPaths),
|
|
@@ -1571,9 +1784,21 @@ export class ScopeDataStructure {
|
|
|
1571
1784
|
const remainingPath = this.joinPathParts(remainingPathParts);
|
|
1572
1785
|
if (relevantSubPathParts.every((part, i) => part === schemaPathParts[i]) &&
|
|
1573
1786
|
equivalentValue.scopeNodeName === scopeNode.name) {
|
|
1787
|
+
// DEBUG
|
|
1574
1788
|
continue;
|
|
1575
1789
|
}
|
|
1576
1790
|
const newEquivalentPath = this.joinPathParts([schemaPath, remainingPath]);
|
|
1791
|
+
// PERF: Detect repeated patterns in paths to prevent exponential blowup
|
|
1792
|
+
// Paths like `signature[0].attributes.properties[].attributes.properties[]...`
|
|
1793
|
+
// indicate recursive type structures that cause exponential schema explosion
|
|
1794
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
1795
|
+
if (traceId && debugLevel > 0) {
|
|
1796
|
+
console.info('Debug: skipping path with excessive pattern repetition', {
|
|
1797
|
+
path: newEquivalentPath,
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
continue;
|
|
1801
|
+
}
|
|
1577
1802
|
if (!equivalentScopeNode) {
|
|
1578
1803
|
if (traceId) {
|
|
1579
1804
|
console.info('Debug Propagation: missing equivalent scope info', {
|
|
@@ -1701,6 +1926,8 @@ export class ScopeDataStructure {
|
|
|
1701
1926
|
return;
|
|
1702
1927
|
}
|
|
1703
1928
|
const usageScopeNode = this.getScopeOrFunctionCallInfo(usageEquivalency.scopeNodeName);
|
|
1929
|
+
if (!usageScopeNode)
|
|
1930
|
+
continue;
|
|
1704
1931
|
// Guard against infinite recursion by tracking which paths we've already
|
|
1705
1932
|
// added from addComplexSourcePathVariables
|
|
1706
1933
|
if (this.visitedTracker.checkAndMarkComplexSourceVisited(usageScopeNode.name, newUsageEquivalentPath)) {
|
|
@@ -1749,6 +1976,8 @@ export class ScopeDataStructure {
|
|
|
1749
1976
|
continue;
|
|
1750
1977
|
}
|
|
1751
1978
|
const usageScopeNode = this.getScopeOrFunctionCallInfo(usageEquivalency.scopeNodeName);
|
|
1979
|
+
if (!usageScopeNode)
|
|
1980
|
+
continue;
|
|
1752
1981
|
// This is put in place to avoid propagating array functions like 'filter' through complex equivalencies
|
|
1753
1982
|
// but may cause problems if the funtion call is not on a known object (e.g. string or array)
|
|
1754
1983
|
if (newUsageEquivalentPath.endsWith(')') ||
|
|
@@ -1845,9 +2074,70 @@ export class ScopeDataStructure {
|
|
|
1845
2074
|
// Update inverted index
|
|
1846
2075
|
this.intermediatesOrderIndex.set(pathId, databaseEntry);
|
|
1847
2076
|
if (intermediateIndex === 0) {
|
|
1848
|
-
|
|
2077
|
+
let isValidSourceCandidate = pathInfo.schemaPath.startsWith('signature[') ||
|
|
1849
2078
|
pathInfo.schemaPath.includes('functionCallReturnValue');
|
|
1850
|
-
if
|
|
2079
|
+
// Check if path STARTS with a spread pattern like [...var]
|
|
2080
|
+
// This handles cases like [...files][][0] or [...files].sort(...).functionCallReturnValue[][0]
|
|
2081
|
+
// where the spread source variable needs to be resolved to a signature path.
|
|
2082
|
+
// We do this REGARDLESS of isValidSourceCandidate because even paths containing
|
|
2083
|
+
// functionCallReturnValue may need spread resolution to trace back to the signature.
|
|
2084
|
+
const spreadMatch = pathInfo.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
2085
|
+
if (spreadMatch) {
|
|
2086
|
+
const spreadVar = spreadMatch[1];
|
|
2087
|
+
const spreadPattern = spreadMatch[0]; // The full [...var] match
|
|
2088
|
+
const scopeNode = this.scopeNodes[pathInfo.scopeNodeName];
|
|
2089
|
+
if (scopeNode?.equivalencies) {
|
|
2090
|
+
// Follow the equivalency chain to find a signature path
|
|
2091
|
+
// e.g., files (cyScope1) → files (root) → signature[0].files
|
|
2092
|
+
const resolveToSignature = (varName, currentScopeName, visited) => {
|
|
2093
|
+
const visitKey = `${currentScopeName}::${varName}`;
|
|
2094
|
+
if (visited.has(visitKey))
|
|
2095
|
+
return null;
|
|
2096
|
+
visited.add(visitKey);
|
|
2097
|
+
const currentScope = this.scopeNodes[currentScopeName];
|
|
2098
|
+
if (!currentScope?.equivalencies)
|
|
2099
|
+
return null;
|
|
2100
|
+
const varEquivs = currentScope.equivalencies[varName];
|
|
2101
|
+
if (!varEquivs)
|
|
2102
|
+
return null;
|
|
2103
|
+
// First check if any equivalency directly points to a signature path
|
|
2104
|
+
const signatureEquiv = varEquivs.find((eq) => eq.schemaPath.startsWith('signature['));
|
|
2105
|
+
if (signatureEquiv) {
|
|
2106
|
+
return signatureEquiv;
|
|
2107
|
+
}
|
|
2108
|
+
// Otherwise, follow the chain to other scopes
|
|
2109
|
+
for (const equiv of varEquivs) {
|
|
2110
|
+
// If the equivalency points to the same variable in a different scope,
|
|
2111
|
+
// follow the chain
|
|
2112
|
+
if (equiv.schemaPath === varName &&
|
|
2113
|
+
equiv.scopeNodeName !== currentScopeName) {
|
|
2114
|
+
const result = resolveToSignature(varName, equiv.scopeNodeName, visited);
|
|
2115
|
+
if (result)
|
|
2116
|
+
return result;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
return null;
|
|
2120
|
+
};
|
|
2121
|
+
const signatureEquiv = resolveToSignature(spreadVar, pathInfo.scopeNodeName, new Set());
|
|
2122
|
+
if (signatureEquiv) {
|
|
2123
|
+
// Replace ONLY the [...var] part with the resolved signature path
|
|
2124
|
+
// This preserves any suffix like .sort(...).functionCallReturnValue[][0]
|
|
2125
|
+
const resolvedPath = pathInfo.schemaPath.replace(spreadPattern, signatureEquiv.schemaPath);
|
|
2126
|
+
// Add the resolved path as a source candidate
|
|
2127
|
+
if (!databaseEntry.sourceCandidates.some((sc) => sc.schemaPath === resolvedPath &&
|
|
2128
|
+
sc.scopeNodeName === pathInfo.scopeNodeName)) {
|
|
2129
|
+
databaseEntry.sourceCandidates.push({
|
|
2130
|
+
scopeNodeName: pathInfo.scopeNodeName,
|
|
2131
|
+
schemaPath: resolvedPath,
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
isValidSourceCandidate = true;
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
if (isValidSourceCandidate &&
|
|
2139
|
+
!databaseEntry.sourceCandidates.some((sc) => sc.schemaPath === pathInfo.schemaPath &&
|
|
2140
|
+
sc.scopeNodeName === pathInfo.scopeNodeName)) {
|
|
1851
2141
|
databaseEntry.sourceCandidates.push(pathInfo);
|
|
1852
2142
|
}
|
|
1853
2143
|
}
|
|
@@ -1993,6 +2283,13 @@ export class ScopeDataStructure {
|
|
|
1993
2283
|
delete scopeNode.schema[key];
|
|
1994
2284
|
}
|
|
1995
2285
|
}
|
|
2286
|
+
// Ensure parameter-to-signature equivalencies are fully propagated.
|
|
2287
|
+
// When a parameter variable (e.g., `node`) is equivalenced to `signature[N]`,
|
|
2288
|
+
// all sub-paths of that variable should also appear under `signature[N]`.
|
|
2289
|
+
// This handles cases where the sub-path was added to the schema via a propagation
|
|
2290
|
+
// chain that already included the variable↔signature equivalency, causing the
|
|
2291
|
+
// cycle detection to prevent the reverse mapping.
|
|
2292
|
+
this.propagateParameterToSignaturePaths(scopeNode);
|
|
1996
2293
|
fillInSchemaGapsAndUnknowns(scopeNode, fillInUnknowns);
|
|
1997
2294
|
if (final) {
|
|
1998
2295
|
for (const manager of this.equivalencyManagers) {
|
|
@@ -2004,6 +2301,40 @@ export class ScopeDataStructure {
|
|
|
2004
2301
|
ensureSchemaConsistency(scopeNode.schema);
|
|
2005
2302
|
}
|
|
2006
2303
|
}
|
|
2304
|
+
/**
|
|
2305
|
+
* For each equivalency where a simple variable maps to signature[N],
|
|
2306
|
+
* ensure all sub-paths of that variable are reflected under signature[N].
|
|
2307
|
+
*/
|
|
2308
|
+
propagateParameterToSignaturePaths(scopeNode) {
|
|
2309
|
+
// Find variable → signature[N] equivalencies
|
|
2310
|
+
for (const [varName, equivalencies] of Object.entries(scopeNode.equivalencies)) {
|
|
2311
|
+
// Only process simple variable names (no dots, brackets, or parens)
|
|
2312
|
+
if (varName.includes('.') ||
|
|
2313
|
+
varName.includes('[') ||
|
|
2314
|
+
varName.includes('(')) {
|
|
2315
|
+
continue;
|
|
2316
|
+
}
|
|
2317
|
+
for (const equiv of equivalencies) {
|
|
2318
|
+
if (equiv.scopeNodeName === scopeNode.name &&
|
|
2319
|
+
equiv.schemaPath.startsWith('signature[')) {
|
|
2320
|
+
const signaturePath = equiv.schemaPath;
|
|
2321
|
+
const varPrefix = varName + '.';
|
|
2322
|
+
const varBracketPrefix = varName + '[';
|
|
2323
|
+
// Find all schema keys starting with the variable
|
|
2324
|
+
for (const key in scopeNode.schema) {
|
|
2325
|
+
if (key.startsWith(varPrefix) || key.startsWith(varBracketPrefix)) {
|
|
2326
|
+
const suffix = key.slice(varName.length);
|
|
2327
|
+
const sigKey = signaturePath + suffix;
|
|
2328
|
+
// Only add if the signature path doesn't already exist
|
|
2329
|
+
if (!scopeNode.schema[sigKey]) {
|
|
2330
|
+
scopeNode.schema[sigKey] = scopeNode.schema[key];
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2007
2338
|
filterAndConvertSchema({ filterPath, newPath, schema, }) {
|
|
2008
2339
|
const filterPathParts = this.splitPath(filterPath);
|
|
2009
2340
|
return Object.keys(schema).reduce((acc, key) => {
|
|
@@ -2063,6 +2394,10 @@ export class ScopeDataStructure {
|
|
|
2063
2394
|
path,
|
|
2064
2395
|
...this.splitPath(key).slice(equivalentValueSchemaPathParts.length),
|
|
2065
2396
|
]);
|
|
2397
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
2398
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
2399
|
+
if (this.hasExcessivePatternRepetition(newKey))
|
|
2400
|
+
continue;
|
|
2066
2401
|
resolvedSchema[newKey] = value;
|
|
2067
2402
|
}
|
|
2068
2403
|
}
|
|
@@ -2084,6 +2419,9 @@ export class ScopeDataStructure {
|
|
|
2084
2419
|
if (!subSchema)
|
|
2085
2420
|
continue;
|
|
2086
2421
|
for (const resolvedKey in subSchema) {
|
|
2422
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
2423
|
+
if (this.hasExcessivePatternRepetition(resolvedKey))
|
|
2424
|
+
continue;
|
|
2087
2425
|
if (!resolvedSchema[resolvedKey] ||
|
|
2088
2426
|
subSchema[resolvedKey] === 'unknown') {
|
|
2089
2427
|
resolvedSchema[resolvedKey] = subSchema[resolvedKey];
|
|
@@ -2220,9 +2558,22 @@ export class ScopeDataStructure {
|
|
|
2220
2558
|
}
|
|
2221
2559
|
}
|
|
2222
2560
|
}
|
|
2223
|
-
return mergedSchema;
|
|
2561
|
+
return this.filterDuplicateKeys(mergedSchema);
|
|
2224
2562
|
}
|
|
2225
|
-
return schema;
|
|
2563
|
+
return this.filterDuplicateKeys(schema);
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* Filter out ::cyDuplicateKey:: entries from a schema.
|
|
2567
|
+
* These are internal markers for tracking variable reassignments
|
|
2568
|
+
* and should not appear in output schemas or LLM prompts.
|
|
2569
|
+
*/
|
|
2570
|
+
filterDuplicateKeys(schema) {
|
|
2571
|
+
return Object.entries(schema).reduce((acc, [key, value]) => {
|
|
2572
|
+
if (!key.includes('::cyDuplicateKey')) {
|
|
2573
|
+
acc[key] = value;
|
|
2574
|
+
}
|
|
2575
|
+
return acc;
|
|
2576
|
+
}, {});
|
|
2226
2577
|
}
|
|
2227
2578
|
getEquivalencies(scopeName) {
|
|
2228
2579
|
const scopeNode = this.getScopeOrFunctionCallInfo(scopeName);
|
|
@@ -2244,18 +2595,204 @@ export class ScopeDataStructure {
|
|
|
2244
2595
|
if (!scopeNode) {
|
|
2245
2596
|
return {};
|
|
2246
2597
|
}
|
|
2247
|
-
|
|
2248
|
-
|
|
2598
|
+
// Collect all descendant scope names (including the scope itself)
|
|
2599
|
+
// This ensures we include external calls from nested scopes like cyScope2
|
|
2600
|
+
const getAllDescendantScopeNames = (node) => {
|
|
2601
|
+
const names = new Set([node.name]);
|
|
2602
|
+
for (const child of node.children) {
|
|
2603
|
+
for (const name of getAllDescendantScopeNames(child)) {
|
|
2604
|
+
names.add(name);
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
return names;
|
|
2608
|
+
};
|
|
2609
|
+
const treeNode = this.scopeTreeManager.findNode(scopeNode.name);
|
|
2610
|
+
const descendantScopeNames = treeNode
|
|
2611
|
+
? getAllDescendantScopeNames(treeNode)
|
|
2612
|
+
: new Set([scopeNode.name]);
|
|
2613
|
+
// Get all external function calls made from this scope or any descendant scope
|
|
2614
|
+
// This allows us to include prop equivalencies from JSX components
|
|
2615
|
+
// that were rendered in nested scopes (e.g., FileTableRow called from cyScope2)
|
|
2616
|
+
const externalCallsFromScope = this.externalFunctionCalls.filter((efc) => descendantScopeNames.has(efc.callScope));
|
|
2617
|
+
const externalCallNames = new Set(externalCallsFromScope.map((efc) => efc.name));
|
|
2618
|
+
// Helper to check if a usage belongs to this scope (directly, via descendant, or via external call)
|
|
2619
|
+
const usageMatchesScope = (usage) => descendantScopeNames.has(usage.scopeNodeName) ||
|
|
2620
|
+
externalCallNames.has(usage.scopeNodeName);
|
|
2621
|
+
const entries = this.equivalencyDatabase.filter((entry) => entry.usages.some(usageMatchesScope));
|
|
2622
|
+
// Helper to resolve a source candidate through equivalency chains to find signature paths
|
|
2623
|
+
const resolveToSignature = (source, visited) => {
|
|
2624
|
+
const visitKey = `${source.scopeNodeName}::${source.schemaPath}`;
|
|
2625
|
+
if (visited.has(visitKey))
|
|
2626
|
+
return [];
|
|
2627
|
+
visited.add(visitKey);
|
|
2628
|
+
// If already a signature path, return as-is
|
|
2629
|
+
if (source.schemaPath.startsWith('signature[')) {
|
|
2630
|
+
return [source];
|
|
2631
|
+
}
|
|
2632
|
+
const currentScope = this.scopeNodes[source.scopeNodeName];
|
|
2633
|
+
if (!currentScope?.equivalencies)
|
|
2634
|
+
return [source];
|
|
2635
|
+
// Check for direct equivalencies FIRST (full path match)
|
|
2636
|
+
// This ensures paths like "useMemo(...).functionCallReturnValue" follow to "cyScope1::returnValue"
|
|
2637
|
+
// before prefix matching tries "useMemo(...)" which goes to the useMemo scope
|
|
2638
|
+
const directEquivs = currentScope.equivalencies[source.schemaPath];
|
|
2639
|
+
if (directEquivs?.length > 0) {
|
|
2640
|
+
const results = [];
|
|
2641
|
+
for (const equiv of directEquivs) {
|
|
2642
|
+
const resolved = resolveToSignature({
|
|
2643
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
2644
|
+
schemaPath: equiv.schemaPath,
|
|
2645
|
+
}, visited);
|
|
2646
|
+
results.push(...resolved);
|
|
2647
|
+
}
|
|
2648
|
+
if (results.length > 0)
|
|
2649
|
+
return results;
|
|
2650
|
+
}
|
|
2651
|
+
// Handle spread patterns like [...items].sort().functionCallReturnValue
|
|
2652
|
+
// Extract the spread variable and resolve it through the equivalency chain
|
|
2653
|
+
const spreadMatch = source.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
2654
|
+
if (spreadMatch) {
|
|
2655
|
+
const spreadVar = spreadMatch[1];
|
|
2656
|
+
const spreadPattern = spreadMatch[0];
|
|
2657
|
+
const varEquivs = currentScope.equivalencies[spreadVar];
|
|
2658
|
+
if (varEquivs?.length > 0) {
|
|
2659
|
+
const results = [];
|
|
2660
|
+
for (const equiv of varEquivs) {
|
|
2661
|
+
// Follow the variable equivalency and then resolve from there
|
|
2662
|
+
const resolvedVar = resolveToSignature({
|
|
2663
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
2664
|
+
schemaPath: equiv.schemaPath,
|
|
2665
|
+
}, visited);
|
|
2666
|
+
// For each resolved variable path, create the full path with array element suffix
|
|
2667
|
+
for (const rv of resolvedVar) {
|
|
2668
|
+
if (rv.schemaPath.startsWith('signature[')) {
|
|
2669
|
+
// Get the suffix after the spread pattern
|
|
2670
|
+
let suffix = source.schemaPath.slice(spreadPattern.length);
|
|
2671
|
+
// Clean the suffix: strip array method chains like .sort(...).functionCallReturnValue[]
|
|
2672
|
+
// These don't change the data identity, just transform it.
|
|
2673
|
+
// Keep only the final element access parts like [0], [1], etc.
|
|
2674
|
+
// Pattern: strip everything from a method call up through functionCallReturnValue[]
|
|
2675
|
+
suffix = suffix.replace(/\.\w+\([^)]*\)\.functionCallReturnValue\[\]/g, '');
|
|
2676
|
+
// Also handle simpler case without nested parens
|
|
2677
|
+
suffix = suffix.replace(/\.sort\(\w*\(\)\)\.functionCallReturnValue\[\]/g, '');
|
|
2678
|
+
// Add [] to indicate array element access from the spread
|
|
2679
|
+
const resolvedPath = rv.schemaPath + '[]' + suffix;
|
|
2680
|
+
results.push({
|
|
2681
|
+
scopeNodeName: rv.scopeNodeName,
|
|
2682
|
+
schemaPath: resolvedPath,
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
if (results.length > 0)
|
|
2688
|
+
return results;
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
// Try to find prefix equivalencies that can resolve this path
|
|
2692
|
+
// For path like "cyScope3().signature[0][0]", check "cyScope3().signature[0]", etc.
|
|
2693
|
+
const pathParts = this.splitPath(source.schemaPath);
|
|
2694
|
+
for (let i = pathParts.length - 1; i > 0; i--) {
|
|
2695
|
+
const prefix = this.joinPathParts(pathParts.slice(0, i));
|
|
2696
|
+
const suffix = this.joinPathParts(pathParts.slice(i));
|
|
2697
|
+
const prefixEquivs = currentScope.equivalencies[prefix];
|
|
2698
|
+
if (prefixEquivs?.length > 0) {
|
|
2699
|
+
const results = [];
|
|
2700
|
+
for (const equiv of prefixEquivs) {
|
|
2701
|
+
const newPath = this.joinPathParts([equiv.schemaPath, suffix]);
|
|
2702
|
+
const resolved = resolveToSignature({ scopeNodeName: equiv.scopeNodeName, schemaPath: newPath }, visited);
|
|
2703
|
+
results.push(...resolved);
|
|
2704
|
+
}
|
|
2705
|
+
if (results.length > 0)
|
|
2706
|
+
return results;
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
return [source];
|
|
2710
|
+
};
|
|
2711
|
+
const acc = entries.reduce((result, entry) => {
|
|
2249
2712
|
var _a;
|
|
2250
2713
|
if (entry.sourceCandidates.length === 0)
|
|
2251
|
-
return
|
|
2252
|
-
const usages = entry.usages.filter(
|
|
2714
|
+
return result;
|
|
2715
|
+
const usages = entry.usages.filter(usageMatchesScope);
|
|
2253
2716
|
for (const usage of usages) {
|
|
2254
|
-
|
|
2255
|
-
|
|
2717
|
+
result[_a = usage.schemaPath] || (result[_a] = []);
|
|
2718
|
+
// Resolve each source candidate through the equivalency chain
|
|
2719
|
+
for (const source of entry.sourceCandidates) {
|
|
2720
|
+
const resolvedSources = resolveToSignature(source, new Set());
|
|
2721
|
+
result[usage.schemaPath].push(...resolvedSources);
|
|
2722
|
+
}
|
|
2256
2723
|
}
|
|
2257
|
-
return
|
|
2724
|
+
return result;
|
|
2258
2725
|
}, {});
|
|
2726
|
+
// Post-processing: enrich useState-backed sources with co-located external
|
|
2727
|
+
// function calls. When a useState value resolves to a setter variable that
|
|
2728
|
+
// lives in the same scope as a fetch/API call, that fetch is a data source.
|
|
2729
|
+
this.enrichUseStateSourcesWithCoLocatedCalls(acc);
|
|
2730
|
+
return acc;
|
|
2731
|
+
}
|
|
2732
|
+
/**
|
|
2733
|
+
* For each source that ends at a useState path, check if the setter was called
|
|
2734
|
+
* from a scope that also contains external function calls (like fetch).
|
|
2735
|
+
* If so, add those external calls as additional source candidates.
|
|
2736
|
+
*/
|
|
2737
|
+
enrichUseStateSourcesWithCoLocatedCalls(acc) {
|
|
2738
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
2739
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
2740
|
+
if (!rootScope)
|
|
2741
|
+
return;
|
|
2742
|
+
// Collect all descendants for each scope node
|
|
2743
|
+
const getAllDescendants = (node) => {
|
|
2744
|
+
const names = new Set([node.name]);
|
|
2745
|
+
for (const child of node.children) {
|
|
2746
|
+
for (const name of getAllDescendants(child)) {
|
|
2747
|
+
names.add(name);
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
return names;
|
|
2751
|
+
};
|
|
2752
|
+
for (const [usagePath, sources] of Object.entries(acc)) {
|
|
2753
|
+
const additionalSources = [];
|
|
2754
|
+
for (const source of sources) {
|
|
2755
|
+
// Check if this source is a useState-related terminal path
|
|
2756
|
+
// (e.g., useState(X).functionCallReturnValue[1] or useState(X).signature[0])
|
|
2757
|
+
if (!source.schemaPath.match(/^useState\([^)]*\)\./))
|
|
2758
|
+
continue;
|
|
2759
|
+
// Find the useState call from the source path
|
|
2760
|
+
const useStateCallMatch = source.schemaPath.match(/^(useState\([^)]*\))\./);
|
|
2761
|
+
if (!useStateCallMatch)
|
|
2762
|
+
continue;
|
|
2763
|
+
const useStateCall = useStateCallMatch[1];
|
|
2764
|
+
// Look in the root scope for the useState value equivalency
|
|
2765
|
+
// which tells us where the setter was called from
|
|
2766
|
+
const valuePath = `${useStateCall}.functionCallReturnValue[0]`;
|
|
2767
|
+
const valueEquivs = rootScope.equivalencies[valuePath];
|
|
2768
|
+
if (!valueEquivs)
|
|
2769
|
+
continue;
|
|
2770
|
+
for (const equiv of valueEquivs) {
|
|
2771
|
+
// Find the scope where the setter was called
|
|
2772
|
+
const setterScopeName = equiv.scopeNodeName;
|
|
2773
|
+
const setterScopeTree = this.scopeTreeManager.findNode(setterScopeName);
|
|
2774
|
+
if (!setterScopeTree)
|
|
2775
|
+
continue;
|
|
2776
|
+
// Get all descendant scope names from the setter scope
|
|
2777
|
+
const relatedScopes = getAllDescendants(setterScopeTree);
|
|
2778
|
+
// Find external function calls in those scopes whose return values
|
|
2779
|
+
// are actually consumed (assigned to a variable). This excludes
|
|
2780
|
+
// fire-and-forget calls like analytics.track() or console.log().
|
|
2781
|
+
const coLocatedCalls = this.externalFunctionCalls.filter((efc) => relatedScopes.has(efc.callScope) &&
|
|
2782
|
+
efc.receivingVariableNames &&
|
|
2783
|
+
efc.receivingVariableNames.length > 0);
|
|
2784
|
+
for (const call of coLocatedCalls) {
|
|
2785
|
+
additionalSources.push({
|
|
2786
|
+
scopeNodeName: call.callScope,
|
|
2787
|
+
schemaPath: `${call.callSignature}.functionCallReturnValue`,
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
if (additionalSources.length > 0) {
|
|
2793
|
+
acc[usagePath].push(...additionalSources);
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2259
2796
|
}
|
|
2260
2797
|
getUsageEquivalencies(functionName) {
|
|
2261
2798
|
const scopeNode = this.getScopeOrFunctionCallInfo(functionName);
|
|
@@ -2288,26 +2825,106 @@ export class ScopeDataStructure {
|
|
|
2288
2825
|
return acc;
|
|
2289
2826
|
}, {});
|
|
2290
2827
|
const equivalencies = this.getEquivalencies(functionName);
|
|
2828
|
+
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
2291
2829
|
for (const equivalenceKey in equivalencies ?? {}) {
|
|
2292
2830
|
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
2293
2831
|
const schemaPath = equivalenceValue.schemaPath;
|
|
2294
2832
|
if (schemaPath.startsWith('signature[') &&
|
|
2295
|
-
equivalenceValue.scopeNodeName ===
|
|
2833
|
+
equivalenceValue.scopeNodeName === scopeName &&
|
|
2296
2834
|
!signatureInSchema[schemaPath]) {
|
|
2297
2835
|
signatureInSchema[schemaPath] = 'unknown';
|
|
2298
2836
|
}
|
|
2299
2837
|
}
|
|
2300
2838
|
}
|
|
2301
2839
|
const tempScopeNode = this.createTempScopeNode(functionName ?? this.scopeTreeManager.getRootName(), signatureInSchema, equivalencies);
|
|
2302
|
-
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
2303
|
-
// during this "getter" method. validateSchema triggers manager.finalize which
|
|
2304
|
-
// can call addToSchema -> addToEquivalencyDatabase -> mergeEquivalencyDatabaseEntries,
|
|
2305
|
-
// which would incorrectly remove entries from the database.
|
|
2306
|
-
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
2307
|
-
this.onlyEquivalencies = true;
|
|
2308
2840
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
2309
|
-
|
|
2310
|
-
|
|
2841
|
+
// After validateSchema has filled in types, propagate nested paths from
|
|
2842
|
+
// variables to their signature equivalents.
|
|
2843
|
+
// e.g., workouts[].activity_type -> signature[0].workouts[].activity_type
|
|
2844
|
+
//
|
|
2845
|
+
// Build a map of variable names that are equivalent to signature paths
|
|
2846
|
+
// e.g., { 'workouts': 'signature[0].workouts' }
|
|
2847
|
+
const variableToSignatureMap = {};
|
|
2848
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
2849
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
2850
|
+
const schemaPath = equivalenceValue.schemaPath;
|
|
2851
|
+
// Track which variables map to signature paths
|
|
2852
|
+
// equivalenceKey is the variable name (e.g., 'workouts')
|
|
2853
|
+
// schemaPath is where it comes from (e.g., 'signature[0].workouts')
|
|
2854
|
+
if (schemaPath.startsWith('signature[') &&
|
|
2855
|
+
equivalenceValue.scopeNodeName === scopeName) {
|
|
2856
|
+
variableToSignatureMap[equivalenceKey] = schemaPath;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
// Enrich schema with deeply nested paths from internal function call scopes.
|
|
2861
|
+
// When a function call like traverse(tree) exists, and traverse's scope has
|
|
2862
|
+
// signature[0].children[path][entityName] (from propagateParameterToSignaturePaths),
|
|
2863
|
+
// we need to map those paths back to the argument variable (tree) in this scope.
|
|
2864
|
+
// This handles cases where cycle detection prevented the equivalency chain from
|
|
2865
|
+
// propagating deep paths during Phase 2 batch queue processing.
|
|
2866
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
2867
|
+
// Look for keys matching function call pattern: funcName(...).signature[N]
|
|
2868
|
+
const funcCallMatch = equivalenceKey.match(/^([^(]+)\(.*?\)\.(signature\[\d+\])$/);
|
|
2869
|
+
if (!funcCallMatch)
|
|
2870
|
+
continue;
|
|
2871
|
+
const calledFunctionName = funcCallMatch[1];
|
|
2872
|
+
const signatureParam = funcCallMatch[2]; // e.g., "signature[0]"
|
|
2873
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
2874
|
+
if (equivalenceValue.scopeNodeName !== scopeName)
|
|
2875
|
+
continue;
|
|
2876
|
+
const targetVariable = equivalenceValue.schemaPath;
|
|
2877
|
+
// Get the called function's schema (includes propagated parameter paths)
|
|
2878
|
+
const childSchema = this.getSchema({
|
|
2879
|
+
scopeName: calledFunctionName,
|
|
2880
|
+
});
|
|
2881
|
+
if (!childSchema)
|
|
2882
|
+
continue;
|
|
2883
|
+
// Map child function's signature paths to parent variable paths
|
|
2884
|
+
const sigPrefix = signatureParam + '.';
|
|
2885
|
+
const sigBracketPrefix = signatureParam + '[';
|
|
2886
|
+
for (const childKey in childSchema) {
|
|
2887
|
+
let suffix = null;
|
|
2888
|
+
if (childKey.startsWith(sigPrefix)) {
|
|
2889
|
+
suffix = childKey.slice(signatureParam.length);
|
|
2890
|
+
}
|
|
2891
|
+
else if (childKey.startsWith(sigBracketPrefix)) {
|
|
2892
|
+
suffix = childKey.slice(signatureParam.length);
|
|
2893
|
+
}
|
|
2894
|
+
if (suffix !== null) {
|
|
2895
|
+
const parentKey = targetVariable + suffix;
|
|
2896
|
+
if (!schema[parentKey]) {
|
|
2897
|
+
schema[parentKey] = childSchema[childKey];
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
// Propagate nested paths from variables to their signature equivalents
|
|
2904
|
+
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
2905
|
+
// signature[0].workouts[].title
|
|
2906
|
+
for (const schemaKey in schema) {
|
|
2907
|
+
// Skip keys that already start with signature[
|
|
2908
|
+
if (schemaKey.startsWith('signature['))
|
|
2909
|
+
continue;
|
|
2910
|
+
// Check if this key starts with a variable that maps to a signature path
|
|
2911
|
+
for (const [variableName, signaturePath] of Object.entries(variableToSignatureMap)) {
|
|
2912
|
+
// Check if schemaKey starts with variableName followed by a property accessor
|
|
2913
|
+
// e.g., 'workouts[]' starts with 'workouts'
|
|
2914
|
+
if (schemaKey === variableName ||
|
|
2915
|
+
schemaKey.startsWith(variableName + '.') ||
|
|
2916
|
+
schemaKey.startsWith(variableName + '[')) {
|
|
2917
|
+
// Transform the path: replace the variable prefix with the signature path
|
|
2918
|
+
const suffix = schemaKey.slice(variableName.length);
|
|
2919
|
+
const signatureKey = signaturePath + suffix;
|
|
2920
|
+
// Add to schema if not already present
|
|
2921
|
+
if (!tempScopeNode.schema[signatureKey]) {
|
|
2922
|
+
tempScopeNode.schema[signatureKey] = schema[schemaKey];
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
return this.filterDuplicateKeys(tempScopeNode.schema);
|
|
2311
2928
|
}
|
|
2312
2929
|
getReturnValue({ functionName, fillInUnknowns, }) {
|
|
2313
2930
|
// Trigger finalization on all managers to apply any pending updates
|
|
@@ -2350,14 +2967,27 @@ export class ScopeDataStructure {
|
|
|
2350
2967
|
// Include function paths even if their return value wasn't captured
|
|
2351
2968
|
// This ensures methods like onAuthStateChange are included in the schema
|
|
2352
2969
|
// But exclude signature entries (they should only be included via functionCallReturnValue paths)
|
|
2353
|
-
|
|
2970
|
+
// Also exclude bare function call signatures - paths that are JUST a call like
|
|
2971
|
+
// "useCustomSizes(projectSlug)" should not be included as return values.
|
|
2972
|
+
// These represent "the function exists" not actual return data, and including
|
|
2973
|
+
// them causes nested path bugs in dependencySchemas.
|
|
2974
|
+
(schema[key] === 'function' &&
|
|
2975
|
+
key.indexOf('signature[') === -1 &&
|
|
2976
|
+
// Exclude bare call signatures: function calls with no dots OUTSIDE parentheses
|
|
2977
|
+
// e.g., "useCustomSizes(projectSlug)" is bare (exclude)
|
|
2978
|
+
// e.g., "loadProject({nested.property})" is bare - dots are inside args (exclude)
|
|
2979
|
+
// e.g., "getSupabase().auth.method()" has dots outside - method chain (include)
|
|
2980
|
+
!this.isBareCallSignature(key)))
|
|
2354
2981
|
.reduce((acc, key) => {
|
|
2355
2982
|
acc[key] = schema[key];
|
|
2356
2983
|
const keyParts = this.splitPath(key);
|
|
2357
2984
|
for (const path in schema) {
|
|
2358
2985
|
const pathParts = this.splitPath(path);
|
|
2359
2986
|
if (pathParts.every((p, i) => keyParts[i] === p)) {
|
|
2360
|
-
|
|
2987
|
+
// Also exclude bare call signatures from prefix paths
|
|
2988
|
+
if (!this.isBareCallSignature(path)) {
|
|
2989
|
+
acc[path] = schema[path];
|
|
2990
|
+
}
|
|
2361
2991
|
}
|
|
2362
2992
|
}
|
|
2363
2993
|
return acc;
|
|
@@ -2371,7 +3001,56 @@ export class ScopeDataStructure {
|
|
|
2371
3001
|
this.onlyEquivalencies = true;
|
|
2372
3002
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
2373
3003
|
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
2374
|
-
return
|
|
3004
|
+
// Remove bare call signatures from the return value schema.
|
|
3005
|
+
// fillInSchemaGapsAndUnknowns may add parent paths like "useCustomSizes(projectSlug)"
|
|
3006
|
+
// when it sees "useCustomSizes(projectSlug).functionCallReturnValue". These bare
|
|
3007
|
+
// call signatures represent "the function exists" not actual return data, and
|
|
3008
|
+
// including them causes nested path bugs in dependencySchemas.
|
|
3009
|
+
const resultSchema = tempScopeNode.schema;
|
|
3010
|
+
for (const key of Object.keys(resultSchema)) {
|
|
3011
|
+
if (this.isBareCallSignature(key)) {
|
|
3012
|
+
delete resultSchema[key];
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
return resultSchema;
|
|
3016
|
+
}
|
|
3017
|
+
/**
|
|
3018
|
+
* Checks if a schema key is a "bare call signature" - a function call with no
|
|
3019
|
+
* method chain before it and no path segments after it.
|
|
3020
|
+
*
|
|
3021
|
+
* A bare call signature represents "this function exists" rather than actual
|
|
3022
|
+
* return data, and including them causes nested path bugs in dependencySchemas.
|
|
3023
|
+
*
|
|
3024
|
+
* Examples:
|
|
3025
|
+
* - "useCustomSizes(projectSlug)" -> bare (true)
|
|
3026
|
+
* - "loadProject({nested.property})" -> bare (dots are inside args, true)
|
|
3027
|
+
* - "getSupabase().auth.method()" -> not bare (has dots outside parens, false)
|
|
3028
|
+
* - "useProject().functionCallReturnValue" -> not bare (has path after, false)
|
|
3029
|
+
*/
|
|
3030
|
+
isBareCallSignature(key) {
|
|
3031
|
+
// Must end with ) and contain ( to be a call
|
|
3032
|
+
if (!key.endsWith(')') || key.indexOf('(') === -1) {
|
|
3033
|
+
return false;
|
|
3034
|
+
}
|
|
3035
|
+
// Check if there are any dots OUTSIDE of parentheses
|
|
3036
|
+
// Strip out content inside balanced parentheses, then check for dots
|
|
3037
|
+
let depth = 0;
|
|
3038
|
+
let hasDotsOutsideParens = false;
|
|
3039
|
+
for (let i = 0; i < key.length; i++) {
|
|
3040
|
+
const char = key[i];
|
|
3041
|
+
if (char === '(') {
|
|
3042
|
+
depth++;
|
|
3043
|
+
}
|
|
3044
|
+
else if (char === ')') {
|
|
3045
|
+
depth--;
|
|
3046
|
+
}
|
|
3047
|
+
else if (char === '.' && depth === 0) {
|
|
3048
|
+
hasDotsOutsideParens = true;
|
|
3049
|
+
break;
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
// It's a bare call signature if there are no dots outside parentheses
|
|
3053
|
+
return !hasDotsOutsideParens;
|
|
2375
3054
|
}
|
|
2376
3055
|
/**
|
|
2377
3056
|
* Replaces cyScope placeholder references (e.g., cyScope10()) in schema keys
|
|
@@ -2442,13 +3121,372 @@ export class ScopeDataStructure {
|
|
|
2442
3121
|
getEquivalentSignatureVariables() {
|
|
2443
3122
|
const scopeNode = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
2444
3123
|
const equivalentSignatureVariables = {};
|
|
3124
|
+
// Helper to add equivalencies - accumulates into array if multiple values for same key
|
|
3125
|
+
// This is critical for OR expressions like `x = a || b` where x should map to both a and b
|
|
3126
|
+
const addEquivalency = (key, value) => {
|
|
3127
|
+
const existing = equivalentSignatureVariables[key];
|
|
3128
|
+
if (existing === undefined) {
|
|
3129
|
+
// First value - store as string
|
|
3130
|
+
equivalentSignatureVariables[key] = value;
|
|
3131
|
+
}
|
|
3132
|
+
else if (typeof existing === 'string') {
|
|
3133
|
+
if (existing !== value) {
|
|
3134
|
+
// Second different value - convert to array
|
|
3135
|
+
equivalentSignatureVariables[key] = [existing, value];
|
|
3136
|
+
}
|
|
3137
|
+
// Same value - no change needed
|
|
3138
|
+
}
|
|
3139
|
+
else {
|
|
3140
|
+
// Already an array - add if not already present
|
|
3141
|
+
if (!existing.includes(value)) {
|
|
3142
|
+
existing.push(value);
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
};
|
|
2445
3146
|
for (const [path, equivalentValues] of Object.entries(scopeNode.equivalencies)) {
|
|
2446
3147
|
for (const equivalentValue of equivalentValues) {
|
|
3148
|
+
// Case 1: Props/signature equivalencies (existing behavior)
|
|
3149
|
+
// Maps local variable names to their signature paths
|
|
3150
|
+
// e.g., "propValue" -> "signature[0].prop"
|
|
2447
3151
|
if (path.startsWith('signature[')) {
|
|
2448
|
-
|
|
3152
|
+
addEquivalency(equivalentValue.schemaPath, path);
|
|
3153
|
+
}
|
|
3154
|
+
// Case 2: Hook variable equivalencies (new behavior)
|
|
3155
|
+
// The equivalencies are stored as: path = variable name, schemaPath = data source
|
|
3156
|
+
// e.g., path = "debugFetcher", schemaPath = "useFetcher<...>().functionCallReturnValue"
|
|
3157
|
+
// We need to map: "debugFetcher" -> "useFetcher<...>()"
|
|
3158
|
+
// This enables resolving paths like "debugFetcher.state" to
|
|
3159
|
+
// "useFetcher<...>().state" for execution flow validation
|
|
3160
|
+
if (equivalentValue.schemaPath.endsWith('.functionCallReturnValue')) {
|
|
3161
|
+
// Extract the hook call path (everything before .functionCallReturnValue)
|
|
3162
|
+
let hookCallPath = equivalentValue.schemaPath.slice(0, -'.functionCallReturnValue'.length);
|
|
3163
|
+
// Only include if it looks like a hook call (contains parentheses)
|
|
3164
|
+
// and the variable name (path) is a simple identifier (no dots)
|
|
3165
|
+
if (hookCallPath.includes('(') && !path.includes('.')) {
|
|
3166
|
+
// Special case: If hookCallPath is a callback scope (cyScope pattern),
|
|
3167
|
+
// trace through it to find what the callback actually returns.
|
|
3168
|
+
// This handles useState(() => { return prop; }) patterns.
|
|
3169
|
+
const cyScopeMatch = hookCallPath.match(/^(cyScope\d+)\(\)$/);
|
|
3170
|
+
if (cyScopeMatch) {
|
|
3171
|
+
// Use the equivalency database to trace the callback's return value
|
|
3172
|
+
// to its actual source (e.g., viewModeFromUrl -> segments -> params -> useParams)
|
|
3173
|
+
const dbEntry = this.getEquivalenciesDatabaseEntry(scopeNode.name, // Component scope
|
|
3174
|
+
path);
|
|
3175
|
+
if (dbEntry?.sourceCandidates?.length > 0) {
|
|
3176
|
+
// Use the traced source instead of the callback scope
|
|
3177
|
+
hookCallPath = dbEntry.sourceCandidates[0].schemaPath;
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
addEquivalency(path, hookCallPath);
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
// Case 3: Destructured variables from local variables
|
|
3184
|
+
// e.g., const { scenarios } = currentEntityAnalysis;
|
|
3185
|
+
// This creates: path = "scenarios", schemaPath = "currentEntityAnalysis.scenarios"
|
|
3186
|
+
// We need to map: "scenarios" -> "currentEntityAnalysis.scenarios"
|
|
3187
|
+
// AND resolve transitively if currentEntityAnalysis is itself equivalent to a hook call
|
|
3188
|
+
if (!path.includes('.') && // path is a simple identifier
|
|
3189
|
+
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
3190
|
+
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
3191
|
+
) {
|
|
3192
|
+
// Skip bare "returnValue" from child scopes — this is the child's return value,
|
|
3193
|
+
// not a meaningful data source path in the parent scope
|
|
3194
|
+
if (equivalentValue.schemaPath === 'returnValue' &&
|
|
3195
|
+
equivalentValue.scopeNodeName !==
|
|
3196
|
+
this.scopeTreeManager.getRootName()) {
|
|
3197
|
+
continue;
|
|
3198
|
+
}
|
|
3199
|
+
// Add equivalency (will accumulate if multiple values for OR expressions)
|
|
3200
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3201
|
+
}
|
|
3202
|
+
// Case 4: Child component prop mappings (Fix 22)
|
|
3203
|
+
// When parent renders <ChildComponent prop={value} />, we get equivalencies like:
|
|
3204
|
+
// path = "ChildComponent().signature[0].prop"
|
|
3205
|
+
// schemaPath = "value" (the variable passed as the prop)
|
|
3206
|
+
// We need to include these so translateChildPathToParent can work.
|
|
3207
|
+
// Pattern: ComponentName().signature[N] or ComponentName().signature[N].propName
|
|
3208
|
+
if (path.includes('().signature[') &&
|
|
3209
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable, not a function call
|
|
3210
|
+
) {
|
|
3211
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3212
|
+
}
|
|
3213
|
+
// Case 5: Destructured function parameters (Fix 25)
|
|
3214
|
+
// When a function has destructured props: function Comp({ propA, propB }: Props)
|
|
3215
|
+
// We get equivalencies like:
|
|
3216
|
+
// path = "propA" (the destructured variable name)
|
|
3217
|
+
// schemaPath = "signature[0].propA" (the signature path)
|
|
3218
|
+
// We need to map: "propA" -> "signature[0].propA"
|
|
3219
|
+
// This enables translateChildPathToParent to resolve child variable paths
|
|
3220
|
+
// to their signature paths when merging execution flows.
|
|
3221
|
+
if (!path.includes('.') && // path is a simple identifier (destructured prop name)
|
|
3222
|
+
equivalentValue.schemaPath.startsWith('signature[') // schemaPath IS a signature path
|
|
3223
|
+
) {
|
|
3224
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3225
|
+
}
|
|
3226
|
+
// Case 7: Method calls on variables that result in .functionCallReturnValue (Fix 33)
|
|
3227
|
+
// When we have patterns like:
|
|
3228
|
+
// path = "segments" (simple identifier)
|
|
3229
|
+
// schemaPath = "splat.split('/').functionCallReturnValue"
|
|
3230
|
+
// This is a method call on a variable (not a hook call), but we still need to
|
|
3231
|
+
// track it so transitive resolution can resolve `splat` to its actual source.
|
|
3232
|
+
// E.g., if splat -> useParams().functionCallReturnValue['*'], then
|
|
3233
|
+
// segments -> useParams().functionCallReturnValue['*'].split('/').functionCallReturnValue
|
|
3234
|
+
if (!path.includes('.') && // path is a simple identifier
|
|
3235
|
+
equivalentValue.schemaPath.endsWith('.functionCallReturnValue') && // ends with function return
|
|
3236
|
+
equivalentValue.schemaPath.includes('.') // has property access (method call)
|
|
3237
|
+
) {
|
|
3238
|
+
// Check if this looks like a method call on a variable (not a hook call)
|
|
3239
|
+
// Hook calls look like: hookName() or hookName<T>()
|
|
3240
|
+
// Method calls look like: variable.method() or variable.method<T>()
|
|
3241
|
+
const hookCallPath = equivalentValue.schemaPath.slice(0, -'.functionCallReturnValue'.length);
|
|
3242
|
+
// If it's a method call (contains a dot before the parenthesis), include it
|
|
3243
|
+
const dotBeforeParen = hookCallPath.indexOf('.');
|
|
3244
|
+
const parenPos = hookCallPath.indexOf('(');
|
|
3245
|
+
if (dotBeforeParen !== -1 && dotBeforeParen < parenPos) {
|
|
3246
|
+
// This is a method call like "splat.split('/')", not a hook call
|
|
3247
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3248
|
+
}
|
|
2449
3249
|
}
|
|
2450
3250
|
}
|
|
2451
3251
|
}
|
|
3252
|
+
// Case 6: Collect JSX child prop equivalencies from child scopes (Fix 26)
|
|
3253
|
+
// When a parent component renders <ChildComponent prop={value} />, the JSX
|
|
3254
|
+
// return statement may be in a child scope (e.g., cyScope2). The equivalencies
|
|
3255
|
+
// like ChildComponent().signature[0].prop -> value get stored in that child scope.
|
|
3256
|
+
// But translateChildPathToParent needs to find them from the parent scope's context.
|
|
3257
|
+
// So we collect Case 4 patterns from ALL child scopes that belong to this root scope.
|
|
3258
|
+
const rootName = this.scopeTreeManager.getRootName();
|
|
3259
|
+
for (const [scopeName, childScopeNode] of Object.entries(this.scopeNodes)) {
|
|
3260
|
+
// Skip the root scope (already processed above)
|
|
3261
|
+
if (scopeName === rootName)
|
|
3262
|
+
continue;
|
|
3263
|
+
// Only include scopes that are children of the root (their tree includes root)
|
|
3264
|
+
if (!childScopeNode.tree?.includes(rootName))
|
|
3265
|
+
continue;
|
|
3266
|
+
// Look for Case 4 patterns in the child scope
|
|
3267
|
+
for (const [path, equivalentValues] of Object.entries(childScopeNode.equivalencies || {})) {
|
|
3268
|
+
for (const equivalentValue of equivalentValues) {
|
|
3269
|
+
// Case 4 pattern: ChildComponent().signature[0].propName -> parentVariable
|
|
3270
|
+
if (path.includes('().signature[') &&
|
|
3271
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable
|
|
3272
|
+
) {
|
|
3273
|
+
// Only add if not already present from the root scope
|
|
3274
|
+
// Root scope values take precedence over child scope values
|
|
3275
|
+
if (!(path in equivalentSignatureVariables)) {
|
|
3276
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
// Transitive resolution: Resolve variable chains through multiple levels
|
|
3283
|
+
// E.g., analysis → currentEntityAnalysis → useLoaderData().functionCallReturnValue.currentEntityAnalysis
|
|
3284
|
+
// We need multiple passes because resolutions can depend on each other
|
|
3285
|
+
const maxIterations = 5; // Prevent infinite loops
|
|
3286
|
+
// Helper function to resolve a single source path using equivalencies
|
|
3287
|
+
const resolveSourcePath = (sourcePath, equivMap) => {
|
|
3288
|
+
// Extract base variable from the path
|
|
3289
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
3290
|
+
const bracketIndex = sourcePath.indexOf('[');
|
|
3291
|
+
let baseVar;
|
|
3292
|
+
let rest;
|
|
3293
|
+
if (dotIndex === -1 && bracketIndex === -1) {
|
|
3294
|
+
baseVar = sourcePath;
|
|
3295
|
+
rest = '';
|
|
3296
|
+
}
|
|
3297
|
+
else if (dotIndex === -1) {
|
|
3298
|
+
baseVar = sourcePath.slice(0, bracketIndex);
|
|
3299
|
+
rest = sourcePath.slice(bracketIndex);
|
|
3300
|
+
}
|
|
3301
|
+
else if (bracketIndex === -1) {
|
|
3302
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
3303
|
+
rest = sourcePath.slice(dotIndex);
|
|
3304
|
+
}
|
|
3305
|
+
else {
|
|
3306
|
+
const firstIndex = Math.min(dotIndex, bracketIndex);
|
|
3307
|
+
baseVar = sourcePath.slice(0, firstIndex);
|
|
3308
|
+
rest = sourcePath.slice(firstIndex);
|
|
3309
|
+
}
|
|
3310
|
+
// Look up the base variable in equivalencies
|
|
3311
|
+
if (baseVar in equivMap && equivMap[baseVar] !== sourcePath) {
|
|
3312
|
+
const baseResolved = equivMap[baseVar];
|
|
3313
|
+
// Skip if baseResolved is an array (handle later)
|
|
3314
|
+
if (Array.isArray(baseResolved))
|
|
3315
|
+
return null;
|
|
3316
|
+
// If it resolves to a signature path, build the full resolved path
|
|
3317
|
+
if (baseResolved.startsWith('signature[') ||
|
|
3318
|
+
baseResolved.includes('()')) {
|
|
3319
|
+
if (baseResolved.endsWith('()')) {
|
|
3320
|
+
return baseResolved + '.functionCallReturnValue' + rest;
|
|
3321
|
+
}
|
|
3322
|
+
return baseResolved + rest;
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
return null;
|
|
3326
|
+
};
|
|
3327
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
3328
|
+
let changed = false;
|
|
3329
|
+
for (const [varName, sourcePathOrArray] of Object.entries(equivalentSignatureVariables)) {
|
|
3330
|
+
// Handle arrays (OR expressions) by resolving each element
|
|
3331
|
+
if (Array.isArray(sourcePathOrArray)) {
|
|
3332
|
+
const resolvedArray = [];
|
|
3333
|
+
let arrayChanged = false;
|
|
3334
|
+
for (const sourcePath of sourcePathOrArray) {
|
|
3335
|
+
// Try to resolve this path using transitive resolution
|
|
3336
|
+
const resolved = resolveSourcePath(sourcePath, equivalentSignatureVariables);
|
|
3337
|
+
if (resolved && resolved !== sourcePath) {
|
|
3338
|
+
resolvedArray.push(resolved);
|
|
3339
|
+
arrayChanged = true;
|
|
3340
|
+
}
|
|
3341
|
+
else {
|
|
3342
|
+
resolvedArray.push(sourcePath);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
if (arrayChanged) {
|
|
3346
|
+
equivalentSignatureVariables[varName] = resolvedArray;
|
|
3347
|
+
changed = true;
|
|
3348
|
+
}
|
|
3349
|
+
continue;
|
|
3350
|
+
}
|
|
3351
|
+
const sourcePath = sourcePathOrArray;
|
|
3352
|
+
// Skip if already fully resolved (contains function call syntax)
|
|
3353
|
+
// BUT first check for computed value patterns that need resolution (Fix 28)
|
|
3354
|
+
// AND method call patterns that need base variable resolution (Fix 33)
|
|
3355
|
+
if (sourcePath.includes('()')) {
|
|
3356
|
+
// Fix 28: Handle computed value patterns with dependency arrays
|
|
3357
|
+
// Patterns like `functionName(arg, [dep1, dep2, ...])` are NOT controllable
|
|
3358
|
+
// data sources. We trace through the dependencies to find controllable sources.
|
|
3359
|
+
const bracketStart = sourcePath.indexOf('[');
|
|
3360
|
+
const bracketEnd = sourcePath.lastIndexOf(']');
|
|
3361
|
+
if (bracketStart !== -1 && bracketEnd > bracketStart) {
|
|
3362
|
+
const arrayContent = sourcePath.slice(bracketStart + 1, bracketEnd);
|
|
3363
|
+
const items = arrayContent.split(',').map((s) => s.trim());
|
|
3364
|
+
// Only process if this looks like a dependency array:
|
|
3365
|
+
// multiple items that are all simple identifiers (not numbers or expressions)
|
|
3366
|
+
const isIdentifier = (s) => /^\w+$/.test(s) && !/^\d+$/.test(s);
|
|
3367
|
+
if (items.length > 1 && items.every(isIdentifier)) {
|
|
3368
|
+
// Look for a dependency that's already resolved to a controllable source
|
|
3369
|
+
for (const dep of items) {
|
|
3370
|
+
if (dep in equivalentSignatureVariables) {
|
|
3371
|
+
const resolvedDep = equivalentSignatureVariables[dep];
|
|
3372
|
+
// Use if it's a controllable path (contains hook call)
|
|
3373
|
+
// and is NOT another unresolved computed pattern (has comma-separated deps)
|
|
3374
|
+
const hasCommaInBrackets = resolvedDep.includes('[') &&
|
|
3375
|
+
resolvedDep.includes(',') &&
|
|
3376
|
+
resolvedDep.indexOf(',') > resolvedDep.indexOf('[');
|
|
3377
|
+
if (resolvedDep.includes('()') && !hasCommaInBrackets) {
|
|
3378
|
+
// Computed value is typically an element from an array
|
|
3379
|
+
equivalentSignatureVariables[varName] = resolvedDep + '[]';
|
|
3380
|
+
changed = true;
|
|
3381
|
+
break;
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
// Fix 33: Handle method call patterns on variables
|
|
3388
|
+
// Patterns like: "splat.split('/').functionCallReturnValue"
|
|
3389
|
+
// We need to resolve the base variable (splat) to its actual source
|
|
3390
|
+
// Check if this is a method call on a variable (dot before first parenthesis)
|
|
3391
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
3392
|
+
const parenIndex = sourcePath.indexOf('(');
|
|
3393
|
+
if (dotIndex !== -1 &&
|
|
3394
|
+
dotIndex < parenIndex &&
|
|
3395
|
+
!sourcePath.startsWith('use') // Not a hook call like useState()
|
|
3396
|
+
) {
|
|
3397
|
+
// Extract the base variable (before the first dot)
|
|
3398
|
+
const baseVar = sourcePath.slice(0, dotIndex);
|
|
3399
|
+
const rest = sourcePath.slice(dotIndex); // includes ".method(...).functionCallReturnValue"
|
|
3400
|
+
// Check if the base variable can be resolved
|
|
3401
|
+
if (baseVar in equivalentSignatureVariables &&
|
|
3402
|
+
baseVar !== varName) {
|
|
3403
|
+
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
3404
|
+
// Skip if baseResolved is an array (OR expression)
|
|
3405
|
+
if (Array.isArray(baseResolved))
|
|
3406
|
+
continue;
|
|
3407
|
+
// Only resolve if the base resolved to something useful (contains () or .)
|
|
3408
|
+
if (baseResolved.includes('()') || baseResolved.includes('.')) {
|
|
3409
|
+
const newPath = baseResolved + rest;
|
|
3410
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
3411
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
3412
|
+
changed = true;
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
// Fix 38: Handle cyScope lazy initializer return values
|
|
3418
|
+
// When we have viewMode -> cyScope20(), trace through to find what cyScope20 returns.
|
|
3419
|
+
// The lazy initializer's return value should be the controllable data source.
|
|
3420
|
+
// Pattern: cyScopeN() where N is a number
|
|
3421
|
+
const cyScopeMatch = sourcePath.match(/^(cyScope\d+)\(\)$/);
|
|
3422
|
+
if (cyScopeMatch) {
|
|
3423
|
+
const cyScopeName = cyScopeMatch[1];
|
|
3424
|
+
const cyScopeNode = this.scopeNodes[cyScopeName];
|
|
3425
|
+
if (cyScopeNode?.equivalencies) {
|
|
3426
|
+
// Look for returnValue equivalency in the cyScope
|
|
3427
|
+
const returnValueEquivs = cyScopeNode.equivalencies['returnValue'];
|
|
3428
|
+
if (returnValueEquivs && returnValueEquivs.length > 0) {
|
|
3429
|
+
// Get the first return value source
|
|
3430
|
+
const returnSource = returnValueEquivs[0].schemaPath;
|
|
3431
|
+
// If the return source is a simple variable (not a complex path),
|
|
3432
|
+
// resolve varName directly to that variable
|
|
3433
|
+
if (returnSource &&
|
|
3434
|
+
!returnSource.includes('(') &&
|
|
3435
|
+
!returnSource.includes('[')) {
|
|
3436
|
+
// Update varName to point to the return source
|
|
3437
|
+
if (equivalentSignatureVariables[varName] !== returnSource) {
|
|
3438
|
+
equivalentSignatureVariables[varName] = returnSource;
|
|
3439
|
+
changed = true;
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
continue;
|
|
3446
|
+
}
|
|
3447
|
+
// Check if the source path starts with a variable that's also in the map
|
|
3448
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
3449
|
+
let baseVar;
|
|
3450
|
+
let rest;
|
|
3451
|
+
if (dotIndex > 0) {
|
|
3452
|
+
// Path has a dot: "a.b.c" -> baseVar="a", rest=".b.c"
|
|
3453
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
3454
|
+
rest = sourcePath.slice(dotIndex); // includes the leading dot
|
|
3455
|
+
}
|
|
3456
|
+
else {
|
|
3457
|
+
// Path is a simple identifier: "currentEntityAnalysis" -> baseVar="currentEntityAnalysis", rest=""
|
|
3458
|
+
baseVar = sourcePath;
|
|
3459
|
+
rest = '';
|
|
3460
|
+
}
|
|
3461
|
+
if (baseVar in equivalentSignatureVariables && baseVar !== varName) {
|
|
3462
|
+
// Handle array case (OR expressions) - use first element
|
|
3463
|
+
const rawBaseResolved = equivalentSignatureVariables[baseVar];
|
|
3464
|
+
const baseResolved = Array.isArray(rawBaseResolved)
|
|
3465
|
+
? rawBaseResolved[0]
|
|
3466
|
+
: rawBaseResolved;
|
|
3467
|
+
if (!baseResolved)
|
|
3468
|
+
continue;
|
|
3469
|
+
// If the base resolves to a hook call, add .functionCallReturnValue
|
|
3470
|
+
if (baseResolved.endsWith('()')) {
|
|
3471
|
+
const newPath = baseResolved + '.functionCallReturnValue' + rest;
|
|
3472
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
3473
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
3474
|
+
changed = true;
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
else if (baseResolved !== sourcePath) {
|
|
3478
|
+
const newPath = baseResolved + rest;
|
|
3479
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
3480
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
3481
|
+
changed = true;
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
// Stop if no changes were made in this iteration
|
|
3487
|
+
if (!changed)
|
|
3488
|
+
break;
|
|
3489
|
+
}
|
|
2452
3490
|
return equivalentSignatureVariables;
|
|
2453
3491
|
}
|
|
2454
3492
|
getVariableInfo(variableName, scopeName, final) {
|
|
@@ -2608,12 +3646,116 @@ export class ScopeDataStructure {
|
|
|
2608
3646
|
}
|
|
2609
3647
|
}
|
|
2610
3648
|
}
|
|
3649
|
+
/**
|
|
3650
|
+
* Add conditional effects from AST analysis.
|
|
3651
|
+
* Called during scope analysis to collect all setter calls inside conditionals.
|
|
3652
|
+
*/
|
|
3653
|
+
addConditionalEffects(effects) {
|
|
3654
|
+
// Add effects, avoiding duplicates based on effect stateVariable and condition paths
|
|
3655
|
+
for (const effect of effects) {
|
|
3656
|
+
const exists = this.rawConditionalEffects.some((existing) => {
|
|
3657
|
+
// Same effect target (stateVariable + value)
|
|
3658
|
+
const sameEffect = existing.effect.stateVariable === effect.effect.stateVariable &&
|
|
3659
|
+
existing.effect.value === effect.effect.value;
|
|
3660
|
+
if (!sameEffect)
|
|
3661
|
+
return false;
|
|
3662
|
+
// Same condition(s)
|
|
3663
|
+
if (existing.condition && effect.condition) {
|
|
3664
|
+
return (existing.condition.path === effect.condition.path &&
|
|
3665
|
+
existing.condition.requiredValue === effect.condition.requiredValue);
|
|
3666
|
+
}
|
|
3667
|
+
if (existing.conditions && effect.conditions) {
|
|
3668
|
+
if (existing.conditions.length !== effect.conditions.length)
|
|
3669
|
+
return false;
|
|
3670
|
+
return existing.conditions.every((ec, i) => {
|
|
3671
|
+
const newCond = effect.conditions[i];
|
|
3672
|
+
return (ec.path === newCond.path &&
|
|
3673
|
+
ec.requiredValue === newCond.requiredValue);
|
|
3674
|
+
});
|
|
3675
|
+
}
|
|
3676
|
+
return false;
|
|
3677
|
+
});
|
|
3678
|
+
if (!exists) {
|
|
3679
|
+
this.rawConditionalEffects.push(effect);
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
/**
|
|
3684
|
+
* Get conditional effects collected during analysis.
|
|
3685
|
+
*/
|
|
3686
|
+
getConditionalEffects() {
|
|
3687
|
+
return this.rawConditionalEffects;
|
|
3688
|
+
}
|
|
3689
|
+
/**
|
|
3690
|
+
* Add compound conditionals from AST analysis.
|
|
3691
|
+
* Called during scope analysis to collect grouped conditions (e.g., a && b && c).
|
|
3692
|
+
*/
|
|
3693
|
+
addCompoundConditionals(compounds) {
|
|
3694
|
+
// Add compounds, avoiding duplicates based on chainId
|
|
3695
|
+
for (const compound of compounds) {
|
|
3696
|
+
const exists = this.rawCompoundConditionals.some((existing) => existing.chainId === compound.chainId);
|
|
3697
|
+
if (!exists) {
|
|
3698
|
+
this.rawCompoundConditionals.push(compound);
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
/**
|
|
3703
|
+
* Get compound conditionals collected during analysis.
|
|
3704
|
+
*/
|
|
3705
|
+
getCompoundConditionals() {
|
|
3706
|
+
return this.rawCompoundConditionals;
|
|
3707
|
+
}
|
|
3708
|
+
/**
|
|
3709
|
+
* Add child boundary gating conditions from AST analysis.
|
|
3710
|
+
* These track which conditions must be true for a child component to render.
|
|
3711
|
+
*/
|
|
3712
|
+
addChildBoundaryGatingConditions(conditions) {
|
|
3713
|
+
for (const [childName, usages] of Object.entries(conditions)) {
|
|
3714
|
+
if (!this.rawChildBoundaryGatingConditions[childName]) {
|
|
3715
|
+
this.rawChildBoundaryGatingConditions[childName] = [];
|
|
3716
|
+
}
|
|
3717
|
+
// Add usages, avoiding duplicates
|
|
3718
|
+
for (const usage of usages) {
|
|
3719
|
+
const exists = this.rawChildBoundaryGatingConditions[childName].some((existing) => existing.path === usage.path &&
|
|
3720
|
+
existing.conditionType === usage.conditionType &&
|
|
3721
|
+
existing.isNegated === usage.isNegated);
|
|
3722
|
+
if (!exists) {
|
|
3723
|
+
this.rawChildBoundaryGatingConditions[childName].push(usage);
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
/**
|
|
3729
|
+
* Get enriched child boundary gating conditions with source tracing.
|
|
3730
|
+
* Similar to getEnrichedConditionalUsages but for gating conditions.
|
|
3731
|
+
*/
|
|
3732
|
+
getEnrichedChildBoundaryGatingConditions() {
|
|
3733
|
+
const enriched = {};
|
|
3734
|
+
const rootScopeName = this.scopeTreeManager.getTree().name;
|
|
3735
|
+
for (const [childName, usages] of Object.entries(this.rawChildBoundaryGatingConditions)) {
|
|
3736
|
+
enriched[childName] = usages.map((usage) => {
|
|
3737
|
+
// Try to trace this path back to a data source
|
|
3738
|
+
const explanation = this.explainPath(rootScopeName, usage.path);
|
|
3739
|
+
let sourceDataPath;
|
|
3740
|
+
if (explanation.source) {
|
|
3741
|
+
sourceDataPath = `${explanation.source.scope}.${explanation.source.path}`;
|
|
3742
|
+
}
|
|
3743
|
+
return {
|
|
3744
|
+
...usage,
|
|
3745
|
+
sourceDataPath,
|
|
3746
|
+
};
|
|
3747
|
+
});
|
|
3748
|
+
}
|
|
3749
|
+
return enriched;
|
|
3750
|
+
}
|
|
2611
3751
|
/**
|
|
2612
3752
|
* Get enriched conditional usages with source tracing.
|
|
2613
3753
|
* Uses explainPath to trace each local variable back to its data source.
|
|
3754
|
+
* Preserves all fields from the raw conditional usages including derivedFrom.
|
|
2614
3755
|
*/
|
|
2615
3756
|
getEnrichedConditionalUsages() {
|
|
2616
3757
|
const enriched = {};
|
|
3758
|
+
console.log(`[getEnrichedConditionalUsages] Processing ${Object.keys(this.rawConditionalUsages).length} conditional paths: [${Object.keys(this.rawConditionalUsages).join(', ')}]`);
|
|
2617
3759
|
for (const [path, usages] of Object.entries(this.rawConditionalUsages)) {
|
|
2618
3760
|
// Try to trace this path back to a data source
|
|
2619
3761
|
// First, try the root scope
|
|
@@ -2621,9 +3763,47 @@ export class ScopeDataStructure {
|
|
|
2621
3763
|
const explanation = this.explainPath(rootScopeName, path);
|
|
2622
3764
|
let sourceDataPath;
|
|
2623
3765
|
if (explanation.source) {
|
|
2624
|
-
|
|
2625
|
-
|
|
3766
|
+
const { scope, path: sourcePath } = explanation.source;
|
|
3767
|
+
// Build initial path — avoid redundant prefix when path already contains the scope call
|
|
3768
|
+
let fullPath;
|
|
3769
|
+
if (sourcePath.startsWith(`${scope}(`)) {
|
|
3770
|
+
fullPath = sourcePath;
|
|
3771
|
+
}
|
|
3772
|
+
else {
|
|
3773
|
+
fullPath = `${scope}.${sourcePath}`;
|
|
3774
|
+
}
|
|
3775
|
+
sourceDataPath = fullPath;
|
|
3776
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" explainPath → scope="${scope}", sourcePath="${sourcePath}" → sourceDataPath="${sourceDataPath}"`);
|
|
3777
|
+
}
|
|
3778
|
+
else {
|
|
3779
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" explainPath → no source found`);
|
|
2626
3780
|
}
|
|
3781
|
+
// If explainPath didn't find a useful external source (e.g., it traced to
|
|
3782
|
+
// useState or just to the component scope itself), check sourceEquivalencies
|
|
3783
|
+
// for an external function call source like a fetch call
|
|
3784
|
+
const hasExternalSource = sourceDataPath?.includes('.functionCallReturnValue');
|
|
3785
|
+
if (!hasExternalSource) {
|
|
3786
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" no external source (sourceDataPath="${sourceDataPath}"), checking sourceEquivalencies fallback...`);
|
|
3787
|
+
const sourceEquiv = this.getSourceEquivalencies();
|
|
3788
|
+
const returnValueKey = `returnValue.${path}`;
|
|
3789
|
+
const sources = sourceEquiv[returnValueKey];
|
|
3790
|
+
if (sources) {
|
|
3791
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] has ${sources.length} sources: [${sources.map((s) => s.schemaPath).join(', ')}]`);
|
|
3792
|
+
const externalSource = sources.find((s) => s.schemaPath.includes('.functionCallReturnValue') &&
|
|
3793
|
+
!s.schemaPath.startsWith('useState('));
|
|
3794
|
+
if (externalSource) {
|
|
3795
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found external source: "${externalSource.schemaPath}"`);
|
|
3796
|
+
sourceDataPath = externalSource.schemaPath;
|
|
3797
|
+
}
|
|
3798
|
+
else {
|
|
3799
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found no external function call source`);
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
else {
|
|
3803
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] not found`);
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" FINAL sourceDataPath="${sourceDataPath ?? '(none)'}" (${usages.length} usages)`);
|
|
2627
3807
|
enriched[path] = usages.map((usage) => ({
|
|
2628
3808
|
...usage,
|
|
2629
3809
|
sourceDataPath,
|
|
@@ -2631,9 +3811,29 @@ export class ScopeDataStructure {
|
|
|
2631
3811
|
}
|
|
2632
3812
|
return enriched;
|
|
2633
3813
|
}
|
|
3814
|
+
/**
|
|
3815
|
+
* Add JSX rendering usages from AST analysis.
|
|
3816
|
+
* These track arrays rendered via .map() and strings interpolated in JSX.
|
|
3817
|
+
*/
|
|
3818
|
+
addJsxRenderingUsages(usages) {
|
|
3819
|
+
// Add usages, avoiding duplicates based on path and renderingType
|
|
3820
|
+
for (const usage of usages) {
|
|
3821
|
+
const exists = this.rawJsxRenderingUsages.some((existing) => existing.path === usage.path &&
|
|
3822
|
+
existing.renderingType === usage.renderingType);
|
|
3823
|
+
if (!exists) {
|
|
3824
|
+
this.rawJsxRenderingUsages.push(usage);
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
/**
|
|
3829
|
+
* Get JSX rendering usages collected during analysis.
|
|
3830
|
+
*/
|
|
3831
|
+
getJsxRenderingUsages() {
|
|
3832
|
+
return this.rawJsxRenderingUsages;
|
|
3833
|
+
}
|
|
2634
3834
|
toSerializable() {
|
|
2635
|
-
// Helper to clean cyScope from a string
|
|
2636
|
-
const cleanCyScope = (str) => this.replaceCyScopeInString(str);
|
|
3835
|
+
// Helper to clean cyScope and cyDuplicateKey from a string for output
|
|
3836
|
+
const cleanCyScope = (str) => this.replaceCyScopeInString(str).replace(/::cyDuplicateKey\d+::/g, '');
|
|
2637
3837
|
// Helper to convert ScopeVariable to SerializableScopeVariable (with cyScope cleaned)
|
|
2638
3838
|
const toSerializableVariable = (vars) => vars.map((v) => ({
|
|
2639
3839
|
scopeNodeName: cleanCyScope(v.scopeNodeName),
|
|
@@ -2669,22 +3869,336 @@ export class ScopeDataStructure {
|
|
|
2669
3869
|
};
|
|
2670
3870
|
// Convert external function calls - use getExternalFunctionCalls() which cleans cyScope
|
|
2671
3871
|
const cleanedExternalCalls = this.getExternalFunctionCalls();
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
3872
|
+
// Get root scope schema for building per-variable return value schemas
|
|
3873
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
3874
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
3875
|
+
const rootSchema = rootScope?.schema ?? {};
|
|
3876
|
+
const externalFunctionCalls = cleanedExternalCalls.map((efc) => {
|
|
3877
|
+
// Build perVariableSchemas from perCallSignatureSchemas when available.
|
|
3878
|
+
// This preserves distinct schemas per variable when the same function is called
|
|
3879
|
+
// multiple times with DIFFERENT call signatures (e.g., different type parameters).
|
|
3880
|
+
//
|
|
3881
|
+
// When field accesses happen in child scopes (like JSX expressions), the
|
|
3882
|
+
// rootSchema doesn't contain the detailed paths - they end up in child scope
|
|
3883
|
+
// schemas. Using perCallSignatureSchemas ensures we get the correct schema
|
|
3884
|
+
// for each call, regardless of where field accesses occur.
|
|
3885
|
+
let perVariableSchemas;
|
|
3886
|
+
// Use perCallSignatureSchemas only when:
|
|
3887
|
+
// 1. It exists and has distinct entries for different call signatures
|
|
3888
|
+
// 2. The number of distinct call signatures >= number of receiving variables
|
|
3889
|
+
//
|
|
3890
|
+
// This prevents using it when all calls have the same signature (e.g., useFetcher() x 2)
|
|
3891
|
+
// because in that case, perCallSignatureSchemas only has one entry.
|
|
3892
|
+
const numCallSignatures = efc.perCallSignatureSchemas
|
|
3893
|
+
? Object.keys(efc.perCallSignatureSchemas).length
|
|
3894
|
+
: 0;
|
|
3895
|
+
const numReceivingVars = efc.receivingVariableNames?.length ?? 0;
|
|
3896
|
+
const hasDistinctSchemas = numCallSignatures >= numReceivingVars && numCallSignatures > 1;
|
|
3897
|
+
// CASE 1: Multiple call signatures with distinct schemas - use indexed variable names
|
|
3898
|
+
if (hasDistinctSchemas &&
|
|
3899
|
+
efc.perCallSignatureSchemas &&
|
|
3900
|
+
efc.callSignatureToVariable) {
|
|
3901
|
+
perVariableSchemas = {};
|
|
3902
|
+
// Build a reverse map: variable -> array of call signatures (in order)
|
|
3903
|
+
// This handles the case where the same variable name is reused for different calls
|
|
3904
|
+
const varToCallSigs = {};
|
|
3905
|
+
for (const [callSig, varName] of Object.entries(efc.callSignatureToVariable)) {
|
|
3906
|
+
if (!varToCallSigs[varName]) {
|
|
3907
|
+
varToCallSigs[varName] = [];
|
|
3908
|
+
}
|
|
3909
|
+
varToCallSigs[varName].push(callSig);
|
|
3910
|
+
}
|
|
3911
|
+
// Track how many times each variable name has been seen
|
|
3912
|
+
const varNameCounts = {};
|
|
3913
|
+
// For each receiving variable, get its original schema from perCallSignatureSchemas
|
|
3914
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
3915
|
+
const occurrence = varNameCounts[varName] ?? 0;
|
|
3916
|
+
varNameCounts[varName] = occurrence + 1;
|
|
3917
|
+
const callSigs = varToCallSigs[varName];
|
|
3918
|
+
// Use the nth call signature for the nth occurrence of this variable
|
|
3919
|
+
const callSig = callSigs?.[occurrence];
|
|
3920
|
+
if (callSig && efc.perCallSignatureSchemas[callSig]) {
|
|
3921
|
+
// Use indexed key if this variable name is reused (e.g., fetcher, fetcher[1])
|
|
3922
|
+
const key = occurrence === 0 ? varName : `${varName}[${occurrence}]`;
|
|
3923
|
+
// Clone the schema to avoid shared references
|
|
3924
|
+
perVariableSchemas[key] = {
|
|
3925
|
+
...efc.perCallSignatureSchemas[callSig],
|
|
3926
|
+
};
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
// Only include if we have entries for ALL receiving variables
|
|
3930
|
+
if (Object.keys(perVariableSchemas).length < numReceivingVars) {
|
|
3931
|
+
// Not all variables have schemas - fall back to rootSchema extraction
|
|
3932
|
+
perVariableSchemas = undefined;
|
|
3933
|
+
}
|
|
3934
|
+
else {
|
|
3935
|
+
// Also check that at least one schema is non-empty
|
|
3936
|
+
// Bug fix: perCallSignatureSchemas may have entries but with empty schemas {}
|
|
3937
|
+
// In this case, we should fall through to Fallback which uses rootSchema
|
|
3938
|
+
const hasNonEmptySchema = Object.values(perVariableSchemas).some((schema) => Object.keys(schema).length > 0);
|
|
3939
|
+
if (!hasNonEmptySchema) {
|
|
3940
|
+
perVariableSchemas = undefined;
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
// CASE 2: Single call signature with single variable - use perCallSignatureSchemas directly
|
|
3945
|
+
// This handles parameterized calls like useFetcher<ConfigData>() where each is a separate efc entry
|
|
3946
|
+
if (!perVariableSchemas &&
|
|
3947
|
+
efc.perCallSignatureSchemas &&
|
|
3948
|
+
numCallSignatures === 1 &&
|
|
3949
|
+
numReceivingVars === 1) {
|
|
3950
|
+
const varName = efc.receivingVariableNames[0];
|
|
3951
|
+
const callSig = Object.keys(efc.perCallSignatureSchemas)[0];
|
|
3952
|
+
const schema = efc.perCallSignatureSchemas[callSig];
|
|
3953
|
+
if (schema && Object.keys(schema).length > 0) {
|
|
3954
|
+
perVariableSchemas = { [varName]: { ...schema } };
|
|
3955
|
+
}
|
|
3956
|
+
}
|
|
3957
|
+
// CASE 3: Extract from efc.schema when perCallSignatureSchemas is missing or empty
|
|
3958
|
+
// This handles two scenarios:
|
|
3959
|
+
// 1. Parameterized calls that create SEPARATE efc entries (no perCallSignatureSchemas)
|
|
3960
|
+
// 2. Destructuring where perCallSignatureSchemas exists but has EMPTY schemas
|
|
3961
|
+
//
|
|
3962
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create separate
|
|
3963
|
+
// efc entries because getFunctionCallRoot preserves type parameters. Each entry has its own
|
|
3964
|
+
// `schema` field, but due to variable reassignment, the schema may be contaminated with paths
|
|
3965
|
+
// from other calls (the tracer attributes field accesses to ALL equivalencies).
|
|
3966
|
+
//
|
|
3967
|
+
// Solution: Filter efc.schema to only include paths that match THIS entry's call signature.
|
|
3968
|
+
// The schema paths include the full call signature prefix, so we can filter by it.
|
|
3969
|
+
//
|
|
3970
|
+
// Example: ConfigData entry has paths like:
|
|
3971
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.theme"
|
|
3972
|
+
// But also (contaminated):
|
|
3973
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.notifications"
|
|
3974
|
+
//
|
|
3975
|
+
// We filter to only keep paths that should belong to THIS call by checking if the
|
|
3976
|
+
// receiving variable's equivalency points to this call's return value.
|
|
3977
|
+
//
|
|
3978
|
+
// BUG FIX: The old condition `!efc.perCallSignatureSchemas` was FALSE when the object
|
|
3979
|
+
// existed (even with empty schemas), causing this case to be skipped. We now also check
|
|
3980
|
+
// if all schemas in perCallSignatureSchemas are empty.
|
|
3981
|
+
const hasNonEmptyPerCallSignatureSchemas = efc.perCallSignatureSchemas &&
|
|
3982
|
+
Object.values(efc.perCallSignatureSchemas).some((schema) => Object.keys(schema).length > 0);
|
|
3983
|
+
// Build the call signature prefix that paths should start with
|
|
3984
|
+
const callSigPrefix = `${efc.callSignature}.functionCallReturnValue`;
|
|
3985
|
+
// Check if efc.schema has variable-specific paths (indicating destructuring).
|
|
3986
|
+
// Destructuring: const { entities, gitStatus } = useLoaderData()
|
|
3987
|
+
// - efc.schema has paths like: useLoaderData().functionCallReturnValue.entities...
|
|
3988
|
+
// Multiple calls: const x = useFetcher(); const y = useFetcher();
|
|
3989
|
+
// - efc.schema has paths like: useFetcher().functionCallReturnValue.data...
|
|
3990
|
+
// CASE 3 should only run for destructuring (variable-specific paths exist).
|
|
3991
|
+
const hasVariableSpecificPaths = (efc.receivingVariableNames ?? []).some((varName) => Object.keys(efc.schema).some((path) => path.startsWith(`${callSigPrefix}.${varName}`)));
|
|
3992
|
+
if (!perVariableSchemas &&
|
|
3993
|
+
!hasNonEmptyPerCallSignatureSchemas &&
|
|
3994
|
+
numReceivingVars >= 1 &&
|
|
3995
|
+
hasVariableSpecificPaths) {
|
|
3996
|
+
// Filter efc.schema to only include paths matching this call signature
|
|
3997
|
+
const filteredSchema = {};
|
|
3998
|
+
for (const [path, type] of Object.entries(efc.schema)) {
|
|
3999
|
+
if (path.startsWith(callSigPrefix) || path === efc.callSignature) {
|
|
4000
|
+
filteredSchema[path] = type;
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
// Build perVariableSchemas from the filtered schema
|
|
4004
|
+
// For destructuring, filter paths by variable name
|
|
4005
|
+
if (Object.keys(filteredSchema).length > 0) {
|
|
4006
|
+
perVariableSchemas = {};
|
|
4007
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
4008
|
+
// For destructuring, extract only paths specific to this variable
|
|
4009
|
+
const varSpecificPrefix = `${callSigPrefix}.${varName}`;
|
|
4010
|
+
const varSchema = {};
|
|
4011
|
+
for (const [path, type] of Object.entries(filteredSchema)) {
|
|
4012
|
+
if (path.startsWith(varSpecificPrefix)) {
|
|
4013
|
+
// Transform: useLoaderData().functionCallReturnValue.entities.sha
|
|
4014
|
+
// -> functionCallReturnValue.entities.sha (keep the variable name)
|
|
4015
|
+
const suffix = path.slice(callSigPrefix.length);
|
|
4016
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
4017
|
+
varSchema[returnValuePath] = type;
|
|
4018
|
+
}
|
|
4019
|
+
else if (path === efc.callSignature) {
|
|
4020
|
+
// Include the function call type itself
|
|
4021
|
+
varSchema[path] = type;
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
if (Object.keys(varSchema).length > 0) {
|
|
4025
|
+
perVariableSchemas[varName] = varSchema;
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
// Only include if we have entries
|
|
4029
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
4030
|
+
perVariableSchemas = undefined;
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
// Fallback: extract from root scope schema when perCallSignatureSchemas is not available
|
|
4035
|
+
// or doesn't have distinct entries for each variable.
|
|
4036
|
+
// This works when field accesses are in the root scope.
|
|
4037
|
+
if (!perVariableSchemas &&
|
|
4038
|
+
efc.receivingVariableNames &&
|
|
4039
|
+
efc.receivingVariableNames.length > 0) {
|
|
4040
|
+
perVariableSchemas = {};
|
|
4041
|
+
for (const varName of efc.receivingVariableNames) {
|
|
4042
|
+
const varSchema = {};
|
|
4043
|
+
for (const [path, type] of Object.entries(rootSchema)) {
|
|
4044
|
+
// Check if path starts with this variable name
|
|
4045
|
+
if (path === varName ||
|
|
4046
|
+
path.startsWith(varName + '.') ||
|
|
4047
|
+
path.startsWith(varName + '[')) {
|
|
4048
|
+
// Transform to functionCallReturnValue format
|
|
4049
|
+
// e.g., userFetcher.data.id -> functionCallReturnValue.data.id
|
|
4050
|
+
const suffix = path.slice(varName.length);
|
|
4051
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
4052
|
+
varSchema[returnValuePath] = type;
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
if (Object.keys(varSchema).length > 0) {
|
|
4056
|
+
// Clean the variable name when using as key in output
|
|
4057
|
+
perVariableSchemas[cleanCyScope(varName)] = varSchema;
|
|
4058
|
+
}
|
|
4059
|
+
}
|
|
4060
|
+
// Only include if we have any entries
|
|
4061
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
4062
|
+
perVariableSchemas = undefined;
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
// Enrich the schema with inferred types by applying fillInSchemaGapsAndUnknowns.
|
|
4066
|
+
// This ensures the serialized schema has the same type inference as getReturnValue().
|
|
4067
|
+
// Without this, evidence like "entities[].analyses: array" becomes "unknown".
|
|
4068
|
+
const enrichedSchema = { ...efc.schema };
|
|
4069
|
+
const tempScopeNode = {
|
|
4070
|
+
name: efc.name,
|
|
4071
|
+
schema: enrichedSchema,
|
|
4072
|
+
equivalencies: efc.equivalencies ?? {},
|
|
4073
|
+
};
|
|
4074
|
+
fillInSchemaGapsAndUnknowns(tempScopeNode, true);
|
|
4075
|
+
return {
|
|
4076
|
+
name: efc.name,
|
|
4077
|
+
callSignature: efc.callSignature,
|
|
4078
|
+
callScope: efc.callScope,
|
|
4079
|
+
schema: enrichedSchema,
|
|
4080
|
+
equivalencies: efc.equivalencies
|
|
4081
|
+
? Object.entries(efc.equivalencies).reduce((acc, [key, vars]) => {
|
|
4082
|
+
// Clean cyScope from the key as well as variable properties
|
|
4083
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
4084
|
+
return acc;
|
|
4085
|
+
}, {})
|
|
4086
|
+
: undefined,
|
|
4087
|
+
allCallSignatures: efc.allCallSignatures,
|
|
4088
|
+
receivingVariableNames: efc.receivingVariableNames?.map(cleanCyScope),
|
|
4089
|
+
callSignatureToVariable: efc.callSignatureToVariable
|
|
4090
|
+
? Object.fromEntries(Object.entries(efc.callSignatureToVariable).map(([k, v]) => [
|
|
4091
|
+
k,
|
|
4092
|
+
cleanCyScope(v),
|
|
4093
|
+
]))
|
|
4094
|
+
: undefined,
|
|
4095
|
+
perVariableSchemas,
|
|
4096
|
+
};
|
|
4097
|
+
});
|
|
4098
|
+
// POST-PROCESSING: Deduplicate schemas across parameterized calls to same base function
|
|
4099
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create
|
|
4100
|
+
// separate entries. Due to variable reassignment, BOTH entries may have ALL fields.
|
|
4101
|
+
// We deduplicate by assigning each field to ONLY ONE entry based on order of appearance.
|
|
4102
|
+
//
|
|
4103
|
+
// Strategy: Fields that appear first in order belong to the first entry,
|
|
4104
|
+
// fields that appear later belong to later entries (split evenly).
|
|
4105
|
+
const deduplicateParameterizedEntries = (entries) => {
|
|
4106
|
+
// Group entries by base function name (without type parameters)
|
|
4107
|
+
const groups = new Map();
|
|
4108
|
+
for (const entry of entries) {
|
|
4109
|
+
// Extract base function name by stripping type parameters
|
|
4110
|
+
// e.g., "useFetcher<{ data: ConfigData | null }>" -> "useFetcher"
|
|
4111
|
+
const baseName = entry.name.replace(/<.*>$/, '');
|
|
4112
|
+
const group = groups.get(baseName) || [];
|
|
4113
|
+
group.push(entry);
|
|
4114
|
+
groups.set(baseName, group);
|
|
4115
|
+
}
|
|
4116
|
+
// Process groups with multiple parameterized entries
|
|
4117
|
+
for (const [, group] of groups) {
|
|
4118
|
+
if (group.length <= 1)
|
|
4119
|
+
continue;
|
|
4120
|
+
// Check if these are parameterized calls (have type parameters in name)
|
|
4121
|
+
const hasTypeParams = group.every((e) => e.name.includes('<'));
|
|
4122
|
+
if (!hasTypeParams)
|
|
4123
|
+
continue;
|
|
4124
|
+
// Collect ALL unique field suffixes across all entries (in order of first appearance)
|
|
4125
|
+
// Field suffix is the path after functionCallReturnValue, e.g., ".data.data.theme"
|
|
4126
|
+
const allFieldSuffixes = [];
|
|
4127
|
+
for (const entry of group) {
|
|
4128
|
+
if (!entry.perVariableSchemas)
|
|
4129
|
+
continue;
|
|
4130
|
+
for (const varSchema of Object.values(entry.perVariableSchemas)) {
|
|
4131
|
+
for (const path of Object.keys(varSchema)) {
|
|
4132
|
+
// Skip the base "functionCallReturnValue" entry
|
|
4133
|
+
if (path === 'functionCallReturnValue')
|
|
4134
|
+
continue;
|
|
4135
|
+
// Extract field suffix
|
|
4136
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
4137
|
+
if (!match)
|
|
4138
|
+
continue;
|
|
4139
|
+
const fieldSuffix = match[1];
|
|
4140
|
+
if (!allFieldSuffixes.includes(fieldSuffix)) {
|
|
4141
|
+
allFieldSuffixes.push(fieldSuffix);
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
// Assign fields to entries: split evenly based on order
|
|
4147
|
+
// First N/2 fields go to first entry, remaining go to second entry
|
|
4148
|
+
const fieldToEntryMap = new Map();
|
|
4149
|
+
const fieldsPerEntry = Math.ceil(allFieldSuffixes.length / group.length);
|
|
4150
|
+
for (let i = 0; i < allFieldSuffixes.length; i++) {
|
|
4151
|
+
const fieldSuffix = allFieldSuffixes[i];
|
|
4152
|
+
const entryIdx = Math.min(Math.floor(i / fieldsPerEntry), group.length - 1);
|
|
4153
|
+
fieldToEntryMap.set(fieldSuffix, entryIdx);
|
|
4154
|
+
}
|
|
4155
|
+
// Filter each entry's perVariableSchemas to only include its assigned fields
|
|
4156
|
+
for (let i = 0; i < group.length; i++) {
|
|
4157
|
+
const entry = group[i];
|
|
4158
|
+
if (!entry.perVariableSchemas)
|
|
4159
|
+
continue;
|
|
4160
|
+
const filteredPerVarSchemas = {};
|
|
4161
|
+
for (const [varName, varSchema] of Object.entries(entry.perVariableSchemas)) {
|
|
4162
|
+
const filteredVarSchema = {};
|
|
4163
|
+
for (const [path, type] of Object.entries(varSchema)) {
|
|
4164
|
+
// Always keep the base functionCallReturnValue
|
|
4165
|
+
if (path === 'functionCallReturnValue') {
|
|
4166
|
+
filteredVarSchema[path] = type;
|
|
4167
|
+
continue;
|
|
4168
|
+
}
|
|
4169
|
+
// Extract field suffix
|
|
4170
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
4171
|
+
if (!match) {
|
|
4172
|
+
// Keep non-field paths
|
|
4173
|
+
filteredVarSchema[path] = type;
|
|
4174
|
+
continue;
|
|
4175
|
+
}
|
|
4176
|
+
const fieldSuffix = match[1];
|
|
4177
|
+
// Only include if this entry owns this field
|
|
4178
|
+
if (fieldToEntryMap.get(fieldSuffix) === i) {
|
|
4179
|
+
filteredVarSchema[path] = type;
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
if (Object.keys(filteredVarSchema).length > 0) {
|
|
4183
|
+
filteredPerVarSchemas[varName] = filteredVarSchema;
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
entry.perVariableSchemas =
|
|
4187
|
+
Object.keys(filteredPerVarSchemas).length > 0
|
|
4188
|
+
? filteredPerVarSchemas
|
|
4189
|
+
: undefined;
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
return entries;
|
|
4193
|
+
};
|
|
4194
|
+
// Apply deduplication
|
|
4195
|
+
const deduplicatedExternalFunctionCalls = deduplicateParameterizedEntries(externalFunctionCalls);
|
|
4196
|
+
// IMPORTANT: Get equivalent signature variables BEFORE calling getFunctionResult
|
|
4197
|
+
// because getFunctionResult calls validateSchema which may remove equivalencies
|
|
4198
|
+
// during the finalize step (e.g., cleanNonObjectFunctions removes method call
|
|
4199
|
+
// equivalencies like `segments -> splat.split('/').functionCallReturnValue`).
|
|
4200
|
+
// Fix 33: Move this call before any schema validation to preserve method call chains.
|
|
4201
|
+
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
2688
4202
|
// Get root function result
|
|
2689
4203
|
const rootFunction = getFunctionResult();
|
|
2690
4204
|
// Get results for each external function (use cleaned calls for consistency)
|
|
@@ -2692,21 +4206,40 @@ export class ScopeDataStructure {
|
|
|
2692
4206
|
for (const efc of cleanedExternalCalls) {
|
|
2693
4207
|
functionResults[efc.name] = getFunctionResult(efc.name);
|
|
2694
4208
|
}
|
|
2695
|
-
// Get equivalent signature variables
|
|
2696
|
-
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
2697
4209
|
const environmentVariables = this.getEnvironmentVariables();
|
|
2698
4210
|
// Get enriched conditional usages with source tracing
|
|
2699
4211
|
const enrichedConditionalUsages = this.getEnrichedConditionalUsages();
|
|
2700
4212
|
const conditionalUsages = Object.keys(enrichedConditionalUsages).length > 0
|
|
2701
4213
|
? enrichedConditionalUsages
|
|
2702
4214
|
: undefined;
|
|
4215
|
+
// Get conditional effects (setter calls inside conditionals)
|
|
4216
|
+
const conditionalEffects = this.rawConditionalEffects.length > 0
|
|
4217
|
+
? this.rawConditionalEffects
|
|
4218
|
+
: undefined;
|
|
4219
|
+
// Get compound conditionals (grouped conditions that must all be true)
|
|
4220
|
+
const compoundConditionals = this.rawCompoundConditionals.length > 0
|
|
4221
|
+
? this.rawCompoundConditionals
|
|
4222
|
+
: undefined;
|
|
4223
|
+
// Get child boundary gating conditions
|
|
4224
|
+
const enrichedGatingConditions = this.getEnrichedChildBoundaryGatingConditions();
|
|
4225
|
+
const childBoundaryGatingConditions = Object.keys(enrichedGatingConditions).length > 0
|
|
4226
|
+
? enrichedGatingConditions
|
|
4227
|
+
: undefined;
|
|
4228
|
+
// Get JSX rendering usages (arrays via .map(), strings via interpolation)
|
|
4229
|
+
const jsxRenderingUsages = this.rawJsxRenderingUsages.length > 0
|
|
4230
|
+
? this.rawJsxRenderingUsages
|
|
4231
|
+
: undefined;
|
|
2703
4232
|
return {
|
|
2704
|
-
externalFunctionCalls,
|
|
4233
|
+
externalFunctionCalls: deduplicatedExternalFunctionCalls,
|
|
2705
4234
|
rootFunction,
|
|
2706
4235
|
functionResults,
|
|
2707
4236
|
equivalentSignatureVariables,
|
|
2708
4237
|
environmentVariables,
|
|
2709
4238
|
conditionalUsages,
|
|
4239
|
+
conditionalEffects,
|
|
4240
|
+
compoundConditionals,
|
|
4241
|
+
childBoundaryGatingConditions,
|
|
4242
|
+
jsxRenderingUsages,
|
|
2710
4243
|
};
|
|
2711
4244
|
}
|
|
2712
4245
|
// ═══════════════════════════════════════════════════════════════════════════
|