@codeyam/codeyam-cli 0.1.0-staging.76566f9 → 0.1.0-staging.79ef713
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +15 -12
- package/analyzer-template/packages/ai/index.ts +20 -5
- package/analyzer-template/packages/ai/package.json +3 -3
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +212 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +183 -10
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +15 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1128 -30
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +259 -6
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1577 -313
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +296 -35
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +10 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +54 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +129 -20
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +80 -5
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +393 -90
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +33 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +86 -142
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +59 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1358 -67
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +200 -196
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +578 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2267 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +5 -5
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -142
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +90 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -89
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +11 -11
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +122 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +449 -283
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +34 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +201 -46
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +254 -41
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +306 -20
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -3
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +723 -46
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +3 -3
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +8 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +17 -1
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +8 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -18
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +17 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +3 -4
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js +0 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +71 -27
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +3 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +9 -54
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +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 +3 -6
- package/analyzer-template/packages/types/src/types/Analysis.ts +87 -27
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +9 -77
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +181 -5
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/index.d.ts +3 -4
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js +0 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +71 -27
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +3 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +9 -54
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +57 -26
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1004 -105
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +18 -7
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +81 -9
- package/analyzer-template/project/reconcileMockDataKeys.ts +240 -0
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +51 -15
- package/analyzer-template/project/startScenarioCapture.ts +6 -0
- package/analyzer-template/project/writeMockDataTsx.ts +298 -11
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +312 -42
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +23 -13
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +1 -29
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/local/execAsync.js +1 -1
- package/background/src/lib/local/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/common/execAsync.js +1 -1
- package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +879 -69
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +7 -5
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +65 -10
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +199 -0
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +47 -15
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +7 -0
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +255 -8
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +245 -41
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +23 -13
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +7 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +1 -1
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +174 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +35 -23
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +0 -15
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +264 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +29 -18
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/report.js +46 -1
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +1 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +29 -15
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +16 -2
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +4 -3
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +76 -17
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +109 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +6 -0
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +285 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +115 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +6 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +78 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/versionInfo.js +25 -19
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +74 -20
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +40 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-B86KKU7e.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-CzGX-miz.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BqY8gDAW.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-ClaLpuOo.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-BDhPilK7.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CBQPrpT0.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-D1CdlbrV.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-wDPcZNKx.js → LogViewer-Bm3PmcCz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-C6PKeMYR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-BfmDgXxG.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BNLaXBHR.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-6J7zDUD5.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-B3TDXxnk.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BtBFH820.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DfKzxuoe.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BYimnrHg.js → chevron-down-TJp6ofnp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-JE9ZIoBl.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CaVsIRxt.js → circle-check-CXhHQYrI.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CgUsG7ib.js → createLucideIcon-Ca9fAY46.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-C5lqplTC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-Dt-SjPsw.js → entity._sha._-n38keI1k.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DGgZjdFg.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CfLCUi9S.js → entity._sha_.edit._scenarioId-38yPijoD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DKJyZfAY.js → entry.client-BSHEfydn.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DAtOlaWE.js → fileTableUtils-DCPhhSMo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-0N0YJQv7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{git-D62Lxxmv.js → git-DXnyr8uP.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/globals-Bh6jH0cL.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-BosqDOlH.js → index-CcsFv748.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-CzNNiTkw.js → index-ChN9-fAY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-CdVUfvji.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CNp9QFCX.js → loader-circle-CTqLEAGU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-87319d0f.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CPIDnDEj.js +76 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-D6oziHts.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-DDGjYAMJ.js → search-B8VUL8nl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-eBI36Yv5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CPoAg7Zo.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CBc5dE1s.js → triangle-alert-BZz2NjYa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DNwUduNu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BqPPNjAl.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CpZgwliL.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-DWHcCcl1.js → useToast-Bv9JFvUO.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-9ox9LcrG.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Cq5Vqcob.js +260 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
- package/codeyam-cli/templates/{debug-codeyam.md → codeyam:diagnose.md} +204 -26
- package/codeyam-cli/templates/codeyam:memory.md +404 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +1 -1
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +590 -0
- package/codeyam-cli/templates/rules-instructions.md +123 -0
- package/package.json +12 -9
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +165 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +138 -9
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +7 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +866 -29
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +178 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1240 -181
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +230 -23
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +7 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +52 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +111 -14
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +73 -5
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +333 -81
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +111 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +21 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +78 -120
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +47 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1082 -62
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +177 -163
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +400 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1646 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -2
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +88 -46
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -100
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +68 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -70
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +9 -9
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +94 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +196 -57
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +24 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +170 -40
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +211 -29
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +218 -20
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -3
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +599 -38
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +8 -1
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/loadAnalyses.js +45 -2
- package/packages/database/src/lib/loadAnalyses.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js +0 -1
- package/packages/types/index.js.map +1 -1
- package/packages/types/src/types/Scenario.js +1 -21
- package/packages/types/src/types/Scenario.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +3 -3
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -409
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -288
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -495
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -120
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CVP_WGQ3.js +0 -32
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-C9s7Lhdl.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-0d27da29.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-B_wIKCIf.js +0 -56
- package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CU58-Ttc.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-D35o2uae.js +0 -175
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -298
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -226
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -408
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -77
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.link-scenario-value-l0sNRNKZ.js → api.agent-transcripts-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-key-attributes-l0sNRNKZ.js → api.health-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-valid-values-l0sNRNKZ.js → api.memory-profile-l0sNRNKZ.js} +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -82,21 +82,36 @@
|
|
|
82
82
|
import { ScopeAnalysis } from '~codeyam/types';
|
|
83
83
|
import { EquivalencyManager } from './equivalencyManagers/EquivalencyManager';
|
|
84
84
|
import fillInSchemaGapsAndUnknowns from './helpers/fillInSchemaGapsAndUnknowns';
|
|
85
|
+
import { clearCleanKnownObjectFunctionsCache } from './helpers/cleanKnownObjectFunctions';
|
|
86
|
+
import { clearCleanNonObjectFunctionsCache } from './helpers/cleanNonObjectFunctions';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Patterns that indicate recursive type structures in schema paths.
|
|
90
|
+
* Used by hasExcessivePatternRepetition() to detect exponential path blowup.
|
|
91
|
+
*/
|
|
92
|
+
const RECURSIVE_PATH_PATTERNS = [
|
|
93
|
+
/\.attributes\.properties\[\]/g, // TypeScript AST JSX nodes
|
|
94
|
+
/\.children\[\]/g, // Tree structures
|
|
95
|
+
/\.elements\[\]/g, // Array-like structures
|
|
96
|
+
/\.members\[\]/g, // Class/interface members
|
|
97
|
+
/\.properties\[\]/g, // Object properties
|
|
98
|
+
/\.items\[\]/g, // Generic items arrays
|
|
99
|
+
];
|
|
85
100
|
import ensureSchemaConsistency from './helpers/ensureSchemaConsistency';
|
|
86
101
|
import cleanPath from './helpers/cleanPath';
|
|
87
102
|
import { PathManager } from './helpers/PathManager';
|
|
88
103
|
import {
|
|
89
104
|
uniqueId,
|
|
90
|
-
uniqueScopeVariables,
|
|
91
105
|
uniqueScopeAndPaths,
|
|
106
|
+
uniqueScopeVariables,
|
|
92
107
|
} from './helpers/uniqueIdUtils';
|
|
93
108
|
import selectBestValue from './helpers/selectBestValue';
|
|
94
109
|
import { VisitedTracker } from './helpers/VisitedTracker';
|
|
95
110
|
import { DebugTracer } from './helpers/DebugTracer';
|
|
96
111
|
import { BatchSchemaProcessor } from './helpers/BatchSchemaProcessor';
|
|
97
112
|
import {
|
|
98
|
-
ScopeTreeManager,
|
|
99
113
|
ROOT_SCOPE_NAME,
|
|
114
|
+
ScopeTreeManager,
|
|
100
115
|
ScopeTreeNode,
|
|
101
116
|
} from './helpers/ScopeTreeManager';
|
|
102
117
|
import cleanScopeNodeName from './helpers/cleanScopeNodeName';
|
|
@@ -108,6 +123,7 @@ import type {
|
|
|
108
123
|
SerializableFunctionCallInfo,
|
|
109
124
|
SerializableFunctionResult,
|
|
110
125
|
SerializableScopeVariable,
|
|
126
|
+
EnrichedConditionalUsage,
|
|
111
127
|
} from '../worker/SerializableDataStructure';
|
|
112
128
|
|
|
113
129
|
/**
|
|
@@ -125,6 +141,21 @@ export interface ScopeInfo {
|
|
|
125
141
|
isStatic?: boolean;
|
|
126
142
|
isClassScope?: boolean;
|
|
127
143
|
analysis?: any;
|
|
144
|
+
/** For JSX child scopes, the original JSX tag name (e.g., 'ChildViewer') */
|
|
145
|
+
jsxTagName?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Gating conditions detected during JSX extraction (before JSX is simplified).
|
|
148
|
+
* Maps child component name to conditions that must be true for it to render.
|
|
149
|
+
* This is populated by processJSXForScope in isolateScopes.ts.
|
|
150
|
+
*/
|
|
151
|
+
extractedGatingConditions?: {
|
|
152
|
+
[childComponentName: string]: Array<{
|
|
153
|
+
path: string;
|
|
154
|
+
conditionType: 'truthiness' | 'comparison';
|
|
155
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
156
|
+
isNegated?: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
};
|
|
128
159
|
}
|
|
129
160
|
|
|
130
161
|
/**
|
|
@@ -303,6 +334,19 @@ export function resetScopeDataStructureMetrics() {
|
|
|
303
334
|
followEquivalenciesEarlyExitPhase1Count = 0;
|
|
304
335
|
followEquivalenciesWithWorkCount = 0;
|
|
305
336
|
addEquivalencyCallCount = 0;
|
|
337
|
+
|
|
338
|
+
// Clear module-level caches to prevent unbounded memory growth across entities
|
|
339
|
+
const knownObjectCache = clearCleanKnownObjectFunctionsCache();
|
|
340
|
+
const nonObjectCache = clearCleanNonObjectFunctionsCache();
|
|
341
|
+
if (knownObjectCache.count > 0 || nonObjectCache.count > 0) {
|
|
342
|
+
const totalBytes =
|
|
343
|
+
knownObjectCache.estimatedBytes + nonObjectCache.estimatedBytes;
|
|
344
|
+
console.log('CodeYam: Cleared analysis caches', {
|
|
345
|
+
knownObjectCache: `${knownObjectCache.count} entries, ${(knownObjectCache.estimatedBytes / 1024).toFixed(1)}KB`,
|
|
346
|
+
nonObjectCache: `${nonObjectCache.count} entries, ${(nonObjectCache.estimatedBytes / 1024).toFixed(1)}KB`,
|
|
347
|
+
totalKB: `${(totalBytes / 1024).toFixed(1)}KB`,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
306
350
|
}
|
|
307
351
|
|
|
308
352
|
// Performance: Pre-computed Sets for equivalency reason filtering (O(1) vs O(n))
|
|
@@ -380,10 +424,40 @@ export class ScopeDataStructure {
|
|
|
380
424
|
path: string;
|
|
381
425
|
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
382
426
|
comparedValues?: string[];
|
|
383
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
427
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
384
428
|
}>
|
|
385
429
|
> = {};
|
|
386
430
|
|
|
431
|
+
/**
|
|
432
|
+
* Conditional effects collected during AST analysis.
|
|
433
|
+
* Tracks what setter calls happen inside conditionals (if, switch, ternary).
|
|
434
|
+
*/
|
|
435
|
+
private rawConditionalEffects: import('../astScopes/types').ConditionalEffect[] =
|
|
436
|
+
[];
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Compound conditionals collected during AST analysis.
|
|
440
|
+
* Groups conditions that must all be true together (e.g., a && b && c).
|
|
441
|
+
*/
|
|
442
|
+
private rawCompoundConditionals: import('../astScopes/types').CompoundConditional[] =
|
|
443
|
+
[];
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Gating conditions for child component boundaries.
|
|
447
|
+
* Maps child component name to the conditions that must be true for it to render.
|
|
448
|
+
*/
|
|
449
|
+
private rawChildBoundaryGatingConditions: Record<
|
|
450
|
+
string,
|
|
451
|
+
import('../astScopes/types').ConditionalUsage[]
|
|
452
|
+
> = {};
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* JSX rendering usages collected during AST analysis.
|
|
456
|
+
* Tracks arrays rendered via .map() and strings interpolated in JSX.
|
|
457
|
+
*/
|
|
458
|
+
private rawJsxRenderingUsages: import('../astScopes/types').JsxRenderingUsage[] =
|
|
459
|
+
[];
|
|
460
|
+
|
|
387
461
|
private lastAddToSchemaId = 0;
|
|
388
462
|
private lastEquivalencyId = 0;
|
|
389
463
|
private lastEquivalencyDatabaseId = 0;
|
|
@@ -725,6 +799,11 @@ export class ScopeDataStructure {
|
|
|
725
799
|
return;
|
|
726
800
|
}
|
|
727
801
|
|
|
802
|
+
// PERF: Early exit for paths with repeated function-call signature patterns
|
|
803
|
+
if (this.hasExcessivePatternRepetition(path)) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
|
|
728
807
|
// Update chain metadata for database tracking
|
|
729
808
|
if (equivalencyValueChain.length > 0) {
|
|
730
809
|
equivalencyValueChain[equivalencyValueChain.length - 1].addToSchemaId =
|
|
@@ -968,8 +1047,8 @@ export class ScopeDataStructure {
|
|
|
968
1047
|
equivalencyValueChain?: EquivalencyValueChainItem[],
|
|
969
1048
|
traceId?: number,
|
|
970
1049
|
) {
|
|
971
|
-
// DEBUG: Detect infinite loops
|
|
972
1050
|
addEquivalencyCallCount++;
|
|
1051
|
+
|
|
973
1052
|
if (addEquivalencyCallCount > 50000) {
|
|
974
1053
|
console.error('INFINITE LOOP DETECTED in addEquivalency', {
|
|
975
1054
|
callCount: addEquivalencyCallCount,
|
|
@@ -1412,6 +1491,15 @@ export class ScopeDataStructure {
|
|
|
1412
1491
|
|
|
1413
1492
|
const bestValue = selectBestValue(value1, value2);
|
|
1414
1493
|
|
|
1494
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
1495
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
1496
|
+
if (
|
|
1497
|
+
this.hasExcessivePatternRepetition(schemaPath) ||
|
|
1498
|
+
this.hasExcessivePatternRepetition(equivalentSchemaPath)
|
|
1499
|
+
) {
|
|
1500
|
+
continue;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1415
1503
|
scopeNode.schema[schemaPath] = bestValue;
|
|
1416
1504
|
equivalentScopeNode.schema[equivalentSchemaPath] = bestValue;
|
|
1417
1505
|
} else if (
|
|
@@ -1425,6 +1513,11 @@ export class ScopeDataStructure {
|
|
|
1425
1513
|
...remainingSchemaPathParts,
|
|
1426
1514
|
]);
|
|
1427
1515
|
|
|
1516
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
1517
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
1518
|
+
continue;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1428
1521
|
equivalentScopeNode.schema[newEquivalentPath] =
|
|
1429
1522
|
scopeNode.schema[schemaPath];
|
|
1430
1523
|
}
|
|
@@ -1515,6 +1608,77 @@ export class ScopeDataStructure {
|
|
|
1515
1608
|
return this.pathManager.isValidPath(path);
|
|
1516
1609
|
}
|
|
1517
1610
|
|
|
1611
|
+
/**
|
|
1612
|
+
* Detects if a path contains excessive repetition of the same pattern.
|
|
1613
|
+
*
|
|
1614
|
+
* This prevents exponential blowup when analyzing recursive type structures.
|
|
1615
|
+
* For example, TypeScript AST nodes have `.attributes.properties[]` where each
|
|
1616
|
+
* property is also a node with `.attributes.properties[]`. Without this check,
|
|
1617
|
+
* paths like `signature[0].attributes.properties[].attributes.properties[].attributes.properties[]...`
|
|
1618
|
+
* would be generated exponentially.
|
|
1619
|
+
*
|
|
1620
|
+
* Two detection strategies:
|
|
1621
|
+
* 1. Known patterns: Check RECURSIVE_PATH_PATTERNS for common recursive structures
|
|
1622
|
+
* 2. Generic detection: For longer paths, detect any 2-3 part segment that repeats
|
|
1623
|
+
*
|
|
1624
|
+
* @param path - The schema path to check
|
|
1625
|
+
* @param maxRepetitions - Maximum allowed repetitions of any pattern (default: 2)
|
|
1626
|
+
* @returns true if the path has excessive repetition
|
|
1627
|
+
*/
|
|
1628
|
+
private hasExcessivePatternRepetition(
|
|
1629
|
+
path: string,
|
|
1630
|
+
maxRepetitions = 2,
|
|
1631
|
+
): boolean {
|
|
1632
|
+
// Check known recursive patterns
|
|
1633
|
+
for (const pattern of RECURSIVE_PATH_PATTERNS) {
|
|
1634
|
+
const matches = path.match(pattern);
|
|
1635
|
+
if (matches && matches.length > maxRepetitions) {
|
|
1636
|
+
return true;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// Check for repeated function calls that indicate recursive type expansion.
|
|
1641
|
+
// E.g., localeCompare(b[])...localeCompare(b[]) means string.localeCompare
|
|
1642
|
+
// returns a type that again has localeCompare, causing infinite expansion.
|
|
1643
|
+
// We extract all function call patterns like "funcName(args)" and check if
|
|
1644
|
+
// the same normalized call appears more than once.
|
|
1645
|
+
const funcCallPattern = /(?:^|\.)[^.([]+\([^)]*\)/g;
|
|
1646
|
+
const funcCallMatches = path.match(funcCallPattern);
|
|
1647
|
+
if (funcCallMatches && funcCallMatches.length > 1) {
|
|
1648
|
+
const seen = new Set<string>();
|
|
1649
|
+
for (const match of funcCallMatches) {
|
|
1650
|
+
// Strip leading dot and normalize array indices
|
|
1651
|
+
const normalized = match.replace(/^\./, '').replace(/\[\d+\]/g, '[]');
|
|
1652
|
+
if (seen.has(normalized)) return true;
|
|
1653
|
+
seen.add(normalized);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
// For longer paths, detect any repeated multi-part segments we haven't explicitly listed
|
|
1658
|
+
const pathParts = this.splitPath(path);
|
|
1659
|
+
if (pathParts.length <= 6) {
|
|
1660
|
+
return false;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
// Check for repeated sequences of 2-3 consecutive parts
|
|
1664
|
+
for (let segmentLength = 2; segmentLength <= 3; segmentLength++) {
|
|
1665
|
+
const seen = new Map<string, number>();
|
|
1666
|
+
|
|
1667
|
+
for (let i = 0; i <= pathParts.length - segmentLength; i++) {
|
|
1668
|
+
const segment = pathParts.slice(i, i + segmentLength).join('.');
|
|
1669
|
+
const normalizedSegment = segment.replace(/\[\d+\]/g, '[]');
|
|
1670
|
+
const count = (seen.get(normalizedSegment) || 0) + 1;
|
|
1671
|
+
seen.set(normalizedSegment, count);
|
|
1672
|
+
|
|
1673
|
+
if (count > maxRepetitions) {
|
|
1674
|
+
return true;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
return false;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1518
1682
|
private addToTree(pathParts: string[]) {
|
|
1519
1683
|
this.scopeTreeManager.addPath(pathParts);
|
|
1520
1684
|
}
|
|
@@ -1522,17 +1686,26 @@ export class ScopeDataStructure {
|
|
|
1522
1686
|
private setInstantiatedVariables(scopeNode: ScopeNode) {
|
|
1523
1687
|
let instantiatedVariables = scopeNode.analysis?.instantiatedVariables ?? [];
|
|
1524
1688
|
|
|
1525
|
-
for (const [path,
|
|
1689
|
+
for (const [path, rawEquivalentPath] of Object.entries(
|
|
1526
1690
|
scopeNode.analysis.isolatedEquivalentVariables ?? {},
|
|
1527
1691
|
)) {
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1692
|
+
// Normalize to array for consistent handling (supports both string and string[])
|
|
1693
|
+
const equivalentPaths = Array.isArray(rawEquivalentPath)
|
|
1694
|
+
? rawEquivalentPath
|
|
1695
|
+
: rawEquivalentPath
|
|
1696
|
+
? [rawEquivalentPath]
|
|
1697
|
+
: [];
|
|
1698
|
+
|
|
1699
|
+
for (const equivalentPath of equivalentPaths) {
|
|
1700
|
+
if (typeof equivalentPath !== 'string') {
|
|
1701
|
+
continue;
|
|
1702
|
+
}
|
|
1531
1703
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1704
|
+
if (equivalentPath.startsWith('signature[')) {
|
|
1705
|
+
const equivalentPathParts = this.splitPath(equivalentPath);
|
|
1706
|
+
instantiatedVariables.push(equivalentPathParts[0]);
|
|
1707
|
+
instantiatedVariables.push(path);
|
|
1708
|
+
}
|
|
1536
1709
|
}
|
|
1537
1710
|
|
|
1538
1711
|
const duplicateInstantiated = instantiatedVariables.find(
|
|
@@ -1545,9 +1718,14 @@ export class ScopeDataStructure {
|
|
|
1545
1718
|
}
|
|
1546
1719
|
}
|
|
1547
1720
|
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1721
|
+
const instantiatedSeen = new Set<string>();
|
|
1722
|
+
instantiatedVariables = instantiatedVariables.filter((varName) => {
|
|
1723
|
+
if (instantiatedSeen.has(varName)) {
|
|
1724
|
+
return false;
|
|
1725
|
+
}
|
|
1726
|
+
instantiatedSeen.add(varName);
|
|
1727
|
+
return true;
|
|
1728
|
+
});
|
|
1551
1729
|
|
|
1552
1730
|
scopeNode.instantiatedVariables = instantiatedVariables;
|
|
1553
1731
|
|
|
@@ -1568,13 +1746,19 @@ export class ScopeDataStructure {
|
|
|
1568
1746
|
...parentScopeNode.instantiatedVariables.filter(
|
|
1569
1747
|
(v) => !v.startsWith('signature[') && !v.startsWith('returnValue'),
|
|
1570
1748
|
),
|
|
1571
|
-
].filter(
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1749
|
+
].filter((varName) => !instantiatedSeen.has(varName));
|
|
1750
|
+
|
|
1751
|
+
const parentInstantiatedSeen = new Set<string>();
|
|
1752
|
+
const dedupedParentInstantiatedVariables =
|
|
1753
|
+
parentInstantiatedVariables.filter((varName) => {
|
|
1754
|
+
if (parentInstantiatedSeen.has(varName)) {
|
|
1755
|
+
return false;
|
|
1756
|
+
}
|
|
1757
|
+
parentInstantiatedSeen.add(varName);
|
|
1758
|
+
return true;
|
|
1759
|
+
});
|
|
1576
1760
|
|
|
1577
|
-
scopeNode.parentInstantiatedVariables =
|
|
1761
|
+
scopeNode.parentInstantiatedVariables = dedupedParentInstantiatedVariables;
|
|
1578
1762
|
}
|
|
1579
1763
|
|
|
1580
1764
|
private trackFunctionCalls(scopeNode: ScopeNode) {
|
|
@@ -1583,197 +1767,205 @@ export class ScopeDataStructure {
|
|
|
1583
1767
|
}
|
|
1584
1768
|
|
|
1585
1769
|
private determineEquivalenciesAndBuildSchema(scopeNode: ScopeNode) {
|
|
1770
|
+
if (!scopeNode.analysis) {
|
|
1771
|
+
return;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1586
1774
|
const { isolatedStructure, isolatedEquivalentVariables } =
|
|
1587
1775
|
scopeNode.analysis;
|
|
1588
1776
|
|
|
1589
|
-
//
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
)
|
|
1594
|
-
) {
|
|
1595
|
-
console.log(
|
|
1596
|
-
'CodeYam DEBUG determineEquivalenciesAndBuildSchema:',
|
|
1597
|
-
JSON.stringify(
|
|
1598
|
-
{
|
|
1599
|
-
scopeNodeName: scopeNode.name,
|
|
1600
|
-
fetcherEquivalencies: Object.entries(
|
|
1601
|
-
isolatedEquivalentVariables || {},
|
|
1602
|
-
)
|
|
1603
|
-
.filter(
|
|
1604
|
-
([k, v]) =>
|
|
1605
|
-
k.includes('Fetcher') ||
|
|
1606
|
-
k.includes('fetcher') ||
|
|
1607
|
-
String(v).includes('Fetcher') ||
|
|
1608
|
-
String(v).includes('fetcher'),
|
|
1609
|
-
)
|
|
1610
|
-
.reduce(
|
|
1611
|
-
(acc, [k, v]) => {
|
|
1612
|
-
acc[k] = v;
|
|
1613
|
-
return acc;
|
|
1614
|
-
},
|
|
1615
|
-
{} as Record<string, string>,
|
|
1616
|
-
),
|
|
1617
|
-
},
|
|
1618
|
-
null,
|
|
1619
|
-
2,
|
|
1620
|
-
),
|
|
1621
|
-
);
|
|
1622
|
-
}
|
|
1777
|
+
// Flatten isolatedEquivalentVariables values for allPaths (handles both string and string[])
|
|
1778
|
+
const flattenedEquivValues = Object.values(
|
|
1779
|
+
isolatedEquivalentVariables || {},
|
|
1780
|
+
).flatMap((v) => (Array.isArray(v) ? v : [v]));
|
|
1623
1781
|
|
|
1624
1782
|
const allPaths = Array.from(
|
|
1625
1783
|
new Set([
|
|
1626
1784
|
...Object.keys(isolatedStructure || {}),
|
|
1627
1785
|
...Object.keys(isolatedEquivalentVariables || {}),
|
|
1628
|
-
...
|
|
1786
|
+
...flattenedEquivValues,
|
|
1629
1787
|
]),
|
|
1630
1788
|
);
|
|
1631
1789
|
|
|
1632
1790
|
for (let path in isolatedEquivalentVariables) {
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
)
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1791
|
+
const rawEquivalentValue = isolatedEquivalentVariables?.[path];
|
|
1792
|
+
// Normalize to array for consistent handling
|
|
1793
|
+
const equivalentValues = Array.isArray(rawEquivalentValue)
|
|
1794
|
+
? rawEquivalentValue
|
|
1795
|
+
: [rawEquivalentValue];
|
|
1796
|
+
|
|
1797
|
+
for (let equivalentValue of equivalentValues) {
|
|
1798
|
+
if (equivalentValue && this.isValidPath(equivalentValue)) {
|
|
1799
|
+
// IMPORTANT: DO NOT strip ::cyDuplicateKey:: markers from equivalencies.
|
|
1800
|
+
// These markers are critical for distinguishing variable reassignments.
|
|
1801
|
+
// For example, with:
|
|
1802
|
+
// let fetcher = useFetcher<ConfigData>();
|
|
1803
|
+
// const configData = fetcher.data?.data;
|
|
1804
|
+
// fetcher = useFetcher<SettingsData>();
|
|
1805
|
+
// const settingsData = fetcher.data?.data;
|
|
1806
|
+
//
|
|
1807
|
+
// mergeStatements creates:
|
|
1808
|
+
// fetcher → useFetcher<ConfigData>()...
|
|
1809
|
+
// fetcher::cyDuplicateKey1:: → useFetcher<SettingsData>()...
|
|
1810
|
+
// configData → fetcher.data.data
|
|
1811
|
+
// settingsData → fetcher::cyDuplicateKey1::.data.data
|
|
1812
|
+
//
|
|
1813
|
+
// If we strip ::cyDuplicateKey::, settingsData would incorrectly trace
|
|
1814
|
+
// to useFetcher<ConfigData>() instead of useFetcher<SettingsData>().
|
|
1815
|
+
path = cleanPath(path, allPaths);
|
|
1816
|
+
equivalentValue = cleanPath(equivalentValue, allPaths);
|
|
1817
|
+
|
|
1818
|
+
this.addEquivalency(
|
|
1819
|
+
path,
|
|
1820
|
+
equivalentValue,
|
|
1821
|
+
scopeNode.name,
|
|
1822
|
+
scopeNode,
|
|
1823
|
+
'original equivalency',
|
|
1824
|
+
);
|
|
1649
1825
|
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1826
|
+
// Propagate equivalencies involving parent-scope variables to those parent scopes.
|
|
1827
|
+
// This handles patterns like: collected.push({...entity}) where 'collected' is defined
|
|
1828
|
+
// in a parent scope. The equivalency collected[] -> push().signature[0] needs to be
|
|
1829
|
+
// visible when tracing from the parent scope.
|
|
1830
|
+
const rootVariable = this.extractRootVariable(path);
|
|
1831
|
+
const equivalentRootVariable =
|
|
1832
|
+
this.extractRootVariable(equivalentValue);
|
|
1833
|
+
|
|
1834
|
+
// Skip propagation for self-referential reassignment patterns like:
|
|
1835
|
+
// x = x.method().functionCallReturnValue
|
|
1836
|
+
// where the path IS the variable itself (not a sub-path like x[] or x.prop).
|
|
1837
|
+
// These create circular references since both sides reference the same variable.
|
|
1838
|
+
//
|
|
1839
|
+
// But DO propagate for patterns like collected[] -> collected.push(...).signature[0]
|
|
1840
|
+
// where the path has additional segments beyond the root variable.
|
|
1841
|
+
const pathIsJustRootVariable = path === rootVariable;
|
|
1842
|
+
const isSelfReferentialReassignment =
|
|
1843
|
+
pathIsJustRootVariable && rootVariable === equivalentRootVariable;
|
|
1668
1844
|
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1845
|
+
if (
|
|
1846
|
+
rootVariable &&
|
|
1847
|
+
!isSelfReferentialReassignment &&
|
|
1848
|
+
scopeNode.parentInstantiatedVariables?.includes(rootVariable)
|
|
1849
|
+
) {
|
|
1850
|
+
// Find the parent scope where this variable is defined
|
|
1851
|
+
for (const parentScopeName of scopeNode.tree || []) {
|
|
1852
|
+
const parentScope = this.scopeNodes[parentScopeName];
|
|
1853
|
+
if (parentScope?.instantiatedVariables?.includes(rootVariable)) {
|
|
1854
|
+
// Add the equivalency to the parent scope as well
|
|
1855
|
+
this.addEquivalency(
|
|
1856
|
+
path,
|
|
1857
|
+
equivalentValue,
|
|
1858
|
+
scopeNode.name, // The equivalent path's scope remains the child scope
|
|
1859
|
+
parentScope, // But store it in the parent scope's equivalencies
|
|
1860
|
+
'propagated parent-variable equivalency',
|
|
1861
|
+
);
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1687
1864
|
}
|
|
1688
1865
|
}
|
|
1689
|
-
}
|
|
1690
1866
|
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
const
|
|
1722
|
-
|
|
1723
|
-
|
|
1867
|
+
// Propagate sub-property equivalencies when the equivalentValue is a simple variable
|
|
1868
|
+
// that has sub-properties defined in the isolatedEquivalentVariables.
|
|
1869
|
+
// This handles cases like: dataItem={{ structure: completeDataStructure }}
|
|
1870
|
+
// where completeDataStructure has sub-properties like completeDataStructure['Function Arguments']
|
|
1871
|
+
// We need to propagate these to create: dataItem.structure['Function Arguments'] equivalencies
|
|
1872
|
+
const isSimpleVariable =
|
|
1873
|
+
!equivalentValue.startsWith('signature[') &&
|
|
1874
|
+
!equivalentValue.includes('functionCallReturnValue') &&
|
|
1875
|
+
!equivalentValue.includes('.') &&
|
|
1876
|
+
!equivalentValue.includes('[');
|
|
1877
|
+
|
|
1878
|
+
if (isSimpleVariable) {
|
|
1879
|
+
// Look in current scope and all parent scopes for sub-properties
|
|
1880
|
+
const scopesToCheck = [scopeNode.name, ...scopeNode.tree];
|
|
1881
|
+
for (const scopeName of scopesToCheck) {
|
|
1882
|
+
const checkScope = this.scopeNodes[scopeName];
|
|
1883
|
+
if (!checkScope?.analysis?.isolatedEquivalentVariables) continue;
|
|
1884
|
+
|
|
1885
|
+
for (const [subPath, rawSubValue] of Object.entries(
|
|
1886
|
+
checkScope.analysis.isolatedEquivalentVariables,
|
|
1887
|
+
)) {
|
|
1888
|
+
// Normalize to array for consistent handling
|
|
1889
|
+
const subValues = Array.isArray(rawSubValue)
|
|
1890
|
+
? rawSubValue
|
|
1891
|
+
: rawSubValue
|
|
1892
|
+
? [rawSubValue]
|
|
1893
|
+
: [];
|
|
1894
|
+
|
|
1895
|
+
// Check if this is a sub-property of the equivalentValue variable
|
|
1896
|
+
// e.g., completeDataStructure['Function Arguments'] or completeDataStructure.foo
|
|
1897
|
+
const matchesDot = subPath.startsWith(equivalentValue + '.');
|
|
1898
|
+
const matchesBracket = subPath.startsWith(
|
|
1899
|
+
equivalentValue + '[',
|
|
1724
1900
|
);
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
this.isValidPath(newEquivalentValue)
|
|
1729
|
-
) {
|
|
1730
|
-
this.addEquivalency(
|
|
1731
|
-
newPath,
|
|
1732
|
-
newEquivalentValue,
|
|
1733
|
-
checkScope.name, // Use the scope where the sub-property was found
|
|
1734
|
-
scopeNode,
|
|
1735
|
-
'propagated sub-property equivalency',
|
|
1901
|
+
if (matchesDot || matchesBracket) {
|
|
1902
|
+
const subPropertyPath = subPath.substring(
|
|
1903
|
+
equivalentValue.length,
|
|
1736
1904
|
);
|
|
1905
|
+
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
1906
|
+
|
|
1907
|
+
for (const subValue of subValues) {
|
|
1908
|
+
if (typeof subValue !== 'string') continue;
|
|
1909
|
+
const newEquivalentValue = cleanPath(
|
|
1910
|
+
subValue.replace(/::cyDuplicateKey\d+::/g, ''),
|
|
1911
|
+
allPaths,
|
|
1912
|
+
);
|
|
1913
|
+
|
|
1914
|
+
if (
|
|
1915
|
+
newEquivalentValue &&
|
|
1916
|
+
this.isValidPath(newEquivalentValue)
|
|
1917
|
+
) {
|
|
1918
|
+
this.addEquivalency(
|
|
1919
|
+
newPath,
|
|
1920
|
+
newEquivalentValue,
|
|
1921
|
+
checkScope.name, // Use the scope where the sub-property was found
|
|
1922
|
+
scopeNode,
|
|
1923
|
+
'propagated sub-property equivalency',
|
|
1924
|
+
);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1737
1927
|
}
|
|
1738
|
-
}
|
|
1739
1928
|
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1929
|
+
// Also check if equivalentValue itself maps to a functionCallReturnValue
|
|
1930
|
+
// e.g., result = useMemo(...).functionCallReturnValue
|
|
1931
|
+
for (const subValue of subValues) {
|
|
1932
|
+
if (
|
|
1933
|
+
subPath === equivalentValue &&
|
|
1934
|
+
typeof subValue === 'string' &&
|
|
1935
|
+
subValue.endsWith('.functionCallReturnValue')
|
|
1936
|
+
) {
|
|
1937
|
+
this.propagateFunctionCallReturnSubProperties(
|
|
1938
|
+
path,
|
|
1939
|
+
subValue,
|
|
1940
|
+
scopeNode,
|
|
1941
|
+
allPaths,
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1753
1945
|
}
|
|
1754
1946
|
}
|
|
1755
1947
|
}
|
|
1756
|
-
}
|
|
1757
1948
|
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1949
|
+
// Handle function call return values by propagating returnValue.* sub-properties
|
|
1950
|
+
// from the callback scope to the usage path
|
|
1951
|
+
if (equivalentValue.endsWith('.functionCallReturnValue')) {
|
|
1952
|
+
this.propagateFunctionCallReturnSubProperties(
|
|
1953
|
+
path,
|
|
1954
|
+
equivalentValue,
|
|
1955
|
+
scopeNode,
|
|
1956
|
+
allPaths,
|
|
1957
|
+
);
|
|
1767
1958
|
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1959
|
+
// Track which variable receives the return value of each function call
|
|
1960
|
+
// This enables generating separate mock data for each call site
|
|
1961
|
+
this.trackReceivingVariable(path, equivalentValue);
|
|
1962
|
+
}
|
|
1772
1963
|
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1964
|
+
// Also track variables that receive destructured properties from function call return values
|
|
1965
|
+
// e.g., "userData" -> "db.query('users').functionCallReturnValue.data"
|
|
1966
|
+
if (equivalentValue.includes('.functionCallReturnValue.')) {
|
|
1967
|
+
this.trackReceivingVariable(path, equivalentValue);
|
|
1968
|
+
}
|
|
1777
1969
|
}
|
|
1778
1970
|
}
|
|
1779
1971
|
}
|
|
@@ -1783,7 +1975,7 @@ export class ScopeDataStructure {
|
|
|
1783
1975
|
this.batchProcessor = new BatchSchemaProcessor();
|
|
1784
1976
|
this.batchQueuedSet = new Set();
|
|
1785
1977
|
|
|
1786
|
-
for (const key of
|
|
1978
|
+
for (const key of allPaths) {
|
|
1787
1979
|
let value = isolatedStructure[key] ?? 'unknown';
|
|
1788
1980
|
|
|
1789
1981
|
if (['null', 'undefined'].includes(value)) {
|
|
@@ -1824,7 +2016,19 @@ export class ScopeDataStructure {
|
|
|
1824
2016
|
private processBatchQueue(): void {
|
|
1825
2017
|
if (!this.batchProcessor) return;
|
|
1826
2018
|
|
|
2019
|
+
let iterations = 0;
|
|
2020
|
+
|
|
1827
2021
|
while (this.batchProcessor.hasWork()) {
|
|
2022
|
+
iterations++;
|
|
2023
|
+
|
|
2024
|
+
// Safety: detect potential infinite loops
|
|
2025
|
+
if (iterations > 100000) {
|
|
2026
|
+
console.error(
|
|
2027
|
+
`[ScopeDataStructure] processBatchQueue exceeded 100k iterations, possible infinite loop!`,
|
|
2028
|
+
);
|
|
2029
|
+
break;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
1828
2032
|
const item = this.batchProcessor.getNextWork();
|
|
1829
2033
|
if (!item) break;
|
|
1830
2034
|
|
|
@@ -1882,26 +2086,6 @@ export class ScopeDataStructure {
|
|
|
1882
2086
|
const functionCallInfo =
|
|
1883
2087
|
this.getExternalFunctionCallsIndex().get(searchKey);
|
|
1884
2088
|
|
|
1885
|
-
// DEBUG: Track useFetcher calls
|
|
1886
|
-
if (searchKey === 'useFetcher' || callSignature.includes('useFetcher')) {
|
|
1887
|
-
console.log(
|
|
1888
|
-
'CodeYam DEBUG trackReceivingVariable:',
|
|
1889
|
-
JSON.stringify(
|
|
1890
|
-
{
|
|
1891
|
-
receivingVariable,
|
|
1892
|
-
equivalentValue,
|
|
1893
|
-
callSignature,
|
|
1894
|
-
searchKey,
|
|
1895
|
-
foundFunctionCallInfo: !!functionCallInfo,
|
|
1896
|
-
existingRecvVars: functionCallInfo?.receivingVariableNames,
|
|
1897
|
-
existingCallSigToVar: functionCallInfo?.callSignatureToVariable,
|
|
1898
|
-
},
|
|
1899
|
-
null,
|
|
1900
|
-
2,
|
|
1901
|
-
),
|
|
1902
|
-
);
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
2089
|
if (!functionCallInfo) {
|
|
1906
2090
|
return;
|
|
1907
2091
|
}
|
|
@@ -1962,9 +2146,18 @@ export class ScopeDataStructure {
|
|
|
1962
2146
|
const checkScope = this.scopeNodes[scopeName];
|
|
1963
2147
|
if (!checkScope?.analysis?.isolatedEquivalentVariables) continue;
|
|
1964
2148
|
|
|
1965
|
-
const
|
|
2149
|
+
const rawFunctionRef =
|
|
1966
2150
|
checkScope.analysis.isolatedEquivalentVariables[functionName];
|
|
1967
|
-
|
|
2151
|
+
// Normalize to array and find first string ending with 'F'
|
|
2152
|
+
const functionRefs = Array.isArray(rawFunctionRef)
|
|
2153
|
+
? rawFunctionRef
|
|
2154
|
+
: rawFunctionRef
|
|
2155
|
+
? [rawFunctionRef]
|
|
2156
|
+
: [];
|
|
2157
|
+
const functionRef = functionRefs.find(
|
|
2158
|
+
(r) => typeof r === 'string' && r.endsWith('F'),
|
|
2159
|
+
);
|
|
2160
|
+
if (typeof functionRef === 'string') {
|
|
1968
2161
|
callbackScopeName = functionRef.slice(0, -1);
|
|
1969
2162
|
break;
|
|
1970
2163
|
}
|
|
@@ -1992,19 +2185,24 @@ export class ScopeDataStructure {
|
|
|
1992
2185
|
|
|
1993
2186
|
const isolatedVars = callbackScope.analysis.isolatedEquivalentVariables;
|
|
1994
2187
|
|
|
2188
|
+
// Get the first returnValue equivalency (normalize array to single value for these checks)
|
|
2189
|
+
const rawReturnValue = isolatedVars.returnValue;
|
|
2190
|
+
const firstReturnValue = Array.isArray(rawReturnValue)
|
|
2191
|
+
? rawReturnValue[0]
|
|
2192
|
+
: rawReturnValue;
|
|
2193
|
+
|
|
1995
2194
|
// First, check if returnValue is an alias to another variable (e.g., returnValue = intermediate)
|
|
1996
2195
|
// If so, we need to look for that variable's sub-properties too
|
|
1997
2196
|
const returnValueAlias =
|
|
1998
|
-
typeof
|
|
1999
|
-
|
|
2000
|
-
? isolatedVars.returnValue
|
|
2197
|
+
typeof firstReturnValue === 'string' && !firstReturnValue.includes('.')
|
|
2198
|
+
? firstReturnValue
|
|
2001
2199
|
: undefined;
|
|
2002
2200
|
|
|
2003
2201
|
// Pattern 3: Object.keys(X).reduce() - the reduce result has the same sub-properties as X
|
|
2004
2202
|
// When returnValue = "Object.keys(source).reduce(...).functionCallReturnValue", look for source.* sub-properties
|
|
2005
2203
|
let reduceSourceVar: string | undefined;
|
|
2006
|
-
if (typeof
|
|
2007
|
-
const reduceMatch =
|
|
2204
|
+
if (typeof firstReturnValue === 'string') {
|
|
2205
|
+
const reduceMatch = firstReturnValue.match(
|
|
2008
2206
|
/^Object\.keys\((\w+)\)\.reduce\(.*\)\.functionCallReturnValue$/,
|
|
2009
2207
|
);
|
|
2010
2208
|
if (reduceMatch) {
|
|
@@ -2012,7 +2210,14 @@ export class ScopeDataStructure {
|
|
|
2012
2210
|
}
|
|
2013
2211
|
}
|
|
2014
2212
|
|
|
2015
|
-
for (const [subPath,
|
|
2213
|
+
for (const [subPath, rawSubValue] of Object.entries(isolatedVars)) {
|
|
2214
|
+
// Normalize to array for consistent handling
|
|
2215
|
+
const subValues = Array.isArray(rawSubValue)
|
|
2216
|
+
? rawSubValue
|
|
2217
|
+
: rawSubValue
|
|
2218
|
+
? [rawSubValue]
|
|
2219
|
+
: [];
|
|
2220
|
+
|
|
2016
2221
|
// Check for direct returnValue.* sub-properties
|
|
2017
2222
|
const isReturnValueSub =
|
|
2018
2223
|
subPath.startsWith('returnValue.') ||
|
|
@@ -2030,57 +2235,59 @@ export class ScopeDataStructure {
|
|
|
2030
2235
|
(subPath.startsWith(reduceSourceVar + '.') ||
|
|
2031
2236
|
subPath.startsWith(reduceSourceVar + '['));
|
|
2032
2237
|
|
|
2033
|
-
if (
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2238
|
+
if (!isReturnValueSub && !isAliasSub && !isReduceSourceSub) continue;
|
|
2239
|
+
|
|
2240
|
+
for (const subValue of subValues) {
|
|
2241
|
+
if (typeof subValue !== 'string') continue;
|
|
2242
|
+
|
|
2243
|
+
// Convert alias/reduceSource paths to returnValue paths
|
|
2244
|
+
let effectiveSubPath = subPath;
|
|
2245
|
+
if (isAliasSub && !isReturnValueSub) {
|
|
2246
|
+
// Replace the alias prefix with returnValue
|
|
2247
|
+
effectiveSubPath =
|
|
2248
|
+
'returnValue' + subPath.substring(returnValueAlias!.length);
|
|
2249
|
+
} else if (isReduceSourceSub && !isReturnValueSub && !isAliasSub) {
|
|
2250
|
+
// Replace the reduce source prefix with returnValue
|
|
2251
|
+
effectiveSubPath =
|
|
2252
|
+
'returnValue' + subPath.substring(reduceSourceVar!.length);
|
|
2253
|
+
}
|
|
2254
|
+
const subPropertyPath = effectiveSubPath.substring(
|
|
2255
|
+
'returnValue'.length,
|
|
2256
|
+
);
|
|
2257
|
+
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
2258
|
+
let newEquivalentValue = cleanPath(
|
|
2259
|
+
subValue.replace(/::cyDuplicateKey\d+::/g, ''),
|
|
2260
|
+
allPaths,
|
|
2261
|
+
);
|
|
2056
2262
|
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2263
|
+
// Resolve variable references through parent scope equivalencies
|
|
2264
|
+
const resolved = this.resolveVariableThroughParentScopes(
|
|
2265
|
+
newEquivalentValue,
|
|
2266
|
+
callbackScope,
|
|
2267
|
+
allPaths,
|
|
2268
|
+
);
|
|
2269
|
+
newEquivalentValue = resolved.resolvedPath;
|
|
2270
|
+
const equivalentScopeName = resolved.scopeName;
|
|
2065
2271
|
|
|
2066
|
-
|
|
2067
|
-
|
|
2272
|
+
if (!newEquivalentValue || !this.isValidPath(newEquivalentValue))
|
|
2273
|
+
continue;
|
|
2068
2274
|
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2275
|
+
this.addEquivalency(
|
|
2276
|
+
newPath,
|
|
2277
|
+
newEquivalentValue,
|
|
2278
|
+
equivalentScopeName,
|
|
2279
|
+
scopeNode,
|
|
2280
|
+
'propagated function call return sub-property equivalency',
|
|
2281
|
+
);
|
|
2076
2282
|
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2283
|
+
// Ensure the database entry has the usage path
|
|
2284
|
+
this.addUsageToEquivalencyDatabaseEntry(
|
|
2285
|
+
newPath,
|
|
2286
|
+
newEquivalentValue,
|
|
2287
|
+
equivalentScopeName,
|
|
2288
|
+
scopeNode.name,
|
|
2289
|
+
);
|
|
2290
|
+
}
|
|
2084
2291
|
}
|
|
2085
2292
|
}
|
|
2086
2293
|
|
|
@@ -2120,8 +2327,15 @@ export class ScopeDataStructure {
|
|
|
2120
2327
|
const parentScope = this.scopeNodes[parentScopeName];
|
|
2121
2328
|
if (!parentScope?.analysis?.isolatedEquivalentVariables) continue;
|
|
2122
2329
|
|
|
2123
|
-
const
|
|
2330
|
+
const rawRootEquiv =
|
|
2124
2331
|
parentScope.analysis.isolatedEquivalentVariables[rootVar];
|
|
2332
|
+
// Normalize to array and use first string value
|
|
2333
|
+
const rootEquivs = Array.isArray(rawRootEquiv)
|
|
2334
|
+
? rawRootEquiv
|
|
2335
|
+
: rawRootEquiv
|
|
2336
|
+
? [rawRootEquiv]
|
|
2337
|
+
: [];
|
|
2338
|
+
const rootEquiv = rootEquivs.find((r) => typeof r === 'string');
|
|
2125
2339
|
if (typeof rootEquiv === 'string') {
|
|
2126
2340
|
return {
|
|
2127
2341
|
resolvedPath: cleanPath(rootEquiv + restOfPath, allPaths),
|
|
@@ -2396,11 +2610,27 @@ export class ScopeDataStructure {
|
|
|
2396
2610
|
relevantSubPathParts.every((part, i) => part === schemaPathParts[i]) &&
|
|
2397
2611
|
equivalentValue.scopeNodeName === scopeNode.name
|
|
2398
2612
|
) {
|
|
2613
|
+
// DEBUG
|
|
2399
2614
|
continue;
|
|
2400
2615
|
}
|
|
2401
2616
|
|
|
2402
2617
|
const newEquivalentPath = this.joinPathParts([schemaPath, remainingPath]);
|
|
2403
2618
|
|
|
2619
|
+
// PERF: Detect repeated patterns in paths to prevent exponential blowup
|
|
2620
|
+
// Paths like `signature[0].attributes.properties[].attributes.properties[]...`
|
|
2621
|
+
// indicate recursive type structures that cause exponential schema explosion
|
|
2622
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
2623
|
+
if (traceId && debugLevel > 0) {
|
|
2624
|
+
console.info(
|
|
2625
|
+
'Debug: skipping path with excessive pattern repetition',
|
|
2626
|
+
{
|
|
2627
|
+
path: newEquivalentPath,
|
|
2628
|
+
},
|
|
2629
|
+
);
|
|
2630
|
+
}
|
|
2631
|
+
continue;
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2404
2634
|
if (!equivalentScopeNode) {
|
|
2405
2635
|
if (traceId) {
|
|
2406
2636
|
console.info('Debug Propagation: missing equivalent scope info', {
|
|
@@ -2772,10 +3002,105 @@ export class ScopeDataStructure {
|
|
|
2772
3002
|
this.intermediatesOrderIndex.set(pathId, databaseEntry);
|
|
2773
3003
|
|
|
2774
3004
|
if (intermediateIndex === 0) {
|
|
2775
|
-
|
|
3005
|
+
let isValidSourceCandidate =
|
|
2776
3006
|
pathInfo.schemaPath.startsWith('signature[') ||
|
|
2777
3007
|
pathInfo.schemaPath.includes('functionCallReturnValue');
|
|
2778
|
-
|
|
3008
|
+
|
|
3009
|
+
// Check if path STARTS with a spread pattern like [...var]
|
|
3010
|
+
// This handles cases like [...files][][0] or [...files].sort(...).functionCallReturnValue[][0]
|
|
3011
|
+
// where the spread source variable needs to be resolved to a signature path.
|
|
3012
|
+
// We do this REGARDLESS of isValidSourceCandidate because even paths containing
|
|
3013
|
+
// functionCallReturnValue may need spread resolution to trace back to the signature.
|
|
3014
|
+
const spreadMatch = pathInfo.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
3015
|
+
if (spreadMatch) {
|
|
3016
|
+
const spreadVar = spreadMatch[1];
|
|
3017
|
+
const spreadPattern = spreadMatch[0]; // The full [...var] match
|
|
3018
|
+
const scopeNode = this.scopeNodes[pathInfo.scopeNodeName];
|
|
3019
|
+
|
|
3020
|
+
if (scopeNode?.equivalencies) {
|
|
3021
|
+
// Follow the equivalency chain to find a signature path
|
|
3022
|
+
// e.g., files (cyScope1) → files (root) → signature[0].files
|
|
3023
|
+
const resolveToSignature = (
|
|
3024
|
+
varName: string,
|
|
3025
|
+
currentScopeName: string,
|
|
3026
|
+
visited: Set<string>,
|
|
3027
|
+
): { schemaPath: string; scopeNodeName: string } | null => {
|
|
3028
|
+
const visitKey = `${currentScopeName}::${varName}`;
|
|
3029
|
+
if (visited.has(visitKey)) return null;
|
|
3030
|
+
visited.add(visitKey);
|
|
3031
|
+
|
|
3032
|
+
const currentScope = this.scopeNodes[currentScopeName];
|
|
3033
|
+
if (!currentScope?.equivalencies) return null;
|
|
3034
|
+
|
|
3035
|
+
const varEquivs = currentScope.equivalencies[varName];
|
|
3036
|
+
if (!varEquivs) return null;
|
|
3037
|
+
|
|
3038
|
+
// First check if any equivalency directly points to a signature path
|
|
3039
|
+
const signatureEquiv = varEquivs.find((eq) =>
|
|
3040
|
+
eq.schemaPath.startsWith('signature['),
|
|
3041
|
+
);
|
|
3042
|
+
if (signatureEquiv) {
|
|
3043
|
+
return signatureEquiv;
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
// Otherwise, follow the chain to other scopes
|
|
3047
|
+
for (const equiv of varEquivs) {
|
|
3048
|
+
// If the equivalency points to the same variable in a different scope,
|
|
3049
|
+
// follow the chain
|
|
3050
|
+
if (
|
|
3051
|
+
equiv.schemaPath === varName &&
|
|
3052
|
+
equiv.scopeNodeName !== currentScopeName
|
|
3053
|
+
) {
|
|
3054
|
+
const result = resolveToSignature(
|
|
3055
|
+
varName,
|
|
3056
|
+
equiv.scopeNodeName,
|
|
3057
|
+
visited,
|
|
3058
|
+
);
|
|
3059
|
+
if (result) return result;
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
return null;
|
|
3064
|
+
};
|
|
3065
|
+
|
|
3066
|
+
const signatureEquiv = resolveToSignature(
|
|
3067
|
+
spreadVar,
|
|
3068
|
+
pathInfo.scopeNodeName,
|
|
3069
|
+
new Set(),
|
|
3070
|
+
);
|
|
3071
|
+
if (signatureEquiv) {
|
|
3072
|
+
// Replace ONLY the [...var] part with the resolved signature path
|
|
3073
|
+
// This preserves any suffix like .sort(...).functionCallReturnValue[][0]
|
|
3074
|
+
const resolvedPath = pathInfo.schemaPath.replace(
|
|
3075
|
+
spreadPattern,
|
|
3076
|
+
signatureEquiv.schemaPath,
|
|
3077
|
+
);
|
|
3078
|
+
// Add the resolved path as a source candidate
|
|
3079
|
+
if (
|
|
3080
|
+
!databaseEntry.sourceCandidates.some(
|
|
3081
|
+
(sc) =>
|
|
3082
|
+
sc.schemaPath === resolvedPath &&
|
|
3083
|
+
sc.scopeNodeName === pathInfo.scopeNodeName,
|
|
3084
|
+
)
|
|
3085
|
+
) {
|
|
3086
|
+
databaseEntry.sourceCandidates.push({
|
|
3087
|
+
scopeNodeName: pathInfo.scopeNodeName,
|
|
3088
|
+
schemaPath: resolvedPath,
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
isValidSourceCandidate = true;
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
if (
|
|
3097
|
+
isValidSourceCandidate &&
|
|
3098
|
+
!databaseEntry.sourceCandidates.some(
|
|
3099
|
+
(sc) =>
|
|
3100
|
+
sc.schemaPath === pathInfo.schemaPath &&
|
|
3101
|
+
sc.scopeNodeName === pathInfo.scopeNodeName,
|
|
3102
|
+
)
|
|
3103
|
+
) {
|
|
2779
3104
|
databaseEntry.sourceCandidates.push(pathInfo);
|
|
2780
3105
|
}
|
|
2781
3106
|
} else {
|
|
@@ -3003,6 +3328,14 @@ export class ScopeDataStructure {
|
|
|
3003
3328
|
}
|
|
3004
3329
|
}
|
|
3005
3330
|
|
|
3331
|
+
// Ensure parameter-to-signature equivalencies are fully propagated.
|
|
3332
|
+
// When a parameter variable (e.g., `node`) is equivalenced to `signature[N]`,
|
|
3333
|
+
// all sub-paths of that variable should also appear under `signature[N]`.
|
|
3334
|
+
// This handles cases where the sub-path was added to the schema via a propagation
|
|
3335
|
+
// chain that already included the variable↔signature equivalency, causing the
|
|
3336
|
+
// cycle detection to prevent the reverse mapping.
|
|
3337
|
+
this.propagateParameterToSignaturePaths(scopeNode);
|
|
3338
|
+
|
|
3006
3339
|
fillInSchemaGapsAndUnknowns(scopeNode, fillInUnknowns);
|
|
3007
3340
|
|
|
3008
3341
|
if (final) {
|
|
@@ -3017,6 +3350,50 @@ export class ScopeDataStructure {
|
|
|
3017
3350
|
}
|
|
3018
3351
|
}
|
|
3019
3352
|
|
|
3353
|
+
/**
|
|
3354
|
+
* For each equivalency where a simple variable maps to signature[N],
|
|
3355
|
+
* ensure all sub-paths of that variable are reflected under signature[N].
|
|
3356
|
+
*/
|
|
3357
|
+
private propagateParameterToSignaturePaths(scopeNode: ScopeNode) {
|
|
3358
|
+
// Find variable → signature[N] equivalencies
|
|
3359
|
+
for (const [varName, equivalencies] of Object.entries(
|
|
3360
|
+
scopeNode.equivalencies,
|
|
3361
|
+
)) {
|
|
3362
|
+
// Only process simple variable names (no dots, brackets, or parens)
|
|
3363
|
+
if (
|
|
3364
|
+
varName.includes('.') ||
|
|
3365
|
+
varName.includes('[') ||
|
|
3366
|
+
varName.includes('(')
|
|
3367
|
+
) {
|
|
3368
|
+
continue;
|
|
3369
|
+
}
|
|
3370
|
+
|
|
3371
|
+
for (const equiv of equivalencies) {
|
|
3372
|
+
if (
|
|
3373
|
+
equiv.scopeNodeName === scopeNode.name &&
|
|
3374
|
+
equiv.schemaPath.startsWith('signature[')
|
|
3375
|
+
) {
|
|
3376
|
+
const signaturePath = equiv.schemaPath;
|
|
3377
|
+
const varPrefix = varName + '.';
|
|
3378
|
+
const varBracketPrefix = varName + '[';
|
|
3379
|
+
|
|
3380
|
+
// Find all schema keys starting with the variable
|
|
3381
|
+
for (const key in scopeNode.schema) {
|
|
3382
|
+
if (key.startsWith(varPrefix) || key.startsWith(varBracketPrefix)) {
|
|
3383
|
+
const suffix = key.slice(varName.length);
|
|
3384
|
+
const sigKey = signaturePath + suffix;
|
|
3385
|
+
|
|
3386
|
+
// Only add if the signature path doesn't already exist
|
|
3387
|
+
if (!scopeNode.schema[sigKey]) {
|
|
3388
|
+
scopeNode.schema[sigKey] = scopeNode.schema[key];
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
|
|
3020
3397
|
private filterAndConvertSchema({
|
|
3021
3398
|
filterPath,
|
|
3022
3399
|
newPath,
|
|
@@ -3103,6 +3480,9 @@ export class ScopeDataStructure {
|
|
|
3103
3480
|
equivalentValueSchemaPathParts.length,
|
|
3104
3481
|
),
|
|
3105
3482
|
]);
|
|
3483
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
3484
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
3485
|
+
if (this.hasExcessivePatternRepetition(newKey)) continue;
|
|
3106
3486
|
resolvedSchema[newKey] = value;
|
|
3107
3487
|
}
|
|
3108
3488
|
}
|
|
@@ -3125,6 +3505,8 @@ export class ScopeDataStructure {
|
|
|
3125
3505
|
if (!subSchema) continue;
|
|
3126
3506
|
|
|
3127
3507
|
for (const resolvedKey in subSchema) {
|
|
3508
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
3509
|
+
if (this.hasExcessivePatternRepetition(resolvedKey)) continue;
|
|
3128
3510
|
if (
|
|
3129
3511
|
!resolvedSchema[resolvedKey] ||
|
|
3130
3512
|
subSchema[resolvedKey] === 'unknown'
|
|
@@ -3310,15 +3692,34 @@ export class ScopeDataStructure {
|
|
|
3310
3692
|
}
|
|
3311
3693
|
}
|
|
3312
3694
|
}
|
|
3313
|
-
return mergedSchema;
|
|
3695
|
+
return this.filterDuplicateKeys(mergedSchema);
|
|
3314
3696
|
}
|
|
3315
3697
|
|
|
3316
|
-
return schema;
|
|
3317
|
-
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3698
|
+
return this.filterDuplicateKeys(schema);
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
/**
|
|
3702
|
+
* Filter out ::cyDuplicateKey:: entries from a schema.
|
|
3703
|
+
* These are internal markers for tracking variable reassignments
|
|
3704
|
+
* and should not appear in output schemas or LLM prompts.
|
|
3705
|
+
*/
|
|
3706
|
+
private filterDuplicateKeys(
|
|
3707
|
+
schema: Record<string, string>,
|
|
3708
|
+
): Record<string, string> {
|
|
3709
|
+
return Object.entries(schema).reduce(
|
|
3710
|
+
(acc, [key, value]) => {
|
|
3711
|
+
if (!key.includes('::cyDuplicateKey')) {
|
|
3712
|
+
acc[key] = value;
|
|
3713
|
+
}
|
|
3714
|
+
return acc;
|
|
3715
|
+
},
|
|
3716
|
+
{} as Record<string, string>,
|
|
3717
|
+
);
|
|
3718
|
+
}
|
|
3719
|
+
|
|
3720
|
+
getEquivalencies(scopeName?: string) {
|
|
3721
|
+
const scopeNode = this.getScopeOrFunctionCallInfo(scopeName);
|
|
3722
|
+
return scopeNode?.equivalencies;
|
|
3322
3723
|
}
|
|
3323
3724
|
|
|
3324
3725
|
getEquivalenciesDatabaseEntry(scopeNodeName: string, schemaPath: string) {
|
|
@@ -3343,18 +3744,171 @@ export class ScopeDataStructure {
|
|
|
3343
3744
|
return {};
|
|
3344
3745
|
}
|
|
3345
3746
|
|
|
3747
|
+
// Collect all descendant scope names (including the scope itself)
|
|
3748
|
+
// This ensures we include external calls from nested scopes like cyScope2
|
|
3749
|
+
const getAllDescendantScopeNames = (
|
|
3750
|
+
node: import('./helpers/ScopeTreeManager').ScopeTreeNode,
|
|
3751
|
+
): Set<string> => {
|
|
3752
|
+
const names = new Set<string>([node.name]);
|
|
3753
|
+
for (const child of node.children) {
|
|
3754
|
+
for (const name of getAllDescendantScopeNames(child)) {
|
|
3755
|
+
names.add(name);
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
return names;
|
|
3759
|
+
};
|
|
3760
|
+
|
|
3761
|
+
const treeNode = this.scopeTreeManager.findNode(scopeNode.name);
|
|
3762
|
+
const descendantScopeNames = treeNode
|
|
3763
|
+
? getAllDescendantScopeNames(treeNode)
|
|
3764
|
+
: new Set<string>([scopeNode.name]);
|
|
3765
|
+
|
|
3766
|
+
// Get all external function calls made from this scope or any descendant scope
|
|
3767
|
+
// This allows us to include prop equivalencies from JSX components
|
|
3768
|
+
// that were rendered in nested scopes (e.g., FileTableRow called from cyScope2)
|
|
3769
|
+
const externalCallsFromScope = this.externalFunctionCalls.filter((efc) =>
|
|
3770
|
+
descendantScopeNames.has(efc.callScope),
|
|
3771
|
+
);
|
|
3772
|
+
const externalCallNames = new Set(
|
|
3773
|
+
externalCallsFromScope.map((efc) => efc.name),
|
|
3774
|
+
);
|
|
3775
|
+
|
|
3776
|
+
// Helper to check if a usage belongs to this scope (directly, via descendant, or via external call)
|
|
3777
|
+
const usageMatchesScope = (usage: { scopeNodeName: string }) =>
|
|
3778
|
+
descendantScopeNames.has(usage.scopeNodeName) ||
|
|
3779
|
+
externalCallNames.has(usage.scopeNodeName);
|
|
3780
|
+
|
|
3346
3781
|
const entries = this.equivalencyDatabase.filter((entry) =>
|
|
3347
|
-
entry.usages.some(
|
|
3782
|
+
entry.usages.some(usageMatchesScope),
|
|
3348
3783
|
);
|
|
3784
|
+
|
|
3785
|
+
// Helper to resolve a source candidate through equivalency chains to find signature paths
|
|
3786
|
+
const resolveToSignature = (
|
|
3787
|
+
source: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>,
|
|
3788
|
+
visited: Set<string>,
|
|
3789
|
+
): Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] => {
|
|
3790
|
+
const visitKey = `${source.scopeNodeName}::${source.schemaPath}`;
|
|
3791
|
+
if (visited.has(visitKey)) return [];
|
|
3792
|
+
visited.add(visitKey);
|
|
3793
|
+
|
|
3794
|
+
// If already a signature path, return as-is
|
|
3795
|
+
if (source.schemaPath.startsWith('signature[')) {
|
|
3796
|
+
return [source];
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
const currentScope = this.scopeNodes[source.scopeNodeName];
|
|
3800
|
+
if (!currentScope?.equivalencies) return [source];
|
|
3801
|
+
|
|
3802
|
+
// Check for direct equivalencies FIRST (full path match)
|
|
3803
|
+
// This ensures paths like "useMemo(...).functionCallReturnValue" follow to "cyScope1::returnValue"
|
|
3804
|
+
// before prefix matching tries "useMemo(...)" which goes to the useMemo scope
|
|
3805
|
+
const directEquivs = currentScope.equivalencies[source.schemaPath];
|
|
3806
|
+
if (directEquivs?.length > 0) {
|
|
3807
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3808
|
+
[];
|
|
3809
|
+
for (const equiv of directEquivs) {
|
|
3810
|
+
const resolved = resolveToSignature(
|
|
3811
|
+
{
|
|
3812
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
3813
|
+
schemaPath: equiv.schemaPath,
|
|
3814
|
+
},
|
|
3815
|
+
visited,
|
|
3816
|
+
);
|
|
3817
|
+
results.push(...resolved);
|
|
3818
|
+
}
|
|
3819
|
+
if (results.length > 0) return results;
|
|
3820
|
+
}
|
|
3821
|
+
|
|
3822
|
+
// Handle spread patterns like [...items].sort().functionCallReturnValue
|
|
3823
|
+
// Extract the spread variable and resolve it through the equivalency chain
|
|
3824
|
+
const spreadMatch = source.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
3825
|
+
if (spreadMatch) {
|
|
3826
|
+
const spreadVar = spreadMatch[1];
|
|
3827
|
+
const spreadPattern = spreadMatch[0];
|
|
3828
|
+
const varEquivs = currentScope.equivalencies[spreadVar];
|
|
3829
|
+
|
|
3830
|
+
if (varEquivs?.length > 0) {
|
|
3831
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3832
|
+
[];
|
|
3833
|
+
for (const equiv of varEquivs) {
|
|
3834
|
+
// Follow the variable equivalency and then resolve from there
|
|
3835
|
+
const resolvedVar = resolveToSignature(
|
|
3836
|
+
{
|
|
3837
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
3838
|
+
schemaPath: equiv.schemaPath,
|
|
3839
|
+
},
|
|
3840
|
+
visited,
|
|
3841
|
+
);
|
|
3842
|
+
// For each resolved variable path, create the full path with array element suffix
|
|
3843
|
+
for (const rv of resolvedVar) {
|
|
3844
|
+
if (rv.schemaPath.startsWith('signature[')) {
|
|
3845
|
+
// Get the suffix after the spread pattern
|
|
3846
|
+
let suffix = source.schemaPath.slice(spreadPattern.length);
|
|
3847
|
+
|
|
3848
|
+
// Clean the suffix: strip array method chains like .sort(...).functionCallReturnValue[]
|
|
3849
|
+
// These don't change the data identity, just transform it.
|
|
3850
|
+
// Keep only the final element access parts like [0], [1], etc.
|
|
3851
|
+
// Pattern: strip everything from a method call up through functionCallReturnValue[]
|
|
3852
|
+
suffix = suffix.replace(
|
|
3853
|
+
/\.\w+\([^)]*\)\.functionCallReturnValue\[\]/g,
|
|
3854
|
+
'',
|
|
3855
|
+
);
|
|
3856
|
+
// Also handle simpler case without nested parens
|
|
3857
|
+
suffix = suffix.replace(
|
|
3858
|
+
/\.sort\(\w*\(\)\)\.functionCallReturnValue\[\]/g,
|
|
3859
|
+
'',
|
|
3860
|
+
);
|
|
3861
|
+
|
|
3862
|
+
// Add [] to indicate array element access from the spread
|
|
3863
|
+
const resolvedPath = rv.schemaPath + '[]' + suffix;
|
|
3864
|
+
results.push({
|
|
3865
|
+
scopeNodeName: rv.scopeNodeName,
|
|
3866
|
+
schemaPath: resolvedPath,
|
|
3867
|
+
});
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
if (results.length > 0) return results;
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
|
|
3875
|
+
// Try to find prefix equivalencies that can resolve this path
|
|
3876
|
+
// For path like "cyScope3().signature[0][0]", check "cyScope3().signature[0]", etc.
|
|
3877
|
+
const pathParts = this.splitPath(source.schemaPath);
|
|
3878
|
+
for (let i = pathParts.length - 1; i > 0; i--) {
|
|
3879
|
+
const prefix = this.joinPathParts(pathParts.slice(0, i));
|
|
3880
|
+
const suffix = this.joinPathParts(pathParts.slice(i));
|
|
3881
|
+
const prefixEquivs = currentScope.equivalencies[prefix];
|
|
3882
|
+
|
|
3883
|
+
if (prefixEquivs?.length > 0) {
|
|
3884
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3885
|
+
[];
|
|
3886
|
+
for (const equiv of prefixEquivs) {
|
|
3887
|
+
const newPath = this.joinPathParts([equiv.schemaPath, suffix]);
|
|
3888
|
+
const resolved = resolveToSignature(
|
|
3889
|
+
{ scopeNodeName: equiv.scopeNodeName, schemaPath: newPath },
|
|
3890
|
+
visited,
|
|
3891
|
+
);
|
|
3892
|
+
results.push(...resolved);
|
|
3893
|
+
}
|
|
3894
|
+
if (results.length > 0) return results;
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
return [source];
|
|
3899
|
+
};
|
|
3900
|
+
|
|
3349
3901
|
return entries.reduce(
|
|
3350
3902
|
(acc, entry) => {
|
|
3351
3903
|
if (entry.sourceCandidates.length === 0) return acc;
|
|
3352
|
-
const usages = entry.usages.filter(
|
|
3353
|
-
(u) => u.scopeNodeName === scopeNode.name,
|
|
3354
|
-
);
|
|
3904
|
+
const usages = entry.usages.filter(usageMatchesScope);
|
|
3355
3905
|
for (const usage of usages) {
|
|
3356
3906
|
acc[usage.schemaPath] ||= [];
|
|
3357
|
-
|
|
3907
|
+
// Resolve each source candidate through the equivalency chain
|
|
3908
|
+
for (const source of entry.sourceCandidates) {
|
|
3909
|
+
const resolvedSources = resolveToSignature(source, new Set());
|
|
3910
|
+
acc[usage.schemaPath].push(...resolvedSources);
|
|
3911
|
+
}
|
|
3358
3912
|
}
|
|
3359
3913
|
return acc;
|
|
3360
3914
|
},
|
|
@@ -3467,6 +4021,54 @@ export class ScopeDataStructure {
|
|
|
3467
4021
|
}
|
|
3468
4022
|
}
|
|
3469
4023
|
|
|
4024
|
+
// Enrich schema with deeply nested paths from internal function call scopes.
|
|
4025
|
+
// When a function call like traverse(tree) exists, and traverse's scope has
|
|
4026
|
+
// signature[0].children[path][entityName] (from propagateParameterToSignaturePaths),
|
|
4027
|
+
// we need to map those paths back to the argument variable (tree) in this scope.
|
|
4028
|
+
// This handles cases where cycle detection prevented the equivalency chain from
|
|
4029
|
+
// propagating deep paths during Phase 2 batch queue processing.
|
|
4030
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
4031
|
+
// Look for keys matching function call pattern: funcName(...).signature[N]
|
|
4032
|
+
const funcCallMatch = equivalenceKey.match(
|
|
4033
|
+
/^([^(]+)\(.*?\)\.(signature\[\d+\])$/,
|
|
4034
|
+
);
|
|
4035
|
+
if (!funcCallMatch) continue;
|
|
4036
|
+
|
|
4037
|
+
const calledFunctionName = funcCallMatch[1];
|
|
4038
|
+
const signatureParam = funcCallMatch[2]; // e.g., "signature[0]"
|
|
4039
|
+
|
|
4040
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
4041
|
+
if (equivalenceValue.scopeNodeName !== scopeName) continue;
|
|
4042
|
+
|
|
4043
|
+
const targetVariable = equivalenceValue.schemaPath;
|
|
4044
|
+
|
|
4045
|
+
// Get the called function's schema (includes propagated parameter paths)
|
|
4046
|
+
const childSchema = this.getSchema({
|
|
4047
|
+
scopeName: calledFunctionName,
|
|
4048
|
+
});
|
|
4049
|
+
if (!childSchema) continue;
|
|
4050
|
+
|
|
4051
|
+
// Map child function's signature paths to parent variable paths
|
|
4052
|
+
const sigPrefix = signatureParam + '.';
|
|
4053
|
+
const sigBracketPrefix = signatureParam + '[';
|
|
4054
|
+
for (const childKey in childSchema) {
|
|
4055
|
+
let suffix: string | null = null;
|
|
4056
|
+
if (childKey.startsWith(sigPrefix)) {
|
|
4057
|
+
suffix = childKey.slice(signatureParam.length);
|
|
4058
|
+
} else if (childKey.startsWith(sigBracketPrefix)) {
|
|
4059
|
+
suffix = childKey.slice(signatureParam.length);
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4062
|
+
if (suffix !== null) {
|
|
4063
|
+
const parentKey = targetVariable + suffix;
|
|
4064
|
+
if (!schema[parentKey]) {
|
|
4065
|
+
schema[parentKey] = childSchema[childKey];
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
|
|
3470
4072
|
// Propagate nested paths from variables to their signature equivalents
|
|
3471
4073
|
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
3472
4074
|
// signature[0].workouts[].title
|
|
@@ -3497,7 +4099,7 @@ export class ScopeDataStructure {
|
|
|
3497
4099
|
}
|
|
3498
4100
|
}
|
|
3499
4101
|
|
|
3500
|
-
return tempScopeNode.schema;
|
|
4102
|
+
return this.filterDuplicateKeys(tempScopeNode.schema);
|
|
3501
4103
|
}
|
|
3502
4104
|
|
|
3503
4105
|
getReturnValue({
|
|
@@ -3559,7 +4161,17 @@ export class ScopeDataStructure {
|
|
|
3559
4161
|
// Include function paths even if their return value wasn't captured
|
|
3560
4162
|
// This ensures methods like onAuthStateChange are included in the schema
|
|
3561
4163
|
// But exclude signature entries (they should only be included via functionCallReturnValue paths)
|
|
3562
|
-
|
|
4164
|
+
// Also exclude bare function call signatures - paths that are JUST a call like
|
|
4165
|
+
// "useCustomSizes(projectSlug)" should not be included as return values.
|
|
4166
|
+
// These represent "the function exists" not actual return data, and including
|
|
4167
|
+
// them causes nested path bugs in dependencySchemas.
|
|
4168
|
+
(schema[key] === 'function' &&
|
|
4169
|
+
key.indexOf('signature[') === -1 &&
|
|
4170
|
+
// Exclude bare call signatures: function calls with no dots OUTSIDE parentheses
|
|
4171
|
+
// e.g., "useCustomSizes(projectSlug)" is bare (exclude)
|
|
4172
|
+
// e.g., "loadProject({nested.property})" is bare - dots are inside args (exclude)
|
|
4173
|
+
// e.g., "getSupabase().auth.method()" has dots outside - method chain (include)
|
|
4174
|
+
!this.isBareCallSignature(key)),
|
|
3563
4175
|
)
|
|
3564
4176
|
.reduce(
|
|
3565
4177
|
(acc, key) => {
|
|
@@ -3569,7 +4181,10 @@ export class ScopeDataStructure {
|
|
|
3569
4181
|
for (const path in schema) {
|
|
3570
4182
|
const pathParts = this.splitPath(path);
|
|
3571
4183
|
if (pathParts.every((p, i) => keyParts[i] === p)) {
|
|
3572
|
-
|
|
4184
|
+
// Also exclude bare call signatures from prefix paths
|
|
4185
|
+
if (!this.isBareCallSignature(path)) {
|
|
4186
|
+
acc[path] = schema[path];
|
|
4187
|
+
}
|
|
3573
4188
|
}
|
|
3574
4189
|
}
|
|
3575
4190
|
|
|
@@ -3590,7 +4205,59 @@ export class ScopeDataStructure {
|
|
|
3590
4205
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
3591
4206
|
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
3592
4207
|
|
|
3593
|
-
return
|
|
4208
|
+
// Remove bare call signatures from the return value schema.
|
|
4209
|
+
// fillInSchemaGapsAndUnknowns may add parent paths like "useCustomSizes(projectSlug)"
|
|
4210
|
+
// when it sees "useCustomSizes(projectSlug).functionCallReturnValue". These bare
|
|
4211
|
+
// call signatures represent "the function exists" not actual return data, and
|
|
4212
|
+
// including them causes nested path bugs in dependencySchemas.
|
|
4213
|
+
const resultSchema = tempScopeNode.schema;
|
|
4214
|
+
for (const key of Object.keys(resultSchema)) {
|
|
4215
|
+
if (this.isBareCallSignature(key)) {
|
|
4216
|
+
delete resultSchema[key];
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
return resultSchema;
|
|
4221
|
+
}
|
|
4222
|
+
|
|
4223
|
+
/**
|
|
4224
|
+
* Checks if a schema key is a "bare call signature" - a function call with no
|
|
4225
|
+
* method chain before it and no path segments after it.
|
|
4226
|
+
*
|
|
4227
|
+
* A bare call signature represents "this function exists" rather than actual
|
|
4228
|
+
* return data, and including them causes nested path bugs in dependencySchemas.
|
|
4229
|
+
*
|
|
4230
|
+
* Examples:
|
|
4231
|
+
* - "useCustomSizes(projectSlug)" -> bare (true)
|
|
4232
|
+
* - "loadProject({nested.property})" -> bare (dots are inside args, true)
|
|
4233
|
+
* - "getSupabase().auth.method()" -> not bare (has dots outside parens, false)
|
|
4234
|
+
* - "useProject().functionCallReturnValue" -> not bare (has path after, false)
|
|
4235
|
+
*/
|
|
4236
|
+
private isBareCallSignature(key: string): boolean {
|
|
4237
|
+
// Must end with ) and contain ( to be a call
|
|
4238
|
+
if (!key.endsWith(')') || key.indexOf('(') === -1) {
|
|
4239
|
+
return false;
|
|
4240
|
+
}
|
|
4241
|
+
|
|
4242
|
+
// Check if there are any dots OUTSIDE of parentheses
|
|
4243
|
+
// Strip out content inside balanced parentheses, then check for dots
|
|
4244
|
+
let depth = 0;
|
|
4245
|
+
let hasDotsOutsideParens = false;
|
|
4246
|
+
|
|
4247
|
+
for (let i = 0; i < key.length; i++) {
|
|
4248
|
+
const char = key[i];
|
|
4249
|
+
if (char === '(') {
|
|
4250
|
+
depth++;
|
|
4251
|
+
} else if (char === ')') {
|
|
4252
|
+
depth--;
|
|
4253
|
+
} else if (char === '.' && depth === 0) {
|
|
4254
|
+
hasDotsOutsideParens = true;
|
|
4255
|
+
break;
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4259
|
+
// It's a bare call signature if there are no dots outside parentheses
|
|
4260
|
+
return !hasDotsOutsideParens;
|
|
3594
4261
|
}
|
|
3595
4262
|
|
|
3596
4263
|
/**
|
|
@@ -3674,20 +4341,421 @@ export class ScopeDataStructure {
|
|
|
3674
4341
|
return scopeText;
|
|
3675
4342
|
}
|
|
3676
4343
|
|
|
3677
|
-
getEquivalentSignatureVariables() {
|
|
4344
|
+
getEquivalentSignatureVariables(): Record<string, string | string[]> {
|
|
3678
4345
|
const scopeNode = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
3679
4346
|
|
|
3680
|
-
const equivalentSignatureVariables: Record<string, string> = {};
|
|
4347
|
+
const equivalentSignatureVariables: Record<string, string | string[]> = {};
|
|
4348
|
+
|
|
4349
|
+
// Helper to add equivalencies - accumulates into array if multiple values for same key
|
|
4350
|
+
// This is critical for OR expressions like `x = a || b` where x should map to both a and b
|
|
4351
|
+
const addEquivalency = (key: string, value: string) => {
|
|
4352
|
+
const existing = equivalentSignatureVariables[key];
|
|
4353
|
+
if (existing === undefined) {
|
|
4354
|
+
// First value - store as string
|
|
4355
|
+
equivalentSignatureVariables[key] = value;
|
|
4356
|
+
} else if (typeof existing === 'string') {
|
|
4357
|
+
if (existing !== value) {
|
|
4358
|
+
// Second different value - convert to array
|
|
4359
|
+
equivalentSignatureVariables[key] = [existing, value];
|
|
4360
|
+
}
|
|
4361
|
+
// Same value - no change needed
|
|
4362
|
+
} else {
|
|
4363
|
+
// Already an array - add if not already present
|
|
4364
|
+
if (!existing.includes(value)) {
|
|
4365
|
+
existing.push(value);
|
|
4366
|
+
}
|
|
4367
|
+
}
|
|
4368
|
+
};
|
|
4369
|
+
|
|
3681
4370
|
for (const [path, equivalentValues] of Object.entries(
|
|
3682
4371
|
scopeNode.equivalencies,
|
|
3683
4372
|
)) {
|
|
3684
4373
|
for (const equivalentValue of equivalentValues) {
|
|
4374
|
+
// Case 1: Props/signature equivalencies (existing behavior)
|
|
4375
|
+
// Maps local variable names to their signature paths
|
|
4376
|
+
// e.g., "propValue" -> "signature[0].prop"
|
|
3685
4377
|
if (path.startsWith('signature[')) {
|
|
3686
|
-
|
|
4378
|
+
addEquivalency(equivalentValue.schemaPath, path);
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
// Case 2: Hook variable equivalencies (new behavior)
|
|
4382
|
+
// The equivalencies are stored as: path = variable name, schemaPath = data source
|
|
4383
|
+
// e.g., path = "debugFetcher", schemaPath = "useFetcher<...>().functionCallReturnValue"
|
|
4384
|
+
// We need to map: "debugFetcher" -> "useFetcher<...>()"
|
|
4385
|
+
// This enables resolving paths like "debugFetcher.state" to
|
|
4386
|
+
// "useFetcher<...>().state" for execution flow validation
|
|
4387
|
+
if (equivalentValue.schemaPath.endsWith('.functionCallReturnValue')) {
|
|
4388
|
+
// Extract the hook call path (everything before .functionCallReturnValue)
|
|
4389
|
+
let hookCallPath = equivalentValue.schemaPath.slice(
|
|
4390
|
+
0,
|
|
4391
|
+
-'.functionCallReturnValue'.length,
|
|
4392
|
+
);
|
|
4393
|
+
// Only include if it looks like a hook call (contains parentheses)
|
|
4394
|
+
// and the variable name (path) is a simple identifier (no dots)
|
|
4395
|
+
if (hookCallPath.includes('(') && !path.includes('.')) {
|
|
4396
|
+
// Special case: If hookCallPath is a callback scope (cyScope pattern),
|
|
4397
|
+
// trace through it to find what the callback actually returns.
|
|
4398
|
+
// This handles useState(() => { return prop; }) patterns.
|
|
4399
|
+
const cyScopeMatch = hookCallPath.match(/^(cyScope\d+)\(\)$/);
|
|
4400
|
+
if (cyScopeMatch) {
|
|
4401
|
+
// Use the equivalency database to trace the callback's return value
|
|
4402
|
+
// to its actual source (e.g., viewModeFromUrl -> segments -> params -> useParams)
|
|
4403
|
+
const dbEntry = this.getEquivalenciesDatabaseEntry(
|
|
4404
|
+
scopeNode.name, // Component scope
|
|
4405
|
+
path, // variable name (e.g., viewMode)
|
|
4406
|
+
);
|
|
4407
|
+
if (dbEntry?.sourceCandidates?.length > 0) {
|
|
4408
|
+
// Use the traced source instead of the callback scope
|
|
4409
|
+
hookCallPath = dbEntry.sourceCandidates[0].schemaPath;
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
addEquivalency(path, hookCallPath);
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4415
|
+
|
|
4416
|
+
// Case 3: Destructured variables from local variables
|
|
4417
|
+
// e.g., const { scenarios } = currentEntityAnalysis;
|
|
4418
|
+
// This creates: path = "scenarios", schemaPath = "currentEntityAnalysis.scenarios"
|
|
4419
|
+
// We need to map: "scenarios" -> "currentEntityAnalysis.scenarios"
|
|
4420
|
+
// AND resolve transitively if currentEntityAnalysis is itself equivalent to a hook call
|
|
4421
|
+
if (
|
|
4422
|
+
!path.includes('.') && // path is a simple identifier
|
|
4423
|
+
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
4424
|
+
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
4425
|
+
) {
|
|
4426
|
+
// Add equivalency (will accumulate if multiple values for OR expressions)
|
|
4427
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4428
|
+
}
|
|
4429
|
+
|
|
4430
|
+
// Case 4: Child component prop mappings (Fix 22)
|
|
4431
|
+
// When parent renders <ChildComponent prop={value} />, we get equivalencies like:
|
|
4432
|
+
// path = "ChildComponent().signature[0].prop"
|
|
4433
|
+
// schemaPath = "value" (the variable passed as the prop)
|
|
4434
|
+
// We need to include these so translateChildPathToParent can work.
|
|
4435
|
+
// Pattern: ComponentName().signature[N] or ComponentName().signature[N].propName
|
|
4436
|
+
if (
|
|
4437
|
+
path.includes('().signature[') &&
|
|
4438
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable, not a function call
|
|
4439
|
+
) {
|
|
4440
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4441
|
+
}
|
|
4442
|
+
|
|
4443
|
+
// Case 5: Destructured function parameters (Fix 25)
|
|
4444
|
+
// When a function has destructured props: function Comp({ propA, propB }: Props)
|
|
4445
|
+
// We get equivalencies like:
|
|
4446
|
+
// path = "propA" (the destructured variable name)
|
|
4447
|
+
// schemaPath = "signature[0].propA" (the signature path)
|
|
4448
|
+
// We need to map: "propA" -> "signature[0].propA"
|
|
4449
|
+
// This enables translateChildPathToParent to resolve child variable paths
|
|
4450
|
+
// to their signature paths when merging execution flows.
|
|
4451
|
+
if (
|
|
4452
|
+
!path.includes('.') && // path is a simple identifier (destructured prop name)
|
|
4453
|
+
equivalentValue.schemaPath.startsWith('signature[') // schemaPath IS a signature path
|
|
4454
|
+
) {
|
|
4455
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4458
|
+
// Case 7: Method calls on variables that result in .functionCallReturnValue (Fix 33)
|
|
4459
|
+
// When we have patterns like:
|
|
4460
|
+
// path = "segments" (simple identifier)
|
|
4461
|
+
// schemaPath = "splat.split('/').functionCallReturnValue"
|
|
4462
|
+
// This is a method call on a variable (not a hook call), but we still need to
|
|
4463
|
+
// track it so transitive resolution can resolve `splat` to its actual source.
|
|
4464
|
+
// E.g., if splat -> useParams().functionCallReturnValue['*'], then
|
|
4465
|
+
// segments -> useParams().functionCallReturnValue['*'].split('/').functionCallReturnValue
|
|
4466
|
+
if (
|
|
4467
|
+
!path.includes('.') && // path is a simple identifier
|
|
4468
|
+
equivalentValue.schemaPath.endsWith('.functionCallReturnValue') && // ends with function return
|
|
4469
|
+
equivalentValue.schemaPath.includes('.') // has property access (method call)
|
|
4470
|
+
) {
|
|
4471
|
+
// Check if this looks like a method call on a variable (not a hook call)
|
|
4472
|
+
// Hook calls look like: hookName() or hookName<T>()
|
|
4473
|
+
// Method calls look like: variable.method() or variable.method<T>()
|
|
4474
|
+
const hookCallPath = equivalentValue.schemaPath.slice(
|
|
4475
|
+
0,
|
|
4476
|
+
-'.functionCallReturnValue'.length,
|
|
4477
|
+
);
|
|
4478
|
+
// If it's a method call (contains a dot before the parenthesis), include it
|
|
4479
|
+
const dotBeforeParen = hookCallPath.indexOf('.');
|
|
4480
|
+
const parenPos = hookCallPath.indexOf('(');
|
|
4481
|
+
if (dotBeforeParen !== -1 && dotBeforeParen < parenPos) {
|
|
4482
|
+
// This is a method call like "splat.split('/')", not a hook call
|
|
4483
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4484
|
+
}
|
|
3687
4485
|
}
|
|
3688
4486
|
}
|
|
3689
4487
|
}
|
|
3690
4488
|
|
|
4489
|
+
// Case 6: Collect JSX child prop equivalencies from child scopes (Fix 26)
|
|
4490
|
+
// When a parent component renders <ChildComponent prop={value} />, the JSX
|
|
4491
|
+
// return statement may be in a child scope (e.g., cyScope2). The equivalencies
|
|
4492
|
+
// like ChildComponent().signature[0].prop -> value get stored in that child scope.
|
|
4493
|
+
// But translateChildPathToParent needs to find them from the parent scope's context.
|
|
4494
|
+
// So we collect Case 4 patterns from ALL child scopes that belong to this root scope.
|
|
4495
|
+
const rootName = this.scopeTreeManager.getRootName();
|
|
4496
|
+
for (const [scopeName, childScopeNode] of Object.entries(this.scopeNodes)) {
|
|
4497
|
+
// Skip the root scope (already processed above)
|
|
4498
|
+
if (scopeName === rootName) continue;
|
|
4499
|
+
|
|
4500
|
+
// Only include scopes that are children of the root (their tree includes root)
|
|
4501
|
+
if (!childScopeNode.tree?.includes(rootName)) continue;
|
|
4502
|
+
|
|
4503
|
+
// Look for Case 4 patterns in the child scope
|
|
4504
|
+
for (const [path, equivalentValues] of Object.entries(
|
|
4505
|
+
childScopeNode.equivalencies || {},
|
|
4506
|
+
)) {
|
|
4507
|
+
for (const equivalentValue of equivalentValues) {
|
|
4508
|
+
// Case 4 pattern: ChildComponent().signature[0].propName -> parentVariable
|
|
4509
|
+
if (
|
|
4510
|
+
path.includes('().signature[') &&
|
|
4511
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable
|
|
4512
|
+
) {
|
|
4513
|
+
// Only add if not already present from the root scope
|
|
4514
|
+
// Root scope values take precedence over child scope values
|
|
4515
|
+
if (!(path in equivalentSignatureVariables)) {
|
|
4516
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4517
|
+
}
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
|
|
4523
|
+
// Transitive resolution: Resolve variable chains through multiple levels
|
|
4524
|
+
// E.g., analysis → currentEntityAnalysis → useLoaderData().functionCallReturnValue.currentEntityAnalysis
|
|
4525
|
+
// We need multiple passes because resolutions can depend on each other
|
|
4526
|
+
const maxIterations = 5; // Prevent infinite loops
|
|
4527
|
+
|
|
4528
|
+
// Helper function to resolve a single source path using equivalencies
|
|
4529
|
+
const resolveSourcePath = (
|
|
4530
|
+
sourcePath: string,
|
|
4531
|
+
equivMap: Record<string, string | string[]>,
|
|
4532
|
+
): string | null => {
|
|
4533
|
+
// Extract base variable from the path
|
|
4534
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4535
|
+
const bracketIndex = sourcePath.indexOf('[');
|
|
4536
|
+
|
|
4537
|
+
let baseVar: string;
|
|
4538
|
+
let rest: string;
|
|
4539
|
+
|
|
4540
|
+
if (dotIndex === -1 && bracketIndex === -1) {
|
|
4541
|
+
baseVar = sourcePath;
|
|
4542
|
+
rest = '';
|
|
4543
|
+
} else if (dotIndex === -1) {
|
|
4544
|
+
baseVar = sourcePath.slice(0, bracketIndex);
|
|
4545
|
+
rest = sourcePath.slice(bracketIndex);
|
|
4546
|
+
} else if (bracketIndex === -1) {
|
|
4547
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
4548
|
+
rest = sourcePath.slice(dotIndex);
|
|
4549
|
+
} else {
|
|
4550
|
+
const firstIndex = Math.min(dotIndex, bracketIndex);
|
|
4551
|
+
baseVar = sourcePath.slice(0, firstIndex);
|
|
4552
|
+
rest = sourcePath.slice(firstIndex);
|
|
4553
|
+
}
|
|
4554
|
+
|
|
4555
|
+
// Look up the base variable in equivalencies
|
|
4556
|
+
if (baseVar in equivMap && equivMap[baseVar] !== sourcePath) {
|
|
4557
|
+
const baseResolved = equivMap[baseVar];
|
|
4558
|
+
// Skip if baseResolved is an array (handle later)
|
|
4559
|
+
if (Array.isArray(baseResolved)) return null;
|
|
4560
|
+
// If it resolves to a signature path, build the full resolved path
|
|
4561
|
+
if (
|
|
4562
|
+
baseResolved.startsWith('signature[') ||
|
|
4563
|
+
baseResolved.includes('()')
|
|
4564
|
+
) {
|
|
4565
|
+
if (baseResolved.endsWith('()')) {
|
|
4566
|
+
return baseResolved + '.functionCallReturnValue' + rest;
|
|
4567
|
+
}
|
|
4568
|
+
return baseResolved + rest;
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4571
|
+
return null;
|
|
4572
|
+
};
|
|
4573
|
+
|
|
4574
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
4575
|
+
let changed = false;
|
|
4576
|
+
|
|
4577
|
+
for (const [varName, sourcePathOrArray] of Object.entries(
|
|
4578
|
+
equivalentSignatureVariables,
|
|
4579
|
+
)) {
|
|
4580
|
+
// Handle arrays (OR expressions) by resolving each element
|
|
4581
|
+
if (Array.isArray(sourcePathOrArray)) {
|
|
4582
|
+
const resolvedArray: string[] = [];
|
|
4583
|
+
let arrayChanged = false;
|
|
4584
|
+
for (const sourcePath of sourcePathOrArray) {
|
|
4585
|
+
// Try to resolve this path using transitive resolution
|
|
4586
|
+
const resolved = resolveSourcePath(
|
|
4587
|
+
sourcePath,
|
|
4588
|
+
equivalentSignatureVariables,
|
|
4589
|
+
);
|
|
4590
|
+
if (resolved && resolved !== sourcePath) {
|
|
4591
|
+
resolvedArray.push(resolved);
|
|
4592
|
+
arrayChanged = true;
|
|
4593
|
+
} else {
|
|
4594
|
+
resolvedArray.push(sourcePath);
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
if (arrayChanged) {
|
|
4598
|
+
equivalentSignatureVariables[varName] = resolvedArray;
|
|
4599
|
+
changed = true;
|
|
4600
|
+
}
|
|
4601
|
+
continue;
|
|
4602
|
+
}
|
|
4603
|
+
const sourcePath = sourcePathOrArray;
|
|
4604
|
+
|
|
4605
|
+
// Skip if already fully resolved (contains function call syntax)
|
|
4606
|
+
// BUT first check for computed value patterns that need resolution (Fix 28)
|
|
4607
|
+
// AND method call patterns that need base variable resolution (Fix 33)
|
|
4608
|
+
if (sourcePath.includes('()')) {
|
|
4609
|
+
// Fix 28: Handle computed value patterns with dependency arrays
|
|
4610
|
+
// Patterns like `functionName(arg, [dep1, dep2, ...])` are NOT controllable
|
|
4611
|
+
// data sources. We trace through the dependencies to find controllable sources.
|
|
4612
|
+
const bracketStart = sourcePath.indexOf('[');
|
|
4613
|
+
const bracketEnd = sourcePath.lastIndexOf(']');
|
|
4614
|
+
|
|
4615
|
+
if (bracketStart !== -1 && bracketEnd > bracketStart) {
|
|
4616
|
+
const arrayContent = sourcePath.slice(bracketStart + 1, bracketEnd);
|
|
4617
|
+
const items = arrayContent.split(',').map((s) => s.trim());
|
|
4618
|
+
|
|
4619
|
+
// Only process if this looks like a dependency array:
|
|
4620
|
+
// multiple items that are all simple identifiers (not numbers or expressions)
|
|
4621
|
+
const isIdentifier = (s: string) =>
|
|
4622
|
+
/^\w+$/.test(s) && !/^\d+$/.test(s);
|
|
4623
|
+
if (items.length > 1 && items.every(isIdentifier)) {
|
|
4624
|
+
// Look for a dependency that's already resolved to a controllable source
|
|
4625
|
+
for (const dep of items) {
|
|
4626
|
+
if (dep in equivalentSignatureVariables) {
|
|
4627
|
+
const resolvedDep = equivalentSignatureVariables[dep];
|
|
4628
|
+
// Use if it's a controllable path (contains hook call)
|
|
4629
|
+
// and is NOT another unresolved computed pattern (has comma-separated deps)
|
|
4630
|
+
const hasCommaInBrackets =
|
|
4631
|
+
resolvedDep.includes('[') &&
|
|
4632
|
+
resolvedDep.includes(',') &&
|
|
4633
|
+
resolvedDep.indexOf(',') > resolvedDep.indexOf('[');
|
|
4634
|
+
if (resolvedDep.includes('()') && !hasCommaInBrackets) {
|
|
4635
|
+
// Computed value is typically an element from an array
|
|
4636
|
+
equivalentSignatureVariables[varName] = resolvedDep + '[]';
|
|
4637
|
+
changed = true;
|
|
4638
|
+
break;
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4641
|
+
}
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
|
|
4645
|
+
// Fix 33: Handle method call patterns on variables
|
|
4646
|
+
// Patterns like: "splat.split('/').functionCallReturnValue"
|
|
4647
|
+
// We need to resolve the base variable (splat) to its actual source
|
|
4648
|
+
// Check if this is a method call on a variable (dot before first parenthesis)
|
|
4649
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4650
|
+
const parenIndex = sourcePath.indexOf('(');
|
|
4651
|
+
if (
|
|
4652
|
+
dotIndex !== -1 &&
|
|
4653
|
+
dotIndex < parenIndex &&
|
|
4654
|
+
!sourcePath.startsWith('use') // Not a hook call like useState()
|
|
4655
|
+
) {
|
|
4656
|
+
// Extract the base variable (before the first dot)
|
|
4657
|
+
const baseVar = sourcePath.slice(0, dotIndex);
|
|
4658
|
+
const rest = sourcePath.slice(dotIndex); // includes ".method(...).functionCallReturnValue"
|
|
4659
|
+
|
|
4660
|
+
// Check if the base variable can be resolved
|
|
4661
|
+
if (
|
|
4662
|
+
baseVar in equivalentSignatureVariables &&
|
|
4663
|
+
baseVar !== varName
|
|
4664
|
+
) {
|
|
4665
|
+
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
4666
|
+
// Skip if baseResolved is an array (OR expression)
|
|
4667
|
+
if (Array.isArray(baseResolved)) continue;
|
|
4668
|
+
// Only resolve if the base resolved to something useful (contains () or .)
|
|
4669
|
+
if (baseResolved.includes('()') || baseResolved.includes('.')) {
|
|
4670
|
+
const newPath = baseResolved + rest;
|
|
4671
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4672
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4673
|
+
changed = true;
|
|
4674
|
+
}
|
|
4675
|
+
}
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4678
|
+
|
|
4679
|
+
// Fix 38: Handle cyScope lazy initializer return values
|
|
4680
|
+
// When we have viewMode -> cyScope20(), trace through to find what cyScope20 returns.
|
|
4681
|
+
// The lazy initializer's return value should be the controllable data source.
|
|
4682
|
+
// Pattern: cyScopeN() where N is a number
|
|
4683
|
+
const cyScopeMatch = sourcePath.match(/^(cyScope\d+)\(\)$/);
|
|
4684
|
+
if (cyScopeMatch) {
|
|
4685
|
+
const cyScopeName = cyScopeMatch[1];
|
|
4686
|
+
const cyScopeNode = this.scopeNodes[cyScopeName];
|
|
4687
|
+
|
|
4688
|
+
if (cyScopeNode?.equivalencies) {
|
|
4689
|
+
// Look for returnValue equivalency in the cyScope
|
|
4690
|
+
const returnValueEquivs =
|
|
4691
|
+
cyScopeNode.equivalencies['returnValue'];
|
|
4692
|
+
if (returnValueEquivs && returnValueEquivs.length > 0) {
|
|
4693
|
+
// Get the first return value source
|
|
4694
|
+
const returnSource = returnValueEquivs[0].schemaPath;
|
|
4695
|
+
|
|
4696
|
+
// If the return source is a simple variable (not a complex path),
|
|
4697
|
+
// resolve varName directly to that variable
|
|
4698
|
+
if (
|
|
4699
|
+
returnSource &&
|
|
4700
|
+
!returnSource.includes('(') &&
|
|
4701
|
+
!returnSource.includes('[')
|
|
4702
|
+
) {
|
|
4703
|
+
// Update varName to point to the return source
|
|
4704
|
+
if (equivalentSignatureVariables[varName] !== returnSource) {
|
|
4705
|
+
equivalentSignatureVariables[varName] = returnSource;
|
|
4706
|
+
changed = true;
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
|
|
4713
|
+
continue;
|
|
4714
|
+
}
|
|
4715
|
+
|
|
4716
|
+
// Check if the source path starts with a variable that's also in the map
|
|
4717
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4718
|
+
let baseVar: string;
|
|
4719
|
+
let rest: string;
|
|
4720
|
+
|
|
4721
|
+
if (dotIndex > 0) {
|
|
4722
|
+
// Path has a dot: "a.b.c" -> baseVar="a", rest=".b.c"
|
|
4723
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
4724
|
+
rest = sourcePath.slice(dotIndex); // includes the leading dot
|
|
4725
|
+
} else {
|
|
4726
|
+
// Path is a simple identifier: "currentEntityAnalysis" -> baseVar="currentEntityAnalysis", rest=""
|
|
4727
|
+
baseVar = sourcePath;
|
|
4728
|
+
rest = '';
|
|
4729
|
+
}
|
|
4730
|
+
|
|
4731
|
+
if (baseVar in equivalentSignatureVariables && baseVar !== varName) {
|
|
4732
|
+
// Handle array case (OR expressions) - use first element
|
|
4733
|
+
const rawBaseResolved = equivalentSignatureVariables[baseVar];
|
|
4734
|
+
const baseResolved = Array.isArray(rawBaseResolved)
|
|
4735
|
+
? rawBaseResolved[0]
|
|
4736
|
+
: rawBaseResolved;
|
|
4737
|
+
if (!baseResolved) continue;
|
|
4738
|
+
// If the base resolves to a hook call, add .functionCallReturnValue
|
|
4739
|
+
if (baseResolved.endsWith('()')) {
|
|
4740
|
+
const newPath = baseResolved + '.functionCallReturnValue' + rest;
|
|
4741
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4742
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4743
|
+
changed = true;
|
|
4744
|
+
}
|
|
4745
|
+
} else if (baseResolved !== sourcePath) {
|
|
4746
|
+
const newPath = baseResolved + rest;
|
|
4747
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4748
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4749
|
+
changed = true;
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
|
|
4755
|
+
// Stop if no changes were made in this iteration
|
|
4756
|
+
if (!changed) break;
|
|
4757
|
+
}
|
|
4758
|
+
|
|
3691
4759
|
return equivalentSignatureVariables;
|
|
3692
4760
|
}
|
|
3693
4761
|
|
|
@@ -3886,7 +4954,7 @@ export class ScopeDataStructure {
|
|
|
3886
4954
|
path: string;
|
|
3887
4955
|
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
3888
4956
|
comparedValues?: string[];
|
|
3889
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
4957
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
3890
4958
|
}>
|
|
3891
4959
|
>,
|
|
3892
4960
|
): void {
|
|
@@ -3911,29 +4979,145 @@ export class ScopeDataStructure {
|
|
|
3911
4979
|
}
|
|
3912
4980
|
|
|
3913
4981
|
/**
|
|
3914
|
-
*
|
|
3915
|
-
*
|
|
4982
|
+
* Add conditional effects from AST analysis.
|
|
4983
|
+
* Called during scope analysis to collect all setter calls inside conditionals.
|
|
4984
|
+
*/
|
|
4985
|
+
addConditionalEffects(
|
|
4986
|
+
effects: import('../astScopes/types').ConditionalEffect[],
|
|
4987
|
+
): void {
|
|
4988
|
+
// Add effects, avoiding duplicates based on effect stateVariable and condition paths
|
|
4989
|
+
for (const effect of effects) {
|
|
4990
|
+
const exists = this.rawConditionalEffects.some((existing) => {
|
|
4991
|
+
// Same effect target (stateVariable + value)
|
|
4992
|
+
const sameEffect =
|
|
4993
|
+
existing.effect.stateVariable === effect.effect.stateVariable &&
|
|
4994
|
+
existing.effect.value === effect.effect.value;
|
|
4995
|
+
if (!sameEffect) return false;
|
|
4996
|
+
|
|
4997
|
+
// Same condition(s)
|
|
4998
|
+
if (existing.condition && effect.condition) {
|
|
4999
|
+
return (
|
|
5000
|
+
existing.condition.path === effect.condition.path &&
|
|
5001
|
+
existing.condition.requiredValue === effect.condition.requiredValue
|
|
5002
|
+
);
|
|
5003
|
+
}
|
|
5004
|
+
if (existing.conditions && effect.conditions) {
|
|
5005
|
+
if (existing.conditions.length !== effect.conditions.length)
|
|
5006
|
+
return false;
|
|
5007
|
+
return existing.conditions.every((ec, i) => {
|
|
5008
|
+
const newCond = effect.conditions![i];
|
|
5009
|
+
return (
|
|
5010
|
+
ec.path === newCond.path &&
|
|
5011
|
+
ec.requiredValue === newCond.requiredValue
|
|
5012
|
+
);
|
|
5013
|
+
});
|
|
5014
|
+
}
|
|
5015
|
+
return false;
|
|
5016
|
+
});
|
|
5017
|
+
if (!exists) {
|
|
5018
|
+
this.rawConditionalEffects.push(effect);
|
|
5019
|
+
}
|
|
5020
|
+
}
|
|
5021
|
+
}
|
|
5022
|
+
|
|
5023
|
+
/**
|
|
5024
|
+
* Get conditional effects collected during analysis.
|
|
5025
|
+
*/
|
|
5026
|
+
getConditionalEffects(): import('../astScopes/types').ConditionalEffect[] {
|
|
5027
|
+
return this.rawConditionalEffects;
|
|
5028
|
+
}
|
|
5029
|
+
|
|
5030
|
+
/**
|
|
5031
|
+
* Add compound conditionals from AST analysis.
|
|
5032
|
+
* Called during scope analysis to collect grouped conditions (e.g., a && b && c).
|
|
5033
|
+
*/
|
|
5034
|
+
addCompoundConditionals(
|
|
5035
|
+
compounds: import('../astScopes/types').CompoundConditional[],
|
|
5036
|
+
): void {
|
|
5037
|
+
// Add compounds, avoiding duplicates based on chainId
|
|
5038
|
+
for (const compound of compounds) {
|
|
5039
|
+
const exists = this.rawCompoundConditionals.some(
|
|
5040
|
+
(existing) => existing.chainId === compound.chainId,
|
|
5041
|
+
);
|
|
5042
|
+
if (!exists) {
|
|
5043
|
+
this.rawCompoundConditionals.push(compound);
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
|
|
5048
|
+
/**
|
|
5049
|
+
* Get compound conditionals collected during analysis.
|
|
5050
|
+
*/
|
|
5051
|
+
getCompoundConditionals(): import('../astScopes/types').CompoundConditional[] {
|
|
5052
|
+
return this.rawCompoundConditionals;
|
|
5053
|
+
}
|
|
5054
|
+
|
|
5055
|
+
/**
|
|
5056
|
+
* Add child boundary gating conditions from AST analysis.
|
|
5057
|
+
* These track which conditions must be true for a child component to render.
|
|
5058
|
+
*/
|
|
5059
|
+
addChildBoundaryGatingConditions(
|
|
5060
|
+
conditions: Record<string, import('../astScopes/types').ConditionalUsage[]>,
|
|
5061
|
+
): void {
|
|
5062
|
+
for (const [childName, usages] of Object.entries(conditions)) {
|
|
5063
|
+
if (!this.rawChildBoundaryGatingConditions[childName]) {
|
|
5064
|
+
this.rawChildBoundaryGatingConditions[childName] = [];
|
|
5065
|
+
}
|
|
5066
|
+
// Add usages, avoiding duplicates
|
|
5067
|
+
for (const usage of usages) {
|
|
5068
|
+
const exists = this.rawChildBoundaryGatingConditions[childName].some(
|
|
5069
|
+
(existing) =>
|
|
5070
|
+
existing.path === usage.path &&
|
|
5071
|
+
existing.conditionType === usage.conditionType &&
|
|
5072
|
+
existing.isNegated === usage.isNegated,
|
|
5073
|
+
);
|
|
5074
|
+
if (!exists) {
|
|
5075
|
+
this.rawChildBoundaryGatingConditions[childName].push(usage);
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
|
|
5081
|
+
/**
|
|
5082
|
+
* Get enriched child boundary gating conditions with source tracing.
|
|
5083
|
+
* Similar to getEnrichedConditionalUsages but for gating conditions.
|
|
3916
5084
|
*/
|
|
3917
|
-
|
|
5085
|
+
getEnrichedChildBoundaryGatingConditions(): Record<
|
|
3918
5086
|
string,
|
|
3919
|
-
|
|
3920
|
-
path: string;
|
|
3921
|
-
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
3922
|
-
comparedValues?: string[];
|
|
3923
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
3924
|
-
sourceDataPath?: string;
|
|
3925
|
-
}>
|
|
5087
|
+
EnrichedConditionalUsage[]
|
|
3926
5088
|
> {
|
|
3927
|
-
const enriched: Record<
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
5089
|
+
const enriched: Record<string, EnrichedConditionalUsage[]> = {};
|
|
5090
|
+
const rootScopeName = this.scopeTreeManager.getTree().name;
|
|
5091
|
+
|
|
5092
|
+
for (const [childName, usages] of Object.entries(
|
|
5093
|
+
this.rawChildBoundaryGatingConditions,
|
|
5094
|
+
)) {
|
|
5095
|
+
enriched[childName] = usages.map((usage) => {
|
|
5096
|
+
// Try to trace this path back to a data source
|
|
5097
|
+
const explanation = this.explainPath(rootScopeName, usage.path);
|
|
5098
|
+
|
|
5099
|
+
let sourceDataPath: string | undefined;
|
|
5100
|
+
if (explanation.source) {
|
|
5101
|
+
sourceDataPath = `${explanation.source.scope}.${explanation.source.path}`;
|
|
5102
|
+
}
|
|
5103
|
+
|
|
5104
|
+
return {
|
|
5105
|
+
...usage,
|
|
5106
|
+
sourceDataPath,
|
|
5107
|
+
};
|
|
5108
|
+
});
|
|
5109
|
+
}
|
|
5110
|
+
|
|
5111
|
+
return enriched;
|
|
5112
|
+
}
|
|
5113
|
+
|
|
5114
|
+
/**
|
|
5115
|
+
* Get enriched conditional usages with source tracing.
|
|
5116
|
+
* Uses explainPath to trace each local variable back to its data source.
|
|
5117
|
+
* Preserves all fields from the raw conditional usages including derivedFrom.
|
|
5118
|
+
*/
|
|
5119
|
+
getEnrichedConditionalUsages(): Record<string, EnrichedConditionalUsage[]> {
|
|
5120
|
+
const enriched: Record<string, EnrichedConditionalUsage[]> = {};
|
|
3937
5121
|
|
|
3938
5122
|
for (const [path, usages] of Object.entries(this.rawConditionalUsages)) {
|
|
3939
5123
|
// Try to trace this path back to a data source
|
|
@@ -3956,10 +5140,37 @@ export class ScopeDataStructure {
|
|
|
3956
5140
|
return enriched;
|
|
3957
5141
|
}
|
|
3958
5142
|
|
|
5143
|
+
/**
|
|
5144
|
+
* Add JSX rendering usages from AST analysis.
|
|
5145
|
+
* These track arrays rendered via .map() and strings interpolated in JSX.
|
|
5146
|
+
*/
|
|
5147
|
+
addJsxRenderingUsages(
|
|
5148
|
+
usages: import('../astScopes/types').JsxRenderingUsage[],
|
|
5149
|
+
): void {
|
|
5150
|
+
// Add usages, avoiding duplicates based on path and renderingType
|
|
5151
|
+
for (const usage of usages) {
|
|
5152
|
+
const exists = this.rawJsxRenderingUsages.some(
|
|
5153
|
+
(existing) =>
|
|
5154
|
+
existing.path === usage.path &&
|
|
5155
|
+
existing.renderingType === usage.renderingType,
|
|
5156
|
+
);
|
|
5157
|
+
if (!exists) {
|
|
5158
|
+
this.rawJsxRenderingUsages.push(usage);
|
|
5159
|
+
}
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
|
|
5163
|
+
/**
|
|
5164
|
+
* Get JSX rendering usages collected during analysis.
|
|
5165
|
+
*/
|
|
5166
|
+
getJsxRenderingUsages(): import('../astScopes/types').JsxRenderingUsage[] {
|
|
5167
|
+
return this.rawJsxRenderingUsages;
|
|
5168
|
+
}
|
|
5169
|
+
|
|
3959
5170
|
toSerializable(): SerializableDataStructure {
|
|
3960
|
-
// Helper to clean cyScope from a string
|
|
5171
|
+
// Helper to clean cyScope and cyDuplicateKey from a string for output
|
|
3961
5172
|
const cleanCyScope = (str: string): string =>
|
|
3962
|
-
this.replaceCyScopeInString(str);
|
|
5173
|
+
this.replaceCyScopeInString(str).replace(/::cyDuplicateKey\d+::/g, '');
|
|
3963
5174
|
|
|
3964
5175
|
// Helper to convert ScopeVariable to SerializableScopeVariable (with cyScope cleaned)
|
|
3965
5176
|
const toSerializableVariable = (
|
|
@@ -4257,7 +5468,8 @@ export class ScopeDataStructure {
|
|
|
4257
5468
|
}
|
|
4258
5469
|
}
|
|
4259
5470
|
if (Object.keys(varSchema).length > 0) {
|
|
4260
|
-
|
|
5471
|
+
// Clean the variable name when using as key in output
|
|
5472
|
+
perVariableSchemas[cleanCyScope(varName)] = varSchema;
|
|
4261
5473
|
}
|
|
4262
5474
|
}
|
|
4263
5475
|
// Only include if we have any entries
|
|
@@ -4266,11 +5478,22 @@ export class ScopeDataStructure {
|
|
|
4266
5478
|
}
|
|
4267
5479
|
}
|
|
4268
5480
|
|
|
5481
|
+
// Enrich the schema with inferred types by applying fillInSchemaGapsAndUnknowns.
|
|
5482
|
+
// This ensures the serialized schema has the same type inference as getReturnValue().
|
|
5483
|
+
// Without this, evidence like "entities[].analyses: array" becomes "unknown".
|
|
5484
|
+
const enrichedSchema = { ...efc.schema };
|
|
5485
|
+
const tempScopeNode = {
|
|
5486
|
+
name: efc.name,
|
|
5487
|
+
schema: enrichedSchema,
|
|
5488
|
+
equivalencies: efc.equivalencies ?? {},
|
|
5489
|
+
};
|
|
5490
|
+
fillInSchemaGapsAndUnknowns(tempScopeNode, true);
|
|
5491
|
+
|
|
4269
5492
|
return {
|
|
4270
5493
|
name: efc.name,
|
|
4271
5494
|
callSignature: efc.callSignature,
|
|
4272
5495
|
callScope: efc.callScope,
|
|
4273
|
-
schema:
|
|
5496
|
+
schema: enrichedSchema,
|
|
4274
5497
|
equivalencies: efc.equivalencies
|
|
4275
5498
|
? Object.entries(efc.equivalencies).reduce(
|
|
4276
5499
|
(acc, [key, vars]) => {
|
|
@@ -4282,8 +5505,15 @@ export class ScopeDataStructure {
|
|
|
4282
5505
|
)
|
|
4283
5506
|
: undefined,
|
|
4284
5507
|
allCallSignatures: efc.allCallSignatures,
|
|
4285
|
-
receivingVariableNames: efc.receivingVariableNames,
|
|
4286
|
-
callSignatureToVariable: efc.callSignatureToVariable
|
|
5508
|
+
receivingVariableNames: efc.receivingVariableNames?.map(cleanCyScope),
|
|
5509
|
+
callSignatureToVariable: efc.callSignatureToVariable
|
|
5510
|
+
? Object.fromEntries(
|
|
5511
|
+
Object.entries(efc.callSignatureToVariable).map(([k, v]) => [
|
|
5512
|
+
k,
|
|
5513
|
+
cleanCyScope(v),
|
|
5514
|
+
]),
|
|
5515
|
+
)
|
|
5516
|
+
: undefined,
|
|
4287
5517
|
perVariableSchemas,
|
|
4288
5518
|
};
|
|
4289
5519
|
});
|
|
@@ -4403,6 +5633,13 @@ export class ScopeDataStructure {
|
|
|
4403
5633
|
externalFunctionCalls,
|
|
4404
5634
|
);
|
|
4405
5635
|
|
|
5636
|
+
// IMPORTANT: Get equivalent signature variables BEFORE calling getFunctionResult
|
|
5637
|
+
// because getFunctionResult calls validateSchema which may remove equivalencies
|
|
5638
|
+
// during the finalize step (e.g., cleanNonObjectFunctions removes method call
|
|
5639
|
+
// equivalencies like `segments -> splat.split('/').functionCallReturnValue`).
|
|
5640
|
+
// Fix 33: Move this call before any schema validation to preserve method call chains.
|
|
5641
|
+
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
5642
|
+
|
|
4406
5643
|
// Get root function result
|
|
4407
5644
|
const rootFunction = getFunctionResult();
|
|
4408
5645
|
|
|
@@ -4412,9 +5649,6 @@ export class ScopeDataStructure {
|
|
|
4412
5649
|
functionResults[efc.name] = getFunctionResult(efc.name);
|
|
4413
5650
|
}
|
|
4414
5651
|
|
|
4415
|
-
// Get equivalent signature variables
|
|
4416
|
-
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
4417
|
-
|
|
4418
5652
|
const environmentVariables = this.getEnvironmentVariables();
|
|
4419
5653
|
|
|
4420
5654
|
// Get enriched conditional usages with source tracing
|
|
@@ -4424,6 +5658,32 @@ export class ScopeDataStructure {
|
|
|
4424
5658
|
? enrichedConditionalUsages
|
|
4425
5659
|
: undefined;
|
|
4426
5660
|
|
|
5661
|
+
// Get conditional effects (setter calls inside conditionals)
|
|
5662
|
+
const conditionalEffects =
|
|
5663
|
+
this.rawConditionalEffects.length > 0
|
|
5664
|
+
? this.rawConditionalEffects
|
|
5665
|
+
: undefined;
|
|
5666
|
+
|
|
5667
|
+
// Get compound conditionals (grouped conditions that must all be true)
|
|
5668
|
+
const compoundConditionals =
|
|
5669
|
+
this.rawCompoundConditionals.length > 0
|
|
5670
|
+
? this.rawCompoundConditionals
|
|
5671
|
+
: undefined;
|
|
5672
|
+
|
|
5673
|
+
// Get child boundary gating conditions
|
|
5674
|
+
const enrichedGatingConditions =
|
|
5675
|
+
this.getEnrichedChildBoundaryGatingConditions();
|
|
5676
|
+
const childBoundaryGatingConditions =
|
|
5677
|
+
Object.keys(enrichedGatingConditions).length > 0
|
|
5678
|
+
? enrichedGatingConditions
|
|
5679
|
+
: undefined;
|
|
5680
|
+
|
|
5681
|
+
// Get JSX rendering usages (arrays via .map(), strings via interpolation)
|
|
5682
|
+
const jsxRenderingUsages =
|
|
5683
|
+
this.rawJsxRenderingUsages.length > 0
|
|
5684
|
+
? this.rawJsxRenderingUsages
|
|
5685
|
+
: undefined;
|
|
5686
|
+
|
|
4427
5687
|
return {
|
|
4428
5688
|
externalFunctionCalls: deduplicatedExternalFunctionCalls,
|
|
4429
5689
|
rootFunction,
|
|
@@ -4431,6 +5691,10 @@ export class ScopeDataStructure {
|
|
|
4431
5691
|
equivalentSignatureVariables,
|
|
4432
5692
|
environmentVariables,
|
|
4433
5693
|
conditionalUsages,
|
|
5694
|
+
conditionalEffects,
|
|
5695
|
+
compoundConditionals,
|
|
5696
|
+
childBoundaryGatingConditions,
|
|
5697
|
+
jsxRenderingUsages,
|
|
4434
5698
|
};
|
|
4435
5699
|
}
|
|
4436
5700
|
|