@codeyam/codeyam-cli 0.1.0-staging.15d0f46 → 0.1.0-staging.1669d45
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 +7 -7
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +9 -5
- package/analyzer-template/packages/ai/index.ts +5 -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 +152 -6
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +107 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +42 -0
- 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 +301 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +972 -106
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +232 -0
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +18 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1409 -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 +771 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +233 -75
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +39 -4
- 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/deepEqual.ts +30 -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 +486 -86
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +182 -104
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +201 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1019 -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/generateEntityScenarioDataGenerator.ts +71 -4
- 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/resolvePathToControllable.ts +690 -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 +102 -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/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 +458 -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/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 +196 -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 +299 -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 +384 -94
- 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 +2 -2
- 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 +63 -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 +146 -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/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 +4 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +79 -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 +161 -0
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +63 -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 +146 -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/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/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 +868 -132
- 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 +49 -33
- package/analyzer-template/project/orchestrateCapture.ts +10 -3
- package/analyzer-template/project/reconcileMockDataKeys.ts +102 -2
- package/analyzer-template/project/runAnalysis.ts +7 -0
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +26 -4
- package/analyzer-template/project/startScenarioCapture.ts +72 -40
- package/analyzer-template/project/writeMockDataTsx.ts +118 -55
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +263 -92
- 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 +799 -121
- 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 +42 -28
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +7 -4
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +87 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +6 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +21 -4
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +56 -30
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +110 -48
- 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 +211 -75
- 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 +5 -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 +28 -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 +44 -23
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/report.js +72 -24
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/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 +27 -27
- 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 +12 -2
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +11 -11
- 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 +239 -16
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +19 -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 +5 -5
- 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 +96 -0
- 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 +2 -5
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-vauWK972.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DKdsUF7Y.js → EntityTypeBadge-COi5OvsN.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BwdQv49w.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-CEleMv_j.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D68KarMg.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-L75Wvqgw.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-C53WM8qn.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-CrNkmy4i.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DzJRkCkr.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CQifa1n-.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CyaBFX7l.js +20 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-CWjSsLqY.js → TruncatedFilePath-D36O1rzU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-Be83mo_j.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BN6wu6Y-.js +37 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DgTPh8H-.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-DdQKK6on.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-Dmr2bb1R.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-Do4ZLUYa.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-Bn6aCAy_.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CbdFyxZh.js +23 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-B4iCfs5M.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-wDWZZO1W.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BMbl7MeQ.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-5wRKRIH9.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-DD3SDH7t.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-DKyMFI90.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-zXjT7J0G.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-DTTQ3gY7.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-DLbXwndH.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-gPZ-lad1.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-BsPXJ81F.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-22590fcf.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-BsAarjAM.js +57 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-P2FKIUql.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-B2eDuBj8.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-L18M6-kN.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BDz7kbVA.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-29dDmbH8.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-CmrTPlIB.js → useLastLogLine-BUm0UVJm.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CkIOKTrZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-C1ig_BmP.js → useToast-KKw5kTn-.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-BND5I5fv.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CFXnd7MG.js +228 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +1 -1
- package/codeyam-cli/templates/codeyam:diagnose.md +625 -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 +8 -8
- package/packages/ai/index.js +2 -4
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +107 -0
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +76 -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 +29 -0
- 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 +239 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +728 -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 +17 -1
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1126 -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 +482 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +173 -55
- 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 +35 -2
- 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/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.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 +398 -81
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +168 -82
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +123 -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 +742 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.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/generateEntityScenarioDataGenerator.js +58 -4
- 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/resolvePathToControllable.js +563 -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 +22 -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/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 +214 -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/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 +159 -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 +235 -81
- 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 +307 -89
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.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/scripts/finalize-analyzer.cjs +3 -1
- 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-D0VW1-W7.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BAk4S4pI.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-Y756iZxZ.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-zzrrjW1p.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-QMn7bJg6.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DmP5mRxX.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BXwvsbLw.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DAmUX_1y.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-Df-nk4J5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-_ZUyFdie.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-Eoh0PhcW.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CZgPLy5i.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-DI-p9ZLZ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-DvyV2x6y.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DURu2qlF.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-DDobn9Xh.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CGdWnLD_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-DgMmzrKs.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-DEVXuhkn.js +0 -13
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-WPRQyc68.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-B9u3lJer.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-YGnKIuHU.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/globals-28lrWTTo.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-CJ0uPJjV.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/index-CfqeA2XG.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-DIjSvh6B.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-8125c15c.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-BXl3LOEh.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-C-g286WP.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-xBKWfOxd.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-DVY_wGOx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-Be1pJo5A.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-CR-FkSvx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DABetnSj.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-DcR7DH9q.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BDBrfp7e.js +0 -175
- package/codeyam-cli/templates/debug-codeyam.md +0 -527
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -79,15 +79,27 @@
|
|
|
79
79
|
* - `helpers/README.md` - Overview of the helper module architecture
|
|
80
80
|
*/
|
|
81
81
|
import fillInSchemaGapsAndUnknowns from "./helpers/fillInSchemaGapsAndUnknowns.js";
|
|
82
|
+
/**
|
|
83
|
+
* Patterns that indicate recursive type structures in schema paths.
|
|
84
|
+
* Used by hasExcessivePatternRepetition() to detect exponential path blowup.
|
|
85
|
+
*/
|
|
86
|
+
const RECURSIVE_PATH_PATTERNS = [
|
|
87
|
+
/\.attributes\.properties\[\]/g, // TypeScript AST JSX nodes
|
|
88
|
+
/\.children\[\]/g, // Tree structures
|
|
89
|
+
/\.elements\[\]/g, // Array-like structures
|
|
90
|
+
/\.members\[\]/g, // Class/interface members
|
|
91
|
+
/\.properties\[\]/g, // Object properties
|
|
92
|
+
/\.items\[\]/g, // Generic items arrays
|
|
93
|
+
];
|
|
82
94
|
import ensureSchemaConsistency from "./helpers/ensureSchemaConsistency.js";
|
|
83
95
|
import cleanPath from "./helpers/cleanPath.js";
|
|
84
96
|
import { PathManager } from "./helpers/PathManager.js";
|
|
85
|
-
import { uniqueId,
|
|
97
|
+
import { uniqueId, uniqueScopeAndPaths, uniqueScopeVariables, } from "./helpers/uniqueIdUtils.js";
|
|
86
98
|
import selectBestValue from "./helpers/selectBestValue.js";
|
|
87
99
|
import { VisitedTracker } from "./helpers/VisitedTracker.js";
|
|
88
100
|
import { DebugTracer } from "./helpers/DebugTracer.js";
|
|
89
101
|
import { BatchSchemaProcessor } from "./helpers/BatchSchemaProcessor.js";
|
|
90
|
-
import {
|
|
102
|
+
import { ROOT_SCOPE_NAME, ScopeTreeManager, } from "./helpers/ScopeTreeManager.js";
|
|
91
103
|
import cleanScopeNodeName from "./helpers/cleanScopeNodeName.js";
|
|
92
104
|
import getFunctionCallRoot from "./helpers/getFunctionCallRoot.js";
|
|
93
105
|
import cleanPathOfNonTransformingFunctions from "./helpers/cleanPathOfNonTransformingFunctions.js";
|
|
@@ -140,6 +152,10 @@ const ALLOWED_EQUIVALENCY_REASONS = new Set([
|
|
|
140
152
|
'propagated function call return sub-property equivalency',
|
|
141
153
|
'propagated parent-variable equivalency', // Added: propagate child scope equivalencies to parent scope when variable is defined in parent
|
|
142
154
|
'where was this function called from', // Added: tracks which scope called an external function
|
|
155
|
+
'MUI DataGrid renderCell params.row equivalency', // Added: links DataGrid renderCell params.row to rows array elements
|
|
156
|
+
'MUI Autocomplete getOptionLabel option equivalency', // Added: links Autocomplete getOptionLabel callback param to options array
|
|
157
|
+
'MUI Autocomplete renderOption option equivalency', // Added: links Autocomplete renderOption callback param to options array
|
|
158
|
+
'MUI Autocomplete option property equivalency', // Added: propagates property accesses from Autocomplete callbacks
|
|
143
159
|
]);
|
|
144
160
|
const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
145
161
|
'signature of functionCall',
|
|
@@ -172,6 +188,21 @@ export class ScopeDataStructure {
|
|
|
172
188
|
* Maps local variable path to array of usages.
|
|
173
189
|
*/
|
|
174
190
|
this.rawConditionalUsages = {};
|
|
191
|
+
/**
|
|
192
|
+
* Conditional effects collected during AST analysis.
|
|
193
|
+
* Tracks what setter calls happen inside conditionals (if, switch, ternary).
|
|
194
|
+
*/
|
|
195
|
+
this.rawConditionalEffects = [];
|
|
196
|
+
/**
|
|
197
|
+
* Compound conditionals collected during AST analysis.
|
|
198
|
+
* Groups conditions that must all be true together (e.g., a && b && c).
|
|
199
|
+
*/
|
|
200
|
+
this.rawCompoundConditionals = [];
|
|
201
|
+
/**
|
|
202
|
+
* Gating conditions for child component boundaries.
|
|
203
|
+
* Maps child component name to the conditions that must be true for it to render.
|
|
204
|
+
*/
|
|
205
|
+
this.rawChildBoundaryGatingConditions = {};
|
|
175
206
|
this.lastAddToSchemaId = 0;
|
|
176
207
|
this.lastEquivalencyId = 0;
|
|
177
208
|
this.lastEquivalencyDatabaseId = 0;
|
|
@@ -183,6 +214,9 @@ export class ScopeDataStructure {
|
|
|
183
214
|
// Index for O(1) lookup of external function calls by name
|
|
184
215
|
// Invalidated by setting to null; rebuilt lazily on next access
|
|
185
216
|
this.externalFunctionCallsIndex = null;
|
|
217
|
+
// Tracks internal functions that have been filtered out during captureCompleteSchema
|
|
218
|
+
// Prevents re-adding them via subsequent equivalency propagation (e.g., from getReturnValue)
|
|
219
|
+
this.filteredInternalFunctions = new Set();
|
|
186
220
|
// Debug tracer for selective path/scope tracing
|
|
187
221
|
// Enable via: CODEYAM_DEBUG=true CODEYAM_DEBUG_PATHS="user.*,signature" npm test
|
|
188
222
|
this.tracer = new DebugTracer({
|
|
@@ -301,6 +335,8 @@ export class ScopeDataStructure {
|
|
|
301
335
|
const efcName = this.pathManager.stripGenerics(efc.name);
|
|
302
336
|
for (const manager of this.equivalencyManagers) {
|
|
303
337
|
if (manager.internalFunctions.has(efcName)) {
|
|
338
|
+
// Track this so we don't re-add it via subsequent finalize calls
|
|
339
|
+
this.filteredInternalFunctions.add(efcName);
|
|
304
340
|
return false;
|
|
305
341
|
}
|
|
306
342
|
}
|
|
@@ -321,11 +357,42 @@ export class ScopeDataStructure {
|
|
|
321
357
|
});
|
|
322
358
|
entry.sourceCandidates = entry.sourceCandidates.filter((candidate) => {
|
|
323
359
|
const baseName = this.pathManager.stripGenerics(candidate.scopeNodeName);
|
|
360
|
+
// Check if this is a local variable path (doesn't contain function call pattern)
|
|
361
|
+
// Local variables like "surveys[]" or "items[]" are important for tracing data flow
|
|
362
|
+
// from parent to child components (e.g., surveys[] -> SurveyCard().signature[0].survey)
|
|
363
|
+
const isLocalVariablePath = !candidate.schemaPath.includes('()') &&
|
|
364
|
+
!candidate.schemaPath.startsWith('signature[') &&
|
|
365
|
+
!candidate.schemaPath.startsWith('returnValue');
|
|
324
366
|
return (validExternalFacingScopeNames.has(baseName) &&
|
|
325
367
|
(candidate.schemaPath.startsWith('signature[') ||
|
|
326
|
-
candidate.schemaPath.startsWith(baseName)
|
|
368
|
+
candidate.schemaPath.startsWith(baseName) ||
|
|
369
|
+
isLocalVariablePath) &&
|
|
327
370
|
!containsArrayMethod(candidate.schemaPath));
|
|
328
371
|
});
|
|
372
|
+
// If all sourceCandidates were filtered out (e.g., because they belonged to
|
|
373
|
+
// internal functions like useState), look for the highest-order intermediate
|
|
374
|
+
// that belongs to a valid external-facing scope
|
|
375
|
+
if (entry.sourceCandidates.length === 0 &&
|
|
376
|
+
Object.keys(entry.intermediatesOrder).length > 0) {
|
|
377
|
+
// Find intermediates that belong to valid external-facing scopes
|
|
378
|
+
const validIntermediates = Object.entries(entry.intermediatesOrder)
|
|
379
|
+
.filter(([pathId]) => {
|
|
380
|
+
const [scopeNodeName, schemaPath] = pathId.split('::');
|
|
381
|
+
if (!scopeNodeName || !schemaPath)
|
|
382
|
+
return false;
|
|
383
|
+
const baseName = this.pathManager.stripGenerics(scopeNodeName);
|
|
384
|
+
return (validExternalFacingScopeNames.has(baseName) &&
|
|
385
|
+
!containsArrayMethod(schemaPath));
|
|
386
|
+
})
|
|
387
|
+
.sort((a, b) => b[1] - a[1]); // Sort by order descending (highest first)
|
|
388
|
+
if (validIntermediates.length > 0) {
|
|
389
|
+
const [pathId] = validIntermediates[0];
|
|
390
|
+
const [scopeNodeName, schemaPath] = pathId.split('::');
|
|
391
|
+
if (scopeNodeName && schemaPath) {
|
|
392
|
+
entry.sourceCandidates.push({ scopeNodeName, schemaPath });
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
329
396
|
}
|
|
330
397
|
this.propagateSourceAndUsageEquivalencies(this.scopeNodes[this.scopeTreeManager.getRootName()]);
|
|
331
398
|
for (const externalFunctionCall of this.externalFunctionCalls) {
|
|
@@ -559,7 +626,6 @@ export class ScopeDataStructure {
|
|
|
559
626
|
}
|
|
560
627
|
addEquivalency(path, equivalentPath, equivalentScopeName, scopeNode, equivalencyReason, equivalencyValueChain, traceId) {
|
|
561
628
|
var _a;
|
|
562
|
-
// DEBUG: Detect infinite loops
|
|
563
629
|
addEquivalencyCallCount++;
|
|
564
630
|
if (addEquivalencyCallCount > 50000) {
|
|
565
631
|
console.error('INFINITE LOOP DETECTED in addEquivalency', {
|
|
@@ -754,10 +820,31 @@ export class ScopeDataStructure {
|
|
|
754
820
|
const searchKey = getFunctionCallRoot(functionCallInfo.callSignature);
|
|
755
821
|
const existingFunctionCall = this.getExternalFunctionCallsIndex().get(searchKey);
|
|
756
822
|
if (existingFunctionCall) {
|
|
757
|
-
|
|
823
|
+
// Preserve per-call schemas BEFORE merging to enable per-variable mock data.
|
|
824
|
+
// This is critical for hooks like useFetcher<UserData>() vs useFetcher<ReportData>()
|
|
825
|
+
// where each call returns different typed data.
|
|
826
|
+
if (!existingFunctionCall.perCallSignatureSchemas) {
|
|
827
|
+
// First merge - save the existing call's schema
|
|
828
|
+
existingFunctionCall.perCallSignatureSchemas = {
|
|
829
|
+
[existingFunctionCall.callSignature]: {
|
|
830
|
+
...existingFunctionCall.schema,
|
|
831
|
+
},
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
// Save the new call's schema before it gets merged
|
|
835
|
+
existingFunctionCall.perCallSignatureSchemas[functionCallInfo.callSignature] = { ...functionCallInfo.schema };
|
|
836
|
+
// Merge schemas using selectBestValue to preserve specific types like 'null'
|
|
837
|
+
// over generic types like 'unknown'. This ensures ref variables detected
|
|
838
|
+
// earlier (marked as 'null') aren't overwritten by later 'unknown' values.
|
|
839
|
+
const mergedSchema = {
|
|
758
840
|
...existingFunctionCall.schema,
|
|
759
|
-
...functionCallInfo.schema,
|
|
760
841
|
};
|
|
842
|
+
for (const key in functionCallInfo.schema) {
|
|
843
|
+
const existingValue = existingFunctionCall.schema[key];
|
|
844
|
+
const newValue = functionCallInfo.schema[key];
|
|
845
|
+
mergedSchema[key] = selectBestValue(existingValue, newValue, newValue);
|
|
846
|
+
}
|
|
847
|
+
existingFunctionCall.schema = mergedSchema;
|
|
761
848
|
existingFunctionCall.equivalencies = {
|
|
762
849
|
...existingFunctionCall.equivalencies,
|
|
763
850
|
...functionCallInfo.equivalencies,
|
|
@@ -777,8 +864,13 @@ export class ScopeDataStructure {
|
|
|
777
864
|
const isExternal = !callingScopeNode.instantiatedVariables?.includes(functionCallInfoNameParts[0]) &&
|
|
778
865
|
!callingScopeNode.parentInstantiatedVariables?.includes(functionCallInfoNameParts[0]);
|
|
779
866
|
if (isExternal) {
|
|
780
|
-
this
|
|
781
|
-
|
|
867
|
+
// Check if this function was already filtered out as an internal function
|
|
868
|
+
// (e.g., useState was filtered in captureCompleteSchema but finalize is trying to re-add it)
|
|
869
|
+
const strippedName = this.pathManager.stripGenerics(functionCallInfo.name);
|
|
870
|
+
if (!this.filteredInternalFunctions.has(strippedName)) {
|
|
871
|
+
this.externalFunctionCalls.push(functionCallInfo);
|
|
872
|
+
this.invalidateExternalFunctionCallsIndex();
|
|
873
|
+
}
|
|
782
874
|
}
|
|
783
875
|
}
|
|
784
876
|
}
|
|
@@ -847,6 +939,17 @@ export class ScopeDataStructure {
|
|
|
847
939
|
const remainingKey = remainingSchemaPathParts.join('|');
|
|
848
940
|
const equivalentSchemaPath = equivalentSchemaPathMap.get(remainingKey);
|
|
849
941
|
if (equivalentSchemaPath) {
|
|
942
|
+
// Skip propagation when there's a structural mismatch:
|
|
943
|
+
// - schemaPath ends with [] (array element, represents an object)
|
|
944
|
+
// - equivalentSchemaPath doesn't end with [] (non-array prop, usually a scalar)
|
|
945
|
+
// This prevents incorrectly typing array elements as strings when they're
|
|
946
|
+
// equivalent to scalar props like JSX keys (e.g., workouts[] ↔ Card().key)
|
|
947
|
+
const schemaPathEndsWithArray = schemaPath.endsWith('[]');
|
|
948
|
+
const equivalentEndsWithArray = equivalentSchemaPath.endsWith('[]');
|
|
949
|
+
if (schemaPathEndsWithArray !== equivalentEndsWithArray) {
|
|
950
|
+
// Don't propagate between array element paths and non-array paths
|
|
951
|
+
continue;
|
|
952
|
+
}
|
|
850
953
|
const value1 = scopeNode.schema[schemaPath];
|
|
851
954
|
const value2 = equivalentScopeNode.schema[equivalentSchemaPath];
|
|
852
955
|
const bestValue = selectBestValue(value1, value2);
|
|
@@ -917,6 +1020,51 @@ export class ScopeDataStructure {
|
|
|
917
1020
|
isValidPath(path) {
|
|
918
1021
|
return this.pathManager.isValidPath(path);
|
|
919
1022
|
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Detects if a path contains excessive repetition of the same pattern.
|
|
1025
|
+
*
|
|
1026
|
+
* This prevents exponential blowup when analyzing recursive type structures.
|
|
1027
|
+
* For example, TypeScript AST nodes have `.attributes.properties[]` where each
|
|
1028
|
+
* property is also a node with `.attributes.properties[]`. Without this check,
|
|
1029
|
+
* paths like `signature[0].attributes.properties[].attributes.properties[].attributes.properties[]...`
|
|
1030
|
+
* would be generated exponentially.
|
|
1031
|
+
*
|
|
1032
|
+
* Two detection strategies:
|
|
1033
|
+
* 1. Known patterns: Check RECURSIVE_PATH_PATTERNS for common recursive structures
|
|
1034
|
+
* 2. Generic detection: For longer paths, detect any 2-3 part segment that repeats
|
|
1035
|
+
*
|
|
1036
|
+
* @param path - The schema path to check
|
|
1037
|
+
* @param maxRepetitions - Maximum allowed repetitions of any pattern (default: 2)
|
|
1038
|
+
* @returns true if the path has excessive repetition
|
|
1039
|
+
*/
|
|
1040
|
+
hasExcessivePatternRepetition(path, maxRepetitions = 2) {
|
|
1041
|
+
// Check known recursive patterns
|
|
1042
|
+
for (const pattern of RECURSIVE_PATH_PATTERNS) {
|
|
1043
|
+
const matches = path.match(pattern);
|
|
1044
|
+
if (matches && matches.length > maxRepetitions) {
|
|
1045
|
+
return true;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
// For longer paths, detect any repeated multi-part segments we haven't explicitly listed
|
|
1049
|
+
const pathParts = this.splitPath(path);
|
|
1050
|
+
if (pathParts.length <= 6) {
|
|
1051
|
+
return false;
|
|
1052
|
+
}
|
|
1053
|
+
// Check for repeated sequences of 2-3 consecutive parts
|
|
1054
|
+
for (let segmentLength = 2; segmentLength <= 3; segmentLength++) {
|
|
1055
|
+
const seen = new Map();
|
|
1056
|
+
for (let i = 0; i <= pathParts.length - segmentLength; i++) {
|
|
1057
|
+
const segment = pathParts.slice(i, i + segmentLength).join('.');
|
|
1058
|
+
const normalizedSegment = segment.replace(/\[\d+\]/g, '[]');
|
|
1059
|
+
const count = (seen.get(normalizedSegment) || 0) + 1;
|
|
1060
|
+
seen.set(normalizedSegment, count);
|
|
1061
|
+
if (count > maxRepetitions) {
|
|
1062
|
+
return true;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return false;
|
|
1067
|
+
}
|
|
920
1068
|
addToTree(pathParts) {
|
|
921
1069
|
this.scopeTreeManager.addPath(pathParts);
|
|
922
1070
|
}
|
|
@@ -957,22 +1105,10 @@ export class ScopeDataStructure {
|
|
|
957
1105
|
this.checkExternalFunctionCalls();
|
|
958
1106
|
}
|
|
959
1107
|
determineEquivalenciesAndBuildSchema(scopeNode) {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
if (Object.keys(isolatedEquivalentVariables || {}).some((k) => k.includes('Fetcher') || k.includes('fetcher'))) {
|
|
963
|
-
console.log('CodeYam DEBUG determineEquivalenciesAndBuildSchema:', JSON.stringify({
|
|
964
|
-
scopeNodeName: scopeNode.name,
|
|
965
|
-
fetcherEquivalencies: Object.entries(isolatedEquivalentVariables || {})
|
|
966
|
-
.filter(([k, v]) => k.includes('Fetcher') ||
|
|
967
|
-
k.includes('fetcher') ||
|
|
968
|
-
String(v).includes('Fetcher') ||
|
|
969
|
-
String(v).includes('fetcher'))
|
|
970
|
-
.reduce((acc, [k, v]) => {
|
|
971
|
-
acc[k] = v;
|
|
972
|
-
return acc;
|
|
973
|
-
}, {}),
|
|
974
|
-
}, null, 2));
|
|
1108
|
+
if (!scopeNode.analysis) {
|
|
1109
|
+
return;
|
|
975
1110
|
}
|
|
1111
|
+
const { isolatedStructure, isolatedEquivalentVariables } = scopeNode.analysis;
|
|
976
1112
|
const allPaths = Array.from(new Set([
|
|
977
1113
|
...Object.keys(isolatedStructure || {}),
|
|
978
1114
|
...Object.keys(isolatedEquivalentVariables || {}),
|
|
@@ -981,8 +1117,24 @@ export class ScopeDataStructure {
|
|
|
981
1117
|
for (let path in isolatedEquivalentVariables) {
|
|
982
1118
|
let equivalentValue = isolatedEquivalentVariables?.[path];
|
|
983
1119
|
if (equivalentValue && this.isValidPath(equivalentValue)) {
|
|
984
|
-
|
|
985
|
-
|
|
1120
|
+
// IMPORTANT: DO NOT strip ::cyDuplicateKey:: markers from equivalencies.
|
|
1121
|
+
// These markers are critical for distinguishing variable reassignments.
|
|
1122
|
+
// For example, with:
|
|
1123
|
+
// let fetcher = useFetcher<ConfigData>();
|
|
1124
|
+
// const configData = fetcher.data?.data;
|
|
1125
|
+
// fetcher = useFetcher<SettingsData>();
|
|
1126
|
+
// const settingsData = fetcher.data?.data;
|
|
1127
|
+
//
|
|
1128
|
+
// mergeStatements creates:
|
|
1129
|
+
// fetcher → useFetcher<ConfigData>()...
|
|
1130
|
+
// fetcher::cyDuplicateKey1:: → useFetcher<SettingsData>()...
|
|
1131
|
+
// configData → fetcher.data.data
|
|
1132
|
+
// settingsData → fetcher::cyDuplicateKey1::.data.data
|
|
1133
|
+
//
|
|
1134
|
+
// If we strip ::cyDuplicateKey::, settingsData would incorrectly trace
|
|
1135
|
+
// to useFetcher<ConfigData>() instead of useFetcher<SettingsData>().
|
|
1136
|
+
path = cleanPath(path, allPaths);
|
|
1137
|
+
equivalentValue = cleanPath(equivalentValue, allPaths);
|
|
986
1138
|
this.addEquivalency(path, equivalentValue, scopeNode.name, scopeNode, 'original equivalency');
|
|
987
1139
|
// Propagate equivalencies involving parent-scope variables to those parent scopes.
|
|
988
1140
|
// This handles patterns like: collected.push({...entity}) where 'collected' is defined
|
|
@@ -1074,7 +1226,7 @@ export class ScopeDataStructure {
|
|
|
1074
1226
|
// This eliminates deep call stacks and improves deduplication
|
|
1075
1227
|
this.batchProcessor = new BatchSchemaProcessor();
|
|
1076
1228
|
this.batchQueuedSet = new Set();
|
|
1077
|
-
for (const key of
|
|
1229
|
+
for (const key of allPaths) {
|
|
1078
1230
|
let value = isolatedStructure[key] ?? 'unknown';
|
|
1079
1231
|
if (['null', 'undefined'].includes(value)) {
|
|
1080
1232
|
value = 'unknown';
|
|
@@ -1108,7 +1260,14 @@ export class ScopeDataStructure {
|
|
|
1108
1260
|
processBatchQueue() {
|
|
1109
1261
|
if (!this.batchProcessor)
|
|
1110
1262
|
return;
|
|
1263
|
+
let iterations = 0;
|
|
1111
1264
|
while (this.batchProcessor.hasWork()) {
|
|
1265
|
+
iterations++;
|
|
1266
|
+
// Safety: detect potential infinite loops
|
|
1267
|
+
if (iterations > 100000) {
|
|
1268
|
+
console.error(`[ScopeDataStructure] processBatchQueue exceeded 100k iterations, possible infinite loop!`);
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1112
1271
|
const item = this.batchProcessor.getNextWork();
|
|
1113
1272
|
if (!item)
|
|
1114
1273
|
break;
|
|
@@ -1155,18 +1314,6 @@ export class ScopeDataStructure {
|
|
|
1155
1314
|
// Find the FunctionCallInfo that matches this call signature
|
|
1156
1315
|
const searchKey = getFunctionCallRoot(callSignature);
|
|
1157
1316
|
const functionCallInfo = this.getExternalFunctionCallsIndex().get(searchKey);
|
|
1158
|
-
// DEBUG: Track useFetcher calls
|
|
1159
|
-
if (searchKey === 'useFetcher' || callSignature.includes('useFetcher')) {
|
|
1160
|
-
console.log('CodeYam DEBUG trackReceivingVariable:', JSON.stringify({
|
|
1161
|
-
receivingVariable,
|
|
1162
|
-
equivalentValue,
|
|
1163
|
-
callSignature,
|
|
1164
|
-
searchKey,
|
|
1165
|
-
foundFunctionCallInfo: !!functionCallInfo,
|
|
1166
|
-
existingRecvVars: functionCallInfo?.receivingVariableNames,
|
|
1167
|
-
existingCallSigToVar: functionCallInfo?.callSignatureToVariable,
|
|
1168
|
-
}, null, 2));
|
|
1169
|
-
}
|
|
1170
1317
|
if (!functionCallInfo) {
|
|
1171
1318
|
return;
|
|
1172
1319
|
}
|
|
@@ -1521,6 +1668,17 @@ export class ScopeDataStructure {
|
|
|
1521
1668
|
continue;
|
|
1522
1669
|
}
|
|
1523
1670
|
const newEquivalentPath = this.joinPathParts([schemaPath, remainingPath]);
|
|
1671
|
+
// PERF: Detect repeated patterns in paths to prevent exponential blowup
|
|
1672
|
+
// Paths like `signature[0].attributes.properties[].attributes.properties[]...`
|
|
1673
|
+
// indicate recursive type structures that cause exponential schema explosion
|
|
1674
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
1675
|
+
if (traceId && debugLevel > 0) {
|
|
1676
|
+
console.info('Debug: skipping path with excessive pattern repetition', {
|
|
1677
|
+
path: newEquivalentPath,
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1524
1682
|
if (!equivalentScopeNode) {
|
|
1525
1683
|
if (traceId) {
|
|
1526
1684
|
console.info('Debug Propagation: missing equivalent scope info', {
|
|
@@ -2133,7 +2291,12 @@ export class ScopeDataStructure {
|
|
|
2133
2291
|
return acc;
|
|
2134
2292
|
}, {});
|
|
2135
2293
|
}
|
|
2294
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
2295
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
2296
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
2297
|
+
this.onlyEquivalencies = true;
|
|
2136
2298
|
this.validateSchema(scopeNode, true, fillInUnknowns);
|
|
2299
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
2137
2300
|
const { schema } = scopeNode;
|
|
2138
2301
|
// For root scope, merge in external function call schemas
|
|
2139
2302
|
// This ensures that imported objects used as method call targets (like logger.error())
|
|
@@ -2162,9 +2325,22 @@ export class ScopeDataStructure {
|
|
|
2162
2325
|
}
|
|
2163
2326
|
}
|
|
2164
2327
|
}
|
|
2165
|
-
return mergedSchema;
|
|
2328
|
+
return this.filterDuplicateKeys(mergedSchema);
|
|
2166
2329
|
}
|
|
2167
|
-
return schema;
|
|
2330
|
+
return this.filterDuplicateKeys(schema);
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* Filter out ::cyDuplicateKey:: entries from a schema.
|
|
2334
|
+
* These are internal markers for tracking variable reassignments
|
|
2335
|
+
* and should not appear in output schemas or LLM prompts.
|
|
2336
|
+
*/
|
|
2337
|
+
filterDuplicateKeys(schema) {
|
|
2338
|
+
return Object.entries(schema).reduce((acc, [key, value]) => {
|
|
2339
|
+
if (!key.includes('::cyDuplicateKey')) {
|
|
2340
|
+
acc[key] = value;
|
|
2341
|
+
}
|
|
2342
|
+
return acc;
|
|
2343
|
+
}, {});
|
|
2168
2344
|
}
|
|
2169
2345
|
getEquivalencies(scopeName) {
|
|
2170
2346
|
const scopeNode = this.getScopeOrFunctionCallInfo(scopeName);
|
|
@@ -2230,11 +2406,12 @@ export class ScopeDataStructure {
|
|
|
2230
2406
|
return acc;
|
|
2231
2407
|
}, {});
|
|
2232
2408
|
const equivalencies = this.getEquivalencies(functionName);
|
|
2409
|
+
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
2233
2410
|
for (const equivalenceKey in equivalencies ?? {}) {
|
|
2234
2411
|
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
2235
2412
|
const schemaPath = equivalenceValue.schemaPath;
|
|
2236
2413
|
if (schemaPath.startsWith('signature[') &&
|
|
2237
|
-
equivalenceValue.scopeNodeName ===
|
|
2414
|
+
equivalenceValue.scopeNodeName === scopeName &&
|
|
2238
2415
|
!signatureInSchema[schemaPath]) {
|
|
2239
2416
|
signatureInSchema[schemaPath] = 'unknown';
|
|
2240
2417
|
}
|
|
@@ -2242,9 +2419,60 @@ export class ScopeDataStructure {
|
|
|
2242
2419
|
}
|
|
2243
2420
|
const tempScopeNode = this.createTempScopeNode(functionName ?? this.scopeTreeManager.getRootName(), signatureInSchema, equivalencies);
|
|
2244
2421
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
2245
|
-
|
|
2422
|
+
// After validateSchema has filled in types, propagate nested paths from
|
|
2423
|
+
// variables to their signature equivalents.
|
|
2424
|
+
// e.g., workouts[].activity_type -> signature[0].workouts[].activity_type
|
|
2425
|
+
//
|
|
2426
|
+
// Build a map of variable names that are equivalent to signature paths
|
|
2427
|
+
// e.g., { 'workouts': 'signature[0].workouts' }
|
|
2428
|
+
const variableToSignatureMap = {};
|
|
2429
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
2430
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
2431
|
+
const schemaPath = equivalenceValue.schemaPath;
|
|
2432
|
+
// Track which variables map to signature paths
|
|
2433
|
+
// equivalenceKey is the variable name (e.g., 'workouts')
|
|
2434
|
+
// schemaPath is where it comes from (e.g., 'signature[0].workouts')
|
|
2435
|
+
if (schemaPath.startsWith('signature[') &&
|
|
2436
|
+
equivalenceValue.scopeNodeName === scopeName) {
|
|
2437
|
+
variableToSignatureMap[equivalenceKey] = schemaPath;
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
// Propagate nested paths from variables to their signature equivalents
|
|
2442
|
+
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
2443
|
+
// signature[0].workouts[].title
|
|
2444
|
+
for (const schemaKey in schema) {
|
|
2445
|
+
// Skip keys that already start with signature[
|
|
2446
|
+
if (schemaKey.startsWith('signature['))
|
|
2447
|
+
continue;
|
|
2448
|
+
// Check if this key starts with a variable that maps to a signature path
|
|
2449
|
+
for (const [variableName, signaturePath] of Object.entries(variableToSignatureMap)) {
|
|
2450
|
+
// Check if schemaKey starts with variableName followed by a property accessor
|
|
2451
|
+
// e.g., 'workouts[]' starts with 'workouts'
|
|
2452
|
+
if (schemaKey === variableName ||
|
|
2453
|
+
schemaKey.startsWith(variableName + '.') ||
|
|
2454
|
+
schemaKey.startsWith(variableName + '[')) {
|
|
2455
|
+
// Transform the path: replace the variable prefix with the signature path
|
|
2456
|
+
const suffix = schemaKey.slice(variableName.length);
|
|
2457
|
+
const signatureKey = signaturePath + suffix;
|
|
2458
|
+
// Add to schema if not already present
|
|
2459
|
+
if (!tempScopeNode.schema[signatureKey]) {
|
|
2460
|
+
tempScopeNode.schema[signatureKey] = schema[schemaKey];
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
return this.filterDuplicateKeys(tempScopeNode.schema);
|
|
2246
2466
|
}
|
|
2247
2467
|
getReturnValue({ functionName, fillInUnknowns, }) {
|
|
2468
|
+
// Trigger finalization on all managers to apply any pending updates
|
|
2469
|
+
// (e.g., ref type propagation to external function call schemas)
|
|
2470
|
+
const rootScope = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
2471
|
+
if (rootScope) {
|
|
2472
|
+
for (const manager of this.equivalencyManagers) {
|
|
2473
|
+
manager.finalize(rootScope, this);
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2248
2476
|
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
2249
2477
|
const scopeNode = this.scopeNodes[scopeName];
|
|
2250
2478
|
let schema = {};
|
|
@@ -2255,7 +2483,8 @@ export class ScopeDataStructure {
|
|
|
2255
2483
|
});
|
|
2256
2484
|
}
|
|
2257
2485
|
else {
|
|
2258
|
-
|
|
2486
|
+
// Use getExternalFunctionCalls() which cleans cyScope from schemas
|
|
2487
|
+
for (const externalFunctionCall of this.getExternalFunctionCalls()) {
|
|
2259
2488
|
const functionNameParts = this.splitPath(functionName).map((p) => this.functionOrScopeName(p));
|
|
2260
2489
|
const nameParts = this.splitPath(externalFunctionCall.name).map((p) => this.functionOrScopeName(p));
|
|
2261
2490
|
if (functionNameParts.every((part, index) => part === nameParts[index])) {
|
|
@@ -2276,14 +2505,27 @@ export class ScopeDataStructure {
|
|
|
2276
2505
|
// Include function paths even if their return value wasn't captured
|
|
2277
2506
|
// This ensures methods like onAuthStateChange are included in the schema
|
|
2278
2507
|
// But exclude signature entries (they should only be included via functionCallReturnValue paths)
|
|
2279
|
-
|
|
2508
|
+
// Also exclude bare function call signatures - paths that are JUST a call like
|
|
2509
|
+
// "useCustomSizes(projectSlug)" should not be included as return values.
|
|
2510
|
+
// These represent "the function exists" not actual return data, and including
|
|
2511
|
+
// them causes nested path bugs in dependencySchemas.
|
|
2512
|
+
(schema[key] === 'function' &&
|
|
2513
|
+
key.indexOf('signature[') === -1 &&
|
|
2514
|
+
// Exclude bare call signatures: function calls with no dots OUTSIDE parentheses
|
|
2515
|
+
// e.g., "useCustomSizes(projectSlug)" is bare (exclude)
|
|
2516
|
+
// e.g., "loadProject({nested.property})" is bare - dots are inside args (exclude)
|
|
2517
|
+
// e.g., "getSupabase().auth.method()" has dots outside - method chain (include)
|
|
2518
|
+
!this.isBareCallSignature(key)))
|
|
2280
2519
|
.reduce((acc, key) => {
|
|
2281
2520
|
acc[key] = schema[key];
|
|
2282
2521
|
const keyParts = this.splitPath(key);
|
|
2283
2522
|
for (const path in schema) {
|
|
2284
2523
|
const pathParts = this.splitPath(path);
|
|
2285
2524
|
if (pathParts.every((p, i) => keyParts[i] === p)) {
|
|
2286
|
-
|
|
2525
|
+
// Also exclude bare call signatures from prefix paths
|
|
2526
|
+
if (!this.isBareCallSignature(path)) {
|
|
2527
|
+
acc[path] = schema[path];
|
|
2528
|
+
}
|
|
2287
2529
|
}
|
|
2288
2530
|
}
|
|
2289
2531
|
return acc;
|
|
@@ -2291,12 +2533,68 @@ export class ScopeDataStructure {
|
|
|
2291
2533
|
// Replace cyScope placeholders with actual callback text
|
|
2292
2534
|
const resolvedSchema = this.replaceCyScopePlaceholders(returnValueSchema);
|
|
2293
2535
|
const tempScopeNode = this.createTempScopeNode(scopeName, resolvedSchema);
|
|
2536
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
2537
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
2538
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
2539
|
+
this.onlyEquivalencies = true;
|
|
2294
2540
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
2295
|
-
|
|
2541
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
2542
|
+
// Remove bare call signatures from the return value schema.
|
|
2543
|
+
// fillInSchemaGapsAndUnknowns may add parent paths like "useCustomSizes(projectSlug)"
|
|
2544
|
+
// when it sees "useCustomSizes(projectSlug).functionCallReturnValue". These bare
|
|
2545
|
+
// call signatures represent "the function exists" not actual return data, and
|
|
2546
|
+
// including them causes nested path bugs in dependencySchemas.
|
|
2547
|
+
const resultSchema = tempScopeNode.schema;
|
|
2548
|
+
for (const key of Object.keys(resultSchema)) {
|
|
2549
|
+
if (this.isBareCallSignature(key)) {
|
|
2550
|
+
delete resultSchema[key];
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
return resultSchema;
|
|
2554
|
+
}
|
|
2555
|
+
/**
|
|
2556
|
+
* Checks if a schema key is a "bare call signature" - a function call with no
|
|
2557
|
+
* method chain before it and no path segments after it.
|
|
2558
|
+
*
|
|
2559
|
+
* A bare call signature represents "this function exists" rather than actual
|
|
2560
|
+
* return data, and including them causes nested path bugs in dependencySchemas.
|
|
2561
|
+
*
|
|
2562
|
+
* Examples:
|
|
2563
|
+
* - "useCustomSizes(projectSlug)" -> bare (true)
|
|
2564
|
+
* - "loadProject({nested.property})" -> bare (dots are inside args, true)
|
|
2565
|
+
* - "getSupabase().auth.method()" -> not bare (has dots outside parens, false)
|
|
2566
|
+
* - "useProject().functionCallReturnValue" -> not bare (has path after, false)
|
|
2567
|
+
*/
|
|
2568
|
+
isBareCallSignature(key) {
|
|
2569
|
+
// Must end with ) and contain ( to be a call
|
|
2570
|
+
if (!key.endsWith(')') || key.indexOf('(') === -1) {
|
|
2571
|
+
return false;
|
|
2572
|
+
}
|
|
2573
|
+
// Check if there are any dots OUTSIDE of parentheses
|
|
2574
|
+
// Strip out content inside balanced parentheses, then check for dots
|
|
2575
|
+
let depth = 0;
|
|
2576
|
+
let hasDotsOutsideParens = false;
|
|
2577
|
+
for (let i = 0; i < key.length; i++) {
|
|
2578
|
+
const char = key[i];
|
|
2579
|
+
if (char === '(') {
|
|
2580
|
+
depth++;
|
|
2581
|
+
}
|
|
2582
|
+
else if (char === ')') {
|
|
2583
|
+
depth--;
|
|
2584
|
+
}
|
|
2585
|
+
else if (char === '.' && depth === 0) {
|
|
2586
|
+
hasDotsOutsideParens = true;
|
|
2587
|
+
break;
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
// It's a bare call signature if there are no dots outside parentheses
|
|
2591
|
+
return !hasDotsOutsideParens;
|
|
2296
2592
|
}
|
|
2297
2593
|
/**
|
|
2298
2594
|
* Replaces cyScope placeholder references (e.g., cyScope10()) in schema keys
|
|
2299
2595
|
* with the actual callback function text from the corresponding scope node.
|
|
2596
|
+
* If the scope text can't be found, uses a generic fallback to avoid leaking
|
|
2597
|
+
* internal cyScope names into stored data.
|
|
2300
2598
|
*/
|
|
2301
2599
|
replaceCyScopePlaceholders(schema) {
|
|
2302
2600
|
const cyScopePattern = /cyScope(\d+)\(\)/g;
|
|
@@ -2308,10 +2606,10 @@ export class ScopeDataStructure {
|
|
|
2308
2606
|
for (const match of matches) {
|
|
2309
2607
|
const cyScopeName = `cyScope${match[1]}`;
|
|
2310
2608
|
const scopeText = this.findCyScopeText(cyScopeName);
|
|
2311
|
-
if
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2609
|
+
// Always replace cyScope references - use actual text if available,
|
|
2610
|
+
// otherwise use a generic callback placeholder
|
|
2611
|
+
const replacement = scopeText || '() => {}';
|
|
2612
|
+
newKey = newKey.replace(match[0], replacement);
|
|
2315
2613
|
}
|
|
2316
2614
|
result[newKey] = value;
|
|
2317
2615
|
}
|
|
@@ -2363,11 +2661,229 @@ export class ScopeDataStructure {
|
|
|
2363
2661
|
const equivalentSignatureVariables = {};
|
|
2364
2662
|
for (const [path, equivalentValues] of Object.entries(scopeNode.equivalencies)) {
|
|
2365
2663
|
for (const equivalentValue of equivalentValues) {
|
|
2664
|
+
// Case 1: Props/signature equivalencies (existing behavior)
|
|
2665
|
+
// Maps local variable names to their signature paths
|
|
2666
|
+
// e.g., "propValue" -> "signature[0].prop"
|
|
2366
2667
|
if (path.startsWith('signature[')) {
|
|
2367
2668
|
equivalentSignatureVariables[equivalentValue.schemaPath] = path;
|
|
2368
2669
|
}
|
|
2670
|
+
// Case 2: Hook variable equivalencies (new behavior)
|
|
2671
|
+
// The equivalencies are stored as: path = variable name, schemaPath = data source
|
|
2672
|
+
// e.g., path = "debugFetcher", schemaPath = "useFetcher<...>().functionCallReturnValue"
|
|
2673
|
+
// We need to map: "debugFetcher" -> "useFetcher<...>()"
|
|
2674
|
+
// This enables resolving paths like "debugFetcher.state" to
|
|
2675
|
+
// "useFetcher<...>().state" for execution flow validation
|
|
2676
|
+
if (equivalentValue.schemaPath.endsWith('.functionCallReturnValue')) {
|
|
2677
|
+
// Extract the hook call path (everything before .functionCallReturnValue)
|
|
2678
|
+
const hookCallPath = equivalentValue.schemaPath.slice(0, -'.functionCallReturnValue'.length);
|
|
2679
|
+
// Only include if it looks like a hook call (contains parentheses)
|
|
2680
|
+
// and the variable name (path) is a simple identifier (no dots)
|
|
2681
|
+
if (hookCallPath.includes('(') && !path.includes('.')) {
|
|
2682
|
+
equivalentSignatureVariables[path] = hookCallPath;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
// Case 3: Destructured variables from local variables
|
|
2686
|
+
// e.g., const { scenarios } = currentEntityAnalysis;
|
|
2687
|
+
// This creates: path = "scenarios", schemaPath = "currentEntityAnalysis.scenarios"
|
|
2688
|
+
// We need to map: "scenarios" -> "currentEntityAnalysis.scenarios"
|
|
2689
|
+
// AND resolve transitively if currentEntityAnalysis is itself equivalent to a hook call
|
|
2690
|
+
if (!path.includes('.') && // path is a simple identifier
|
|
2691
|
+
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
2692
|
+
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
2693
|
+
) {
|
|
2694
|
+
// Only add if we haven't already captured this variable in Case 1 or 2
|
|
2695
|
+
if (!(path in equivalentSignatureVariables)) {
|
|
2696
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
// Case 4: Child component prop mappings (Fix 22)
|
|
2700
|
+
// When parent renders <ChildComponent prop={value} />, we get equivalencies like:
|
|
2701
|
+
// path = "ChildComponent().signature[0].prop"
|
|
2702
|
+
// schemaPath = "value" (the variable passed as the prop)
|
|
2703
|
+
// We need to include these so translateChildPathToParent can work.
|
|
2704
|
+
// Pattern: ComponentName().signature[N] or ComponentName().signature[N].propName
|
|
2705
|
+
if (path.includes('().signature[') &&
|
|
2706
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable, not a function call
|
|
2707
|
+
) {
|
|
2708
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
2709
|
+
}
|
|
2710
|
+
// Case 5: Destructured function parameters (Fix 25)
|
|
2711
|
+
// When a function has destructured props: function Comp({ propA, propB }: Props)
|
|
2712
|
+
// We get equivalencies like:
|
|
2713
|
+
// path = "propA" (the destructured variable name)
|
|
2714
|
+
// schemaPath = "signature[0].propA" (the signature path)
|
|
2715
|
+
// We need to map: "propA" -> "signature[0].propA"
|
|
2716
|
+
// This enables translateChildPathToParent to resolve child variable paths
|
|
2717
|
+
// to their signature paths when merging execution flows.
|
|
2718
|
+
if (!path.includes('.') && // path is a simple identifier (destructured prop name)
|
|
2719
|
+
equivalentValue.schemaPath.startsWith('signature[') // schemaPath IS a signature path
|
|
2720
|
+
) {
|
|
2721
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
2722
|
+
}
|
|
2723
|
+
// Case 7: Method calls on variables that result in .functionCallReturnValue (Fix 33)
|
|
2724
|
+
// When we have patterns like:
|
|
2725
|
+
// path = "segments" (simple identifier)
|
|
2726
|
+
// schemaPath = "splat.split('/').functionCallReturnValue"
|
|
2727
|
+
// This is a method call on a variable (not a hook call), but we still need to
|
|
2728
|
+
// track it so transitive resolution can resolve `splat` to its actual source.
|
|
2729
|
+
// E.g., if splat -> useParams().functionCallReturnValue['*'], then
|
|
2730
|
+
// segments -> useParams().functionCallReturnValue['*'].split('/').functionCallReturnValue
|
|
2731
|
+
if (!path.includes('.') && // path is a simple identifier
|
|
2732
|
+
equivalentValue.schemaPath.endsWith('.functionCallReturnValue') && // ends with function return
|
|
2733
|
+
equivalentValue.schemaPath.includes('.') && // has property access (method call)
|
|
2734
|
+
!(path in equivalentSignatureVariables) // not already captured
|
|
2735
|
+
) {
|
|
2736
|
+
// Check if this looks like a method call on a variable (not a hook call)
|
|
2737
|
+
// Hook calls look like: hookName() or hookName<T>()
|
|
2738
|
+
// Method calls look like: variable.method() or variable.method<T>()
|
|
2739
|
+
const hookCallPath = equivalentValue.schemaPath.slice(0, -'.functionCallReturnValue'.length);
|
|
2740
|
+
// If it's a method call (contains a dot before the parenthesis), include it
|
|
2741
|
+
const dotBeforeParen = hookCallPath.indexOf('.');
|
|
2742
|
+
const parenPos = hookCallPath.indexOf('(');
|
|
2743
|
+
if (dotBeforeParen !== -1 && dotBeforeParen < parenPos) {
|
|
2744
|
+
// This is a method call like "splat.split('/')", not a hook call
|
|
2745
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2369
2748
|
}
|
|
2370
2749
|
}
|
|
2750
|
+
// Case 6: Collect JSX child prop equivalencies from child scopes (Fix 26)
|
|
2751
|
+
// When a parent component renders <ChildComponent prop={value} />, the JSX
|
|
2752
|
+
// return statement may be in a child scope (e.g., cyScope2). The equivalencies
|
|
2753
|
+
// like ChildComponent().signature[0].prop -> value get stored in that child scope.
|
|
2754
|
+
// But translateChildPathToParent needs to find them from the parent scope's context.
|
|
2755
|
+
// So we collect Case 4 patterns from ALL child scopes that belong to this root scope.
|
|
2756
|
+
const rootName = this.scopeTreeManager.getRootName();
|
|
2757
|
+
for (const [scopeName, childScopeNode] of Object.entries(this.scopeNodes)) {
|
|
2758
|
+
// Skip the root scope (already processed above)
|
|
2759
|
+
if (scopeName === rootName)
|
|
2760
|
+
continue;
|
|
2761
|
+
// Only include scopes that are children of the root (their tree includes root)
|
|
2762
|
+
if (!childScopeNode.tree?.includes(rootName))
|
|
2763
|
+
continue;
|
|
2764
|
+
// Look for Case 4 patterns in the child scope
|
|
2765
|
+
for (const [path, equivalentValues] of Object.entries(childScopeNode.equivalencies || {})) {
|
|
2766
|
+
for (const equivalentValue of equivalentValues) {
|
|
2767
|
+
// Case 4 pattern: ChildComponent().signature[0].propName -> parentVariable
|
|
2768
|
+
if (path.includes('().signature[') &&
|
|
2769
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable
|
|
2770
|
+
) {
|
|
2771
|
+
// Only add if not already present from the root scope
|
|
2772
|
+
if (!(path in equivalentSignatureVariables)) {
|
|
2773
|
+
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
// Transitive resolution: Resolve variable chains through multiple levels
|
|
2780
|
+
// E.g., analysis → currentEntityAnalysis → useLoaderData().functionCallReturnValue.currentEntityAnalysis
|
|
2781
|
+
// We need multiple passes because resolutions can depend on each other
|
|
2782
|
+
const maxIterations = 5; // Prevent infinite loops
|
|
2783
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
2784
|
+
let changed = false;
|
|
2785
|
+
for (const [varName, sourcePath] of Object.entries(equivalentSignatureVariables)) {
|
|
2786
|
+
// Skip if already fully resolved (contains function call syntax)
|
|
2787
|
+
// BUT first check for computed value patterns that need resolution (Fix 28)
|
|
2788
|
+
// AND method call patterns that need base variable resolution (Fix 33)
|
|
2789
|
+
if (sourcePath.includes('()')) {
|
|
2790
|
+
// Fix 28: Handle computed value patterns with dependency arrays
|
|
2791
|
+
// Patterns like `functionName(arg, [dep1, dep2, ...])` are NOT controllable
|
|
2792
|
+
// data sources. We trace through the dependencies to find controllable sources.
|
|
2793
|
+
const bracketStart = sourcePath.indexOf('[');
|
|
2794
|
+
const bracketEnd = sourcePath.lastIndexOf(']');
|
|
2795
|
+
if (bracketStart !== -1 && bracketEnd > bracketStart) {
|
|
2796
|
+
const arrayContent = sourcePath.slice(bracketStart + 1, bracketEnd);
|
|
2797
|
+
const items = arrayContent.split(',').map((s) => s.trim());
|
|
2798
|
+
// Only process if this looks like a dependency array:
|
|
2799
|
+
// multiple items that are all simple identifiers (not numbers or expressions)
|
|
2800
|
+
const isIdentifier = (s) => /^\w+$/.test(s) && !/^\d+$/.test(s);
|
|
2801
|
+
if (items.length > 1 && items.every(isIdentifier)) {
|
|
2802
|
+
// Look for a dependency that's already resolved to a controllable source
|
|
2803
|
+
for (const dep of items) {
|
|
2804
|
+
if (dep in equivalentSignatureVariables) {
|
|
2805
|
+
const resolvedDep = equivalentSignatureVariables[dep];
|
|
2806
|
+
// Use if it's a controllable path (contains hook call)
|
|
2807
|
+
// and is NOT another unresolved computed pattern (has comma-separated deps)
|
|
2808
|
+
const hasCommaInBrackets = resolvedDep.includes('[') &&
|
|
2809
|
+
resolvedDep.includes(',') &&
|
|
2810
|
+
resolvedDep.indexOf(',') > resolvedDep.indexOf('[');
|
|
2811
|
+
if (resolvedDep.includes('()') && !hasCommaInBrackets) {
|
|
2812
|
+
// Computed value is typically an element from an array
|
|
2813
|
+
equivalentSignatureVariables[varName] = resolvedDep + '[]';
|
|
2814
|
+
changed = true;
|
|
2815
|
+
break;
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
// Fix 33: Handle method call patterns on variables
|
|
2822
|
+
// Patterns like: "splat.split('/').functionCallReturnValue"
|
|
2823
|
+
// We need to resolve the base variable (splat) to its actual source
|
|
2824
|
+
// Check if this is a method call on a variable (dot before first parenthesis)
|
|
2825
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
2826
|
+
const parenIndex = sourcePath.indexOf('(');
|
|
2827
|
+
if (dotIndex !== -1 &&
|
|
2828
|
+
dotIndex < parenIndex &&
|
|
2829
|
+
!sourcePath.startsWith('use') // Not a hook call like useState()
|
|
2830
|
+
) {
|
|
2831
|
+
// Extract the base variable (before the first dot)
|
|
2832
|
+
const baseVar = sourcePath.slice(0, dotIndex);
|
|
2833
|
+
const rest = sourcePath.slice(dotIndex); // includes ".method(...).functionCallReturnValue"
|
|
2834
|
+
// Check if the base variable can be resolved
|
|
2835
|
+
if (baseVar in equivalentSignatureVariables &&
|
|
2836
|
+
baseVar !== varName) {
|
|
2837
|
+
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
2838
|
+
// Only resolve if the base resolved to something useful (contains () or .)
|
|
2839
|
+
if (baseResolved.includes('()') || baseResolved.includes('.')) {
|
|
2840
|
+
const newPath = baseResolved + rest;
|
|
2841
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
2842
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
2843
|
+
changed = true;
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
continue;
|
|
2849
|
+
}
|
|
2850
|
+
// Check if the source path starts with a variable that's also in the map
|
|
2851
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
2852
|
+
let baseVar;
|
|
2853
|
+
let rest;
|
|
2854
|
+
if (dotIndex > 0) {
|
|
2855
|
+
// Path has a dot: "a.b.c" -> baseVar="a", rest=".b.c"
|
|
2856
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
2857
|
+
rest = sourcePath.slice(dotIndex); // includes the leading dot
|
|
2858
|
+
}
|
|
2859
|
+
else {
|
|
2860
|
+
// Path is a simple identifier: "currentEntityAnalysis" -> baseVar="currentEntityAnalysis", rest=""
|
|
2861
|
+
baseVar = sourcePath;
|
|
2862
|
+
rest = '';
|
|
2863
|
+
}
|
|
2864
|
+
if (baseVar in equivalentSignatureVariables && baseVar !== varName) {
|
|
2865
|
+
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
2866
|
+
// If the base resolves to a hook call, add .functionCallReturnValue
|
|
2867
|
+
if (baseResolved.endsWith('()')) {
|
|
2868
|
+
const newPath = baseResolved + '.functionCallReturnValue' + rest;
|
|
2869
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
2870
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
2871
|
+
changed = true;
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
else if (baseResolved !== sourcePath) {
|
|
2875
|
+
const newPath = baseResolved + rest;
|
|
2876
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
2877
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
2878
|
+
changed = true;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
// Stop if no changes were made in this iteration
|
|
2884
|
+
if (!changed)
|
|
2885
|
+
break;
|
|
2886
|
+
}
|
|
2371
2887
|
return equivalentSignatureVariables;
|
|
2372
2888
|
}
|
|
2373
2889
|
getVariableInfo(variableName, scopeName, final) {
|
|
@@ -2399,7 +2915,12 @@ export class ScopeDataStructure {
|
|
|
2399
2915
|
return { ...acc, ...filterdSchema };
|
|
2400
2916
|
}, {});
|
|
2401
2917
|
const tempScopeNode = this.createTempScopeNode(scopeName ?? this.scopeTreeManager.getRootName(), relevantSchema);
|
|
2918
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
2919
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
2920
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
2921
|
+
this.onlyEquivalencies = true;
|
|
2402
2922
|
this.validateSchema(tempScopeNode, true, final);
|
|
2923
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
2403
2924
|
return {
|
|
2404
2925
|
name: variableName,
|
|
2405
2926
|
equivalentTo: equivalents,
|
|
@@ -2407,7 +2928,96 @@ export class ScopeDataStructure {
|
|
|
2407
2928
|
};
|
|
2408
2929
|
}
|
|
2409
2930
|
getExternalFunctionCalls() {
|
|
2410
|
-
|
|
2931
|
+
// Replace cyScope placeholders in all external function call data
|
|
2932
|
+
// This ensures call signatures and schema paths use actual callback text
|
|
2933
|
+
// instead of internal cyScope names, preventing mock data merge conflicts.
|
|
2934
|
+
return this.externalFunctionCalls.map((efc) => this.cleanCyScopeFromFunctionCallInfo(efc));
|
|
2935
|
+
}
|
|
2936
|
+
/**
|
|
2937
|
+
* Cleans cyScope placeholder references from a FunctionCallInfo.
|
|
2938
|
+
* Replaces cyScopeN() with the actual callback text in:
|
|
2939
|
+
* - callSignature
|
|
2940
|
+
* - allCallSignatures
|
|
2941
|
+
* - schema keys
|
|
2942
|
+
*/
|
|
2943
|
+
cleanCyScopeFromFunctionCallInfo(efc) {
|
|
2944
|
+
const cyScopePattern = /cyScope\d+\(\)/g;
|
|
2945
|
+
// Check if any cleaning is needed
|
|
2946
|
+
const hasCyScope = cyScopePattern.test(efc.callSignature) ||
|
|
2947
|
+
(efc.allCallSignatures &&
|
|
2948
|
+
efc.allCallSignatures.some((sig) => /cyScope\d+\(\)/.test(sig))) ||
|
|
2949
|
+
(efc.schema &&
|
|
2950
|
+
Object.keys(efc.schema).some((key) => /cyScope\d+\(\)/.test(key)));
|
|
2951
|
+
if (!hasCyScope) {
|
|
2952
|
+
return efc;
|
|
2953
|
+
}
|
|
2954
|
+
// Create cleaned copy
|
|
2955
|
+
const cleaned = { ...efc };
|
|
2956
|
+
// Clean callSignature
|
|
2957
|
+
cleaned.callSignature = this.replaceCyScopeInString(efc.callSignature);
|
|
2958
|
+
// Clean allCallSignatures
|
|
2959
|
+
if (efc.allCallSignatures) {
|
|
2960
|
+
cleaned.allCallSignatures = efc.allCallSignatures.map((sig) => this.replaceCyScopeInString(sig));
|
|
2961
|
+
}
|
|
2962
|
+
// Clean schema keys
|
|
2963
|
+
if (efc.schema) {
|
|
2964
|
+
cleaned.schema = this.replaceCyScopePlaceholders(efc.schema);
|
|
2965
|
+
}
|
|
2966
|
+
// Clean callSignatureToVariable keys
|
|
2967
|
+
if (efc.callSignatureToVariable) {
|
|
2968
|
+
cleaned.callSignatureToVariable = Object.entries(efc.callSignatureToVariable).reduce((acc, [key, value]) => {
|
|
2969
|
+
acc[this.replaceCyScopeInString(key)] = value;
|
|
2970
|
+
return acc;
|
|
2971
|
+
}, {});
|
|
2972
|
+
}
|
|
2973
|
+
return cleaned;
|
|
2974
|
+
}
|
|
2975
|
+
/**
|
|
2976
|
+
* Replaces cyScope placeholder references in a single string.
|
|
2977
|
+
* If the scope text can't be found, uses a generic fallback to avoid leaking
|
|
2978
|
+
* internal cyScope names into stored data.
|
|
2979
|
+
*
|
|
2980
|
+
* Handles two patterns:
|
|
2981
|
+
* 1. Function call style: cyScope7() - matched by cyScope(\d+)\(\)
|
|
2982
|
+
* 2. Scope name style: parentName____cyScopeXX or cyScopeXX - matched by (\w+____)?cyScope([0-9A-Fa-f]+)
|
|
2983
|
+
*/
|
|
2984
|
+
replaceCyScopeInString(str) {
|
|
2985
|
+
let result = str;
|
|
2986
|
+
// Pattern 1: Function call style - cyScope7()
|
|
2987
|
+
const functionCallPattern = /cyScope(\d+)\(\)/g;
|
|
2988
|
+
const functionCallMatches = [...str.matchAll(functionCallPattern)];
|
|
2989
|
+
for (const match of functionCallMatches) {
|
|
2990
|
+
const cyScopeName = `cyScope${match[1]}`;
|
|
2991
|
+
const scopeText = this.findCyScopeText(cyScopeName);
|
|
2992
|
+
// Always replace cyScope references - use actual text if available,
|
|
2993
|
+
// otherwise use a generic callback placeholder
|
|
2994
|
+
const replacement = scopeText || '() => {}';
|
|
2995
|
+
result = result.replace(match[0], replacement);
|
|
2996
|
+
}
|
|
2997
|
+
// Pattern 2: Scope name style - parentName____cyScopeXX or just cyScopeXX
|
|
2998
|
+
// This handles hex-encoded scope IDs like cyScope1F
|
|
2999
|
+
const scopeNamePattern = /(\w+____)?cyScope([0-9A-Fa-f]+)/g;
|
|
3000
|
+
const scopeNameMatches = [...result.matchAll(scopeNamePattern)];
|
|
3001
|
+
for (const match of scopeNameMatches) {
|
|
3002
|
+
const fullMatch = match[0];
|
|
3003
|
+
const prefix = match[1] || ''; // e.g., "getTitleColor____"
|
|
3004
|
+
const cyScopeId = match[2]; // e.g., "1F"
|
|
3005
|
+
const cyScopeName = `cyScope${cyScopeId}`;
|
|
3006
|
+
// Try to find the scope text, checking both with and without prefix
|
|
3007
|
+
let scopeText = this.findCyScopeText(cyScopeName);
|
|
3008
|
+
if (!scopeText && prefix) {
|
|
3009
|
+
// Try looking up with the full prefixed name
|
|
3010
|
+
scopeText = this.findCyScopeText(`${prefix}${cyScopeName}`);
|
|
3011
|
+
}
|
|
3012
|
+
if (scopeText) {
|
|
3013
|
+
result = result.replace(fullMatch, scopeText);
|
|
3014
|
+
}
|
|
3015
|
+
else {
|
|
3016
|
+
// Replace with a generic identifier to avoid leaking internal names
|
|
3017
|
+
result = result.replace(fullMatch, 'callback');
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
return result;
|
|
2411
3021
|
}
|
|
2412
3022
|
getEnvironmentVariables() {
|
|
2413
3023
|
return this.environmentVariables;
|
|
@@ -2433,9 +3043,112 @@ export class ScopeDataStructure {
|
|
|
2433
3043
|
}
|
|
2434
3044
|
}
|
|
2435
3045
|
}
|
|
3046
|
+
/**
|
|
3047
|
+
* Add conditional effects from AST analysis.
|
|
3048
|
+
* Called during scope analysis to collect all setter calls inside conditionals.
|
|
3049
|
+
*/
|
|
3050
|
+
addConditionalEffects(effects) {
|
|
3051
|
+
// Add effects, avoiding duplicates based on effect stateVariable and condition paths
|
|
3052
|
+
for (const effect of effects) {
|
|
3053
|
+
const exists = this.rawConditionalEffects.some((existing) => {
|
|
3054
|
+
// Same effect target (stateVariable + value)
|
|
3055
|
+
const sameEffect = existing.effect.stateVariable === effect.effect.stateVariable &&
|
|
3056
|
+
existing.effect.value === effect.effect.value;
|
|
3057
|
+
if (!sameEffect)
|
|
3058
|
+
return false;
|
|
3059
|
+
// Same condition(s)
|
|
3060
|
+
if (existing.condition && effect.condition) {
|
|
3061
|
+
return (existing.condition.path === effect.condition.path &&
|
|
3062
|
+
existing.condition.requiredValue === effect.condition.requiredValue);
|
|
3063
|
+
}
|
|
3064
|
+
if (existing.conditions && effect.conditions) {
|
|
3065
|
+
if (existing.conditions.length !== effect.conditions.length)
|
|
3066
|
+
return false;
|
|
3067
|
+
return existing.conditions.every((ec, i) => {
|
|
3068
|
+
const newCond = effect.conditions[i];
|
|
3069
|
+
return (ec.path === newCond.path &&
|
|
3070
|
+
ec.requiredValue === newCond.requiredValue);
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
return false;
|
|
3074
|
+
});
|
|
3075
|
+
if (!exists) {
|
|
3076
|
+
this.rawConditionalEffects.push(effect);
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
/**
|
|
3081
|
+
* Get conditional effects collected during analysis.
|
|
3082
|
+
*/
|
|
3083
|
+
getConditionalEffects() {
|
|
3084
|
+
return this.rawConditionalEffects;
|
|
3085
|
+
}
|
|
3086
|
+
/**
|
|
3087
|
+
* Add compound conditionals from AST analysis.
|
|
3088
|
+
* Called during scope analysis to collect grouped conditions (e.g., a && b && c).
|
|
3089
|
+
*/
|
|
3090
|
+
addCompoundConditionals(compounds) {
|
|
3091
|
+
// Add compounds, avoiding duplicates based on chainId
|
|
3092
|
+
for (const compound of compounds) {
|
|
3093
|
+
const exists = this.rawCompoundConditionals.some((existing) => existing.chainId === compound.chainId);
|
|
3094
|
+
if (!exists) {
|
|
3095
|
+
this.rawCompoundConditionals.push(compound);
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
/**
|
|
3100
|
+
* Get compound conditionals collected during analysis.
|
|
3101
|
+
*/
|
|
3102
|
+
getCompoundConditionals() {
|
|
3103
|
+
return this.rawCompoundConditionals;
|
|
3104
|
+
}
|
|
3105
|
+
/**
|
|
3106
|
+
* Add child boundary gating conditions from AST analysis.
|
|
3107
|
+
* These track which conditions must be true for a child component to render.
|
|
3108
|
+
*/
|
|
3109
|
+
addChildBoundaryGatingConditions(conditions) {
|
|
3110
|
+
for (const [childName, usages] of Object.entries(conditions)) {
|
|
3111
|
+
if (!this.rawChildBoundaryGatingConditions[childName]) {
|
|
3112
|
+
this.rawChildBoundaryGatingConditions[childName] = [];
|
|
3113
|
+
}
|
|
3114
|
+
// Add usages, avoiding duplicates
|
|
3115
|
+
for (const usage of usages) {
|
|
3116
|
+
const exists = this.rawChildBoundaryGatingConditions[childName].some((existing) => existing.path === usage.path &&
|
|
3117
|
+
existing.conditionType === usage.conditionType &&
|
|
3118
|
+
existing.isNegated === usage.isNegated);
|
|
3119
|
+
if (!exists) {
|
|
3120
|
+
this.rawChildBoundaryGatingConditions[childName].push(usage);
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
/**
|
|
3126
|
+
* Get enriched child boundary gating conditions with source tracing.
|
|
3127
|
+
* Similar to getEnrichedConditionalUsages but for gating conditions.
|
|
3128
|
+
*/
|
|
3129
|
+
getEnrichedChildBoundaryGatingConditions() {
|
|
3130
|
+
const enriched = {};
|
|
3131
|
+
const rootScopeName = this.scopeTreeManager.getTree().name;
|
|
3132
|
+
for (const [childName, usages] of Object.entries(this.rawChildBoundaryGatingConditions)) {
|
|
3133
|
+
enriched[childName] = usages.map((usage) => {
|
|
3134
|
+
// Try to trace this path back to a data source
|
|
3135
|
+
const explanation = this.explainPath(rootScopeName, usage.path);
|
|
3136
|
+
let sourceDataPath;
|
|
3137
|
+
if (explanation.source) {
|
|
3138
|
+
sourceDataPath = `${explanation.source.scope}.${explanation.source.path}`;
|
|
3139
|
+
}
|
|
3140
|
+
return {
|
|
3141
|
+
...usage,
|
|
3142
|
+
sourceDataPath,
|
|
3143
|
+
};
|
|
3144
|
+
});
|
|
3145
|
+
}
|
|
3146
|
+
return enriched;
|
|
3147
|
+
}
|
|
2436
3148
|
/**
|
|
2437
3149
|
* Get enriched conditional usages with source tracing.
|
|
2438
3150
|
* Uses explainPath to trace each local variable back to its data source.
|
|
3151
|
+
* Preserves all fields from the raw conditional usages including derivedFrom.
|
|
2439
3152
|
*/
|
|
2440
3153
|
getEnrichedConditionalUsages() {
|
|
2441
3154
|
const enriched = {};
|
|
@@ -2457,68 +3170,399 @@ export class ScopeDataStructure {
|
|
|
2457
3170
|
return enriched;
|
|
2458
3171
|
}
|
|
2459
3172
|
toSerializable() {
|
|
2460
|
-
// Helper to
|
|
3173
|
+
// Helper to clean cyScope and cyDuplicateKey from a string for output
|
|
3174
|
+
const cleanCyScope = (str) => this.replaceCyScopeInString(str).replace(/::cyDuplicateKey\d+::/g, '');
|
|
3175
|
+
// Helper to convert ScopeVariable to SerializableScopeVariable (with cyScope cleaned)
|
|
2461
3176
|
const toSerializableVariable = (vars) => vars.map((v) => ({
|
|
2462
|
-
scopeNodeName: v.scopeNodeName,
|
|
2463
|
-
schemaPath: v.schemaPath,
|
|
3177
|
+
scopeNodeName: cleanCyScope(v.scopeNodeName),
|
|
3178
|
+
schemaPath: cleanCyScope(v.schemaPath),
|
|
2464
3179
|
}));
|
|
3180
|
+
// Helper to clean cyScope from all keys in a schema
|
|
3181
|
+
const cleanSchemaKeys = (schema) => {
|
|
3182
|
+
return Object.entries(schema).reduce((acc, [key, value]) => {
|
|
3183
|
+
acc[cleanCyScope(key)] = value;
|
|
3184
|
+
return acc;
|
|
3185
|
+
}, {});
|
|
3186
|
+
};
|
|
2465
3187
|
// Helper to get function result for a given function name
|
|
2466
3188
|
const getFunctionResult = (functionName) => {
|
|
2467
3189
|
return {
|
|
2468
|
-
signature: this.getFunctionSignature({ functionName }) ?? {},
|
|
2469
|
-
signatureWithUnknowns: this.getFunctionSignature({ functionName, fillInUnknowns: true }) ??
|
|
2470
|
-
{},
|
|
2471
|
-
returnValue: this.getReturnValue({ functionName }) ?? {},
|
|
2472
|
-
returnValueWithUnknowns: this.getReturnValue({ functionName, fillInUnknowns: true }) ?? {},
|
|
3190
|
+
signature: cleanSchemaKeys(this.getFunctionSignature({ functionName }) ?? {}),
|
|
3191
|
+
signatureWithUnknowns: cleanSchemaKeys(this.getFunctionSignature({ functionName, fillInUnknowns: true }) ??
|
|
3192
|
+
{}),
|
|
3193
|
+
returnValue: cleanSchemaKeys(this.getReturnValue({ functionName }) ?? {}),
|
|
3194
|
+
returnValueWithUnknowns: cleanSchemaKeys(this.getReturnValue({ functionName, fillInUnknowns: true }) ?? {}),
|
|
2473
3195
|
usageEquivalencies: Object.entries(this.getUsageEquivalencies(functionName) ?? {}).reduce((acc, [key, vars]) => {
|
|
2474
|
-
|
|
3196
|
+
// Clean cyScope from the key as well as variable properties
|
|
3197
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
2475
3198
|
return acc;
|
|
2476
3199
|
}, {}),
|
|
2477
3200
|
sourceEquivalencies: Object.entries(this.getSourceEquivalencies(functionName) ?? {}).reduce((acc, [key, vars]) => {
|
|
2478
|
-
|
|
3201
|
+
// Clean cyScope from the key as well as variable properties
|
|
3202
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
2479
3203
|
return acc;
|
|
2480
3204
|
}, {}),
|
|
2481
3205
|
environmentVariables: this.getEnvironmentVariables(),
|
|
2482
3206
|
};
|
|
2483
3207
|
};
|
|
2484
|
-
// Convert external function calls
|
|
2485
|
-
const
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
3208
|
+
// Convert external function calls - use getExternalFunctionCalls() which cleans cyScope
|
|
3209
|
+
const cleanedExternalCalls = this.getExternalFunctionCalls();
|
|
3210
|
+
// Get root scope schema for building per-variable return value schemas
|
|
3211
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
3212
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
3213
|
+
const rootSchema = rootScope?.schema ?? {};
|
|
3214
|
+
const externalFunctionCalls = cleanedExternalCalls.map((efc) => {
|
|
3215
|
+
// Build perVariableSchemas from perCallSignatureSchemas when available.
|
|
3216
|
+
// This preserves distinct schemas per variable when the same function is called
|
|
3217
|
+
// multiple times with DIFFERENT call signatures (e.g., different type parameters).
|
|
3218
|
+
//
|
|
3219
|
+
// When field accesses happen in child scopes (like JSX expressions), the
|
|
3220
|
+
// rootSchema doesn't contain the detailed paths - they end up in child scope
|
|
3221
|
+
// schemas. Using perCallSignatureSchemas ensures we get the correct schema
|
|
3222
|
+
// for each call, regardless of where field accesses occur.
|
|
3223
|
+
let perVariableSchemas;
|
|
3224
|
+
// Use perCallSignatureSchemas only when:
|
|
3225
|
+
// 1. It exists and has distinct entries for different call signatures
|
|
3226
|
+
// 2. The number of distinct call signatures >= number of receiving variables
|
|
3227
|
+
//
|
|
3228
|
+
// This prevents using it when all calls have the same signature (e.g., useFetcher() x 2)
|
|
3229
|
+
// because in that case, perCallSignatureSchemas only has one entry.
|
|
3230
|
+
const numCallSignatures = efc.perCallSignatureSchemas
|
|
3231
|
+
? Object.keys(efc.perCallSignatureSchemas).length
|
|
3232
|
+
: 0;
|
|
3233
|
+
const numReceivingVars = efc.receivingVariableNames?.length ?? 0;
|
|
3234
|
+
const hasDistinctSchemas = numCallSignatures >= numReceivingVars && numCallSignatures > 1;
|
|
3235
|
+
// CASE 1: Multiple call signatures with distinct schemas - use indexed variable names
|
|
3236
|
+
if (hasDistinctSchemas &&
|
|
3237
|
+
efc.perCallSignatureSchemas &&
|
|
3238
|
+
efc.callSignatureToVariable) {
|
|
3239
|
+
perVariableSchemas = {};
|
|
3240
|
+
// Build a reverse map: variable -> array of call signatures (in order)
|
|
3241
|
+
// This handles the case where the same variable name is reused for different calls
|
|
3242
|
+
const varToCallSigs = {};
|
|
3243
|
+
for (const [callSig, varName] of Object.entries(efc.callSignatureToVariable)) {
|
|
3244
|
+
if (!varToCallSigs[varName]) {
|
|
3245
|
+
varToCallSigs[varName] = [];
|
|
3246
|
+
}
|
|
3247
|
+
varToCallSigs[varName].push(callSig);
|
|
3248
|
+
}
|
|
3249
|
+
// Track how many times each variable name has been seen
|
|
3250
|
+
const varNameCounts = {};
|
|
3251
|
+
// For each receiving variable, get its original schema from perCallSignatureSchemas
|
|
3252
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
3253
|
+
const occurrence = varNameCounts[varName] ?? 0;
|
|
3254
|
+
varNameCounts[varName] = occurrence + 1;
|
|
3255
|
+
const callSigs = varToCallSigs[varName];
|
|
3256
|
+
// Use the nth call signature for the nth occurrence of this variable
|
|
3257
|
+
const callSig = callSigs?.[occurrence];
|
|
3258
|
+
if (callSig && efc.perCallSignatureSchemas[callSig]) {
|
|
3259
|
+
// Use indexed key if this variable name is reused (e.g., fetcher, fetcher[1])
|
|
3260
|
+
const key = occurrence === 0 ? varName : `${varName}[${occurrence}]`;
|
|
3261
|
+
// Clone the schema to avoid shared references
|
|
3262
|
+
perVariableSchemas[key] = {
|
|
3263
|
+
...efc.perCallSignatureSchemas[callSig],
|
|
3264
|
+
};
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
// Only include if we have entries for ALL receiving variables
|
|
3268
|
+
if (Object.keys(perVariableSchemas).length < numReceivingVars) {
|
|
3269
|
+
// Not all variables have schemas - fall back to rootSchema extraction
|
|
3270
|
+
perVariableSchemas = undefined;
|
|
3271
|
+
}
|
|
3272
|
+
else {
|
|
3273
|
+
// Also check that at least one schema is non-empty
|
|
3274
|
+
// Bug fix: perCallSignatureSchemas may have entries but with empty schemas {}
|
|
3275
|
+
// In this case, we should fall through to Fallback which uses rootSchema
|
|
3276
|
+
const hasNonEmptySchema = Object.values(perVariableSchemas).some((schema) => Object.keys(schema).length > 0);
|
|
3277
|
+
if (!hasNonEmptySchema) {
|
|
3278
|
+
perVariableSchemas = undefined;
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
// CASE 2: Single call signature with single variable - use perCallSignatureSchemas directly
|
|
3283
|
+
// This handles parameterized calls like useFetcher<ConfigData>() where each is a separate efc entry
|
|
3284
|
+
if (!perVariableSchemas &&
|
|
3285
|
+
efc.perCallSignatureSchemas &&
|
|
3286
|
+
numCallSignatures === 1 &&
|
|
3287
|
+
numReceivingVars === 1) {
|
|
3288
|
+
const varName = efc.receivingVariableNames[0];
|
|
3289
|
+
const callSig = Object.keys(efc.perCallSignatureSchemas)[0];
|
|
3290
|
+
const schema = efc.perCallSignatureSchemas[callSig];
|
|
3291
|
+
if (schema && Object.keys(schema).length > 0) {
|
|
3292
|
+
perVariableSchemas = { [varName]: { ...schema } };
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
// CASE 3: Extract from efc.schema when perCallSignatureSchemas is missing or empty
|
|
3296
|
+
// This handles two scenarios:
|
|
3297
|
+
// 1. Parameterized calls that create SEPARATE efc entries (no perCallSignatureSchemas)
|
|
3298
|
+
// 2. Destructuring where perCallSignatureSchemas exists but has EMPTY schemas
|
|
3299
|
+
//
|
|
3300
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create separate
|
|
3301
|
+
// efc entries because getFunctionCallRoot preserves type parameters. Each entry has its own
|
|
3302
|
+
// `schema` field, but due to variable reassignment, the schema may be contaminated with paths
|
|
3303
|
+
// from other calls (the tracer attributes field accesses to ALL equivalencies).
|
|
3304
|
+
//
|
|
3305
|
+
// Solution: Filter efc.schema to only include paths that match THIS entry's call signature.
|
|
3306
|
+
// The schema paths include the full call signature prefix, so we can filter by it.
|
|
3307
|
+
//
|
|
3308
|
+
// Example: ConfigData entry has paths like:
|
|
3309
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.theme"
|
|
3310
|
+
// But also (contaminated):
|
|
3311
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.notifications"
|
|
3312
|
+
//
|
|
3313
|
+
// We filter to only keep paths that should belong to THIS call by checking if the
|
|
3314
|
+
// receiving variable's equivalency points to this call's return value.
|
|
3315
|
+
//
|
|
3316
|
+
// BUG FIX: The old condition `!efc.perCallSignatureSchemas` was FALSE when the object
|
|
3317
|
+
// existed (even with empty schemas), causing this case to be skipped. We now also check
|
|
3318
|
+
// if all schemas in perCallSignatureSchemas are empty.
|
|
3319
|
+
const hasNonEmptyPerCallSignatureSchemas = efc.perCallSignatureSchemas &&
|
|
3320
|
+
Object.values(efc.perCallSignatureSchemas).some((schema) => Object.keys(schema).length > 0);
|
|
3321
|
+
// Build the call signature prefix that paths should start with
|
|
3322
|
+
const callSigPrefix = `${efc.callSignature}.functionCallReturnValue`;
|
|
3323
|
+
// Check if efc.schema has variable-specific paths (indicating destructuring).
|
|
3324
|
+
// Destructuring: const { entities, gitStatus } = useLoaderData()
|
|
3325
|
+
// - efc.schema has paths like: useLoaderData().functionCallReturnValue.entities...
|
|
3326
|
+
// Multiple calls: const x = useFetcher(); const y = useFetcher();
|
|
3327
|
+
// - efc.schema has paths like: useFetcher().functionCallReturnValue.data...
|
|
3328
|
+
// CASE 3 should only run for destructuring (variable-specific paths exist).
|
|
3329
|
+
const hasVariableSpecificPaths = (efc.receivingVariableNames ?? []).some((varName) => Object.keys(efc.schema).some((path) => path.startsWith(`${callSigPrefix}.${varName}`)));
|
|
3330
|
+
if (!perVariableSchemas &&
|
|
3331
|
+
!hasNonEmptyPerCallSignatureSchemas &&
|
|
3332
|
+
numReceivingVars >= 1 &&
|
|
3333
|
+
hasVariableSpecificPaths) {
|
|
3334
|
+
// Filter efc.schema to only include paths matching this call signature
|
|
3335
|
+
const filteredSchema = {};
|
|
3336
|
+
for (const [path, type] of Object.entries(efc.schema)) {
|
|
3337
|
+
if (path.startsWith(callSigPrefix) || path === efc.callSignature) {
|
|
3338
|
+
filteredSchema[path] = type;
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
// Build perVariableSchemas from the filtered schema
|
|
3342
|
+
// For destructuring, filter paths by variable name
|
|
3343
|
+
if (Object.keys(filteredSchema).length > 0) {
|
|
3344
|
+
perVariableSchemas = {};
|
|
3345
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
3346
|
+
// For destructuring, extract only paths specific to this variable
|
|
3347
|
+
const varSpecificPrefix = `${callSigPrefix}.${varName}`;
|
|
3348
|
+
const varSchema = {};
|
|
3349
|
+
for (const [path, type] of Object.entries(filteredSchema)) {
|
|
3350
|
+
if (path.startsWith(varSpecificPrefix)) {
|
|
3351
|
+
// Transform: useLoaderData().functionCallReturnValue.entities.sha
|
|
3352
|
+
// -> functionCallReturnValue.entities.sha (keep the variable name)
|
|
3353
|
+
const suffix = path.slice(callSigPrefix.length);
|
|
3354
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
3355
|
+
varSchema[returnValuePath] = type;
|
|
3356
|
+
}
|
|
3357
|
+
else if (path === efc.callSignature) {
|
|
3358
|
+
// Include the function call type itself
|
|
3359
|
+
varSchema[path] = type;
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
if (Object.keys(varSchema).length > 0) {
|
|
3363
|
+
perVariableSchemas[varName] = varSchema;
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
// Only include if we have entries
|
|
3367
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
3368
|
+
perVariableSchemas = undefined;
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
3372
|
+
// Fallback: extract from root scope schema when perCallSignatureSchemas is not available
|
|
3373
|
+
// or doesn't have distinct entries for each variable.
|
|
3374
|
+
// This works when field accesses are in the root scope.
|
|
3375
|
+
if (!perVariableSchemas &&
|
|
3376
|
+
efc.receivingVariableNames &&
|
|
3377
|
+
efc.receivingVariableNames.length > 0) {
|
|
3378
|
+
perVariableSchemas = {};
|
|
3379
|
+
for (const varName of efc.receivingVariableNames) {
|
|
3380
|
+
const varSchema = {};
|
|
3381
|
+
for (const [path, type] of Object.entries(rootSchema)) {
|
|
3382
|
+
// Check if path starts with this variable name
|
|
3383
|
+
if (path === varName ||
|
|
3384
|
+
path.startsWith(varName + '.') ||
|
|
3385
|
+
path.startsWith(varName + '[')) {
|
|
3386
|
+
// Transform to functionCallReturnValue format
|
|
3387
|
+
// e.g., userFetcher.data.id -> functionCallReturnValue.data.id
|
|
3388
|
+
const suffix = path.slice(varName.length);
|
|
3389
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
3390
|
+
varSchema[returnValuePath] = type;
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
if (Object.keys(varSchema).length > 0) {
|
|
3394
|
+
// Clean the variable name when using as key in output
|
|
3395
|
+
perVariableSchemas[cleanCyScope(varName)] = varSchema;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
// Only include if we have any entries
|
|
3399
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
3400
|
+
perVariableSchemas = undefined;
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
return {
|
|
3404
|
+
name: efc.name,
|
|
3405
|
+
callSignature: efc.callSignature,
|
|
3406
|
+
callScope: efc.callScope,
|
|
3407
|
+
schema: efc.schema,
|
|
3408
|
+
equivalencies: efc.equivalencies
|
|
3409
|
+
? Object.entries(efc.equivalencies).reduce((acc, [key, vars]) => {
|
|
3410
|
+
// Clean cyScope from the key as well as variable properties
|
|
3411
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
3412
|
+
return acc;
|
|
3413
|
+
}, {})
|
|
3414
|
+
: undefined,
|
|
3415
|
+
allCallSignatures: efc.allCallSignatures,
|
|
3416
|
+
receivingVariableNames: efc.receivingVariableNames?.map(cleanCyScope),
|
|
3417
|
+
callSignatureToVariable: efc.callSignatureToVariable
|
|
3418
|
+
? Object.fromEntries(Object.entries(efc.callSignatureToVariable).map(([k, v]) => [
|
|
3419
|
+
k,
|
|
3420
|
+
cleanCyScope(v),
|
|
3421
|
+
]))
|
|
3422
|
+
: undefined,
|
|
3423
|
+
perVariableSchemas,
|
|
3424
|
+
};
|
|
3425
|
+
});
|
|
3426
|
+
// POST-PROCESSING: Deduplicate schemas across parameterized calls to same base function
|
|
3427
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create
|
|
3428
|
+
// separate entries. Due to variable reassignment, BOTH entries may have ALL fields.
|
|
3429
|
+
// We deduplicate by assigning each field to ONLY ONE entry based on order of appearance.
|
|
3430
|
+
//
|
|
3431
|
+
// Strategy: Fields that appear first in order belong to the first entry,
|
|
3432
|
+
// fields that appear later belong to later entries (split evenly).
|
|
3433
|
+
const deduplicateParameterizedEntries = (entries) => {
|
|
3434
|
+
// Group entries by base function name (without type parameters)
|
|
3435
|
+
const groups = new Map();
|
|
3436
|
+
for (const entry of entries) {
|
|
3437
|
+
// Extract base function name by stripping type parameters
|
|
3438
|
+
// e.g., "useFetcher<{ data: ConfigData | null }>" -> "useFetcher"
|
|
3439
|
+
const baseName = entry.name.replace(/<.*>$/, '');
|
|
3440
|
+
const group = groups.get(baseName) || [];
|
|
3441
|
+
group.push(entry);
|
|
3442
|
+
groups.set(baseName, group);
|
|
3443
|
+
}
|
|
3444
|
+
// Process groups with multiple parameterized entries
|
|
3445
|
+
for (const [, group] of groups) {
|
|
3446
|
+
if (group.length <= 1)
|
|
3447
|
+
continue;
|
|
3448
|
+
// Check if these are parameterized calls (have type parameters in name)
|
|
3449
|
+
const hasTypeParams = group.every((e) => e.name.includes('<'));
|
|
3450
|
+
if (!hasTypeParams)
|
|
3451
|
+
continue;
|
|
3452
|
+
// Collect ALL unique field suffixes across all entries (in order of first appearance)
|
|
3453
|
+
// Field suffix is the path after functionCallReturnValue, e.g., ".data.data.theme"
|
|
3454
|
+
const allFieldSuffixes = [];
|
|
3455
|
+
for (const entry of group) {
|
|
3456
|
+
if (!entry.perVariableSchemas)
|
|
3457
|
+
continue;
|
|
3458
|
+
for (const varSchema of Object.values(entry.perVariableSchemas)) {
|
|
3459
|
+
for (const path of Object.keys(varSchema)) {
|
|
3460
|
+
// Skip the base "functionCallReturnValue" entry
|
|
3461
|
+
if (path === 'functionCallReturnValue')
|
|
3462
|
+
continue;
|
|
3463
|
+
// Extract field suffix
|
|
3464
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
3465
|
+
if (!match)
|
|
3466
|
+
continue;
|
|
3467
|
+
const fieldSuffix = match[1];
|
|
3468
|
+
if (!allFieldSuffixes.includes(fieldSuffix)) {
|
|
3469
|
+
allFieldSuffixes.push(fieldSuffix);
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
// Assign fields to entries: split evenly based on order
|
|
3475
|
+
// First N/2 fields go to first entry, remaining go to second entry
|
|
3476
|
+
const fieldToEntryMap = new Map();
|
|
3477
|
+
const fieldsPerEntry = Math.ceil(allFieldSuffixes.length / group.length);
|
|
3478
|
+
for (let i = 0; i < allFieldSuffixes.length; i++) {
|
|
3479
|
+
const fieldSuffix = allFieldSuffixes[i];
|
|
3480
|
+
const entryIdx = Math.min(Math.floor(i / fieldsPerEntry), group.length - 1);
|
|
3481
|
+
fieldToEntryMap.set(fieldSuffix, entryIdx);
|
|
3482
|
+
}
|
|
3483
|
+
// Filter each entry's perVariableSchemas to only include its assigned fields
|
|
3484
|
+
for (let i = 0; i < group.length; i++) {
|
|
3485
|
+
const entry = group[i];
|
|
3486
|
+
if (!entry.perVariableSchemas)
|
|
3487
|
+
continue;
|
|
3488
|
+
const filteredPerVarSchemas = {};
|
|
3489
|
+
for (const [varName, varSchema] of Object.entries(entry.perVariableSchemas)) {
|
|
3490
|
+
const filteredVarSchema = {};
|
|
3491
|
+
for (const [path, type] of Object.entries(varSchema)) {
|
|
3492
|
+
// Always keep the base functionCallReturnValue
|
|
3493
|
+
if (path === 'functionCallReturnValue') {
|
|
3494
|
+
filteredVarSchema[path] = type;
|
|
3495
|
+
continue;
|
|
3496
|
+
}
|
|
3497
|
+
// Extract field suffix
|
|
3498
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
3499
|
+
if (!match) {
|
|
3500
|
+
// Keep non-field paths
|
|
3501
|
+
filteredVarSchema[path] = type;
|
|
3502
|
+
continue;
|
|
3503
|
+
}
|
|
3504
|
+
const fieldSuffix = match[1];
|
|
3505
|
+
// Only include if this entry owns this field
|
|
3506
|
+
if (fieldToEntryMap.get(fieldSuffix) === i) {
|
|
3507
|
+
filteredVarSchema[path] = type;
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
if (Object.keys(filteredVarSchema).length > 0) {
|
|
3511
|
+
filteredPerVarSchemas[varName] = filteredVarSchema;
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
entry.perVariableSchemas =
|
|
3515
|
+
Object.keys(filteredPerVarSchemas).length > 0
|
|
3516
|
+
? filteredPerVarSchemas
|
|
3517
|
+
: undefined;
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
return entries;
|
|
3521
|
+
};
|
|
3522
|
+
// Apply deduplication
|
|
3523
|
+
const deduplicatedExternalFunctionCalls = deduplicateParameterizedEntries(externalFunctionCalls);
|
|
3524
|
+
// IMPORTANT: Get equivalent signature variables BEFORE calling getFunctionResult
|
|
3525
|
+
// because getFunctionResult calls validateSchema which may remove equivalencies
|
|
3526
|
+
// during the finalize step (e.g., cleanNonObjectFunctions removes method call
|
|
3527
|
+
// equivalencies like `segments -> splat.split('/').functionCallReturnValue`).
|
|
3528
|
+
// Fix 33: Move this call before any schema validation to preserve method call chains.
|
|
3529
|
+
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
2500
3530
|
// Get root function result
|
|
2501
3531
|
const rootFunction = getFunctionResult();
|
|
2502
|
-
// Get results for each external function
|
|
3532
|
+
// Get results for each external function (use cleaned calls for consistency)
|
|
2503
3533
|
const functionResults = {};
|
|
2504
|
-
for (const efc of
|
|
3534
|
+
for (const efc of cleanedExternalCalls) {
|
|
2505
3535
|
functionResults[efc.name] = getFunctionResult(efc.name);
|
|
2506
3536
|
}
|
|
2507
|
-
// Get equivalent signature variables
|
|
2508
|
-
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
2509
3537
|
const environmentVariables = this.getEnvironmentVariables();
|
|
2510
3538
|
// Get enriched conditional usages with source tracing
|
|
2511
3539
|
const enrichedConditionalUsages = this.getEnrichedConditionalUsages();
|
|
2512
3540
|
const conditionalUsages = Object.keys(enrichedConditionalUsages).length > 0
|
|
2513
3541
|
? enrichedConditionalUsages
|
|
2514
3542
|
: undefined;
|
|
3543
|
+
// Get conditional effects (setter calls inside conditionals)
|
|
3544
|
+
const conditionalEffects = this.rawConditionalEffects.length > 0
|
|
3545
|
+
? this.rawConditionalEffects
|
|
3546
|
+
: undefined;
|
|
3547
|
+
// Get compound conditionals (grouped conditions that must all be true)
|
|
3548
|
+
const compoundConditionals = this.rawCompoundConditionals.length > 0
|
|
3549
|
+
? this.rawCompoundConditionals
|
|
3550
|
+
: undefined;
|
|
3551
|
+
// Get child boundary gating conditions
|
|
3552
|
+
const enrichedGatingConditions = this.getEnrichedChildBoundaryGatingConditions();
|
|
3553
|
+
const childBoundaryGatingConditions = Object.keys(enrichedGatingConditions).length > 0
|
|
3554
|
+
? enrichedGatingConditions
|
|
3555
|
+
: undefined;
|
|
2515
3556
|
return {
|
|
2516
|
-
externalFunctionCalls,
|
|
3557
|
+
externalFunctionCalls: deduplicatedExternalFunctionCalls,
|
|
2517
3558
|
rootFunction,
|
|
2518
3559
|
functionResults,
|
|
2519
3560
|
equivalentSignatureVariables,
|
|
2520
3561
|
environmentVariables,
|
|
2521
3562
|
conditionalUsages,
|
|
3563
|
+
conditionalEffects,
|
|
3564
|
+
compoundConditionals,
|
|
3565
|
+
childBoundaryGatingConditions,
|
|
2522
3566
|
};
|
|
2523
3567
|
}
|
|
2524
3568
|
// ═══════════════════════════════════════════════════════════════════════════
|