@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.6e699e5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +10 -6
- package/analyzer-template/packages/ai/index.ts +10 -3
- package/analyzer-template/packages/ai/package.json +1 -1
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +128 -6
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +138 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +140 -6
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1239 -104
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +304 -0
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1501 -138
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +103 -6
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +23 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +42 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +6 -0
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1111 -91
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +207 -104
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +570 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1977 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +276 -3
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +33 -3
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +90 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +812 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +123 -0
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +455 -267
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +18 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +265 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +588 -52
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +336 -133
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +156 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +461 -94
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +3 -3
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +4 -4
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +196 -0
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +5 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +224 -0
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +196 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +37 -18
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
- package/analyzer-template/playwright/takeScreenshot.ts +9 -7
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/analyzeBaselineCommit.ts +4 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +4 -0
- package/analyzer-template/project/constructMockCode.ts +1181 -160
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +82 -36
- package/analyzer-template/project/orchestrateCapture.ts +36 -3
- package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
- package/analyzer-template/project/serverOnlyModules.ts +194 -21
- package/analyzer-template/project/start.ts +26 -4
- package/analyzer-template/project/startScenarioCapture.ts +79 -41
- package/analyzer-template/project/writeMockDataTsx.ts +232 -57
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +769 -181
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +13 -15
- package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +1 -29
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/local/execAsync.js +1 -1
- package/background/src/lib/local/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/common/execAsync.js +1 -1
- package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +1053 -124
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +69 -32
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +27 -4
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +163 -23
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +21 -4
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +199 -50
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +552 -125
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +13 -13
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/src/cli.js +7 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +1 -1
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +174 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +40 -18
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +0 -15
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/recapture.js +226 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -0
- package/codeyam-cli/src/commands/report.js +72 -24
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +1 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +8 -13
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +14 -4
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +31 -17
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +245 -16
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +25 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/versionInfo.js +25 -19
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +98 -1
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +49 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BXhEawa3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Ba2JVPzP.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-C8lyxW9k.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-aht4aafF.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVtiBnY5.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-B0GLXMsr.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-xgeCVgSM.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-D4TZhLuw.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DuDvi0jm.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DEx02QDa.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-BwqWJOgH.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DoLIqZX2.js +37 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.rules-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-Cx24_aWc.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-CXRTFQ3F.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-BOARzkeR.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BdhJEx6B.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BRb-0kQl.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-C2N4Op8e.js +23 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D1T4TGjf.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-CTBG2mmz.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-CS2cb_eZ.js +29 -0
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DMJ7zii9.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-Cs4MdYtv.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-B4RJRvYB.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-commit-horizontal-CysbcZxi.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-DMUaGAqV.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-B1h680n5.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-lzqtyFU8.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-B7B9V-bu.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-f874c610.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-Bz5TunQg.js +57 -0
- package/codeyam-cli/src/webserver/build/client/assets/rules-hEkvVw2-.js +97 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-CxXUmBSd.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DwFIBT09.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B6LgvRJg.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C1v1PQzo.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-aSv48UbS.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DYxHZQuP.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-mBRpZPiu.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-967OuJoF.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-DRTmerg9.js +257 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/codeyam-power-rules-hook.sh +200 -0
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
- package/codeyam-cli/templates/codeyam:diagnose.md +650 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
- package/codeyam-cli/templates/codeyam:power-rules.md +447 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
- package/package.json +17 -16
- package/packages/ai/index.js +5 -4
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +99 -0
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +100 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +97 -6
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +945 -87
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +178 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1198 -82
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +16 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +86 -4
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +20 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +34 -3
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +111 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +5 -0
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +904 -84
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +186 -82
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +392 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1440 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +231 -4
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +26 -3
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +6 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +68 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +667 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +4 -0
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +15 -0
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +218 -50
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +10 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -7
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +209 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +458 -48
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +264 -78
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +96 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +372 -89
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +2 -2
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +6 -4
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
- package/codeyam-cli/templates/debug-command.md +0 -303
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -82,21 +82,34 @@
|
|
|
82
82
|
import { ScopeAnalysis } from '~codeyam/types';
|
|
83
83
|
import { EquivalencyManager } from './equivalencyManagers/EquivalencyManager';
|
|
84
84
|
import fillInSchemaGapsAndUnknowns from './helpers/fillInSchemaGapsAndUnknowns';
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Patterns that indicate recursive type structures in schema paths.
|
|
88
|
+
* Used by hasExcessivePatternRepetition() to detect exponential path blowup.
|
|
89
|
+
*/
|
|
90
|
+
const RECURSIVE_PATH_PATTERNS = [
|
|
91
|
+
/\.attributes\.properties\[\]/g, // TypeScript AST JSX nodes
|
|
92
|
+
/\.children\[\]/g, // Tree structures
|
|
93
|
+
/\.elements\[\]/g, // Array-like structures
|
|
94
|
+
/\.members\[\]/g, // Class/interface members
|
|
95
|
+
/\.properties\[\]/g, // Object properties
|
|
96
|
+
/\.items\[\]/g, // Generic items arrays
|
|
97
|
+
];
|
|
85
98
|
import ensureSchemaConsistency from './helpers/ensureSchemaConsistency';
|
|
86
99
|
import cleanPath from './helpers/cleanPath';
|
|
87
100
|
import { PathManager } from './helpers/PathManager';
|
|
88
101
|
import {
|
|
89
102
|
uniqueId,
|
|
90
|
-
uniqueScopeVariables,
|
|
91
103
|
uniqueScopeAndPaths,
|
|
104
|
+
uniqueScopeVariables,
|
|
92
105
|
} from './helpers/uniqueIdUtils';
|
|
93
106
|
import selectBestValue from './helpers/selectBestValue';
|
|
94
107
|
import { VisitedTracker } from './helpers/VisitedTracker';
|
|
95
108
|
import { DebugTracer } from './helpers/DebugTracer';
|
|
96
109
|
import { BatchSchemaProcessor } from './helpers/BatchSchemaProcessor';
|
|
97
110
|
import {
|
|
98
|
-
ScopeTreeManager,
|
|
99
111
|
ROOT_SCOPE_NAME,
|
|
112
|
+
ScopeTreeManager,
|
|
100
113
|
ScopeTreeNode,
|
|
101
114
|
} from './helpers/ScopeTreeManager';
|
|
102
115
|
import cleanScopeNodeName from './helpers/cleanScopeNodeName';
|
|
@@ -108,6 +121,7 @@ import type {
|
|
|
108
121
|
SerializableFunctionCallInfo,
|
|
109
122
|
SerializableFunctionResult,
|
|
110
123
|
SerializableScopeVariable,
|
|
124
|
+
EnrichedConditionalUsage,
|
|
111
125
|
} from '../worker/SerializableDataStructure';
|
|
112
126
|
|
|
113
127
|
/**
|
|
@@ -125,6 +139,21 @@ export interface ScopeInfo {
|
|
|
125
139
|
isStatic?: boolean;
|
|
126
140
|
isClassScope?: boolean;
|
|
127
141
|
analysis?: any;
|
|
142
|
+
/** For JSX child scopes, the original JSX tag name (e.g., 'ChildViewer') */
|
|
143
|
+
jsxTagName?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Gating conditions detected during JSX extraction (before JSX is simplified).
|
|
146
|
+
* Maps child component name to conditions that must be true for it to render.
|
|
147
|
+
* This is populated by processJSXForScope in isolateScopes.ts.
|
|
148
|
+
*/
|
|
149
|
+
extractedGatingConditions?: {
|
|
150
|
+
[childComponentName: string]: Array<{
|
|
151
|
+
path: string;
|
|
152
|
+
conditionType: 'truthiness' | 'comparison';
|
|
153
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
154
|
+
isNegated?: boolean;
|
|
155
|
+
}>;
|
|
156
|
+
};
|
|
128
157
|
}
|
|
129
158
|
|
|
130
159
|
/**
|
|
@@ -221,6 +250,22 @@ export interface FunctionCallInfo {
|
|
|
221
250
|
* For example: { "db.select(query1)": "result1", "db.select(query2)": "result2" }
|
|
222
251
|
*/
|
|
223
252
|
callSignatureToVariable?: Record<string, string>;
|
|
253
|
+
/**
|
|
254
|
+
* Stores individual schemas per call signature BEFORE merging.
|
|
255
|
+
* When multiple calls to the same function are merged into one FunctionCallInfo,
|
|
256
|
+
* this preserves each call's distinct schema.
|
|
257
|
+
* Key is the call signature (e.g., "useFetcher()").
|
|
258
|
+
* Used internally; converted to perVariableSchemas in toSerializable().
|
|
259
|
+
*/
|
|
260
|
+
perCallSignatureSchemas?: Record<string, Record<string, string>>;
|
|
261
|
+
/**
|
|
262
|
+
* Stores individual return value schemas per receiving variable, BEFORE merging.
|
|
263
|
+
* When multiple calls to the same function have different return types
|
|
264
|
+
* (e.g., useFetcher<UserData>() vs useFetcher<ReportData>()), this preserves
|
|
265
|
+
* each call's distinct schema for mock data generation.
|
|
266
|
+
* Key is the receiving variable name (e.g., "userFetcher", "reportFetcher").
|
|
267
|
+
*/
|
|
268
|
+
perVariableSchemas?: Record<string, Record<string, string>>;
|
|
224
269
|
}
|
|
225
270
|
|
|
226
271
|
/**
|
|
@@ -320,6 +365,10 @@ const ALLOWED_EQUIVALENCY_REASONS = new Set([
|
|
|
320
365
|
'propagated function call return sub-property equivalency',
|
|
321
366
|
'propagated parent-variable equivalency', // Added: propagate child scope equivalencies to parent scope when variable is defined in parent
|
|
322
367
|
'where was this function called from', // Added: tracks which scope called an external function
|
|
368
|
+
'MUI DataGrid renderCell params.row equivalency', // Added: links DataGrid renderCell params.row to rows array elements
|
|
369
|
+
'MUI Autocomplete getOptionLabel option equivalency', // Added: links Autocomplete getOptionLabel callback param to options array
|
|
370
|
+
'MUI Autocomplete renderOption option equivalency', // Added: links Autocomplete renderOption callback param to options array
|
|
371
|
+
'MUI Autocomplete option property equivalency', // Added: propagates property accesses from Autocomplete callbacks
|
|
323
372
|
]);
|
|
324
373
|
|
|
325
374
|
const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
@@ -364,6 +413,36 @@ export class ScopeDataStructure {
|
|
|
364
413
|
}>
|
|
365
414
|
> = {};
|
|
366
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Conditional effects collected during AST analysis.
|
|
418
|
+
* Tracks what setter calls happen inside conditionals (if, switch, ternary).
|
|
419
|
+
*/
|
|
420
|
+
private rawConditionalEffects: import('../astScopes/types').ConditionalEffect[] =
|
|
421
|
+
[];
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Compound conditionals collected during AST analysis.
|
|
425
|
+
* Groups conditions that must all be true together (e.g., a && b && c).
|
|
426
|
+
*/
|
|
427
|
+
private rawCompoundConditionals: import('../astScopes/types').CompoundConditional[] =
|
|
428
|
+
[];
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Gating conditions for child component boundaries.
|
|
432
|
+
* Maps child component name to the conditions that must be true for it to render.
|
|
433
|
+
*/
|
|
434
|
+
private rawChildBoundaryGatingConditions: Record<
|
|
435
|
+
string,
|
|
436
|
+
import('../astScopes/types').ConditionalUsage[]
|
|
437
|
+
> = {};
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* JSX rendering usages collected during AST analysis.
|
|
441
|
+
* Tracks arrays rendered via .map() and strings interpolated in JSX.
|
|
442
|
+
*/
|
|
443
|
+
private rawJsxRenderingUsages: import('../astScopes/types').JsxRenderingUsage[] =
|
|
444
|
+
[];
|
|
445
|
+
|
|
367
446
|
private lastAddToSchemaId = 0;
|
|
368
447
|
private lastEquivalencyId = 0;
|
|
369
448
|
private lastEquivalencyDatabaseId = 0;
|
|
@@ -382,6 +461,10 @@ export class ScopeDataStructure {
|
|
|
382
461
|
private externalFunctionCallsIndex: Map<string, FunctionCallInfo> | null =
|
|
383
462
|
null;
|
|
384
463
|
|
|
464
|
+
// Tracks internal functions that have been filtered out during captureCompleteSchema
|
|
465
|
+
// Prevents re-adding them via subsequent equivalency propagation (e.g., from getReturnValue)
|
|
466
|
+
private filteredInternalFunctions: Set<string> = new Set();
|
|
467
|
+
|
|
385
468
|
// Debug tracer for selective path/scope tracing
|
|
386
469
|
// Enable via: CODEYAM_DEBUG=true CODEYAM_DEBUG_PATHS="user.*,signature" npm test
|
|
387
470
|
private tracer: DebugTracer = new DebugTracer({
|
|
@@ -540,6 +623,8 @@ export class ScopeDataStructure {
|
|
|
540
623
|
const efcName = this.pathManager.stripGenerics(efc.name);
|
|
541
624
|
for (const manager of this.equivalencyManagers) {
|
|
542
625
|
if (manager.internalFunctions.has(efcName)) {
|
|
626
|
+
// Track this so we don't re-add it via subsequent finalize calls
|
|
627
|
+
this.filteredInternalFunctions.add(efcName);
|
|
543
628
|
return false;
|
|
544
629
|
}
|
|
545
630
|
}
|
|
@@ -567,13 +652,51 @@ export class ScopeDataStructure {
|
|
|
567
652
|
const baseName = this.pathManager.stripGenerics(
|
|
568
653
|
candidate.scopeNodeName,
|
|
569
654
|
);
|
|
655
|
+
// Check if this is a local variable path (doesn't contain function call pattern)
|
|
656
|
+
// Local variables like "surveys[]" or "items[]" are important for tracing data flow
|
|
657
|
+
// from parent to child components (e.g., surveys[] -> SurveyCard().signature[0].survey)
|
|
658
|
+
const isLocalVariablePath =
|
|
659
|
+
!candidate.schemaPath.includes('()') &&
|
|
660
|
+
!candidate.schemaPath.startsWith('signature[') &&
|
|
661
|
+
!candidate.schemaPath.startsWith('returnValue');
|
|
662
|
+
|
|
570
663
|
return (
|
|
571
664
|
validExternalFacingScopeNames.has(baseName) &&
|
|
572
665
|
(candidate.schemaPath.startsWith('signature[') ||
|
|
573
|
-
candidate.schemaPath.startsWith(baseName)
|
|
666
|
+
candidate.schemaPath.startsWith(baseName) ||
|
|
667
|
+
isLocalVariablePath) &&
|
|
574
668
|
!containsArrayMethod(candidate.schemaPath)
|
|
575
669
|
);
|
|
576
670
|
});
|
|
671
|
+
|
|
672
|
+
// If all sourceCandidates were filtered out (e.g., because they belonged to
|
|
673
|
+
// internal functions like useState), look for the highest-order intermediate
|
|
674
|
+
// that belongs to a valid external-facing scope
|
|
675
|
+
if (
|
|
676
|
+
entry.sourceCandidates.length === 0 &&
|
|
677
|
+
Object.keys(entry.intermediatesOrder).length > 0
|
|
678
|
+
) {
|
|
679
|
+
// Find intermediates that belong to valid external-facing scopes
|
|
680
|
+
const validIntermediates = Object.entries(entry.intermediatesOrder)
|
|
681
|
+
.filter(([pathId]) => {
|
|
682
|
+
const [scopeNodeName, schemaPath] = pathId.split('::');
|
|
683
|
+
if (!scopeNodeName || !schemaPath) return false;
|
|
684
|
+
const baseName = this.pathManager.stripGenerics(scopeNodeName);
|
|
685
|
+
return (
|
|
686
|
+
validExternalFacingScopeNames.has(baseName) &&
|
|
687
|
+
!containsArrayMethod(schemaPath)
|
|
688
|
+
);
|
|
689
|
+
})
|
|
690
|
+
.sort((a, b) => b[1] - a[1]); // Sort by order descending (highest first)
|
|
691
|
+
|
|
692
|
+
if (validIntermediates.length > 0) {
|
|
693
|
+
const [pathId] = validIntermediates[0];
|
|
694
|
+
const [scopeNodeName, schemaPath] = pathId.split('::');
|
|
695
|
+
if (scopeNodeName && schemaPath) {
|
|
696
|
+
entry.sourceCandidates.push({ scopeNodeName, schemaPath });
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
577
700
|
}
|
|
578
701
|
|
|
579
702
|
this.propagateSourceAndUsageEquivalencies(
|
|
@@ -904,8 +1027,8 @@ export class ScopeDataStructure {
|
|
|
904
1027
|
equivalencyValueChain?: EquivalencyValueChainItem[],
|
|
905
1028
|
traceId?: number,
|
|
906
1029
|
) {
|
|
907
|
-
// DEBUG: Detect infinite loops
|
|
908
1030
|
addEquivalencyCallCount++;
|
|
1031
|
+
|
|
909
1032
|
if (addEquivalencyCallCount > 50000) {
|
|
910
1033
|
console.error('INFINITE LOOP DETECTED in addEquivalency', {
|
|
911
1034
|
callCount: addEquivalencyCallCount,
|
|
@@ -1151,10 +1274,38 @@ export class ScopeDataStructure {
|
|
|
1151
1274
|
const existingFunctionCall =
|
|
1152
1275
|
this.getExternalFunctionCallsIndex().get(searchKey);
|
|
1153
1276
|
if (existingFunctionCall) {
|
|
1154
|
-
|
|
1277
|
+
// Preserve per-call schemas BEFORE merging to enable per-variable mock data.
|
|
1278
|
+
// This is critical for hooks like useFetcher<UserData>() vs useFetcher<ReportData>()
|
|
1279
|
+
// where each call returns different typed data.
|
|
1280
|
+
if (!existingFunctionCall.perCallSignatureSchemas) {
|
|
1281
|
+
// First merge - save the existing call's schema
|
|
1282
|
+
existingFunctionCall.perCallSignatureSchemas = {
|
|
1283
|
+
[existingFunctionCall.callSignature]: {
|
|
1284
|
+
...existingFunctionCall.schema,
|
|
1285
|
+
},
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
// Save the new call's schema before it gets merged
|
|
1289
|
+
existingFunctionCall.perCallSignatureSchemas[
|
|
1290
|
+
functionCallInfo.callSignature
|
|
1291
|
+
] = { ...functionCallInfo.schema };
|
|
1292
|
+
|
|
1293
|
+
// Merge schemas using selectBestValue to preserve specific types like 'null'
|
|
1294
|
+
// over generic types like 'unknown'. This ensures ref variables detected
|
|
1295
|
+
// earlier (marked as 'null') aren't overwritten by later 'unknown' values.
|
|
1296
|
+
const mergedSchema: Record<string, string> = {
|
|
1155
1297
|
...existingFunctionCall.schema,
|
|
1156
|
-
...functionCallInfo.schema,
|
|
1157
1298
|
};
|
|
1299
|
+
for (const key in functionCallInfo.schema) {
|
|
1300
|
+
const existingValue = existingFunctionCall.schema[key];
|
|
1301
|
+
const newValue = functionCallInfo.schema[key];
|
|
1302
|
+
mergedSchema[key] = selectBestValue(
|
|
1303
|
+
existingValue,
|
|
1304
|
+
newValue,
|
|
1305
|
+
newValue,
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
existingFunctionCall.schema = mergedSchema;
|
|
1158
1309
|
|
|
1159
1310
|
existingFunctionCall.equivalencies = {
|
|
1160
1311
|
...existingFunctionCall.equivalencies,
|
|
@@ -1187,8 +1338,15 @@ export class ScopeDataStructure {
|
|
|
1187
1338
|
);
|
|
1188
1339
|
|
|
1189
1340
|
if (isExternal) {
|
|
1190
|
-
this
|
|
1191
|
-
|
|
1341
|
+
// Check if this function was already filtered out as an internal function
|
|
1342
|
+
// (e.g., useState was filtered in captureCompleteSchema but finalize is trying to re-add it)
|
|
1343
|
+
const strippedName = this.pathManager.stripGenerics(
|
|
1344
|
+
functionCallInfo.name,
|
|
1345
|
+
);
|
|
1346
|
+
if (!this.filteredInternalFunctions.has(strippedName)) {
|
|
1347
|
+
this.externalFunctionCalls.push(functionCallInfo);
|
|
1348
|
+
this.invalidateExternalFunctionCallsIndex();
|
|
1349
|
+
}
|
|
1192
1350
|
}
|
|
1193
1351
|
}
|
|
1194
1352
|
}
|
|
@@ -1296,6 +1454,18 @@ export class ScopeDataStructure {
|
|
|
1296
1454
|
const equivalentSchemaPath = equivalentSchemaPathMap.get(remainingKey);
|
|
1297
1455
|
|
|
1298
1456
|
if (equivalentSchemaPath) {
|
|
1457
|
+
// Skip propagation when there's a structural mismatch:
|
|
1458
|
+
// - schemaPath ends with [] (array element, represents an object)
|
|
1459
|
+
// - equivalentSchemaPath doesn't end with [] (non-array prop, usually a scalar)
|
|
1460
|
+
// This prevents incorrectly typing array elements as strings when they're
|
|
1461
|
+
// equivalent to scalar props like JSX keys (e.g., workouts[] ↔ Card().key)
|
|
1462
|
+
const schemaPathEndsWithArray = schemaPath.endsWith('[]');
|
|
1463
|
+
const equivalentEndsWithArray = equivalentSchemaPath.endsWith('[]');
|
|
1464
|
+
if (schemaPathEndsWithArray !== equivalentEndsWithArray) {
|
|
1465
|
+
// Don't propagate between array element paths and non-array paths
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1299
1469
|
const value1 = scopeNode.schema[schemaPath];
|
|
1300
1470
|
const value2 = equivalentScopeNode.schema[equivalentSchemaPath];
|
|
1301
1471
|
|
|
@@ -1404,6 +1574,60 @@ export class ScopeDataStructure {
|
|
|
1404
1574
|
return this.pathManager.isValidPath(path);
|
|
1405
1575
|
}
|
|
1406
1576
|
|
|
1577
|
+
/**
|
|
1578
|
+
* Detects if a path contains excessive repetition of the same pattern.
|
|
1579
|
+
*
|
|
1580
|
+
* This prevents exponential blowup when analyzing recursive type structures.
|
|
1581
|
+
* For example, TypeScript AST nodes have `.attributes.properties[]` where each
|
|
1582
|
+
* property is also a node with `.attributes.properties[]`. Without this check,
|
|
1583
|
+
* paths like `signature[0].attributes.properties[].attributes.properties[].attributes.properties[]...`
|
|
1584
|
+
* would be generated exponentially.
|
|
1585
|
+
*
|
|
1586
|
+
* Two detection strategies:
|
|
1587
|
+
* 1. Known patterns: Check RECURSIVE_PATH_PATTERNS for common recursive structures
|
|
1588
|
+
* 2. Generic detection: For longer paths, detect any 2-3 part segment that repeats
|
|
1589
|
+
*
|
|
1590
|
+
* @param path - The schema path to check
|
|
1591
|
+
* @param maxRepetitions - Maximum allowed repetitions of any pattern (default: 2)
|
|
1592
|
+
* @returns true if the path has excessive repetition
|
|
1593
|
+
*/
|
|
1594
|
+
private hasExcessivePatternRepetition(
|
|
1595
|
+
path: string,
|
|
1596
|
+
maxRepetitions = 2,
|
|
1597
|
+
): boolean {
|
|
1598
|
+
// Check known recursive patterns
|
|
1599
|
+
for (const pattern of RECURSIVE_PATH_PATTERNS) {
|
|
1600
|
+
const matches = path.match(pattern);
|
|
1601
|
+
if (matches && matches.length > maxRepetitions) {
|
|
1602
|
+
return true;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
// For longer paths, detect any repeated multi-part segments we haven't explicitly listed
|
|
1607
|
+
const pathParts = this.splitPath(path);
|
|
1608
|
+
if (pathParts.length <= 6) {
|
|
1609
|
+
return false;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
// Check for repeated sequences of 2-3 consecutive parts
|
|
1613
|
+
for (let segmentLength = 2; segmentLength <= 3; segmentLength++) {
|
|
1614
|
+
const seen = new Map<string, number>();
|
|
1615
|
+
|
|
1616
|
+
for (let i = 0; i <= pathParts.length - segmentLength; i++) {
|
|
1617
|
+
const segment = pathParts.slice(i, i + segmentLength).join('.');
|
|
1618
|
+
const normalizedSegment = segment.replace(/\[\d+\]/g, '[]');
|
|
1619
|
+
const count = (seen.get(normalizedSegment) || 0) + 1;
|
|
1620
|
+
seen.set(normalizedSegment, count);
|
|
1621
|
+
|
|
1622
|
+
if (count > maxRepetitions) {
|
|
1623
|
+
return true;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
return false;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1407
1631
|
private addToTree(pathParts: string[]) {
|
|
1408
1632
|
this.scopeTreeManager.addPath(pathParts);
|
|
1409
1633
|
}
|
|
@@ -1472,44 +1696,13 @@ export class ScopeDataStructure {
|
|
|
1472
1696
|
}
|
|
1473
1697
|
|
|
1474
1698
|
private determineEquivalenciesAndBuildSchema(scopeNode: ScopeNode) {
|
|
1699
|
+
if (!scopeNode.analysis) {
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1475
1703
|
const { isolatedStructure, isolatedEquivalentVariables } =
|
|
1476
1704
|
scopeNode.analysis;
|
|
1477
1705
|
|
|
1478
|
-
// DEBUG: Log all equivalencies related to useFetcher
|
|
1479
|
-
if (
|
|
1480
|
-
Object.keys(isolatedEquivalentVariables || {}).some(
|
|
1481
|
-
(k) => k.includes('Fetcher') || k.includes('fetcher'),
|
|
1482
|
-
)
|
|
1483
|
-
) {
|
|
1484
|
-
console.log(
|
|
1485
|
-
'CodeYam DEBUG determineEquivalenciesAndBuildSchema:',
|
|
1486
|
-
JSON.stringify(
|
|
1487
|
-
{
|
|
1488
|
-
scopeNodeName: scopeNode.name,
|
|
1489
|
-
fetcherEquivalencies: Object.entries(
|
|
1490
|
-
isolatedEquivalentVariables || {},
|
|
1491
|
-
)
|
|
1492
|
-
.filter(
|
|
1493
|
-
([k, v]) =>
|
|
1494
|
-
k.includes('Fetcher') ||
|
|
1495
|
-
k.includes('fetcher') ||
|
|
1496
|
-
String(v).includes('Fetcher') ||
|
|
1497
|
-
String(v).includes('fetcher'),
|
|
1498
|
-
)
|
|
1499
|
-
.reduce(
|
|
1500
|
-
(acc, [k, v]) => {
|
|
1501
|
-
acc[k] = v;
|
|
1502
|
-
return acc;
|
|
1503
|
-
},
|
|
1504
|
-
{} as Record<string, string>,
|
|
1505
|
-
),
|
|
1506
|
-
},
|
|
1507
|
-
null,
|
|
1508
|
-
2,
|
|
1509
|
-
),
|
|
1510
|
-
);
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
1706
|
const allPaths = Array.from(
|
|
1514
1707
|
new Set([
|
|
1515
1708
|
...Object.keys(isolatedStructure || {}),
|
|
@@ -1522,11 +1715,24 @@ export class ScopeDataStructure {
|
|
|
1522
1715
|
let equivalentValue = isolatedEquivalentVariables?.[path];
|
|
1523
1716
|
|
|
1524
1717
|
if (equivalentValue && this.isValidPath(equivalentValue)) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1718
|
+
// IMPORTANT: DO NOT strip ::cyDuplicateKey:: markers from equivalencies.
|
|
1719
|
+
// These markers are critical for distinguishing variable reassignments.
|
|
1720
|
+
// For example, with:
|
|
1721
|
+
// let fetcher = useFetcher<ConfigData>();
|
|
1722
|
+
// const configData = fetcher.data?.data;
|
|
1723
|
+
// fetcher = useFetcher<SettingsData>();
|
|
1724
|
+
// const settingsData = fetcher.data?.data;
|
|
1725
|
+
//
|
|
1726
|
+
// mergeStatements creates:
|
|
1727
|
+
// fetcher → useFetcher<ConfigData>()...
|
|
1728
|
+
// fetcher::cyDuplicateKey1:: → useFetcher<SettingsData>()...
|
|
1729
|
+
// configData → fetcher.data.data
|
|
1730
|
+
// settingsData → fetcher::cyDuplicateKey1::.data.data
|
|
1731
|
+
//
|
|
1732
|
+
// If we strip ::cyDuplicateKey::, settingsData would incorrectly trace
|
|
1733
|
+
// to useFetcher<ConfigData>() instead of useFetcher<SettingsData>().
|
|
1734
|
+
path = cleanPath(path, allPaths);
|
|
1735
|
+
equivalentValue = cleanPath(equivalentValue, allPaths);
|
|
1530
1736
|
|
|
1531
1737
|
this.addEquivalency(
|
|
1532
1738
|
path,
|
|
@@ -1672,7 +1878,7 @@ export class ScopeDataStructure {
|
|
|
1672
1878
|
this.batchProcessor = new BatchSchemaProcessor();
|
|
1673
1879
|
this.batchQueuedSet = new Set();
|
|
1674
1880
|
|
|
1675
|
-
for (const key of
|
|
1881
|
+
for (const key of allPaths) {
|
|
1676
1882
|
let value = isolatedStructure[key] ?? 'unknown';
|
|
1677
1883
|
|
|
1678
1884
|
if (['null', 'undefined'].includes(value)) {
|
|
@@ -1713,7 +1919,19 @@ export class ScopeDataStructure {
|
|
|
1713
1919
|
private processBatchQueue(): void {
|
|
1714
1920
|
if (!this.batchProcessor) return;
|
|
1715
1921
|
|
|
1922
|
+
let iterations = 0;
|
|
1923
|
+
|
|
1716
1924
|
while (this.batchProcessor.hasWork()) {
|
|
1925
|
+
iterations++;
|
|
1926
|
+
|
|
1927
|
+
// Safety: detect potential infinite loops
|
|
1928
|
+
if (iterations > 100000) {
|
|
1929
|
+
console.error(
|
|
1930
|
+
`[ScopeDataStructure] processBatchQueue exceeded 100k iterations, possible infinite loop!`,
|
|
1931
|
+
);
|
|
1932
|
+
break;
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1717
1935
|
const item = this.batchProcessor.getNextWork();
|
|
1718
1936
|
if (!item) break;
|
|
1719
1937
|
|
|
@@ -1771,26 +1989,6 @@ export class ScopeDataStructure {
|
|
|
1771
1989
|
const functionCallInfo =
|
|
1772
1990
|
this.getExternalFunctionCallsIndex().get(searchKey);
|
|
1773
1991
|
|
|
1774
|
-
// DEBUG: Track useFetcher calls
|
|
1775
|
-
if (searchKey === 'useFetcher' || callSignature.includes('useFetcher')) {
|
|
1776
|
-
console.log(
|
|
1777
|
-
'CodeYam DEBUG trackReceivingVariable:',
|
|
1778
|
-
JSON.stringify(
|
|
1779
|
-
{
|
|
1780
|
-
receivingVariable,
|
|
1781
|
-
equivalentValue,
|
|
1782
|
-
callSignature,
|
|
1783
|
-
searchKey,
|
|
1784
|
-
foundFunctionCallInfo: !!functionCallInfo,
|
|
1785
|
-
existingRecvVars: functionCallInfo?.receivingVariableNames,
|
|
1786
|
-
existingCallSigToVar: functionCallInfo?.callSignatureToVariable,
|
|
1787
|
-
},
|
|
1788
|
-
null,
|
|
1789
|
-
2,
|
|
1790
|
-
),
|
|
1791
|
-
);
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
1992
|
if (!functionCallInfo) {
|
|
1795
1993
|
return;
|
|
1796
1994
|
}
|
|
@@ -2290,6 +2488,21 @@ export class ScopeDataStructure {
|
|
|
2290
2488
|
|
|
2291
2489
|
const newEquivalentPath = this.joinPathParts([schemaPath, remainingPath]);
|
|
2292
2490
|
|
|
2491
|
+
// PERF: Detect repeated patterns in paths to prevent exponential blowup
|
|
2492
|
+
// Paths like `signature[0].attributes.properties[].attributes.properties[]...`
|
|
2493
|
+
// indicate recursive type structures that cause exponential schema explosion
|
|
2494
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
2495
|
+
if (traceId && debugLevel > 0) {
|
|
2496
|
+
console.info(
|
|
2497
|
+
'Debug: skipping path with excessive pattern repetition',
|
|
2498
|
+
{
|
|
2499
|
+
path: newEquivalentPath,
|
|
2500
|
+
},
|
|
2501
|
+
);
|
|
2502
|
+
}
|
|
2503
|
+
continue;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2293
2506
|
if (!equivalentScopeNode) {
|
|
2294
2507
|
if (traceId) {
|
|
2295
2508
|
console.info('Debug Propagation: missing equivalent scope info', {
|
|
@@ -3160,7 +3373,12 @@ export class ScopeDataStructure {
|
|
|
3160
3373
|
);
|
|
3161
3374
|
}
|
|
3162
3375
|
|
|
3376
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
3377
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
3378
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
3379
|
+
this.onlyEquivalencies = true;
|
|
3163
3380
|
this.validateSchema(scopeNode, true, fillInUnknowns);
|
|
3381
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
3164
3382
|
|
|
3165
3383
|
const { schema } = scopeNode;
|
|
3166
3384
|
|
|
@@ -3194,10 +3412,29 @@ export class ScopeDataStructure {
|
|
|
3194
3412
|
}
|
|
3195
3413
|
}
|
|
3196
3414
|
}
|
|
3197
|
-
return mergedSchema;
|
|
3415
|
+
return this.filterDuplicateKeys(mergedSchema);
|
|
3198
3416
|
}
|
|
3199
3417
|
|
|
3200
|
-
return schema;
|
|
3418
|
+
return this.filterDuplicateKeys(schema);
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
/**
|
|
3422
|
+
* Filter out ::cyDuplicateKey:: entries from a schema.
|
|
3423
|
+
* These are internal markers for tracking variable reassignments
|
|
3424
|
+
* and should not appear in output schemas or LLM prompts.
|
|
3425
|
+
*/
|
|
3426
|
+
private filterDuplicateKeys(
|
|
3427
|
+
schema: Record<string, string>,
|
|
3428
|
+
): Record<string, string> {
|
|
3429
|
+
return Object.entries(schema).reduce(
|
|
3430
|
+
(acc, [key, value]) => {
|
|
3431
|
+
if (!key.includes('::cyDuplicateKey')) {
|
|
3432
|
+
acc[key] = value;
|
|
3433
|
+
}
|
|
3434
|
+
return acc;
|
|
3435
|
+
},
|
|
3436
|
+
{} as Record<string, string>,
|
|
3437
|
+
);
|
|
3201
3438
|
}
|
|
3202
3439
|
|
|
3203
3440
|
getEquivalencies(scopeName?: string) {
|
|
@@ -3261,6 +3498,7 @@ export class ScopeDataStructure {
|
|
|
3261
3498
|
(candidate) => candidate.scopeNodeName === scopeNode.name,
|
|
3262
3499
|
),
|
|
3263
3500
|
);
|
|
3501
|
+
|
|
3264
3502
|
return entries.reduce(
|
|
3265
3503
|
(acc, entry) => {
|
|
3266
3504
|
if (entry.usages.length === 0) return acc;
|
|
@@ -3304,12 +3542,14 @@ export class ScopeDataStructure {
|
|
|
3304
3542
|
);
|
|
3305
3543
|
|
|
3306
3544
|
const equivalencies = this.getEquivalencies(functionName);
|
|
3545
|
+
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
3546
|
+
|
|
3307
3547
|
for (const equivalenceKey in equivalencies ?? {}) {
|
|
3308
3548
|
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
3309
3549
|
const schemaPath = equivalenceValue.schemaPath;
|
|
3310
3550
|
if (
|
|
3311
3551
|
schemaPath.startsWith('signature[') &&
|
|
3312
|
-
equivalenceValue.scopeNodeName ===
|
|
3552
|
+
equivalenceValue.scopeNodeName === scopeName &&
|
|
3313
3553
|
!signatureInSchema[schemaPath]
|
|
3314
3554
|
) {
|
|
3315
3555
|
signatureInSchema[schemaPath] = 'unknown';
|
|
@@ -3325,7 +3565,60 @@ export class ScopeDataStructure {
|
|
|
3325
3565
|
|
|
3326
3566
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
3327
3567
|
|
|
3328
|
-
|
|
3568
|
+
// After validateSchema has filled in types, propagate nested paths from
|
|
3569
|
+
// variables to their signature equivalents.
|
|
3570
|
+
// e.g., workouts[].activity_type -> signature[0].workouts[].activity_type
|
|
3571
|
+
//
|
|
3572
|
+
// Build a map of variable names that are equivalent to signature paths
|
|
3573
|
+
// e.g., { 'workouts': 'signature[0].workouts' }
|
|
3574
|
+
const variableToSignatureMap: Record<string, string> = {};
|
|
3575
|
+
|
|
3576
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
3577
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
3578
|
+
const schemaPath = equivalenceValue.schemaPath;
|
|
3579
|
+
// Track which variables map to signature paths
|
|
3580
|
+
// equivalenceKey is the variable name (e.g., 'workouts')
|
|
3581
|
+
// schemaPath is where it comes from (e.g., 'signature[0].workouts')
|
|
3582
|
+
if (
|
|
3583
|
+
schemaPath.startsWith('signature[') &&
|
|
3584
|
+
equivalenceValue.scopeNodeName === scopeName
|
|
3585
|
+
) {
|
|
3586
|
+
variableToSignatureMap[equivalenceKey] = schemaPath;
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
// Propagate nested paths from variables to their signature equivalents
|
|
3592
|
+
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
3593
|
+
// signature[0].workouts[].title
|
|
3594
|
+
for (const schemaKey in schema) {
|
|
3595
|
+
// Skip keys that already start with signature[
|
|
3596
|
+
if (schemaKey.startsWith('signature[')) continue;
|
|
3597
|
+
|
|
3598
|
+
// Check if this key starts with a variable that maps to a signature path
|
|
3599
|
+
for (const [variableName, signaturePath] of Object.entries(
|
|
3600
|
+
variableToSignatureMap,
|
|
3601
|
+
)) {
|
|
3602
|
+
// Check if schemaKey starts with variableName followed by a property accessor
|
|
3603
|
+
// e.g., 'workouts[]' starts with 'workouts'
|
|
3604
|
+
if (
|
|
3605
|
+
schemaKey === variableName ||
|
|
3606
|
+
schemaKey.startsWith(variableName + '.') ||
|
|
3607
|
+
schemaKey.startsWith(variableName + '[')
|
|
3608
|
+
) {
|
|
3609
|
+
// Transform the path: replace the variable prefix with the signature path
|
|
3610
|
+
const suffix = schemaKey.slice(variableName.length);
|
|
3611
|
+
const signatureKey = signaturePath + suffix;
|
|
3612
|
+
|
|
3613
|
+
// Add to schema if not already present
|
|
3614
|
+
if (!tempScopeNode.schema[signatureKey]) {
|
|
3615
|
+
tempScopeNode.schema[signatureKey] = schema[schemaKey];
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
return this.filterDuplicateKeys(tempScopeNode.schema);
|
|
3329
3622
|
}
|
|
3330
3623
|
|
|
3331
3624
|
getReturnValue({
|
|
@@ -3335,6 +3628,15 @@ export class ScopeDataStructure {
|
|
|
3335
3628
|
functionName?: string;
|
|
3336
3629
|
fillInUnknowns?: boolean;
|
|
3337
3630
|
}) {
|
|
3631
|
+
// Trigger finalization on all managers to apply any pending updates
|
|
3632
|
+
// (e.g., ref type propagation to external function call schemas)
|
|
3633
|
+
const rootScope = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
3634
|
+
if (rootScope) {
|
|
3635
|
+
for (const manager of this.equivalencyManagers) {
|
|
3636
|
+
manager.finalize(rootScope, this);
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3338
3640
|
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
3339
3641
|
const scopeNode = this.scopeNodes[scopeName];
|
|
3340
3642
|
|
|
@@ -3345,7 +3647,8 @@ export class ScopeDataStructure {
|
|
|
3345
3647
|
scopeNode: scopeNode,
|
|
3346
3648
|
});
|
|
3347
3649
|
} else {
|
|
3348
|
-
|
|
3650
|
+
// Use getExternalFunctionCalls() which cleans cyScope from schemas
|
|
3651
|
+
for (const externalFunctionCall of this.getExternalFunctionCalls()) {
|
|
3349
3652
|
const functionNameParts = this.splitPath(functionName).map((p) =>
|
|
3350
3653
|
this.functionOrScopeName(p),
|
|
3351
3654
|
);
|
|
@@ -3377,7 +3680,17 @@ export class ScopeDataStructure {
|
|
|
3377
3680
|
// Include function paths even if their return value wasn't captured
|
|
3378
3681
|
// This ensures methods like onAuthStateChange are included in the schema
|
|
3379
3682
|
// But exclude signature entries (they should only be included via functionCallReturnValue paths)
|
|
3380
|
-
|
|
3683
|
+
// Also exclude bare function call signatures - paths that are JUST a call like
|
|
3684
|
+
// "useCustomSizes(projectSlug)" should not be included as return values.
|
|
3685
|
+
// These represent "the function exists" not actual return data, and including
|
|
3686
|
+
// them causes nested path bugs in dependencySchemas.
|
|
3687
|
+
(schema[key] === 'function' &&
|
|
3688
|
+
key.indexOf('signature[') === -1 &&
|
|
3689
|
+
// Exclude bare call signatures: function calls with no dots OUTSIDE parentheses
|
|
3690
|
+
// e.g., "useCustomSizes(projectSlug)" is bare (exclude)
|
|
3691
|
+
// e.g., "loadProject({nested.property})" is bare - dots are inside args (exclude)
|
|
3692
|
+
// e.g., "getSupabase().auth.method()" has dots outside - method chain (include)
|
|
3693
|
+
!this.isBareCallSignature(key)),
|
|
3381
3694
|
)
|
|
3382
3695
|
.reduce(
|
|
3383
3696
|
(acc, key) => {
|
|
@@ -3387,7 +3700,10 @@ export class ScopeDataStructure {
|
|
|
3387
3700
|
for (const path in schema) {
|
|
3388
3701
|
const pathParts = this.splitPath(path);
|
|
3389
3702
|
if (pathParts.every((p, i) => keyParts[i] === p)) {
|
|
3390
|
-
|
|
3703
|
+
// Also exclude bare call signatures from prefix paths
|
|
3704
|
+
if (!this.isBareCallSignature(path)) {
|
|
3705
|
+
acc[path] = schema[path];
|
|
3706
|
+
}
|
|
3391
3707
|
}
|
|
3392
3708
|
}
|
|
3393
3709
|
|
|
@@ -3401,14 +3717,73 @@ export class ScopeDataStructure {
|
|
|
3401
3717
|
|
|
3402
3718
|
const tempScopeNode = this.createTempScopeNode(scopeName, resolvedSchema);
|
|
3403
3719
|
|
|
3720
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
3721
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
3722
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
3723
|
+
this.onlyEquivalencies = true;
|
|
3404
3724
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
3725
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
3726
|
+
|
|
3727
|
+
// Remove bare call signatures from the return value schema.
|
|
3728
|
+
// fillInSchemaGapsAndUnknowns may add parent paths like "useCustomSizes(projectSlug)"
|
|
3729
|
+
// when it sees "useCustomSizes(projectSlug).functionCallReturnValue". These bare
|
|
3730
|
+
// call signatures represent "the function exists" not actual return data, and
|
|
3731
|
+
// including them causes nested path bugs in dependencySchemas.
|
|
3732
|
+
const resultSchema = tempScopeNode.schema;
|
|
3733
|
+
for (const key of Object.keys(resultSchema)) {
|
|
3734
|
+
if (this.isBareCallSignature(key)) {
|
|
3735
|
+
delete resultSchema[key];
|
|
3736
|
+
}
|
|
3737
|
+
}
|
|
3405
3738
|
|
|
3406
|
-
return
|
|
3739
|
+
return resultSchema;
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3742
|
+
/**
|
|
3743
|
+
* Checks if a schema key is a "bare call signature" - a function call with no
|
|
3744
|
+
* method chain before it and no path segments after it.
|
|
3745
|
+
*
|
|
3746
|
+
* A bare call signature represents "this function exists" rather than actual
|
|
3747
|
+
* return data, and including them causes nested path bugs in dependencySchemas.
|
|
3748
|
+
*
|
|
3749
|
+
* Examples:
|
|
3750
|
+
* - "useCustomSizes(projectSlug)" -> bare (true)
|
|
3751
|
+
* - "loadProject({nested.property})" -> bare (dots are inside args, true)
|
|
3752
|
+
* - "getSupabase().auth.method()" -> not bare (has dots outside parens, false)
|
|
3753
|
+
* - "useProject().functionCallReturnValue" -> not bare (has path after, false)
|
|
3754
|
+
*/
|
|
3755
|
+
private isBareCallSignature(key: string): boolean {
|
|
3756
|
+
// Must end with ) and contain ( to be a call
|
|
3757
|
+
if (!key.endsWith(')') || key.indexOf('(') === -1) {
|
|
3758
|
+
return false;
|
|
3759
|
+
}
|
|
3760
|
+
|
|
3761
|
+
// Check if there are any dots OUTSIDE of parentheses
|
|
3762
|
+
// Strip out content inside balanced parentheses, then check for dots
|
|
3763
|
+
let depth = 0;
|
|
3764
|
+
let hasDotsOutsideParens = false;
|
|
3765
|
+
|
|
3766
|
+
for (let i = 0; i < key.length; i++) {
|
|
3767
|
+
const char = key[i];
|
|
3768
|
+
if (char === '(') {
|
|
3769
|
+
depth++;
|
|
3770
|
+
} else if (char === ')') {
|
|
3771
|
+
depth--;
|
|
3772
|
+
} else if (char === '.' && depth === 0) {
|
|
3773
|
+
hasDotsOutsideParens = true;
|
|
3774
|
+
break;
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3778
|
+
// It's a bare call signature if there are no dots outside parentheses
|
|
3779
|
+
return !hasDotsOutsideParens;
|
|
3407
3780
|
}
|
|
3408
3781
|
|
|
3409
3782
|
/**
|
|
3410
3783
|
* Replaces cyScope placeholder references (e.g., cyScope10()) in schema keys
|
|
3411
3784
|
* with the actual callback function text from the corresponding scope node.
|
|
3785
|
+
* If the scope text can't be found, uses a generic fallback to avoid leaking
|
|
3786
|
+
* internal cyScope names into stored data.
|
|
3412
3787
|
*/
|
|
3413
3788
|
private replaceCyScopePlaceholders(
|
|
3414
3789
|
schema: Record<string, string>,
|
|
@@ -3424,10 +3799,10 @@ export class ScopeDataStructure {
|
|
|
3424
3799
|
for (const match of matches) {
|
|
3425
3800
|
const cyScopeName = `cyScope${match[1]}`;
|
|
3426
3801
|
const scopeText = this.findCyScopeText(cyScopeName);
|
|
3427
|
-
if
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3802
|
+
// Always replace cyScope references - use actual text if available,
|
|
3803
|
+
// otherwise use a generic callback placeholder
|
|
3804
|
+
const replacement = scopeText || '() => {}';
|
|
3805
|
+
newKey = newKey.replace(match[0], replacement);
|
|
3431
3806
|
}
|
|
3432
3807
|
|
|
3433
3808
|
result[newKey] = value;
|
|
@@ -3493,12 +3868,315 @@ export class ScopeDataStructure {
|
|
|
3493
3868
|
scopeNode.equivalencies,
|
|
3494
3869
|
)) {
|
|
3495
3870
|
for (const equivalentValue of equivalentValues) {
|
|
3871
|
+
// Case 1: Props/signature equivalencies (existing behavior)
|
|
3872
|
+
// Maps local variable names to their signature paths
|
|
3873
|
+
// e.g., "propValue" -> "signature[0].prop"
|
|
3496
3874
|
if (path.startsWith('signature[')) {
|
|
3497
3875
|
equivalentSignatureVariables[equivalentValue.schemaPath] = path;
|
|
3498
3876
|
}
|
|
3877
|
+
|
|
3878
|
+
// Case 2: Hook variable equivalencies (new behavior)
|
|
3879
|
+
// The equivalencies are stored as: path = variable name, schemaPath = data source
|
|
3880
|
+
// e.g., path = "debugFetcher", schemaPath = "useFetcher<...>().functionCallReturnValue"
|
|
3881
|
+
// We need to map: "debugFetcher" -> "useFetcher<...>()"
|
|
3882
|
+
// This enables resolving paths like "debugFetcher.state" to
|
|
3883
|
+
// "useFetcher<...>().state" for execution flow validation
|
|
3884
|
+
if (equivalentValue.schemaPath.endsWith('.functionCallReturnValue')) {
|
|
3885
|
+
// Extract the hook call path (everything before .functionCallReturnValue)
|
|
3886
|
+
let hookCallPath = equivalentValue.schemaPath.slice(
|
|
3887
|
+
0,
|
|
3888
|
+
-'.functionCallReturnValue'.length,
|
|
3889
|
+
);
|
|
3890
|
+
// Only include if it looks like a hook call (contains parentheses)
|
|
3891
|
+
// and the variable name (path) is a simple identifier (no dots)
|
|
3892
|
+
if (hookCallPath.includes('(') && !path.includes('.')) {
|
|
3893
|
+
// Special case: If hookCallPath is a callback scope (cyScope pattern),
|
|
3894
|
+
// trace through it to find what the callback actually returns.
|
|
3895
|
+
// This handles useState(() => { return prop; }) patterns.
|
|
3896
|
+
const cyScopeMatch = hookCallPath.match(/^(cyScope\d+)\(\)$/);
|
|
3897
|
+
if (cyScopeMatch) {
|
|
3898
|
+
// Use the equivalency database to trace the callback's return value
|
|
3899
|
+
// to its actual source (e.g., viewModeFromUrl -> segments -> params -> useParams)
|
|
3900
|
+
const dbEntry = this.getEquivalenciesDatabaseEntry(
|
|
3901
|
+
scopeNode.name, // Component scope
|
|
3902
|
+
path, // variable name (e.g., viewMode)
|
|
3903
|
+
);
|
|
3904
|
+
if (dbEntry?.sourceCandidates?.length > 0) {
|
|
3905
|
+
// Use the traced source instead of the callback scope
|
|
3906
|
+
hookCallPath = dbEntry.sourceCandidates[0].schemaPath;
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
equivalentSignatureVariables[path] = hookCallPath;
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3913
|
+
// Case 3: Destructured variables from local variables
|
|
3914
|
+
// e.g., const { scenarios } = currentEntityAnalysis;
|
|
3915
|
+
// This creates: path = "scenarios", schemaPath = "currentEntityAnalysis.scenarios"
|
|
3916
|
+
// We need to map: "scenarios" -> "currentEntityAnalysis.scenarios"
|
|
3917
|
+
// AND resolve transitively if currentEntityAnalysis is itself equivalent to a hook call
|
|
3918
|
+
if (
|
|
3919
|
+
!path.includes('.') && // path is a simple identifier
|
|
3920
|
+
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
3921
|
+
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
3922
|
+
) {
|
|
3923
|
+
// Only add if we haven't already captured this variable in Case 1 or 2
|
|
3924
|
+
if (!(path in equivalentSignatureVariables)) {
|
|
3925
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
|
|
3929
|
+
// Case 4: Child component prop mappings (Fix 22)
|
|
3930
|
+
// When parent renders <ChildComponent prop={value} />, we get equivalencies like:
|
|
3931
|
+
// path = "ChildComponent().signature[0].prop"
|
|
3932
|
+
// schemaPath = "value" (the variable passed as the prop)
|
|
3933
|
+
// We need to include these so translateChildPathToParent can work.
|
|
3934
|
+
// Pattern: ComponentName().signature[N] or ComponentName().signature[N].propName
|
|
3935
|
+
if (
|
|
3936
|
+
path.includes('().signature[') &&
|
|
3937
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable, not a function call
|
|
3938
|
+
) {
|
|
3939
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
// Case 5: Destructured function parameters (Fix 25)
|
|
3943
|
+
// When a function has destructured props: function Comp({ propA, propB }: Props)
|
|
3944
|
+
// We get equivalencies like:
|
|
3945
|
+
// path = "propA" (the destructured variable name)
|
|
3946
|
+
// schemaPath = "signature[0].propA" (the signature path)
|
|
3947
|
+
// We need to map: "propA" -> "signature[0].propA"
|
|
3948
|
+
// This enables translateChildPathToParent to resolve child variable paths
|
|
3949
|
+
// to their signature paths when merging execution flows.
|
|
3950
|
+
if (
|
|
3951
|
+
!path.includes('.') && // path is a simple identifier (destructured prop name)
|
|
3952
|
+
equivalentValue.schemaPath.startsWith('signature[') // schemaPath IS a signature path
|
|
3953
|
+
) {
|
|
3954
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
3955
|
+
}
|
|
3956
|
+
|
|
3957
|
+
// Case 7: Method calls on variables that result in .functionCallReturnValue (Fix 33)
|
|
3958
|
+
// When we have patterns like:
|
|
3959
|
+
// path = "segments" (simple identifier)
|
|
3960
|
+
// schemaPath = "splat.split('/').functionCallReturnValue"
|
|
3961
|
+
// This is a method call on a variable (not a hook call), but we still need to
|
|
3962
|
+
// track it so transitive resolution can resolve `splat` to its actual source.
|
|
3963
|
+
// E.g., if splat -> useParams().functionCallReturnValue['*'], then
|
|
3964
|
+
// segments -> useParams().functionCallReturnValue['*'].split('/').functionCallReturnValue
|
|
3965
|
+
if (
|
|
3966
|
+
!path.includes('.') && // path is a simple identifier
|
|
3967
|
+
equivalentValue.schemaPath.endsWith('.functionCallReturnValue') && // ends with function return
|
|
3968
|
+
equivalentValue.schemaPath.includes('.') && // has property access (method call)
|
|
3969
|
+
!(path in equivalentSignatureVariables) // not already captured
|
|
3970
|
+
) {
|
|
3971
|
+
// Check if this looks like a method call on a variable (not a hook call)
|
|
3972
|
+
// Hook calls look like: hookName() or hookName<T>()
|
|
3973
|
+
// Method calls look like: variable.method() or variable.method<T>()
|
|
3974
|
+
const hookCallPath = equivalentValue.schemaPath.slice(
|
|
3975
|
+
0,
|
|
3976
|
+
-'.functionCallReturnValue'.length,
|
|
3977
|
+
);
|
|
3978
|
+
// If it's a method call (contains a dot before the parenthesis), include it
|
|
3979
|
+
const dotBeforeParen = hookCallPath.indexOf('.');
|
|
3980
|
+
const parenPos = hookCallPath.indexOf('(');
|
|
3981
|
+
if (dotBeforeParen !== -1 && dotBeforeParen < parenPos) {
|
|
3982
|
+
// This is a method call like "splat.split('/')", not a hook call
|
|
3983
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3499
3986
|
}
|
|
3500
3987
|
}
|
|
3501
3988
|
|
|
3989
|
+
// Case 6: Collect JSX child prop equivalencies from child scopes (Fix 26)
|
|
3990
|
+
// When a parent component renders <ChildComponent prop={value} />, the JSX
|
|
3991
|
+
// return statement may be in a child scope (e.g., cyScope2). The equivalencies
|
|
3992
|
+
// like ChildComponent().signature[0].prop -> value get stored in that child scope.
|
|
3993
|
+
// But translateChildPathToParent needs to find them from the parent scope's context.
|
|
3994
|
+
// So we collect Case 4 patterns from ALL child scopes that belong to this root scope.
|
|
3995
|
+
const rootName = this.scopeTreeManager.getRootName();
|
|
3996
|
+
for (const [scopeName, childScopeNode] of Object.entries(this.scopeNodes)) {
|
|
3997
|
+
// Skip the root scope (already processed above)
|
|
3998
|
+
if (scopeName === rootName) continue;
|
|
3999
|
+
|
|
4000
|
+
// Only include scopes that are children of the root (their tree includes root)
|
|
4001
|
+
if (!childScopeNode.tree?.includes(rootName)) continue;
|
|
4002
|
+
|
|
4003
|
+
// Look for Case 4 patterns in the child scope
|
|
4004
|
+
for (const [path, equivalentValues] of Object.entries(
|
|
4005
|
+
childScopeNode.equivalencies || {},
|
|
4006
|
+
)) {
|
|
4007
|
+
for (const equivalentValue of equivalentValues) {
|
|
4008
|
+
// Case 4 pattern: ChildComponent().signature[0].propName -> parentVariable
|
|
4009
|
+
if (
|
|
4010
|
+
path.includes('().signature[') &&
|
|
4011
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable
|
|
4012
|
+
) {
|
|
4013
|
+
// Only add if not already present from the root scope
|
|
4014
|
+
if (!(path in equivalentSignatureVariables)) {
|
|
4015
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
|
|
4022
|
+
// Transitive resolution: Resolve variable chains through multiple levels
|
|
4023
|
+
// E.g., analysis → currentEntityAnalysis → useLoaderData().functionCallReturnValue.currentEntityAnalysis
|
|
4024
|
+
// We need multiple passes because resolutions can depend on each other
|
|
4025
|
+
const maxIterations = 5; // Prevent infinite loops
|
|
4026
|
+
|
|
4027
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
4028
|
+
let changed = false;
|
|
4029
|
+
|
|
4030
|
+
for (const [varName, sourcePath] of Object.entries(
|
|
4031
|
+
equivalentSignatureVariables,
|
|
4032
|
+
)) {
|
|
4033
|
+
// Skip if already fully resolved (contains function call syntax)
|
|
4034
|
+
// BUT first check for computed value patterns that need resolution (Fix 28)
|
|
4035
|
+
// AND method call patterns that need base variable resolution (Fix 33)
|
|
4036
|
+
if (sourcePath.includes('()')) {
|
|
4037
|
+
// Fix 28: Handle computed value patterns with dependency arrays
|
|
4038
|
+
// Patterns like `functionName(arg, [dep1, dep2, ...])` are NOT controllable
|
|
4039
|
+
// data sources. We trace through the dependencies to find controllable sources.
|
|
4040
|
+
const bracketStart = sourcePath.indexOf('[');
|
|
4041
|
+
const bracketEnd = sourcePath.lastIndexOf(']');
|
|
4042
|
+
|
|
4043
|
+
if (bracketStart !== -1 && bracketEnd > bracketStart) {
|
|
4044
|
+
const arrayContent = sourcePath.slice(bracketStart + 1, bracketEnd);
|
|
4045
|
+
const items = arrayContent.split(',').map((s) => s.trim());
|
|
4046
|
+
|
|
4047
|
+
// Only process if this looks like a dependency array:
|
|
4048
|
+
// multiple items that are all simple identifiers (not numbers or expressions)
|
|
4049
|
+
const isIdentifier = (s: string) =>
|
|
4050
|
+
/^\w+$/.test(s) && !/^\d+$/.test(s);
|
|
4051
|
+
if (items.length > 1 && items.every(isIdentifier)) {
|
|
4052
|
+
// Look for a dependency that's already resolved to a controllable source
|
|
4053
|
+
for (const dep of items) {
|
|
4054
|
+
if (dep in equivalentSignatureVariables) {
|
|
4055
|
+
const resolvedDep = equivalentSignatureVariables[dep];
|
|
4056
|
+
// Use if it's a controllable path (contains hook call)
|
|
4057
|
+
// and is NOT another unresolved computed pattern (has comma-separated deps)
|
|
4058
|
+
const hasCommaInBrackets =
|
|
4059
|
+
resolvedDep.includes('[') &&
|
|
4060
|
+
resolvedDep.includes(',') &&
|
|
4061
|
+
resolvedDep.indexOf(',') > resolvedDep.indexOf('[');
|
|
4062
|
+
if (resolvedDep.includes('()') && !hasCommaInBrackets) {
|
|
4063
|
+
// Computed value is typically an element from an array
|
|
4064
|
+
equivalentSignatureVariables[varName] = resolvedDep + '[]';
|
|
4065
|
+
changed = true;
|
|
4066
|
+
break;
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
// Fix 33: Handle method call patterns on variables
|
|
4074
|
+
// Patterns like: "splat.split('/').functionCallReturnValue"
|
|
4075
|
+
// We need to resolve the base variable (splat) to its actual source
|
|
4076
|
+
// Check if this is a method call on a variable (dot before first parenthesis)
|
|
4077
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4078
|
+
const parenIndex = sourcePath.indexOf('(');
|
|
4079
|
+
if (
|
|
4080
|
+
dotIndex !== -1 &&
|
|
4081
|
+
dotIndex < parenIndex &&
|
|
4082
|
+
!sourcePath.startsWith('use') // Not a hook call like useState()
|
|
4083
|
+
) {
|
|
4084
|
+
// Extract the base variable (before the first dot)
|
|
4085
|
+
const baseVar = sourcePath.slice(0, dotIndex);
|
|
4086
|
+
const rest = sourcePath.slice(dotIndex); // includes ".method(...).functionCallReturnValue"
|
|
4087
|
+
|
|
4088
|
+
// Check if the base variable can be resolved
|
|
4089
|
+
if (
|
|
4090
|
+
baseVar in equivalentSignatureVariables &&
|
|
4091
|
+
baseVar !== varName
|
|
4092
|
+
) {
|
|
4093
|
+
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
4094
|
+
// Only resolve if the base resolved to something useful (contains () or .)
|
|
4095
|
+
if (baseResolved.includes('()') || baseResolved.includes('.')) {
|
|
4096
|
+
const newPath = baseResolved + rest;
|
|
4097
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4098
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4099
|
+
changed = true;
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
// Fix 38: Handle cyScope lazy initializer return values
|
|
4106
|
+
// When we have viewMode -> cyScope20(), trace through to find what cyScope20 returns.
|
|
4107
|
+
// The lazy initializer's return value should be the controllable data source.
|
|
4108
|
+
// Pattern: cyScopeN() where N is a number
|
|
4109
|
+
const cyScopeMatch = sourcePath.match(/^(cyScope\d+)\(\)$/);
|
|
4110
|
+
if (cyScopeMatch) {
|
|
4111
|
+
const cyScopeName = cyScopeMatch[1];
|
|
4112
|
+
const cyScopeNode = this.scopeNodes[cyScopeName];
|
|
4113
|
+
|
|
4114
|
+
if (cyScopeNode?.equivalencies) {
|
|
4115
|
+
// Look for returnValue equivalency in the cyScope
|
|
4116
|
+
const returnValueEquivs =
|
|
4117
|
+
cyScopeNode.equivalencies['returnValue'];
|
|
4118
|
+
if (returnValueEquivs && returnValueEquivs.length > 0) {
|
|
4119
|
+
// Get the first return value source
|
|
4120
|
+
const returnSource = returnValueEquivs[0].schemaPath;
|
|
4121
|
+
|
|
4122
|
+
// If the return source is a simple variable (not a complex path),
|
|
4123
|
+
// resolve varName directly to that variable
|
|
4124
|
+
if (
|
|
4125
|
+
returnSource &&
|
|
4126
|
+
!returnSource.includes('(') &&
|
|
4127
|
+
!returnSource.includes('[')
|
|
4128
|
+
) {
|
|
4129
|
+
// Update varName to point to the return source
|
|
4130
|
+
if (equivalentSignatureVariables[varName] !== returnSource) {
|
|
4131
|
+
equivalentSignatureVariables[varName] = returnSource;
|
|
4132
|
+
changed = true;
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
continue;
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
// Check if the source path starts with a variable that's also in the map
|
|
4143
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4144
|
+
let baseVar: string;
|
|
4145
|
+
let rest: string;
|
|
4146
|
+
|
|
4147
|
+
if (dotIndex > 0) {
|
|
4148
|
+
// Path has a dot: "a.b.c" -> baseVar="a", rest=".b.c"
|
|
4149
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
4150
|
+
rest = sourcePath.slice(dotIndex); // includes the leading dot
|
|
4151
|
+
} else {
|
|
4152
|
+
// Path is a simple identifier: "currentEntityAnalysis" -> baseVar="currentEntityAnalysis", rest=""
|
|
4153
|
+
baseVar = sourcePath;
|
|
4154
|
+
rest = '';
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4157
|
+
if (baseVar in equivalentSignatureVariables && baseVar !== varName) {
|
|
4158
|
+
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
4159
|
+
// If the base resolves to a hook call, add .functionCallReturnValue
|
|
4160
|
+
if (baseResolved.endsWith('()')) {
|
|
4161
|
+
const newPath = baseResolved + '.functionCallReturnValue' + rest;
|
|
4162
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4163
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4164
|
+
changed = true;
|
|
4165
|
+
}
|
|
4166
|
+
} else if (baseResolved !== sourcePath) {
|
|
4167
|
+
const newPath = baseResolved + rest;
|
|
4168
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4169
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4170
|
+
changed = true;
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
|
|
4176
|
+
// Stop if no changes were made in this iteration
|
|
4177
|
+
if (!changed) break;
|
|
4178
|
+
}
|
|
4179
|
+
|
|
3502
4180
|
return equivalentSignatureVariables;
|
|
3503
4181
|
}
|
|
3504
4182
|
|
|
@@ -3549,7 +4227,12 @@ export class ScopeDataStructure {
|
|
|
3549
4227
|
relevantSchema,
|
|
3550
4228
|
);
|
|
3551
4229
|
|
|
4230
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
4231
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
4232
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
4233
|
+
this.onlyEquivalencies = true;
|
|
3552
4234
|
this.validateSchema(tempScopeNode, true, final);
|
|
4235
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
3553
4236
|
|
|
3554
4237
|
return {
|
|
3555
4238
|
name: variableName,
|
|
@@ -3558,8 +4241,123 @@ export class ScopeDataStructure {
|
|
|
3558
4241
|
};
|
|
3559
4242
|
}
|
|
3560
4243
|
|
|
3561
|
-
getExternalFunctionCalls() {
|
|
3562
|
-
|
|
4244
|
+
getExternalFunctionCalls(): FunctionCallInfo[] {
|
|
4245
|
+
// Replace cyScope placeholders in all external function call data
|
|
4246
|
+
// This ensures call signatures and schema paths use actual callback text
|
|
4247
|
+
// instead of internal cyScope names, preventing mock data merge conflicts.
|
|
4248
|
+
return this.externalFunctionCalls.map((efc) =>
|
|
4249
|
+
this.cleanCyScopeFromFunctionCallInfo(efc),
|
|
4250
|
+
);
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
/**
|
|
4254
|
+
* Cleans cyScope placeholder references from a FunctionCallInfo.
|
|
4255
|
+
* Replaces cyScopeN() with the actual callback text in:
|
|
4256
|
+
* - callSignature
|
|
4257
|
+
* - allCallSignatures
|
|
4258
|
+
* - schema keys
|
|
4259
|
+
*/
|
|
4260
|
+
private cleanCyScopeFromFunctionCallInfo(
|
|
4261
|
+
efc: FunctionCallInfo,
|
|
4262
|
+
): FunctionCallInfo {
|
|
4263
|
+
const cyScopePattern = /cyScope\d+\(\)/g;
|
|
4264
|
+
|
|
4265
|
+
// Check if any cleaning is needed
|
|
4266
|
+
const hasCyScope =
|
|
4267
|
+
cyScopePattern.test(efc.callSignature) ||
|
|
4268
|
+
(efc.allCallSignatures &&
|
|
4269
|
+
efc.allCallSignatures.some((sig) => /cyScope\d+\(\)/.test(sig))) ||
|
|
4270
|
+
(efc.schema &&
|
|
4271
|
+
Object.keys(efc.schema).some((key) => /cyScope\d+\(\)/.test(key)));
|
|
4272
|
+
|
|
4273
|
+
if (!hasCyScope) {
|
|
4274
|
+
return efc;
|
|
4275
|
+
}
|
|
4276
|
+
|
|
4277
|
+
// Create cleaned copy
|
|
4278
|
+
const cleaned: FunctionCallInfo = { ...efc };
|
|
4279
|
+
|
|
4280
|
+
// Clean callSignature
|
|
4281
|
+
cleaned.callSignature = this.replaceCyScopeInString(efc.callSignature);
|
|
4282
|
+
|
|
4283
|
+
// Clean allCallSignatures
|
|
4284
|
+
if (efc.allCallSignatures) {
|
|
4285
|
+
cleaned.allCallSignatures = efc.allCallSignatures.map((sig) =>
|
|
4286
|
+
this.replaceCyScopeInString(sig),
|
|
4287
|
+
);
|
|
4288
|
+
}
|
|
4289
|
+
|
|
4290
|
+
// Clean schema keys
|
|
4291
|
+
if (efc.schema) {
|
|
4292
|
+
cleaned.schema = this.replaceCyScopePlaceholders(efc.schema);
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4295
|
+
// Clean callSignatureToVariable keys
|
|
4296
|
+
if (efc.callSignatureToVariable) {
|
|
4297
|
+
cleaned.callSignatureToVariable = Object.entries(
|
|
4298
|
+
efc.callSignatureToVariable,
|
|
4299
|
+
).reduce(
|
|
4300
|
+
(acc, [key, value]) => {
|
|
4301
|
+
acc[this.replaceCyScopeInString(key)] = value;
|
|
4302
|
+
return acc;
|
|
4303
|
+
},
|
|
4304
|
+
{} as Record<string, string>,
|
|
4305
|
+
);
|
|
4306
|
+
}
|
|
4307
|
+
|
|
4308
|
+
return cleaned;
|
|
4309
|
+
}
|
|
4310
|
+
|
|
4311
|
+
/**
|
|
4312
|
+
* Replaces cyScope placeholder references in a single string.
|
|
4313
|
+
* If the scope text can't be found, uses a generic fallback to avoid leaking
|
|
4314
|
+
* internal cyScope names into stored data.
|
|
4315
|
+
*
|
|
4316
|
+
* Handles two patterns:
|
|
4317
|
+
* 1. Function call style: cyScope7() - matched by cyScope(\d+)\(\)
|
|
4318
|
+
* 2. Scope name style: parentName____cyScopeXX or cyScopeXX - matched by (\w+____)?cyScope([0-9A-Fa-f]+)
|
|
4319
|
+
*/
|
|
4320
|
+
private replaceCyScopeInString(str: string): string {
|
|
4321
|
+
let result = str;
|
|
4322
|
+
|
|
4323
|
+
// Pattern 1: Function call style - cyScope7()
|
|
4324
|
+
const functionCallPattern = /cyScope(\d+)\(\)/g;
|
|
4325
|
+
const functionCallMatches = [...str.matchAll(functionCallPattern)];
|
|
4326
|
+
for (const match of functionCallMatches) {
|
|
4327
|
+
const cyScopeName = `cyScope${match[1]}`;
|
|
4328
|
+
const scopeText = this.findCyScopeText(cyScopeName);
|
|
4329
|
+
// Always replace cyScope references - use actual text if available,
|
|
4330
|
+
// otherwise use a generic callback placeholder
|
|
4331
|
+
const replacement = scopeText || '() => {}';
|
|
4332
|
+
result = result.replace(match[0], replacement);
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4335
|
+
// Pattern 2: Scope name style - parentName____cyScopeXX or just cyScopeXX
|
|
4336
|
+
// This handles hex-encoded scope IDs like cyScope1F
|
|
4337
|
+
const scopeNamePattern = /(\w+____)?cyScope([0-9A-Fa-f]+)/g;
|
|
4338
|
+
const scopeNameMatches = [...result.matchAll(scopeNamePattern)];
|
|
4339
|
+
for (const match of scopeNameMatches) {
|
|
4340
|
+
const fullMatch = match[0];
|
|
4341
|
+
const prefix = match[1] || ''; // e.g., "getTitleColor____"
|
|
4342
|
+
const cyScopeId = match[2]; // e.g., "1F"
|
|
4343
|
+
const cyScopeName = `cyScope${cyScopeId}`;
|
|
4344
|
+
|
|
4345
|
+
// Try to find the scope text, checking both with and without prefix
|
|
4346
|
+
let scopeText = this.findCyScopeText(cyScopeName);
|
|
4347
|
+
if (!scopeText && prefix) {
|
|
4348
|
+
// Try looking up with the full prefixed name
|
|
4349
|
+
scopeText = this.findCyScopeText(`${prefix}${cyScopeName}`);
|
|
4350
|
+
}
|
|
4351
|
+
|
|
4352
|
+
if (scopeText) {
|
|
4353
|
+
result = result.replace(fullMatch, scopeText);
|
|
4354
|
+
} else {
|
|
4355
|
+
// Replace with a generic identifier to avoid leaking internal names
|
|
4356
|
+
result = result.replace(fullMatch, 'callback');
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
|
|
4360
|
+
return result;
|
|
3563
4361
|
}
|
|
3564
4362
|
|
|
3565
4363
|
getEnvironmentVariables() {
|
|
@@ -3602,29 +4400,145 @@ export class ScopeDataStructure {
|
|
|
3602
4400
|
}
|
|
3603
4401
|
|
|
3604
4402
|
/**
|
|
3605
|
-
*
|
|
3606
|
-
*
|
|
4403
|
+
* Add conditional effects from AST analysis.
|
|
4404
|
+
* Called during scope analysis to collect all setter calls inside conditionals.
|
|
3607
4405
|
*/
|
|
3608
|
-
|
|
4406
|
+
addConditionalEffects(
|
|
4407
|
+
effects: import('../astScopes/types').ConditionalEffect[],
|
|
4408
|
+
): void {
|
|
4409
|
+
// Add effects, avoiding duplicates based on effect stateVariable and condition paths
|
|
4410
|
+
for (const effect of effects) {
|
|
4411
|
+
const exists = this.rawConditionalEffects.some((existing) => {
|
|
4412
|
+
// Same effect target (stateVariable + value)
|
|
4413
|
+
const sameEffect =
|
|
4414
|
+
existing.effect.stateVariable === effect.effect.stateVariable &&
|
|
4415
|
+
existing.effect.value === effect.effect.value;
|
|
4416
|
+
if (!sameEffect) return false;
|
|
4417
|
+
|
|
4418
|
+
// Same condition(s)
|
|
4419
|
+
if (existing.condition && effect.condition) {
|
|
4420
|
+
return (
|
|
4421
|
+
existing.condition.path === effect.condition.path &&
|
|
4422
|
+
existing.condition.requiredValue === effect.condition.requiredValue
|
|
4423
|
+
);
|
|
4424
|
+
}
|
|
4425
|
+
if (existing.conditions && effect.conditions) {
|
|
4426
|
+
if (existing.conditions.length !== effect.conditions.length)
|
|
4427
|
+
return false;
|
|
4428
|
+
return existing.conditions.every((ec, i) => {
|
|
4429
|
+
const newCond = effect.conditions![i];
|
|
4430
|
+
return (
|
|
4431
|
+
ec.path === newCond.path &&
|
|
4432
|
+
ec.requiredValue === newCond.requiredValue
|
|
4433
|
+
);
|
|
4434
|
+
});
|
|
4435
|
+
}
|
|
4436
|
+
return false;
|
|
4437
|
+
});
|
|
4438
|
+
if (!exists) {
|
|
4439
|
+
this.rawConditionalEffects.push(effect);
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4443
|
+
|
|
4444
|
+
/**
|
|
4445
|
+
* Get conditional effects collected during analysis.
|
|
4446
|
+
*/
|
|
4447
|
+
getConditionalEffects(): import('../astScopes/types').ConditionalEffect[] {
|
|
4448
|
+
return this.rawConditionalEffects;
|
|
4449
|
+
}
|
|
4450
|
+
|
|
4451
|
+
/**
|
|
4452
|
+
* Add compound conditionals from AST analysis.
|
|
4453
|
+
* Called during scope analysis to collect grouped conditions (e.g., a && b && c).
|
|
4454
|
+
*/
|
|
4455
|
+
addCompoundConditionals(
|
|
4456
|
+
compounds: import('../astScopes/types').CompoundConditional[],
|
|
4457
|
+
): void {
|
|
4458
|
+
// Add compounds, avoiding duplicates based on chainId
|
|
4459
|
+
for (const compound of compounds) {
|
|
4460
|
+
const exists = this.rawCompoundConditionals.some(
|
|
4461
|
+
(existing) => existing.chainId === compound.chainId,
|
|
4462
|
+
);
|
|
4463
|
+
if (!exists) {
|
|
4464
|
+
this.rawCompoundConditionals.push(compound);
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
|
|
4469
|
+
/**
|
|
4470
|
+
* Get compound conditionals collected during analysis.
|
|
4471
|
+
*/
|
|
4472
|
+
getCompoundConditionals(): import('../astScopes/types').CompoundConditional[] {
|
|
4473
|
+
return this.rawCompoundConditionals;
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
/**
|
|
4477
|
+
* Add child boundary gating conditions from AST analysis.
|
|
4478
|
+
* These track which conditions must be true for a child component to render.
|
|
4479
|
+
*/
|
|
4480
|
+
addChildBoundaryGatingConditions(
|
|
4481
|
+
conditions: Record<string, import('../astScopes/types').ConditionalUsage[]>,
|
|
4482
|
+
): void {
|
|
4483
|
+
for (const [childName, usages] of Object.entries(conditions)) {
|
|
4484
|
+
if (!this.rawChildBoundaryGatingConditions[childName]) {
|
|
4485
|
+
this.rawChildBoundaryGatingConditions[childName] = [];
|
|
4486
|
+
}
|
|
4487
|
+
// Add usages, avoiding duplicates
|
|
4488
|
+
for (const usage of usages) {
|
|
4489
|
+
const exists = this.rawChildBoundaryGatingConditions[childName].some(
|
|
4490
|
+
(existing) =>
|
|
4491
|
+
existing.path === usage.path &&
|
|
4492
|
+
existing.conditionType === usage.conditionType &&
|
|
4493
|
+
existing.isNegated === usage.isNegated,
|
|
4494
|
+
);
|
|
4495
|
+
if (!exists) {
|
|
4496
|
+
this.rawChildBoundaryGatingConditions[childName].push(usage);
|
|
4497
|
+
}
|
|
4498
|
+
}
|
|
4499
|
+
}
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
/**
|
|
4503
|
+
* Get enriched child boundary gating conditions with source tracing.
|
|
4504
|
+
* Similar to getEnrichedConditionalUsages but for gating conditions.
|
|
4505
|
+
*/
|
|
4506
|
+
getEnrichedChildBoundaryGatingConditions(): Record<
|
|
3609
4507
|
string,
|
|
3610
|
-
|
|
3611
|
-
path: string;
|
|
3612
|
-
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
3613
|
-
comparedValues?: string[];
|
|
3614
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
3615
|
-
sourceDataPath?: string;
|
|
3616
|
-
}>
|
|
4508
|
+
EnrichedConditionalUsage[]
|
|
3617
4509
|
> {
|
|
3618
|
-
const enriched: Record<
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
4510
|
+
const enriched: Record<string, EnrichedConditionalUsage[]> = {};
|
|
4511
|
+
const rootScopeName = this.scopeTreeManager.getTree().name;
|
|
4512
|
+
|
|
4513
|
+
for (const [childName, usages] of Object.entries(
|
|
4514
|
+
this.rawChildBoundaryGatingConditions,
|
|
4515
|
+
)) {
|
|
4516
|
+
enriched[childName] = usages.map((usage) => {
|
|
4517
|
+
// Try to trace this path back to a data source
|
|
4518
|
+
const explanation = this.explainPath(rootScopeName, usage.path);
|
|
4519
|
+
|
|
4520
|
+
let sourceDataPath: string | undefined;
|
|
4521
|
+
if (explanation.source) {
|
|
4522
|
+
sourceDataPath = `${explanation.source.scope}.${explanation.source.path}`;
|
|
4523
|
+
}
|
|
4524
|
+
|
|
4525
|
+
return {
|
|
4526
|
+
...usage,
|
|
4527
|
+
sourceDataPath,
|
|
4528
|
+
};
|
|
4529
|
+
});
|
|
4530
|
+
}
|
|
4531
|
+
|
|
4532
|
+
return enriched;
|
|
4533
|
+
}
|
|
4534
|
+
|
|
4535
|
+
/**
|
|
4536
|
+
* Get enriched conditional usages with source tracing.
|
|
4537
|
+
* Uses explainPath to trace each local variable back to its data source.
|
|
4538
|
+
* Preserves all fields from the raw conditional usages including derivedFrom.
|
|
4539
|
+
*/
|
|
4540
|
+
getEnrichedConditionalUsages(): Record<string, EnrichedConditionalUsage[]> {
|
|
4541
|
+
const enriched: Record<string, EnrichedConditionalUsage[]> = {};
|
|
3628
4542
|
|
|
3629
4543
|
for (const [path, usages] of Object.entries(this.rawConditionalUsages)) {
|
|
3630
4544
|
// Try to trace this path back to a data source
|
|
@@ -3647,35 +4561,86 @@ export class ScopeDataStructure {
|
|
|
3647
4561
|
return enriched;
|
|
3648
4562
|
}
|
|
3649
4563
|
|
|
4564
|
+
/**
|
|
4565
|
+
* Add JSX rendering usages from AST analysis.
|
|
4566
|
+
* These track arrays rendered via .map() and strings interpolated in JSX.
|
|
4567
|
+
*/
|
|
4568
|
+
addJsxRenderingUsages(
|
|
4569
|
+
usages: import('../astScopes/types').JsxRenderingUsage[],
|
|
4570
|
+
): void {
|
|
4571
|
+
// Add usages, avoiding duplicates based on path and renderingType
|
|
4572
|
+
for (const usage of usages) {
|
|
4573
|
+
const exists = this.rawJsxRenderingUsages.some(
|
|
4574
|
+
(existing) =>
|
|
4575
|
+
existing.path === usage.path &&
|
|
4576
|
+
existing.renderingType === usage.renderingType,
|
|
4577
|
+
);
|
|
4578
|
+
if (!exists) {
|
|
4579
|
+
this.rawJsxRenderingUsages.push(usage);
|
|
4580
|
+
}
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4583
|
+
|
|
4584
|
+
/**
|
|
4585
|
+
* Get JSX rendering usages collected during analysis.
|
|
4586
|
+
*/
|
|
4587
|
+
getJsxRenderingUsages(): import('../astScopes/types').JsxRenderingUsage[] {
|
|
4588
|
+
return this.rawJsxRenderingUsages;
|
|
4589
|
+
}
|
|
4590
|
+
|
|
3650
4591
|
toSerializable(): SerializableDataStructure {
|
|
3651
|
-
// Helper to
|
|
4592
|
+
// Helper to clean cyScope and cyDuplicateKey from a string for output
|
|
4593
|
+
const cleanCyScope = (str: string): string =>
|
|
4594
|
+
this.replaceCyScopeInString(str).replace(/::cyDuplicateKey\d+::/g, '');
|
|
4595
|
+
|
|
4596
|
+
// Helper to convert ScopeVariable to SerializableScopeVariable (with cyScope cleaned)
|
|
3652
4597
|
const toSerializableVariable = (
|
|
3653
4598
|
vars:
|
|
3654
4599
|
| ScopeVariable[]
|
|
3655
4600
|
| Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[],
|
|
3656
4601
|
): SerializableScopeVariable[] =>
|
|
3657
4602
|
vars.map((v) => ({
|
|
3658
|
-
scopeNodeName: v.scopeNodeName,
|
|
3659
|
-
schemaPath: v.schemaPath,
|
|
4603
|
+
scopeNodeName: cleanCyScope(v.scopeNodeName),
|
|
4604
|
+
schemaPath: cleanCyScope(v.schemaPath),
|
|
3660
4605
|
}));
|
|
3661
4606
|
|
|
4607
|
+
// Helper to clean cyScope from all keys in a schema
|
|
4608
|
+
const cleanSchemaKeys = (
|
|
4609
|
+
schema: Record<string, string>,
|
|
4610
|
+
): Record<string, string> => {
|
|
4611
|
+
return Object.entries(schema).reduce(
|
|
4612
|
+
(acc, [key, value]) => {
|
|
4613
|
+
acc[cleanCyScope(key)] = value;
|
|
4614
|
+
return acc;
|
|
4615
|
+
},
|
|
4616
|
+
{} as Record<string, string>,
|
|
4617
|
+
);
|
|
4618
|
+
};
|
|
4619
|
+
|
|
3662
4620
|
// Helper to get function result for a given function name
|
|
3663
4621
|
const getFunctionResult = (
|
|
3664
4622
|
functionName?: string,
|
|
3665
4623
|
): SerializableFunctionResult => {
|
|
3666
4624
|
return {
|
|
3667
|
-
signature:
|
|
3668
|
-
|
|
4625
|
+
signature: cleanSchemaKeys(
|
|
4626
|
+
this.getFunctionSignature({ functionName }) ?? {},
|
|
4627
|
+
),
|
|
4628
|
+
signatureWithUnknowns: cleanSchemaKeys(
|
|
3669
4629
|
this.getFunctionSignature({ functionName, fillInUnknowns: true }) ??
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
4630
|
+
{},
|
|
4631
|
+
),
|
|
4632
|
+
returnValue: cleanSchemaKeys(
|
|
4633
|
+
this.getReturnValue({ functionName }) ?? {},
|
|
4634
|
+
),
|
|
4635
|
+
returnValueWithUnknowns: cleanSchemaKeys(
|
|
3673
4636
|
this.getReturnValue({ functionName, fillInUnknowns: true }) ?? {},
|
|
4637
|
+
),
|
|
3674
4638
|
usageEquivalencies: Object.entries(
|
|
3675
4639
|
this.getUsageEquivalencies(functionName) ?? {},
|
|
3676
4640
|
).reduce(
|
|
3677
4641
|
(acc, [key, vars]) => {
|
|
3678
|
-
|
|
4642
|
+
// Clean cyScope from the key as well as variable properties
|
|
4643
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
3679
4644
|
return acc;
|
|
3680
4645
|
},
|
|
3681
4646
|
{} as Record<string, SerializableScopeVariable[]>,
|
|
@@ -3684,7 +4649,8 @@ export class ScopeDataStructure {
|
|
|
3684
4649
|
this.getSourceEquivalencies(functionName) ?? {},
|
|
3685
4650
|
).reduce(
|
|
3686
4651
|
(acc, [key, vars]) => {
|
|
3687
|
-
|
|
4652
|
+
// Clean cyScope from the key as well as variable properties
|
|
4653
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
3688
4654
|
return acc;
|
|
3689
4655
|
},
|
|
3690
4656
|
{} as Record<string, SerializableScopeVariable[]>,
|
|
@@ -3693,39 +4659,406 @@ export class ScopeDataStructure {
|
|
|
3693
4659
|
};
|
|
3694
4660
|
};
|
|
3695
4661
|
|
|
3696
|
-
// Convert external function calls
|
|
4662
|
+
// Convert external function calls - use getExternalFunctionCalls() which cleans cyScope
|
|
4663
|
+
const cleanedExternalCalls = this.getExternalFunctionCalls();
|
|
4664
|
+
|
|
4665
|
+
// Get root scope schema for building per-variable return value schemas
|
|
4666
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
4667
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
4668
|
+
const rootSchema = rootScope?.schema ?? {};
|
|
4669
|
+
|
|
3697
4670
|
const externalFunctionCalls: SerializableFunctionCallInfo[] =
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
4671
|
+
cleanedExternalCalls.map((efc) => {
|
|
4672
|
+
// Build perVariableSchemas from perCallSignatureSchemas when available.
|
|
4673
|
+
// This preserves distinct schemas per variable when the same function is called
|
|
4674
|
+
// multiple times with DIFFERENT call signatures (e.g., different type parameters).
|
|
4675
|
+
//
|
|
4676
|
+
// When field accesses happen in child scopes (like JSX expressions), the
|
|
4677
|
+
// rootSchema doesn't contain the detailed paths - they end up in child scope
|
|
4678
|
+
// schemas. Using perCallSignatureSchemas ensures we get the correct schema
|
|
4679
|
+
// for each call, regardless of where field accesses occur.
|
|
4680
|
+
let perVariableSchemas:
|
|
4681
|
+
| Record<string, Record<string, string>>
|
|
4682
|
+
| undefined;
|
|
4683
|
+
|
|
4684
|
+
// Use perCallSignatureSchemas only when:
|
|
4685
|
+
// 1. It exists and has distinct entries for different call signatures
|
|
4686
|
+
// 2. The number of distinct call signatures >= number of receiving variables
|
|
4687
|
+
//
|
|
4688
|
+
// This prevents using it when all calls have the same signature (e.g., useFetcher() x 2)
|
|
4689
|
+
// because in that case, perCallSignatureSchemas only has one entry.
|
|
4690
|
+
const numCallSignatures = efc.perCallSignatureSchemas
|
|
4691
|
+
? Object.keys(efc.perCallSignatureSchemas).length
|
|
4692
|
+
: 0;
|
|
4693
|
+
const numReceivingVars = efc.receivingVariableNames?.length ?? 0;
|
|
4694
|
+
const hasDistinctSchemas =
|
|
4695
|
+
numCallSignatures >= numReceivingVars && numCallSignatures > 1;
|
|
4696
|
+
|
|
4697
|
+
// CASE 1: Multiple call signatures with distinct schemas - use indexed variable names
|
|
4698
|
+
if (
|
|
4699
|
+
hasDistinctSchemas &&
|
|
4700
|
+
efc.perCallSignatureSchemas &&
|
|
4701
|
+
efc.callSignatureToVariable
|
|
4702
|
+
) {
|
|
4703
|
+
perVariableSchemas = {};
|
|
4704
|
+
|
|
4705
|
+
// Build a reverse map: variable -> array of call signatures (in order)
|
|
4706
|
+
// This handles the case where the same variable name is reused for different calls
|
|
4707
|
+
const varToCallSigs: Record<string, string[]> = {};
|
|
4708
|
+
for (const [callSig, varName] of Object.entries(
|
|
4709
|
+
efc.callSignatureToVariable,
|
|
4710
|
+
)) {
|
|
4711
|
+
if (!varToCallSigs[varName]) {
|
|
4712
|
+
varToCallSigs[varName] = [];
|
|
4713
|
+
}
|
|
4714
|
+
varToCallSigs[varName].push(callSig);
|
|
4715
|
+
}
|
|
4716
|
+
|
|
4717
|
+
// Track how many times each variable name has been seen
|
|
4718
|
+
const varNameCounts: Record<string, number> = {};
|
|
4719
|
+
|
|
4720
|
+
// For each receiving variable, get its original schema from perCallSignatureSchemas
|
|
4721
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
4722
|
+
const occurrence = varNameCounts[varName] ?? 0;
|
|
4723
|
+
varNameCounts[varName] = occurrence + 1;
|
|
4724
|
+
|
|
4725
|
+
const callSigs = varToCallSigs[varName];
|
|
4726
|
+
// Use the nth call signature for the nth occurrence of this variable
|
|
4727
|
+
const callSig = callSigs?.[occurrence];
|
|
4728
|
+
|
|
4729
|
+
if (callSig && efc.perCallSignatureSchemas[callSig]) {
|
|
4730
|
+
// Use indexed key if this variable name is reused (e.g., fetcher, fetcher[1])
|
|
4731
|
+
const key =
|
|
4732
|
+
occurrence === 0 ? varName : `${varName}[${occurrence}]`;
|
|
4733
|
+
// Clone the schema to avoid shared references
|
|
4734
|
+
perVariableSchemas[key] = {
|
|
4735
|
+
...efc.perCallSignatureSchemas[callSig],
|
|
4736
|
+
};
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
|
|
4740
|
+
// Only include if we have entries for ALL receiving variables
|
|
4741
|
+
if (Object.keys(perVariableSchemas).length < numReceivingVars) {
|
|
4742
|
+
// Not all variables have schemas - fall back to rootSchema extraction
|
|
4743
|
+
perVariableSchemas = undefined;
|
|
4744
|
+
} else {
|
|
4745
|
+
// Also check that at least one schema is non-empty
|
|
4746
|
+
// Bug fix: perCallSignatureSchemas may have entries but with empty schemas {}
|
|
4747
|
+
// In this case, we should fall through to Fallback which uses rootSchema
|
|
4748
|
+
const hasNonEmptySchema = Object.values(perVariableSchemas).some(
|
|
4749
|
+
(schema) => Object.keys(schema).length > 0,
|
|
4750
|
+
);
|
|
4751
|
+
if (!hasNonEmptySchema) {
|
|
4752
|
+
perVariableSchemas = undefined;
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4756
|
+
|
|
4757
|
+
// CASE 2: Single call signature with single variable - use perCallSignatureSchemas directly
|
|
4758
|
+
// This handles parameterized calls like useFetcher<ConfigData>() where each is a separate efc entry
|
|
4759
|
+
if (
|
|
4760
|
+
!perVariableSchemas &&
|
|
4761
|
+
efc.perCallSignatureSchemas &&
|
|
4762
|
+
numCallSignatures === 1 &&
|
|
4763
|
+
numReceivingVars === 1
|
|
4764
|
+
) {
|
|
4765
|
+
const varName = efc.receivingVariableNames![0];
|
|
4766
|
+
const callSig = Object.keys(efc.perCallSignatureSchemas)[0];
|
|
4767
|
+
const schema = efc.perCallSignatureSchemas[callSig];
|
|
4768
|
+
if (schema && Object.keys(schema).length > 0) {
|
|
4769
|
+
perVariableSchemas = { [varName]: { ...schema } };
|
|
4770
|
+
}
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
// CASE 3: Extract from efc.schema when perCallSignatureSchemas is missing or empty
|
|
4774
|
+
// This handles two scenarios:
|
|
4775
|
+
// 1. Parameterized calls that create SEPARATE efc entries (no perCallSignatureSchemas)
|
|
4776
|
+
// 2. Destructuring where perCallSignatureSchemas exists but has EMPTY schemas
|
|
4777
|
+
//
|
|
4778
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create separate
|
|
4779
|
+
// efc entries because getFunctionCallRoot preserves type parameters. Each entry has its own
|
|
4780
|
+
// `schema` field, but due to variable reassignment, the schema may be contaminated with paths
|
|
4781
|
+
// from other calls (the tracer attributes field accesses to ALL equivalencies).
|
|
4782
|
+
//
|
|
4783
|
+
// Solution: Filter efc.schema to only include paths that match THIS entry's call signature.
|
|
4784
|
+
// The schema paths include the full call signature prefix, so we can filter by it.
|
|
4785
|
+
//
|
|
4786
|
+
// Example: ConfigData entry has paths like:
|
|
4787
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.theme"
|
|
4788
|
+
// But also (contaminated):
|
|
4789
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.notifications"
|
|
4790
|
+
//
|
|
4791
|
+
// We filter to only keep paths that should belong to THIS call by checking if the
|
|
4792
|
+
// receiving variable's equivalency points to this call's return value.
|
|
4793
|
+
//
|
|
4794
|
+
// BUG FIX: The old condition `!efc.perCallSignatureSchemas` was FALSE when the object
|
|
4795
|
+
// existed (even with empty schemas), causing this case to be skipped. We now also check
|
|
4796
|
+
// if all schemas in perCallSignatureSchemas are empty.
|
|
4797
|
+
const hasNonEmptyPerCallSignatureSchemas =
|
|
4798
|
+
efc.perCallSignatureSchemas &&
|
|
4799
|
+
Object.values(efc.perCallSignatureSchemas).some(
|
|
4800
|
+
(schema) => Object.keys(schema).length > 0,
|
|
4801
|
+
);
|
|
4802
|
+
|
|
4803
|
+
// Build the call signature prefix that paths should start with
|
|
4804
|
+
const callSigPrefix = `${efc.callSignature}.functionCallReturnValue`;
|
|
4805
|
+
|
|
4806
|
+
// Check if efc.schema has variable-specific paths (indicating destructuring).
|
|
4807
|
+
// Destructuring: const { entities, gitStatus } = useLoaderData()
|
|
4808
|
+
// - efc.schema has paths like: useLoaderData().functionCallReturnValue.entities...
|
|
4809
|
+
// Multiple calls: const x = useFetcher(); const y = useFetcher();
|
|
4810
|
+
// - efc.schema has paths like: useFetcher().functionCallReturnValue.data...
|
|
4811
|
+
// CASE 3 should only run for destructuring (variable-specific paths exist).
|
|
4812
|
+
const hasVariableSpecificPaths = (
|
|
4813
|
+
efc.receivingVariableNames ?? []
|
|
4814
|
+
).some((varName) =>
|
|
4815
|
+
Object.keys(efc.schema).some((path) =>
|
|
4816
|
+
path.startsWith(`${callSigPrefix}.${varName}`),
|
|
4817
|
+
),
|
|
4818
|
+
);
|
|
4819
|
+
|
|
4820
|
+
if (
|
|
4821
|
+
!perVariableSchemas &&
|
|
4822
|
+
!hasNonEmptyPerCallSignatureSchemas &&
|
|
4823
|
+
numReceivingVars >= 1 &&
|
|
4824
|
+
hasVariableSpecificPaths
|
|
4825
|
+
) {
|
|
4826
|
+
// Filter efc.schema to only include paths matching this call signature
|
|
4827
|
+
const filteredSchema: Record<string, string> = {};
|
|
4828
|
+
for (const [path, type] of Object.entries(efc.schema)) {
|
|
4829
|
+
if (path.startsWith(callSigPrefix) || path === efc.callSignature) {
|
|
4830
|
+
filteredSchema[path] = type;
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
|
|
4834
|
+
// Build perVariableSchemas from the filtered schema
|
|
4835
|
+
// For destructuring, filter paths by variable name
|
|
4836
|
+
if (Object.keys(filteredSchema).length > 0) {
|
|
4837
|
+
perVariableSchemas = {};
|
|
4838
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
4839
|
+
// For destructuring, extract only paths specific to this variable
|
|
4840
|
+
const varSpecificPrefix = `${callSigPrefix}.${varName}`;
|
|
4841
|
+
const varSchema: Record<string, string> = {};
|
|
4842
|
+
|
|
4843
|
+
for (const [path, type] of Object.entries(filteredSchema)) {
|
|
4844
|
+
if (path.startsWith(varSpecificPrefix)) {
|
|
4845
|
+
// Transform: useLoaderData().functionCallReturnValue.entities.sha
|
|
4846
|
+
// -> functionCallReturnValue.entities.sha (keep the variable name)
|
|
4847
|
+
const suffix = path.slice(callSigPrefix.length);
|
|
4848
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
4849
|
+
varSchema[returnValuePath] = type;
|
|
4850
|
+
} else if (path === efc.callSignature) {
|
|
4851
|
+
// Include the function call type itself
|
|
4852
|
+
varSchema[path] = type;
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
if (Object.keys(varSchema).length > 0) {
|
|
4856
|
+
perVariableSchemas[varName] = varSchema;
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
// Only include if we have entries
|
|
4860
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
4861
|
+
perVariableSchemas = undefined;
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
}
|
|
4865
|
+
|
|
4866
|
+
// Fallback: extract from root scope schema when perCallSignatureSchemas is not available
|
|
4867
|
+
// or doesn't have distinct entries for each variable.
|
|
4868
|
+
// This works when field accesses are in the root scope.
|
|
4869
|
+
if (
|
|
4870
|
+
!perVariableSchemas &&
|
|
4871
|
+
efc.receivingVariableNames &&
|
|
4872
|
+
efc.receivingVariableNames.length > 0
|
|
4873
|
+
) {
|
|
4874
|
+
perVariableSchemas = {};
|
|
4875
|
+
for (const varName of efc.receivingVariableNames) {
|
|
4876
|
+
const varSchema: Record<string, string> = {};
|
|
4877
|
+
for (const [path, type] of Object.entries(rootSchema)) {
|
|
4878
|
+
// Check if path starts with this variable name
|
|
4879
|
+
if (
|
|
4880
|
+
path === varName ||
|
|
4881
|
+
path.startsWith(varName + '.') ||
|
|
4882
|
+
path.startsWith(varName + '[')
|
|
4883
|
+
) {
|
|
4884
|
+
// Transform to functionCallReturnValue format
|
|
4885
|
+
// e.g., userFetcher.data.id -> functionCallReturnValue.data.id
|
|
4886
|
+
const suffix = path.slice(varName.length);
|
|
4887
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
4888
|
+
varSchema[returnValuePath] = type;
|
|
4889
|
+
}
|
|
4890
|
+
}
|
|
4891
|
+
if (Object.keys(varSchema).length > 0) {
|
|
4892
|
+
// Clean the variable name when using as key in output
|
|
4893
|
+
perVariableSchemas[cleanCyScope(varName)] = varSchema;
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
// Only include if we have any entries
|
|
4897
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
4898
|
+
perVariableSchemas = undefined;
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
|
|
4902
|
+
return {
|
|
4903
|
+
name: efc.name,
|
|
4904
|
+
callSignature: efc.callSignature,
|
|
4905
|
+
callScope: efc.callScope,
|
|
4906
|
+
schema: efc.schema,
|
|
4907
|
+
equivalencies: efc.equivalencies
|
|
4908
|
+
? Object.entries(efc.equivalencies).reduce(
|
|
4909
|
+
(acc, [key, vars]) => {
|
|
4910
|
+
// Clean cyScope from the key as well as variable properties
|
|
4911
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
4912
|
+
return acc;
|
|
4913
|
+
},
|
|
4914
|
+
{} as Record<string, SerializableScopeVariable[]>,
|
|
4915
|
+
)
|
|
4916
|
+
: undefined,
|
|
4917
|
+
allCallSignatures: efc.allCallSignatures,
|
|
4918
|
+
receivingVariableNames: efc.receivingVariableNames?.map(cleanCyScope),
|
|
4919
|
+
callSignatureToVariable: efc.callSignatureToVariable
|
|
4920
|
+
? Object.fromEntries(
|
|
4921
|
+
Object.entries(efc.callSignatureToVariable).map(([k, v]) => [
|
|
4922
|
+
k,
|
|
4923
|
+
cleanCyScope(v),
|
|
4924
|
+
]),
|
|
4925
|
+
)
|
|
4926
|
+
: undefined,
|
|
4927
|
+
perVariableSchemas,
|
|
4928
|
+
};
|
|
4929
|
+
});
|
|
4930
|
+
|
|
4931
|
+
// POST-PROCESSING: Deduplicate schemas across parameterized calls to same base function
|
|
4932
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create
|
|
4933
|
+
// separate entries. Due to variable reassignment, BOTH entries may have ALL fields.
|
|
4934
|
+
// We deduplicate by assigning each field to ONLY ONE entry based on order of appearance.
|
|
4935
|
+
//
|
|
4936
|
+
// Strategy: Fields that appear first in order belong to the first entry,
|
|
4937
|
+
// fields that appear later belong to later entries (split evenly).
|
|
4938
|
+
const deduplicateParameterizedEntries = (
|
|
4939
|
+
entries: typeof externalFunctionCalls,
|
|
4940
|
+
): typeof externalFunctionCalls => {
|
|
4941
|
+
// Group entries by base function name (without type parameters)
|
|
4942
|
+
const groups = new Map<string, typeof externalFunctionCalls>();
|
|
4943
|
+
for (const entry of entries) {
|
|
4944
|
+
// Extract base function name by stripping type parameters
|
|
4945
|
+
// e.g., "useFetcher<{ data: ConfigData | null }>" -> "useFetcher"
|
|
4946
|
+
const baseName = entry.name.replace(/<.*>$/, '');
|
|
4947
|
+
const group = groups.get(baseName) || [];
|
|
4948
|
+
group.push(entry);
|
|
4949
|
+
groups.set(baseName, group);
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
// Process groups with multiple parameterized entries
|
|
4953
|
+
for (const [, group] of groups) {
|
|
4954
|
+
if (group.length <= 1) continue;
|
|
4955
|
+
|
|
4956
|
+
// Check if these are parameterized calls (have type parameters in name)
|
|
4957
|
+
const hasTypeParams = group.every((e) => e.name.includes('<'));
|
|
4958
|
+
if (!hasTypeParams) continue;
|
|
4959
|
+
|
|
4960
|
+
// Collect ALL unique field suffixes across all entries (in order of first appearance)
|
|
4961
|
+
// Field suffix is the path after functionCallReturnValue, e.g., ".data.data.theme"
|
|
4962
|
+
const allFieldSuffixes: string[] = [];
|
|
4963
|
+
for (const entry of group) {
|
|
4964
|
+
if (!entry.perVariableSchemas) continue;
|
|
4965
|
+
for (const varSchema of Object.values(entry.perVariableSchemas)) {
|
|
4966
|
+
for (const path of Object.keys(varSchema)) {
|
|
4967
|
+
// Skip the base "functionCallReturnValue" entry
|
|
4968
|
+
if (path === 'functionCallReturnValue') continue;
|
|
4969
|
+
// Extract field suffix
|
|
4970
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
4971
|
+
if (!match) continue;
|
|
4972
|
+
const fieldSuffix = match[1];
|
|
4973
|
+
if (!allFieldSuffixes.includes(fieldSuffix)) {
|
|
4974
|
+
allFieldSuffixes.push(fieldSuffix);
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
}
|
|
4979
|
+
|
|
4980
|
+
// Assign fields to entries: split evenly based on order
|
|
4981
|
+
// First N/2 fields go to first entry, remaining go to second entry
|
|
4982
|
+
const fieldToEntryMap = new Map<string, number>();
|
|
4983
|
+
const fieldsPerEntry = Math.ceil(
|
|
4984
|
+
allFieldSuffixes.length / group.length,
|
|
4985
|
+
);
|
|
4986
|
+
for (let i = 0; i < allFieldSuffixes.length; i++) {
|
|
4987
|
+
const fieldSuffix = allFieldSuffixes[i];
|
|
4988
|
+
const entryIdx = Math.min(
|
|
4989
|
+
Math.floor(i / fieldsPerEntry),
|
|
4990
|
+
group.length - 1,
|
|
4991
|
+
);
|
|
4992
|
+
fieldToEntryMap.set(fieldSuffix, entryIdx);
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4995
|
+
// Filter each entry's perVariableSchemas to only include its assigned fields
|
|
4996
|
+
for (let i = 0; i < group.length; i++) {
|
|
4997
|
+
const entry = group[i];
|
|
4998
|
+
if (!entry.perVariableSchemas) continue;
|
|
4999
|
+
|
|
5000
|
+
const filteredPerVarSchemas: Record<
|
|
5001
|
+
string,
|
|
5002
|
+
Record<string, string>
|
|
5003
|
+
> = {};
|
|
5004
|
+
for (const [varName, varSchema] of Object.entries(
|
|
5005
|
+
entry.perVariableSchemas,
|
|
5006
|
+
)) {
|
|
5007
|
+
const filteredVarSchema: Record<string, string> = {};
|
|
5008
|
+
for (const [path, type] of Object.entries(varSchema)) {
|
|
5009
|
+
// Always keep the base functionCallReturnValue
|
|
5010
|
+
if (path === 'functionCallReturnValue') {
|
|
5011
|
+
filteredVarSchema[path] = type;
|
|
5012
|
+
continue;
|
|
5013
|
+
}
|
|
5014
|
+
// Extract field suffix
|
|
5015
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
5016
|
+
if (!match) {
|
|
5017
|
+
// Keep non-field paths
|
|
5018
|
+
filteredVarSchema[path] = type;
|
|
5019
|
+
continue;
|
|
5020
|
+
}
|
|
5021
|
+
const fieldSuffix = match[1];
|
|
5022
|
+
// Only include if this entry owns this field
|
|
5023
|
+
if (fieldToEntryMap.get(fieldSuffix) === i) {
|
|
5024
|
+
filteredVarSchema[path] = type;
|
|
5025
|
+
}
|
|
5026
|
+
}
|
|
5027
|
+
if (Object.keys(filteredVarSchema).length > 0) {
|
|
5028
|
+
filteredPerVarSchemas[varName] = filteredVarSchema;
|
|
5029
|
+
}
|
|
5030
|
+
}
|
|
5031
|
+
entry.perVariableSchemas =
|
|
5032
|
+
Object.keys(filteredPerVarSchemas).length > 0
|
|
5033
|
+
? filteredPerVarSchemas
|
|
5034
|
+
: undefined;
|
|
5035
|
+
}
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5038
|
+
return entries;
|
|
5039
|
+
};
|
|
5040
|
+
|
|
5041
|
+
// Apply deduplication
|
|
5042
|
+
const deduplicatedExternalFunctionCalls = deduplicateParameterizedEntries(
|
|
5043
|
+
externalFunctionCalls,
|
|
5044
|
+
);
|
|
5045
|
+
|
|
5046
|
+
// IMPORTANT: Get equivalent signature variables BEFORE calling getFunctionResult
|
|
5047
|
+
// because getFunctionResult calls validateSchema which may remove equivalencies
|
|
5048
|
+
// during the finalize step (e.g., cleanNonObjectFunctions removes method call
|
|
5049
|
+
// equivalencies like `segments -> splat.split('/').functionCallReturnValue`).
|
|
5050
|
+
// Fix 33: Move this call before any schema validation to preserve method call chains.
|
|
5051
|
+
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
3716
5052
|
|
|
3717
5053
|
// Get root function result
|
|
3718
5054
|
const rootFunction = getFunctionResult();
|
|
3719
5055
|
|
|
3720
|
-
// Get results for each external function
|
|
5056
|
+
// Get results for each external function (use cleaned calls for consistency)
|
|
3721
5057
|
const functionResults: Record<string, SerializableFunctionResult> = {};
|
|
3722
|
-
for (const efc of
|
|
5058
|
+
for (const efc of cleanedExternalCalls) {
|
|
3723
5059
|
functionResults[efc.name] = getFunctionResult(efc.name);
|
|
3724
5060
|
}
|
|
3725
5061
|
|
|
3726
|
-
// Get equivalent signature variables
|
|
3727
|
-
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
3728
|
-
|
|
3729
5062
|
const environmentVariables = this.getEnvironmentVariables();
|
|
3730
5063
|
|
|
3731
5064
|
// Get enriched conditional usages with source tracing
|
|
@@ -3735,13 +5068,43 @@ export class ScopeDataStructure {
|
|
|
3735
5068
|
? enrichedConditionalUsages
|
|
3736
5069
|
: undefined;
|
|
3737
5070
|
|
|
5071
|
+
// Get conditional effects (setter calls inside conditionals)
|
|
5072
|
+
const conditionalEffects =
|
|
5073
|
+
this.rawConditionalEffects.length > 0
|
|
5074
|
+
? this.rawConditionalEffects
|
|
5075
|
+
: undefined;
|
|
5076
|
+
|
|
5077
|
+
// Get compound conditionals (grouped conditions that must all be true)
|
|
5078
|
+
const compoundConditionals =
|
|
5079
|
+
this.rawCompoundConditionals.length > 0
|
|
5080
|
+
? this.rawCompoundConditionals
|
|
5081
|
+
: undefined;
|
|
5082
|
+
|
|
5083
|
+
// Get child boundary gating conditions
|
|
5084
|
+
const enrichedGatingConditions =
|
|
5085
|
+
this.getEnrichedChildBoundaryGatingConditions();
|
|
5086
|
+
const childBoundaryGatingConditions =
|
|
5087
|
+
Object.keys(enrichedGatingConditions).length > 0
|
|
5088
|
+
? enrichedGatingConditions
|
|
5089
|
+
: undefined;
|
|
5090
|
+
|
|
5091
|
+
// Get JSX rendering usages (arrays via .map(), strings via interpolation)
|
|
5092
|
+
const jsxRenderingUsages =
|
|
5093
|
+
this.rawJsxRenderingUsages.length > 0
|
|
5094
|
+
? this.rawJsxRenderingUsages
|
|
5095
|
+
: undefined;
|
|
5096
|
+
|
|
3738
5097
|
return {
|
|
3739
|
-
externalFunctionCalls,
|
|
5098
|
+
externalFunctionCalls: deduplicatedExternalFunctionCalls,
|
|
3740
5099
|
rootFunction,
|
|
3741
5100
|
functionResults,
|
|
3742
5101
|
equivalentSignatureVariables,
|
|
3743
5102
|
environmentVariables,
|
|
3744
5103
|
conditionalUsages,
|
|
5104
|
+
conditionalEffects,
|
|
5105
|
+
compoundConditionals,
|
|
5106
|
+
childBoundaryGatingConditions,
|
|
5107
|
+
jsxRenderingUsages,
|
|
3745
5108
|
};
|
|
3746
5109
|
}
|
|
3747
5110
|
|