@codeyam/codeyam-cli 0.1.0-staging.6e699e5 → 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 +7 -7
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +7 -7
- package/analyzer-template/packages/ai/index.ts +10 -2
- package/analyzer-template/packages/ai/package.json +2 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +86 -18
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +67 -9
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +41 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +308 -50
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +15 -6
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +833 -243
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- 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 +60 -15
- 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 -97
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +283 -1
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +9 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +11 -3
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +297 -7
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +25 -13
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +4 -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 +65 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- 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 +71 -9
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +19 -4
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -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 +0 -3
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- 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 +61 -13
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +37 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +229 -19
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +117 -9
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +459 -39
- 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/package.json +1 -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/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/updateCommitMetadata.ts +7 -14
- 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/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/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/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/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/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/ScenariosDataStructure.d.ts +5 -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/package.json +1 -1
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +6 -5
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -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/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/ScenariosDataStructure.d.ts +5 -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/playwright/capture.ts +20 -8
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/project/analyzeBaselineCommit.ts +5 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +5 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +90 -10
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +11 -6
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +45 -6
- package/analyzer-template/project/start.ts +35 -11
- package/analyzer-template/project/writeMockDataTsx.ts +181 -8
- package/analyzer-template/project/writeScenarioComponents.ts +103 -12
- package/analyzer-template/project/writeSimpleRoot.ts +21 -11
- package/analyzer-template/scripts/comboWorkerLoop.cjs +98 -50
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +5 -0
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +5 -0
- 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 +75 -4
- package/background/src/lib/virtualized/project/constructMockCode.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/loadReadyToBeCaptured.js +19 -8
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.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/SequentialCaptureTaskRunner.js +4 -4
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +38 -6
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +32 -11
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +162 -4
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +85 -15
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
- 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 +2 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/debug.js +7 -5
- package/codeyam-cli/src/commands/debug.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/utils/__tests__/setupClaudeCodeSettings.test.js +2 -2
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +21 -2
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +4 -0
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +55 -10
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +4 -0
- package/codeyam-cli/src/utils/queue/job.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/setupClaudeCodeSettings.js +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +7 -3
- package/codeyam-cli/src/webserver/app/lib/database.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-DLqD3qNt.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-Ba2JVPzP.js → EntityTypeIcon-BqY8gDAW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-C8lyxW9k.js → InlineSpinner-ClaLpuOo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-aht4aafF.js → InteractivePreview-BDhPilK7.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CVtiBnY5.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-B0GLXMsr.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-xgeCVgSM.js → LogViewer-Bm3PmcCz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-D4TZhLuw.js → ReportIssueModal-C6PKeMYR.js} +3 -13
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DuDvi0jm.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DEx02QDa.js → ScenarioViewer-BNLaXBHR.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-DyFZkK0l.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{_index-BwqWJOgH.js → _index-B3TDXxnk.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-DoLIqZX2.js → activity.(_tab)-BtBFH820.js} +6 -16
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DfKzxuoe.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.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-Cx24_aWc.js → chevron-down-TJp6ofnp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-CXRTFQ3F.js → chunk-JZWAC4HX-JE9ZIoBl.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BOARzkeR.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-BdhJEx6B.js → createLucideIcon-Ca9fAY46.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-C5lqplTC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-C2N4Op8e.js → entity._sha._-n38keI1k.js} +10 -10
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js → entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D1T4TGjf.js → entity._sha_.create-scenario-DGgZjdFg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CTBG2mmz.js → entity._sha_.edit._scenarioId-38yPijoD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CS2cb_eZ.js → entry.client-BSHEfydn.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DMJ7zii9.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-B4RJRvYB.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-lzqtyFU8.js → index-CcsFv748.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-B1h680n5.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-B7B9V-bu.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-CxXUmBSd.js → search-B8VUL8nl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{settings-CS5f3WzT.js → settings-eBI36Yv5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-DwFIBT09.js → simulations-CPoAg7Zo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-B6LgvRJg.js → triangle-alert-BZz2NjYa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-C1v1PQzo.js → useCustomSizes-DNwUduNu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-aSv48UbS.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DYxHZQuP.js → useReportContext-CpZgwliL.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-mBRpZPiu.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/templates/{codeyam-power-rules-hook.sh → codeyam-memory-hook.sh} +12 -13
- package/codeyam-cli/templates/codeyam:diagnose.md +178 -25
- package/codeyam-cli/templates/codeyam:memory.md +404 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +2 -2
- 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 +8 -6
- package/packages/ai/index.js +3 -2
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +68 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +54 -8
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/methodSemantics.js +41 -17
- 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/processExpression.js +239 -43
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +650 -166
- 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/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 +55 -11
- 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 -86
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +46 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +205 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +7 -1
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +10 -2
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +209 -3
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +39 -3
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +70 -51
- 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/resolvePathToControllable.js +24 -14
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
- 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 +60 -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/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 +54 -6
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +17 -4
- 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/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 +0 -3
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.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/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 +56 -10
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +33 -8
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +150 -17
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +56 -8
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +399 -31
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.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/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/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/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BXhEawa3.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BRb-0kQl.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-Cs4MdYtv.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-commit-horizontal-CysbcZxi.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-DMUaGAqV.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-f874c610.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-Bz5TunQg.js +0 -57
- package/codeyam-cli/src/webserver/build/client/assets/rules-hEkvVw2-.js +0 -97
- package/codeyam-cli/src/webserver/build/server/assets/index-967OuJoF.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-DRTmerg9.js +0 -257
- package/codeyam-cli/templates/codeyam:power-rules.md +0 -447
- /package/codeyam-cli/src/webserver/build/client/assets/{api.rules-l0sNRNKZ.js → api.agent-transcripts-l0sNRNKZ.js} +0 -0
|
@@ -79,6 +79,8 @@
|
|
|
79
79
|
* - `helpers/README.md` - Overview of the helper module architecture
|
|
80
80
|
*/
|
|
81
81
|
import fillInSchemaGapsAndUnknowns from "./helpers/fillInSchemaGapsAndUnknowns.js";
|
|
82
|
+
import { clearCleanKnownObjectFunctionsCache } from "./helpers/cleanKnownObjectFunctions.js";
|
|
83
|
+
import { clearCleanNonObjectFunctionsCache } from "./helpers/cleanNonObjectFunctions.js";
|
|
82
84
|
/**
|
|
83
85
|
* Patterns that indicate recursive type structures in schema paths.
|
|
84
86
|
* Used by hasExcessivePatternRepetition() to detect exponential path blowup.
|
|
@@ -120,6 +122,17 @@ export function resetScopeDataStructureMetrics() {
|
|
|
120
122
|
followEquivalenciesEarlyExitPhase1Count = 0;
|
|
121
123
|
followEquivalenciesWithWorkCount = 0;
|
|
122
124
|
addEquivalencyCallCount = 0;
|
|
125
|
+
// Clear module-level caches to prevent unbounded memory growth across entities
|
|
126
|
+
const knownObjectCache = clearCleanKnownObjectFunctionsCache();
|
|
127
|
+
const nonObjectCache = clearCleanNonObjectFunctionsCache();
|
|
128
|
+
if (knownObjectCache.count > 0 || nonObjectCache.count > 0) {
|
|
129
|
+
const totalBytes = knownObjectCache.estimatedBytes + nonObjectCache.estimatedBytes;
|
|
130
|
+
console.log('CodeYam: Cleared analysis caches', {
|
|
131
|
+
knownObjectCache: `${knownObjectCache.count} entries, ${(knownObjectCache.estimatedBytes / 1024).toFixed(1)}KB`,
|
|
132
|
+
nonObjectCache: `${nonObjectCache.count} entries, ${(nonObjectCache.estimatedBytes / 1024).toFixed(1)}KB`,
|
|
133
|
+
totalKB: `${(totalBytes / 1024).toFixed(1)}KB`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
123
136
|
}
|
|
124
137
|
// Performance: Pre-computed Sets for equivalency reason filtering (O(1) vs O(n))
|
|
125
138
|
const ALLOWED_EQUIVALENCY_REASONS = new Set([
|
|
@@ -462,6 +475,10 @@ export class ScopeDataStructure {
|
|
|
462
475
|
}
|
|
463
476
|
return;
|
|
464
477
|
}
|
|
478
|
+
// PERF: Early exit for paths with repeated function-call signature patterns
|
|
479
|
+
if (this.hasExcessivePatternRepetition(path)) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
465
482
|
// Update chain metadata for database tracking
|
|
466
483
|
if (equivalencyValueChain.length > 0) {
|
|
467
484
|
equivalencyValueChain[equivalencyValueChain.length - 1].addToSchemaId =
|
|
@@ -958,6 +975,12 @@ export class ScopeDataStructure {
|
|
|
958
975
|
const value1 = scopeNode.schema[schemaPath];
|
|
959
976
|
const value2 = equivalentScopeNode.schema[equivalentSchemaPath];
|
|
960
977
|
const bestValue = selectBestValue(value1, value2);
|
|
978
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
979
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
980
|
+
if (this.hasExcessivePatternRepetition(schemaPath) ||
|
|
981
|
+
this.hasExcessivePatternRepetition(equivalentSchemaPath)) {
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
961
984
|
scopeNode.schema[schemaPath] = bestValue;
|
|
962
985
|
equivalentScopeNode.schema[equivalentSchemaPath] = bestValue;
|
|
963
986
|
}
|
|
@@ -969,6 +992,10 @@ export class ScopeDataStructure {
|
|
|
969
992
|
equivalentPath,
|
|
970
993
|
...remainingSchemaPathParts,
|
|
971
994
|
]);
|
|
995
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
996
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
972
999
|
equivalentScopeNode.schema[newEquivalentPath] =
|
|
973
1000
|
scopeNode.schema[schemaPath];
|
|
974
1001
|
}
|
|
@@ -1050,6 +1077,23 @@ export class ScopeDataStructure {
|
|
|
1050
1077
|
return true;
|
|
1051
1078
|
}
|
|
1052
1079
|
}
|
|
1080
|
+
// Check for repeated function calls that indicate recursive type expansion.
|
|
1081
|
+
// E.g., localeCompare(b[])...localeCompare(b[]) means string.localeCompare
|
|
1082
|
+
// returns a type that again has localeCompare, causing infinite expansion.
|
|
1083
|
+
// We extract all function call patterns like "funcName(args)" and check if
|
|
1084
|
+
// the same normalized call appears more than once.
|
|
1085
|
+
const funcCallPattern = /(?:^|\.)[^.([]+\([^)]*\)/g;
|
|
1086
|
+
const funcCallMatches = path.match(funcCallPattern);
|
|
1087
|
+
if (funcCallMatches && funcCallMatches.length > 1) {
|
|
1088
|
+
const seen = new Set();
|
|
1089
|
+
for (const match of funcCallMatches) {
|
|
1090
|
+
// Strip leading dot and normalize array indices
|
|
1091
|
+
const normalized = match.replace(/^\./, '').replace(/\[\d+\]/g, '[]');
|
|
1092
|
+
if (seen.has(normalized))
|
|
1093
|
+
return true;
|
|
1094
|
+
seen.add(normalized);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1053
1097
|
// For longer paths, detect any repeated multi-part segments we haven't explicitly listed
|
|
1054
1098
|
const pathParts = this.splitPath(path);
|
|
1055
1099
|
if (pathParts.length <= 6) {
|
|
@@ -1075,21 +1119,36 @@ export class ScopeDataStructure {
|
|
|
1075
1119
|
}
|
|
1076
1120
|
setInstantiatedVariables(scopeNode) {
|
|
1077
1121
|
let instantiatedVariables = scopeNode.analysis?.instantiatedVariables ?? [];
|
|
1078
|
-
for (const [path,
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1122
|
+
for (const [path, rawEquivalentPath] of Object.entries(scopeNode.analysis.isolatedEquivalentVariables ?? {})) {
|
|
1123
|
+
// Normalize to array for consistent handling (supports both string and string[])
|
|
1124
|
+
const equivalentPaths = Array.isArray(rawEquivalentPath)
|
|
1125
|
+
? rawEquivalentPath
|
|
1126
|
+
: rawEquivalentPath
|
|
1127
|
+
? [rawEquivalentPath]
|
|
1128
|
+
: [];
|
|
1129
|
+
for (const equivalentPath of equivalentPaths) {
|
|
1130
|
+
if (typeof equivalentPath !== 'string') {
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
if (equivalentPath.startsWith('signature[')) {
|
|
1134
|
+
const equivalentPathParts = this.splitPath(equivalentPath);
|
|
1135
|
+
instantiatedVariables.push(equivalentPathParts[0]);
|
|
1136
|
+
instantiatedVariables.push(path);
|
|
1137
|
+
}
|
|
1086
1138
|
}
|
|
1087
1139
|
const duplicateInstantiated = instantiatedVariables.find((v) => path.split('::cyDuplicateKey')[0] === v.split('::cyDuplicateKey')[0]);
|
|
1088
1140
|
if (duplicateInstantiated) {
|
|
1089
1141
|
instantiatedVariables.push(path);
|
|
1090
1142
|
}
|
|
1091
1143
|
}
|
|
1092
|
-
|
|
1144
|
+
const instantiatedSeen = new Set();
|
|
1145
|
+
instantiatedVariables = instantiatedVariables.filter((varName) => {
|
|
1146
|
+
if (instantiatedSeen.has(varName)) {
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
instantiatedSeen.add(varName);
|
|
1150
|
+
return true;
|
|
1151
|
+
});
|
|
1093
1152
|
scopeNode.instantiatedVariables = instantiatedVariables;
|
|
1094
1153
|
if (!scopeNode.tree || scopeNode.tree.length === 0) {
|
|
1095
1154
|
return;
|
|
@@ -1101,9 +1160,16 @@ export class ScopeDataStructure {
|
|
|
1101
1160
|
const parentInstantiatedVariables = [
|
|
1102
1161
|
...(parentScopeNode.parentInstantiatedVariables ?? []),
|
|
1103
1162
|
...parentScopeNode.instantiatedVariables.filter((v) => !v.startsWith('signature[') && !v.startsWith('returnValue')),
|
|
1104
|
-
].filter((varName
|
|
1105
|
-
|
|
1106
|
-
|
|
1163
|
+
].filter((varName) => !instantiatedSeen.has(varName));
|
|
1164
|
+
const parentInstantiatedSeen = new Set();
|
|
1165
|
+
const dedupedParentInstantiatedVariables = parentInstantiatedVariables.filter((varName) => {
|
|
1166
|
+
if (parentInstantiatedSeen.has(varName)) {
|
|
1167
|
+
return false;
|
|
1168
|
+
}
|
|
1169
|
+
parentInstantiatedSeen.add(varName);
|
|
1170
|
+
return true;
|
|
1171
|
+
});
|
|
1172
|
+
scopeNode.parentInstantiatedVariables = dedupedParentInstantiatedVariables;
|
|
1107
1173
|
}
|
|
1108
1174
|
trackFunctionCalls(scopeNode) {
|
|
1109
1175
|
this.captureFunctionCalls(scopeNode);
|
|
@@ -1114,116 +1180,136 @@ export class ScopeDataStructure {
|
|
|
1114
1180
|
return;
|
|
1115
1181
|
}
|
|
1116
1182
|
const { isolatedStructure, isolatedEquivalentVariables } = scopeNode.analysis;
|
|
1183
|
+
// Flatten isolatedEquivalentVariables values for allPaths (handles both string and string[])
|
|
1184
|
+
const flattenedEquivValues = Object.values(isolatedEquivalentVariables || {}).flatMap((v) => (Array.isArray(v) ? v : [v]));
|
|
1117
1185
|
const allPaths = Array.from(new Set([
|
|
1118
1186
|
...Object.keys(isolatedStructure || {}),
|
|
1119
1187
|
...Object.keys(isolatedEquivalentVariables || {}),
|
|
1120
|
-
...
|
|
1188
|
+
...flattenedEquivValues,
|
|
1121
1189
|
]));
|
|
1122
1190
|
for (let path in isolatedEquivalentVariables) {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1191
|
+
const rawEquivalentValue = isolatedEquivalentVariables?.[path];
|
|
1192
|
+
// Normalize to array for consistent handling
|
|
1193
|
+
const equivalentValues = Array.isArray(rawEquivalentValue)
|
|
1194
|
+
? rawEquivalentValue
|
|
1195
|
+
: [rawEquivalentValue];
|
|
1196
|
+
for (let equivalentValue of equivalentValues) {
|
|
1197
|
+
if (equivalentValue && this.isValidPath(equivalentValue)) {
|
|
1198
|
+
// IMPORTANT: DO NOT strip ::cyDuplicateKey:: markers from equivalencies.
|
|
1199
|
+
// These markers are critical for distinguishing variable reassignments.
|
|
1200
|
+
// For example, with:
|
|
1201
|
+
// let fetcher = useFetcher<ConfigData>();
|
|
1202
|
+
// const configData = fetcher.data?.data;
|
|
1203
|
+
// fetcher = useFetcher<SettingsData>();
|
|
1204
|
+
// const settingsData = fetcher.data?.data;
|
|
1205
|
+
//
|
|
1206
|
+
// mergeStatements creates:
|
|
1207
|
+
// fetcher → useFetcher<ConfigData>()...
|
|
1208
|
+
// fetcher::cyDuplicateKey1:: → useFetcher<SettingsData>()...
|
|
1209
|
+
// configData → fetcher.data.data
|
|
1210
|
+
// settingsData → fetcher::cyDuplicateKey1::.data.data
|
|
1211
|
+
//
|
|
1212
|
+
// If we strip ::cyDuplicateKey::, settingsData would incorrectly trace
|
|
1213
|
+
// to useFetcher<ConfigData>() instead of useFetcher<SettingsData>().
|
|
1214
|
+
path = cleanPath(path, allPaths);
|
|
1215
|
+
equivalentValue = cleanPath(equivalentValue, allPaths);
|
|
1216
|
+
this.addEquivalency(path, equivalentValue, scopeNode.name, scopeNode, 'original equivalency');
|
|
1217
|
+
// Propagate equivalencies involving parent-scope variables to those parent scopes.
|
|
1218
|
+
// This handles patterns like: collected.push({...entity}) where 'collected' is defined
|
|
1219
|
+
// in a parent scope. The equivalency collected[] -> push().signature[0] needs to be
|
|
1220
|
+
// visible when tracing from the parent scope.
|
|
1221
|
+
const rootVariable = this.extractRootVariable(path);
|
|
1222
|
+
const equivalentRootVariable = this.extractRootVariable(equivalentValue);
|
|
1223
|
+
// Skip propagation for self-referential reassignment patterns like:
|
|
1224
|
+
// x = x.method().functionCallReturnValue
|
|
1225
|
+
// where the path IS the variable itself (not a sub-path like x[] or x.prop).
|
|
1226
|
+
// These create circular references since both sides reference the same variable.
|
|
1227
|
+
//
|
|
1228
|
+
// But DO propagate for patterns like collected[] -> collected.push(...).signature[0]
|
|
1229
|
+
// where the path has additional segments beyond the root variable.
|
|
1230
|
+
const pathIsJustRootVariable = path === rootVariable;
|
|
1231
|
+
const isSelfReferentialReassignment = pathIsJustRootVariable && rootVariable === equivalentRootVariable;
|
|
1232
|
+
if (rootVariable &&
|
|
1233
|
+
!isSelfReferentialReassignment &&
|
|
1234
|
+
scopeNode.parentInstantiatedVariables?.includes(rootVariable)) {
|
|
1235
|
+
// Find the parent scope where this variable is defined
|
|
1236
|
+
for (const parentScopeName of scopeNode.tree || []) {
|
|
1237
|
+
const parentScope = this.scopeNodes[parentScopeName];
|
|
1238
|
+
if (parentScope?.instantiatedVariables?.includes(rootVariable)) {
|
|
1239
|
+
// Add the equivalency to the parent scope as well
|
|
1240
|
+
this.addEquivalency(path, equivalentValue, scopeNode.name, // The equivalent path's scope remains the child scope
|
|
1241
|
+
parentScope, // But store it in the parent scope's equivalencies
|
|
1242
|
+
'propagated parent-variable equivalency');
|
|
1243
|
+
break;
|
|
1244
|
+
}
|
|
1171
1245
|
}
|
|
1172
1246
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1247
|
+
// Propagate sub-property equivalencies when the equivalentValue is a simple variable
|
|
1248
|
+
// that has sub-properties defined in the isolatedEquivalentVariables.
|
|
1249
|
+
// This handles cases like: dataItem={{ structure: completeDataStructure }}
|
|
1250
|
+
// where completeDataStructure has sub-properties like completeDataStructure['Function Arguments']
|
|
1251
|
+
// We need to propagate these to create: dataItem.structure['Function Arguments'] equivalencies
|
|
1252
|
+
const isSimpleVariable = !equivalentValue.startsWith('signature[') &&
|
|
1253
|
+
!equivalentValue.includes('functionCallReturnValue') &&
|
|
1254
|
+
!equivalentValue.includes('.') &&
|
|
1255
|
+
!equivalentValue.includes('[');
|
|
1256
|
+
if (isSimpleVariable) {
|
|
1257
|
+
// Look in current scope and all parent scopes for sub-properties
|
|
1258
|
+
const scopesToCheck = [scopeNode.name, ...scopeNode.tree];
|
|
1259
|
+
for (const scopeName of scopesToCheck) {
|
|
1260
|
+
const checkScope = this.scopeNodes[scopeName];
|
|
1261
|
+
if (!checkScope?.analysis?.isolatedEquivalentVariables)
|
|
1262
|
+
continue;
|
|
1263
|
+
for (const [subPath, rawSubValue] of Object.entries(checkScope.analysis.isolatedEquivalentVariables)) {
|
|
1264
|
+
// Normalize to array for consistent handling
|
|
1265
|
+
const subValues = Array.isArray(rawSubValue)
|
|
1266
|
+
? rawSubValue
|
|
1267
|
+
: rawSubValue
|
|
1268
|
+
? [rawSubValue]
|
|
1269
|
+
: [];
|
|
1270
|
+
// Check if this is a sub-property of the equivalentValue variable
|
|
1271
|
+
// e.g., completeDataStructure['Function Arguments'] or completeDataStructure.foo
|
|
1272
|
+
const matchesDot = subPath.startsWith(equivalentValue + '.');
|
|
1273
|
+
const matchesBracket = subPath.startsWith(equivalentValue + '[');
|
|
1274
|
+
if (matchesDot || matchesBracket) {
|
|
1275
|
+
const subPropertyPath = subPath.substring(equivalentValue.length);
|
|
1276
|
+
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
1277
|
+
for (const subValue of subValues) {
|
|
1278
|
+
if (typeof subValue !== 'string')
|
|
1279
|
+
continue;
|
|
1280
|
+
const newEquivalentValue = cleanPath(subValue.replace(/::cyDuplicateKey\d+::/g, ''), allPaths);
|
|
1281
|
+
if (newEquivalentValue &&
|
|
1282
|
+
this.isValidPath(newEquivalentValue)) {
|
|
1283
|
+
this.addEquivalency(newPath, newEquivalentValue, checkScope.name, // Use the scope where the sub-property was found
|
|
1284
|
+
scopeNode, 'propagated sub-property equivalency');
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
// Also check if equivalentValue itself maps to a functionCallReturnValue
|
|
1289
|
+
// e.g., result = useMemo(...).functionCallReturnValue
|
|
1290
|
+
for (const subValue of subValues) {
|
|
1291
|
+
if (subPath === equivalentValue &&
|
|
1292
|
+
typeof subValue === 'string' &&
|
|
1293
|
+
subValue.endsWith('.functionCallReturnValue')) {
|
|
1294
|
+
this.propagateFunctionCallReturnSubProperties(path, subValue, scopeNode, allPaths);
|
|
1295
|
+
}
|
|
1203
1296
|
}
|
|
1204
|
-
}
|
|
1205
|
-
// Also check if equivalentValue itself maps to a functionCallReturnValue
|
|
1206
|
-
// e.g., result = useMemo(...).functionCallReturnValue
|
|
1207
|
-
if (subPath === equivalentValue &&
|
|
1208
|
-
typeof subValue === 'string' &&
|
|
1209
|
-
subValue.endsWith('.functionCallReturnValue')) {
|
|
1210
|
-
this.propagateFunctionCallReturnSubProperties(path, subValue, scopeNode, allPaths);
|
|
1211
1297
|
}
|
|
1212
1298
|
}
|
|
1213
1299
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1300
|
+
// Handle function call return values by propagating returnValue.* sub-properties
|
|
1301
|
+
// from the callback scope to the usage path
|
|
1302
|
+
if (equivalentValue.endsWith('.functionCallReturnValue')) {
|
|
1303
|
+
this.propagateFunctionCallReturnSubProperties(path, equivalentValue, scopeNode, allPaths);
|
|
1304
|
+
// Track which variable receives the return value of each function call
|
|
1305
|
+
// This enables generating separate mock data for each call site
|
|
1306
|
+
this.trackReceivingVariable(path, equivalentValue);
|
|
1307
|
+
}
|
|
1308
|
+
// Also track variables that receive destructured properties from function call return values
|
|
1309
|
+
// e.g., "userData" -> "db.query('users').functionCallReturnValue.data"
|
|
1310
|
+
if (equivalentValue.includes('.functionCallReturnValue.')) {
|
|
1311
|
+
this.trackReceivingVariable(path, equivalentValue);
|
|
1312
|
+
}
|
|
1227
1313
|
}
|
|
1228
1314
|
}
|
|
1229
1315
|
}
|
|
@@ -1367,8 +1453,15 @@ export class ScopeDataStructure {
|
|
|
1367
1453
|
const checkScope = this.scopeNodes[scopeName];
|
|
1368
1454
|
if (!checkScope?.analysis?.isolatedEquivalentVariables)
|
|
1369
1455
|
continue;
|
|
1370
|
-
const
|
|
1371
|
-
|
|
1456
|
+
const rawFunctionRef = checkScope.analysis.isolatedEquivalentVariables[functionName];
|
|
1457
|
+
// Normalize to array and find first string ending with 'F'
|
|
1458
|
+
const functionRefs = Array.isArray(rawFunctionRef)
|
|
1459
|
+
? rawFunctionRef
|
|
1460
|
+
: rawFunctionRef
|
|
1461
|
+
? [rawFunctionRef]
|
|
1462
|
+
: [];
|
|
1463
|
+
const functionRef = functionRefs.find((r) => typeof r === 'string' && r.endsWith('F'));
|
|
1464
|
+
if (typeof functionRef === 'string') {
|
|
1372
1465
|
callbackScopeName = functionRef.slice(0, -1);
|
|
1373
1466
|
break;
|
|
1374
1467
|
}
|
|
@@ -1391,22 +1484,32 @@ export class ScopeDataStructure {
|
|
|
1391
1484
|
if (!callbackScope.analysis?.isolatedEquivalentVariables)
|
|
1392
1485
|
return;
|
|
1393
1486
|
const isolatedVars = callbackScope.analysis.isolatedEquivalentVariables;
|
|
1487
|
+
// Get the first returnValue equivalency (normalize array to single value for these checks)
|
|
1488
|
+
const rawReturnValue = isolatedVars.returnValue;
|
|
1489
|
+
const firstReturnValue = Array.isArray(rawReturnValue)
|
|
1490
|
+
? rawReturnValue[0]
|
|
1491
|
+
: rawReturnValue;
|
|
1394
1492
|
// First, check if returnValue is an alias to another variable (e.g., returnValue = intermediate)
|
|
1395
1493
|
// If so, we need to look for that variable's sub-properties too
|
|
1396
|
-
const returnValueAlias = typeof
|
|
1397
|
-
|
|
1398
|
-
? isolatedVars.returnValue
|
|
1494
|
+
const returnValueAlias = typeof firstReturnValue === 'string' && !firstReturnValue.includes('.')
|
|
1495
|
+
? firstReturnValue
|
|
1399
1496
|
: undefined;
|
|
1400
1497
|
// Pattern 3: Object.keys(X).reduce() - the reduce result has the same sub-properties as X
|
|
1401
1498
|
// When returnValue = "Object.keys(source).reduce(...).functionCallReturnValue", look for source.* sub-properties
|
|
1402
1499
|
let reduceSourceVar;
|
|
1403
|
-
if (typeof
|
|
1404
|
-
const reduceMatch =
|
|
1500
|
+
if (typeof firstReturnValue === 'string') {
|
|
1501
|
+
const reduceMatch = firstReturnValue.match(/^Object\.keys\((\w+)\)\.reduce\(.*\)\.functionCallReturnValue$/);
|
|
1405
1502
|
if (reduceMatch) {
|
|
1406
1503
|
reduceSourceVar = reduceMatch[1];
|
|
1407
1504
|
}
|
|
1408
1505
|
}
|
|
1409
|
-
for (const [subPath,
|
|
1506
|
+
for (const [subPath, rawSubValue] of Object.entries(isolatedVars)) {
|
|
1507
|
+
// Normalize to array for consistent handling
|
|
1508
|
+
const subValues = Array.isArray(rawSubValue)
|
|
1509
|
+
? rawSubValue
|
|
1510
|
+
: rawSubValue
|
|
1511
|
+
? [rawSubValue]
|
|
1512
|
+
: [];
|
|
1410
1513
|
// Check for direct returnValue.* sub-properties
|
|
1411
1514
|
const isReturnValueSub = subPath.startsWith('returnValue.') ||
|
|
1412
1515
|
subPath.startsWith('returnValue[');
|
|
@@ -1418,33 +1521,36 @@ export class ScopeDataStructure {
|
|
|
1418
1521
|
const isReduceSourceSub = reduceSourceVar &&
|
|
1419
1522
|
(subPath.startsWith(reduceSourceVar + '.') ||
|
|
1420
1523
|
subPath.startsWith(reduceSourceVar + '['));
|
|
1421
|
-
if (
|
|
1422
|
-
(!isReturnValueSub && !isAliasSub && !isReduceSourceSub))
|
|
1524
|
+
if (!isReturnValueSub && !isAliasSub && !isReduceSourceSub)
|
|
1423
1525
|
continue;
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
//
|
|
1428
|
-
effectiveSubPath =
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1526
|
+
for (const subValue of subValues) {
|
|
1527
|
+
if (typeof subValue !== 'string')
|
|
1528
|
+
continue;
|
|
1529
|
+
// Convert alias/reduceSource paths to returnValue paths
|
|
1530
|
+
let effectiveSubPath = subPath;
|
|
1531
|
+
if (isAliasSub && !isReturnValueSub) {
|
|
1532
|
+
// Replace the alias prefix with returnValue
|
|
1533
|
+
effectiveSubPath =
|
|
1534
|
+
'returnValue' + subPath.substring(returnValueAlias.length);
|
|
1535
|
+
}
|
|
1536
|
+
else if (isReduceSourceSub && !isReturnValueSub && !isAliasSub) {
|
|
1537
|
+
// Replace the reduce source prefix with returnValue
|
|
1538
|
+
effectiveSubPath =
|
|
1539
|
+
'returnValue' + subPath.substring(reduceSourceVar.length);
|
|
1540
|
+
}
|
|
1541
|
+
const subPropertyPath = effectiveSubPath.substring('returnValue'.length);
|
|
1542
|
+
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
1543
|
+
let newEquivalentValue = cleanPath(subValue.replace(/::cyDuplicateKey\d+::/g, ''), allPaths);
|
|
1544
|
+
// Resolve variable references through parent scope equivalencies
|
|
1545
|
+
const resolved = this.resolveVariableThroughParentScopes(newEquivalentValue, callbackScope, allPaths);
|
|
1546
|
+
newEquivalentValue = resolved.resolvedPath;
|
|
1547
|
+
const equivalentScopeName = resolved.scopeName;
|
|
1548
|
+
if (!newEquivalentValue || !this.isValidPath(newEquivalentValue))
|
|
1549
|
+
continue;
|
|
1550
|
+
this.addEquivalency(newPath, newEquivalentValue, equivalentScopeName, scopeNode, 'propagated function call return sub-property equivalency');
|
|
1551
|
+
// Ensure the database entry has the usage path
|
|
1552
|
+
this.addUsageToEquivalencyDatabaseEntry(newPath, newEquivalentValue, equivalentScopeName, scopeNode.name);
|
|
1553
|
+
}
|
|
1448
1554
|
}
|
|
1449
1555
|
}
|
|
1450
1556
|
/**
|
|
@@ -1476,7 +1582,14 @@ export class ScopeDataStructure {
|
|
|
1476
1582
|
const parentScope = this.scopeNodes[parentScopeName];
|
|
1477
1583
|
if (!parentScope?.analysis?.isolatedEquivalentVariables)
|
|
1478
1584
|
continue;
|
|
1479
|
-
const
|
|
1585
|
+
const rawRootEquiv = parentScope.analysis.isolatedEquivalentVariables[rootVar];
|
|
1586
|
+
// Normalize to array and use first string value
|
|
1587
|
+
const rootEquivs = Array.isArray(rawRootEquiv)
|
|
1588
|
+
? rawRootEquiv
|
|
1589
|
+
: rawRootEquiv
|
|
1590
|
+
? [rawRootEquiv]
|
|
1591
|
+
: [];
|
|
1592
|
+
const rootEquiv = rootEquivs.find((r) => typeof r === 'string');
|
|
1480
1593
|
if (typeof rootEquiv === 'string') {
|
|
1481
1594
|
return {
|
|
1482
1595
|
resolvedPath: cleanPath(rootEquiv + restOfPath, allPaths),
|
|
@@ -1670,6 +1783,7 @@ export class ScopeDataStructure {
|
|
|
1670
1783
|
const remainingPath = this.joinPathParts(remainingPathParts);
|
|
1671
1784
|
if (relevantSubPathParts.every((part, i) => part === schemaPathParts[i]) &&
|
|
1672
1785
|
equivalentValue.scopeNodeName === scopeNode.name) {
|
|
1786
|
+
// DEBUG
|
|
1673
1787
|
continue;
|
|
1674
1788
|
}
|
|
1675
1789
|
const newEquivalentPath = this.joinPathParts([schemaPath, remainingPath]);
|
|
@@ -1955,9 +2069,70 @@ export class ScopeDataStructure {
|
|
|
1955
2069
|
// Update inverted index
|
|
1956
2070
|
this.intermediatesOrderIndex.set(pathId, databaseEntry);
|
|
1957
2071
|
if (intermediateIndex === 0) {
|
|
1958
|
-
|
|
2072
|
+
let isValidSourceCandidate = pathInfo.schemaPath.startsWith('signature[') ||
|
|
1959
2073
|
pathInfo.schemaPath.includes('functionCallReturnValue');
|
|
1960
|
-
if
|
|
2074
|
+
// Check if path STARTS with a spread pattern like [...var]
|
|
2075
|
+
// This handles cases like [...files][][0] or [...files].sort(...).functionCallReturnValue[][0]
|
|
2076
|
+
// where the spread source variable needs to be resolved to a signature path.
|
|
2077
|
+
// We do this REGARDLESS of isValidSourceCandidate because even paths containing
|
|
2078
|
+
// functionCallReturnValue may need spread resolution to trace back to the signature.
|
|
2079
|
+
const spreadMatch = pathInfo.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
2080
|
+
if (spreadMatch) {
|
|
2081
|
+
const spreadVar = spreadMatch[1];
|
|
2082
|
+
const spreadPattern = spreadMatch[0]; // The full [...var] match
|
|
2083
|
+
const scopeNode = this.scopeNodes[pathInfo.scopeNodeName];
|
|
2084
|
+
if (scopeNode?.equivalencies) {
|
|
2085
|
+
// Follow the equivalency chain to find a signature path
|
|
2086
|
+
// e.g., files (cyScope1) → files (root) → signature[0].files
|
|
2087
|
+
const resolveToSignature = (varName, currentScopeName, visited) => {
|
|
2088
|
+
const visitKey = `${currentScopeName}::${varName}`;
|
|
2089
|
+
if (visited.has(visitKey))
|
|
2090
|
+
return null;
|
|
2091
|
+
visited.add(visitKey);
|
|
2092
|
+
const currentScope = this.scopeNodes[currentScopeName];
|
|
2093
|
+
if (!currentScope?.equivalencies)
|
|
2094
|
+
return null;
|
|
2095
|
+
const varEquivs = currentScope.equivalencies[varName];
|
|
2096
|
+
if (!varEquivs)
|
|
2097
|
+
return null;
|
|
2098
|
+
// First check if any equivalency directly points to a signature path
|
|
2099
|
+
const signatureEquiv = varEquivs.find((eq) => eq.schemaPath.startsWith('signature['));
|
|
2100
|
+
if (signatureEquiv) {
|
|
2101
|
+
return signatureEquiv;
|
|
2102
|
+
}
|
|
2103
|
+
// Otherwise, follow the chain to other scopes
|
|
2104
|
+
for (const equiv of varEquivs) {
|
|
2105
|
+
// If the equivalency points to the same variable in a different scope,
|
|
2106
|
+
// follow the chain
|
|
2107
|
+
if (equiv.schemaPath === varName &&
|
|
2108
|
+
equiv.scopeNodeName !== currentScopeName) {
|
|
2109
|
+
const result = resolveToSignature(varName, equiv.scopeNodeName, visited);
|
|
2110
|
+
if (result)
|
|
2111
|
+
return result;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
return null;
|
|
2115
|
+
};
|
|
2116
|
+
const signatureEquiv = resolveToSignature(spreadVar, pathInfo.scopeNodeName, new Set());
|
|
2117
|
+
if (signatureEquiv) {
|
|
2118
|
+
// Replace ONLY the [...var] part with the resolved signature path
|
|
2119
|
+
// This preserves any suffix like .sort(...).functionCallReturnValue[][0]
|
|
2120
|
+
const resolvedPath = pathInfo.schemaPath.replace(spreadPattern, signatureEquiv.schemaPath);
|
|
2121
|
+
// Add the resolved path as a source candidate
|
|
2122
|
+
if (!databaseEntry.sourceCandidates.some((sc) => sc.schemaPath === resolvedPath &&
|
|
2123
|
+
sc.scopeNodeName === pathInfo.scopeNodeName)) {
|
|
2124
|
+
databaseEntry.sourceCandidates.push({
|
|
2125
|
+
scopeNodeName: pathInfo.scopeNodeName,
|
|
2126
|
+
schemaPath: resolvedPath,
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
isValidSourceCandidate = true;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
if (isValidSourceCandidate &&
|
|
2134
|
+
!databaseEntry.sourceCandidates.some((sc) => sc.schemaPath === pathInfo.schemaPath &&
|
|
2135
|
+
sc.scopeNodeName === pathInfo.scopeNodeName)) {
|
|
1961
2136
|
databaseEntry.sourceCandidates.push(pathInfo);
|
|
1962
2137
|
}
|
|
1963
2138
|
}
|
|
@@ -2103,6 +2278,13 @@ export class ScopeDataStructure {
|
|
|
2103
2278
|
delete scopeNode.schema[key];
|
|
2104
2279
|
}
|
|
2105
2280
|
}
|
|
2281
|
+
// Ensure parameter-to-signature equivalencies are fully propagated.
|
|
2282
|
+
// When a parameter variable (e.g., `node`) is equivalenced to `signature[N]`,
|
|
2283
|
+
// all sub-paths of that variable should also appear under `signature[N]`.
|
|
2284
|
+
// This handles cases where the sub-path was added to the schema via a propagation
|
|
2285
|
+
// chain that already included the variable↔signature equivalency, causing the
|
|
2286
|
+
// cycle detection to prevent the reverse mapping.
|
|
2287
|
+
this.propagateParameterToSignaturePaths(scopeNode);
|
|
2106
2288
|
fillInSchemaGapsAndUnknowns(scopeNode, fillInUnknowns);
|
|
2107
2289
|
if (final) {
|
|
2108
2290
|
for (const manager of this.equivalencyManagers) {
|
|
@@ -2114,6 +2296,40 @@ export class ScopeDataStructure {
|
|
|
2114
2296
|
ensureSchemaConsistency(scopeNode.schema);
|
|
2115
2297
|
}
|
|
2116
2298
|
}
|
|
2299
|
+
/**
|
|
2300
|
+
* For each equivalency where a simple variable maps to signature[N],
|
|
2301
|
+
* ensure all sub-paths of that variable are reflected under signature[N].
|
|
2302
|
+
*/
|
|
2303
|
+
propagateParameterToSignaturePaths(scopeNode) {
|
|
2304
|
+
// Find variable → signature[N] equivalencies
|
|
2305
|
+
for (const [varName, equivalencies] of Object.entries(scopeNode.equivalencies)) {
|
|
2306
|
+
// Only process simple variable names (no dots, brackets, or parens)
|
|
2307
|
+
if (varName.includes('.') ||
|
|
2308
|
+
varName.includes('[') ||
|
|
2309
|
+
varName.includes('(')) {
|
|
2310
|
+
continue;
|
|
2311
|
+
}
|
|
2312
|
+
for (const equiv of equivalencies) {
|
|
2313
|
+
if (equiv.scopeNodeName === scopeNode.name &&
|
|
2314
|
+
equiv.schemaPath.startsWith('signature[')) {
|
|
2315
|
+
const signaturePath = equiv.schemaPath;
|
|
2316
|
+
const varPrefix = varName + '.';
|
|
2317
|
+
const varBracketPrefix = varName + '[';
|
|
2318
|
+
// Find all schema keys starting with the variable
|
|
2319
|
+
for (const key in scopeNode.schema) {
|
|
2320
|
+
if (key.startsWith(varPrefix) || key.startsWith(varBracketPrefix)) {
|
|
2321
|
+
const suffix = key.slice(varName.length);
|
|
2322
|
+
const sigKey = signaturePath + suffix;
|
|
2323
|
+
// Only add if the signature path doesn't already exist
|
|
2324
|
+
if (!scopeNode.schema[sigKey]) {
|
|
2325
|
+
scopeNode.schema[sigKey] = scopeNode.schema[key];
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2117
2333
|
filterAndConvertSchema({ filterPath, newPath, schema, }) {
|
|
2118
2334
|
const filterPathParts = this.splitPath(filterPath);
|
|
2119
2335
|
return Object.keys(schema).reduce((acc, key) => {
|
|
@@ -2173,6 +2389,10 @@ export class ScopeDataStructure {
|
|
|
2173
2389
|
path,
|
|
2174
2390
|
...this.splitPath(key).slice(equivalentValueSchemaPathParts.length),
|
|
2175
2391
|
]);
|
|
2392
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
2393
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
2394
|
+
if (this.hasExcessivePatternRepetition(newKey))
|
|
2395
|
+
continue;
|
|
2176
2396
|
resolvedSchema[newKey] = value;
|
|
2177
2397
|
}
|
|
2178
2398
|
}
|
|
@@ -2194,6 +2414,9 @@ export class ScopeDataStructure {
|
|
|
2194
2414
|
if (!subSchema)
|
|
2195
2415
|
continue;
|
|
2196
2416
|
for (const resolvedKey in subSchema) {
|
|
2417
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
2418
|
+
if (this.hasExcessivePatternRepetition(resolvedKey))
|
|
2419
|
+
continue;
|
|
2197
2420
|
if (!resolvedSchema[resolvedKey] ||
|
|
2198
2421
|
subSchema[resolvedKey] === 'unknown') {
|
|
2199
2422
|
resolvedSchema[resolvedKey] = subSchema[resolvedKey];
|
|
@@ -2367,15 +2590,131 @@ export class ScopeDataStructure {
|
|
|
2367
2590
|
if (!scopeNode) {
|
|
2368
2591
|
return {};
|
|
2369
2592
|
}
|
|
2370
|
-
|
|
2593
|
+
// Collect all descendant scope names (including the scope itself)
|
|
2594
|
+
// This ensures we include external calls from nested scopes like cyScope2
|
|
2595
|
+
const getAllDescendantScopeNames = (node) => {
|
|
2596
|
+
const names = new Set([node.name]);
|
|
2597
|
+
for (const child of node.children) {
|
|
2598
|
+
for (const name of getAllDescendantScopeNames(child)) {
|
|
2599
|
+
names.add(name);
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
return names;
|
|
2603
|
+
};
|
|
2604
|
+
const treeNode = this.scopeTreeManager.findNode(scopeNode.name);
|
|
2605
|
+
const descendantScopeNames = treeNode
|
|
2606
|
+
? getAllDescendantScopeNames(treeNode)
|
|
2607
|
+
: new Set([scopeNode.name]);
|
|
2608
|
+
// Get all external function calls made from this scope or any descendant scope
|
|
2609
|
+
// This allows us to include prop equivalencies from JSX components
|
|
2610
|
+
// that were rendered in nested scopes (e.g., FileTableRow called from cyScope2)
|
|
2611
|
+
const externalCallsFromScope = this.externalFunctionCalls.filter((efc) => descendantScopeNames.has(efc.callScope));
|
|
2612
|
+
const externalCallNames = new Set(externalCallsFromScope.map((efc) => efc.name));
|
|
2613
|
+
// Helper to check if a usage belongs to this scope (directly, via descendant, or via external call)
|
|
2614
|
+
const usageMatchesScope = (usage) => descendantScopeNames.has(usage.scopeNodeName) ||
|
|
2615
|
+
externalCallNames.has(usage.scopeNodeName);
|
|
2616
|
+
const entries = this.equivalencyDatabase.filter((entry) => entry.usages.some(usageMatchesScope));
|
|
2617
|
+
// Helper to resolve a source candidate through equivalency chains to find signature paths
|
|
2618
|
+
const resolveToSignature = (source, visited) => {
|
|
2619
|
+
const visitKey = `${source.scopeNodeName}::${source.schemaPath}`;
|
|
2620
|
+
if (visited.has(visitKey))
|
|
2621
|
+
return [];
|
|
2622
|
+
visited.add(visitKey);
|
|
2623
|
+
// If already a signature path, return as-is
|
|
2624
|
+
if (source.schemaPath.startsWith('signature[')) {
|
|
2625
|
+
return [source];
|
|
2626
|
+
}
|
|
2627
|
+
const currentScope = this.scopeNodes[source.scopeNodeName];
|
|
2628
|
+
if (!currentScope?.equivalencies)
|
|
2629
|
+
return [source];
|
|
2630
|
+
// Check for direct equivalencies FIRST (full path match)
|
|
2631
|
+
// This ensures paths like "useMemo(...).functionCallReturnValue" follow to "cyScope1::returnValue"
|
|
2632
|
+
// before prefix matching tries "useMemo(...)" which goes to the useMemo scope
|
|
2633
|
+
const directEquivs = currentScope.equivalencies[source.schemaPath];
|
|
2634
|
+
if (directEquivs?.length > 0) {
|
|
2635
|
+
const results = [];
|
|
2636
|
+
for (const equiv of directEquivs) {
|
|
2637
|
+
const resolved = resolveToSignature({
|
|
2638
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
2639
|
+
schemaPath: equiv.schemaPath,
|
|
2640
|
+
}, visited);
|
|
2641
|
+
results.push(...resolved);
|
|
2642
|
+
}
|
|
2643
|
+
if (results.length > 0)
|
|
2644
|
+
return results;
|
|
2645
|
+
}
|
|
2646
|
+
// Handle spread patterns like [...items].sort().functionCallReturnValue
|
|
2647
|
+
// Extract the spread variable and resolve it through the equivalency chain
|
|
2648
|
+
const spreadMatch = source.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
2649
|
+
if (spreadMatch) {
|
|
2650
|
+
const spreadVar = spreadMatch[1];
|
|
2651
|
+
const spreadPattern = spreadMatch[0];
|
|
2652
|
+
const varEquivs = currentScope.equivalencies[spreadVar];
|
|
2653
|
+
if (varEquivs?.length > 0) {
|
|
2654
|
+
const results = [];
|
|
2655
|
+
for (const equiv of varEquivs) {
|
|
2656
|
+
// Follow the variable equivalency and then resolve from there
|
|
2657
|
+
const resolvedVar = resolveToSignature({
|
|
2658
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
2659
|
+
schemaPath: equiv.schemaPath,
|
|
2660
|
+
}, visited);
|
|
2661
|
+
// For each resolved variable path, create the full path with array element suffix
|
|
2662
|
+
for (const rv of resolvedVar) {
|
|
2663
|
+
if (rv.schemaPath.startsWith('signature[')) {
|
|
2664
|
+
// Get the suffix after the spread pattern
|
|
2665
|
+
let suffix = source.schemaPath.slice(spreadPattern.length);
|
|
2666
|
+
// Clean the suffix: strip array method chains like .sort(...).functionCallReturnValue[]
|
|
2667
|
+
// These don't change the data identity, just transform it.
|
|
2668
|
+
// Keep only the final element access parts like [0], [1], etc.
|
|
2669
|
+
// Pattern: strip everything from a method call up through functionCallReturnValue[]
|
|
2670
|
+
suffix = suffix.replace(/\.\w+\([^)]*\)\.functionCallReturnValue\[\]/g, '');
|
|
2671
|
+
// Also handle simpler case without nested parens
|
|
2672
|
+
suffix = suffix.replace(/\.sort\(\w*\(\)\)\.functionCallReturnValue\[\]/g, '');
|
|
2673
|
+
// Add [] to indicate array element access from the spread
|
|
2674
|
+
const resolvedPath = rv.schemaPath + '[]' + suffix;
|
|
2675
|
+
results.push({
|
|
2676
|
+
scopeNodeName: rv.scopeNodeName,
|
|
2677
|
+
schemaPath: resolvedPath,
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
if (results.length > 0)
|
|
2683
|
+
return results;
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
// Try to find prefix equivalencies that can resolve this path
|
|
2687
|
+
// For path like "cyScope3().signature[0][0]", check "cyScope3().signature[0]", etc.
|
|
2688
|
+
const pathParts = this.splitPath(source.schemaPath);
|
|
2689
|
+
for (let i = pathParts.length - 1; i > 0; i--) {
|
|
2690
|
+
const prefix = this.joinPathParts(pathParts.slice(0, i));
|
|
2691
|
+
const suffix = this.joinPathParts(pathParts.slice(i));
|
|
2692
|
+
const prefixEquivs = currentScope.equivalencies[prefix];
|
|
2693
|
+
if (prefixEquivs?.length > 0) {
|
|
2694
|
+
const results = [];
|
|
2695
|
+
for (const equiv of prefixEquivs) {
|
|
2696
|
+
const newPath = this.joinPathParts([equiv.schemaPath, suffix]);
|
|
2697
|
+
const resolved = resolveToSignature({ scopeNodeName: equiv.scopeNodeName, schemaPath: newPath }, visited);
|
|
2698
|
+
results.push(...resolved);
|
|
2699
|
+
}
|
|
2700
|
+
if (results.length > 0)
|
|
2701
|
+
return results;
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
return [source];
|
|
2705
|
+
};
|
|
2371
2706
|
return entries.reduce((acc, entry) => {
|
|
2372
2707
|
var _a;
|
|
2373
2708
|
if (entry.sourceCandidates.length === 0)
|
|
2374
2709
|
return acc;
|
|
2375
|
-
const usages = entry.usages.filter(
|
|
2710
|
+
const usages = entry.usages.filter(usageMatchesScope);
|
|
2376
2711
|
for (const usage of usages) {
|
|
2377
2712
|
acc[_a = usage.schemaPath] || (acc[_a] = []);
|
|
2378
|
-
|
|
2713
|
+
// Resolve each source candidate through the equivalency chain
|
|
2714
|
+
for (const source of entry.sourceCandidates) {
|
|
2715
|
+
const resolvedSources = resolveToSignature(source, new Set());
|
|
2716
|
+
acc[usage.schemaPath].push(...resolvedSources);
|
|
2717
|
+
}
|
|
2379
2718
|
}
|
|
2380
2719
|
return acc;
|
|
2381
2720
|
}, {});
|
|
@@ -2443,6 +2782,49 @@ export class ScopeDataStructure {
|
|
|
2443
2782
|
}
|
|
2444
2783
|
}
|
|
2445
2784
|
}
|
|
2785
|
+
// Enrich schema with deeply nested paths from internal function call scopes.
|
|
2786
|
+
// When a function call like traverse(tree) exists, and traverse's scope has
|
|
2787
|
+
// signature[0].children[path][entityName] (from propagateParameterToSignaturePaths),
|
|
2788
|
+
// we need to map those paths back to the argument variable (tree) in this scope.
|
|
2789
|
+
// This handles cases where cycle detection prevented the equivalency chain from
|
|
2790
|
+
// propagating deep paths during Phase 2 batch queue processing.
|
|
2791
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
2792
|
+
// Look for keys matching function call pattern: funcName(...).signature[N]
|
|
2793
|
+
const funcCallMatch = equivalenceKey.match(/^([^(]+)\(.*?\)\.(signature\[\d+\])$/);
|
|
2794
|
+
if (!funcCallMatch)
|
|
2795
|
+
continue;
|
|
2796
|
+
const calledFunctionName = funcCallMatch[1];
|
|
2797
|
+
const signatureParam = funcCallMatch[2]; // e.g., "signature[0]"
|
|
2798
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
2799
|
+
if (equivalenceValue.scopeNodeName !== scopeName)
|
|
2800
|
+
continue;
|
|
2801
|
+
const targetVariable = equivalenceValue.schemaPath;
|
|
2802
|
+
// Get the called function's schema (includes propagated parameter paths)
|
|
2803
|
+
const childSchema = this.getSchema({
|
|
2804
|
+
scopeName: calledFunctionName,
|
|
2805
|
+
});
|
|
2806
|
+
if (!childSchema)
|
|
2807
|
+
continue;
|
|
2808
|
+
// Map child function's signature paths to parent variable paths
|
|
2809
|
+
const sigPrefix = signatureParam + '.';
|
|
2810
|
+
const sigBracketPrefix = signatureParam + '[';
|
|
2811
|
+
for (const childKey in childSchema) {
|
|
2812
|
+
let suffix = null;
|
|
2813
|
+
if (childKey.startsWith(sigPrefix)) {
|
|
2814
|
+
suffix = childKey.slice(signatureParam.length);
|
|
2815
|
+
}
|
|
2816
|
+
else if (childKey.startsWith(sigBracketPrefix)) {
|
|
2817
|
+
suffix = childKey.slice(signatureParam.length);
|
|
2818
|
+
}
|
|
2819
|
+
if (suffix !== null) {
|
|
2820
|
+
const parentKey = targetVariable + suffix;
|
|
2821
|
+
if (!schema[parentKey]) {
|
|
2822
|
+
schema[parentKey] = childSchema[childKey];
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2446
2828
|
// Propagate nested paths from variables to their signature equivalents
|
|
2447
2829
|
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
2448
2830
|
// signature[0].workouts[].title
|
|
@@ -2664,13 +3046,35 @@ export class ScopeDataStructure {
|
|
|
2664
3046
|
getEquivalentSignatureVariables() {
|
|
2665
3047
|
const scopeNode = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
2666
3048
|
const equivalentSignatureVariables = {};
|
|
3049
|
+
// Helper to add equivalencies - accumulates into array if multiple values for same key
|
|
3050
|
+
// This is critical for OR expressions like `x = a || b` where x should map to both a and b
|
|
3051
|
+
const addEquivalency = (key, value) => {
|
|
3052
|
+
const existing = equivalentSignatureVariables[key];
|
|
3053
|
+
if (existing === undefined) {
|
|
3054
|
+
// First value - store as string
|
|
3055
|
+
equivalentSignatureVariables[key] = value;
|
|
3056
|
+
}
|
|
3057
|
+
else if (typeof existing === 'string') {
|
|
3058
|
+
if (existing !== value) {
|
|
3059
|
+
// Second different value - convert to array
|
|
3060
|
+
equivalentSignatureVariables[key] = [existing, value];
|
|
3061
|
+
}
|
|
3062
|
+
// Same value - no change needed
|
|
3063
|
+
}
|
|
3064
|
+
else {
|
|
3065
|
+
// Already an array - add if not already present
|
|
3066
|
+
if (!existing.includes(value)) {
|
|
3067
|
+
existing.push(value);
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
};
|
|
2667
3071
|
for (const [path, equivalentValues] of Object.entries(scopeNode.equivalencies)) {
|
|
2668
3072
|
for (const equivalentValue of equivalentValues) {
|
|
2669
3073
|
// Case 1: Props/signature equivalencies (existing behavior)
|
|
2670
3074
|
// Maps local variable names to their signature paths
|
|
2671
3075
|
// e.g., "propValue" -> "signature[0].prop"
|
|
2672
3076
|
if (path.startsWith('signature[')) {
|
|
2673
|
-
|
|
3077
|
+
addEquivalency(equivalentValue.schemaPath, path);
|
|
2674
3078
|
}
|
|
2675
3079
|
// Case 2: Hook variable equivalencies (new behavior)
|
|
2676
3080
|
// The equivalencies are stored as: path = variable name, schemaPath = data source
|
|
@@ -2698,7 +3102,7 @@ export class ScopeDataStructure {
|
|
|
2698
3102
|
hookCallPath = dbEntry.sourceCandidates[0].schemaPath;
|
|
2699
3103
|
}
|
|
2700
3104
|
}
|
|
2701
|
-
|
|
3105
|
+
addEquivalency(path, hookCallPath);
|
|
2702
3106
|
}
|
|
2703
3107
|
}
|
|
2704
3108
|
// Case 3: Destructured variables from local variables
|
|
@@ -2710,10 +3114,8 @@ export class ScopeDataStructure {
|
|
|
2710
3114
|
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
2711
3115
|
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
2712
3116
|
) {
|
|
2713
|
-
//
|
|
2714
|
-
|
|
2715
|
-
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
2716
|
-
}
|
|
3117
|
+
// Add equivalency (will accumulate if multiple values for OR expressions)
|
|
3118
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
2717
3119
|
}
|
|
2718
3120
|
// Case 4: Child component prop mappings (Fix 22)
|
|
2719
3121
|
// When parent renders <ChildComponent prop={value} />, we get equivalencies like:
|
|
@@ -2724,7 +3126,7 @@ export class ScopeDataStructure {
|
|
|
2724
3126
|
if (path.includes('().signature[') &&
|
|
2725
3127
|
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable, not a function call
|
|
2726
3128
|
) {
|
|
2727
|
-
|
|
3129
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
2728
3130
|
}
|
|
2729
3131
|
// Case 5: Destructured function parameters (Fix 25)
|
|
2730
3132
|
// When a function has destructured props: function Comp({ propA, propB }: Props)
|
|
@@ -2737,7 +3139,7 @@ export class ScopeDataStructure {
|
|
|
2737
3139
|
if (!path.includes('.') && // path is a simple identifier (destructured prop name)
|
|
2738
3140
|
equivalentValue.schemaPath.startsWith('signature[') // schemaPath IS a signature path
|
|
2739
3141
|
) {
|
|
2740
|
-
|
|
3142
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
2741
3143
|
}
|
|
2742
3144
|
// Case 7: Method calls on variables that result in .functionCallReturnValue (Fix 33)
|
|
2743
3145
|
// When we have patterns like:
|
|
@@ -2749,8 +3151,7 @@ export class ScopeDataStructure {
|
|
|
2749
3151
|
// segments -> useParams().functionCallReturnValue['*'].split('/').functionCallReturnValue
|
|
2750
3152
|
if (!path.includes('.') && // path is a simple identifier
|
|
2751
3153
|
equivalentValue.schemaPath.endsWith('.functionCallReturnValue') && // ends with function return
|
|
2752
|
-
equivalentValue.schemaPath.includes('.')
|
|
2753
|
-
!(path in equivalentSignatureVariables) // not already captured
|
|
3154
|
+
equivalentValue.schemaPath.includes('.') // has property access (method call)
|
|
2754
3155
|
) {
|
|
2755
3156
|
// Check if this looks like a method call on a variable (not a hook call)
|
|
2756
3157
|
// Hook calls look like: hookName() or hookName<T>()
|
|
@@ -2761,7 +3162,7 @@ export class ScopeDataStructure {
|
|
|
2761
3162
|
const parenPos = hookCallPath.indexOf('(');
|
|
2762
3163
|
if (dotBeforeParen !== -1 && dotBeforeParen < parenPos) {
|
|
2763
3164
|
// This is a method call like "splat.split('/')", not a hook call
|
|
2764
|
-
|
|
3165
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
2765
3166
|
}
|
|
2766
3167
|
}
|
|
2767
3168
|
}
|
|
@@ -2788,8 +3189,9 @@ export class ScopeDataStructure {
|
|
|
2788
3189
|
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable
|
|
2789
3190
|
) {
|
|
2790
3191
|
// Only add if not already present from the root scope
|
|
3192
|
+
// Root scope values take precedence over child scope values
|
|
2791
3193
|
if (!(path in equivalentSignatureVariables)) {
|
|
2792
|
-
|
|
3194
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
2793
3195
|
}
|
|
2794
3196
|
}
|
|
2795
3197
|
}
|
|
@@ -2799,9 +3201,72 @@ export class ScopeDataStructure {
|
|
|
2799
3201
|
// E.g., analysis → currentEntityAnalysis → useLoaderData().functionCallReturnValue.currentEntityAnalysis
|
|
2800
3202
|
// We need multiple passes because resolutions can depend on each other
|
|
2801
3203
|
const maxIterations = 5; // Prevent infinite loops
|
|
3204
|
+
// Helper function to resolve a single source path using equivalencies
|
|
3205
|
+
const resolveSourcePath = (sourcePath, equivMap) => {
|
|
3206
|
+
// Extract base variable from the path
|
|
3207
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
3208
|
+
const bracketIndex = sourcePath.indexOf('[');
|
|
3209
|
+
let baseVar;
|
|
3210
|
+
let rest;
|
|
3211
|
+
if (dotIndex === -1 && bracketIndex === -1) {
|
|
3212
|
+
baseVar = sourcePath;
|
|
3213
|
+
rest = '';
|
|
3214
|
+
}
|
|
3215
|
+
else if (dotIndex === -1) {
|
|
3216
|
+
baseVar = sourcePath.slice(0, bracketIndex);
|
|
3217
|
+
rest = sourcePath.slice(bracketIndex);
|
|
3218
|
+
}
|
|
3219
|
+
else if (bracketIndex === -1) {
|
|
3220
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
3221
|
+
rest = sourcePath.slice(dotIndex);
|
|
3222
|
+
}
|
|
3223
|
+
else {
|
|
3224
|
+
const firstIndex = Math.min(dotIndex, bracketIndex);
|
|
3225
|
+
baseVar = sourcePath.slice(0, firstIndex);
|
|
3226
|
+
rest = sourcePath.slice(firstIndex);
|
|
3227
|
+
}
|
|
3228
|
+
// Look up the base variable in equivalencies
|
|
3229
|
+
if (baseVar in equivMap && equivMap[baseVar] !== sourcePath) {
|
|
3230
|
+
const baseResolved = equivMap[baseVar];
|
|
3231
|
+
// Skip if baseResolved is an array (handle later)
|
|
3232
|
+
if (Array.isArray(baseResolved))
|
|
3233
|
+
return null;
|
|
3234
|
+
// If it resolves to a signature path, build the full resolved path
|
|
3235
|
+
if (baseResolved.startsWith('signature[') ||
|
|
3236
|
+
baseResolved.includes('()')) {
|
|
3237
|
+
if (baseResolved.endsWith('()')) {
|
|
3238
|
+
return baseResolved + '.functionCallReturnValue' + rest;
|
|
3239
|
+
}
|
|
3240
|
+
return baseResolved + rest;
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
return null;
|
|
3244
|
+
};
|
|
2802
3245
|
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
2803
3246
|
let changed = false;
|
|
2804
|
-
for (const [varName,
|
|
3247
|
+
for (const [varName, sourcePathOrArray] of Object.entries(equivalentSignatureVariables)) {
|
|
3248
|
+
// Handle arrays (OR expressions) by resolving each element
|
|
3249
|
+
if (Array.isArray(sourcePathOrArray)) {
|
|
3250
|
+
const resolvedArray = [];
|
|
3251
|
+
let arrayChanged = false;
|
|
3252
|
+
for (const sourcePath of sourcePathOrArray) {
|
|
3253
|
+
// Try to resolve this path using transitive resolution
|
|
3254
|
+
const resolved = resolveSourcePath(sourcePath, equivalentSignatureVariables);
|
|
3255
|
+
if (resolved && resolved !== sourcePath) {
|
|
3256
|
+
resolvedArray.push(resolved);
|
|
3257
|
+
arrayChanged = true;
|
|
3258
|
+
}
|
|
3259
|
+
else {
|
|
3260
|
+
resolvedArray.push(sourcePath);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
if (arrayChanged) {
|
|
3264
|
+
equivalentSignatureVariables[varName] = resolvedArray;
|
|
3265
|
+
changed = true;
|
|
3266
|
+
}
|
|
3267
|
+
continue;
|
|
3268
|
+
}
|
|
3269
|
+
const sourcePath = sourcePathOrArray;
|
|
2805
3270
|
// Skip if already fully resolved (contains function call syntax)
|
|
2806
3271
|
// BUT first check for computed value patterns that need resolution (Fix 28)
|
|
2807
3272
|
// AND method call patterns that need base variable resolution (Fix 33)
|
|
@@ -2854,6 +3319,9 @@ export class ScopeDataStructure {
|
|
|
2854
3319
|
if (baseVar in equivalentSignatureVariables &&
|
|
2855
3320
|
baseVar !== varName) {
|
|
2856
3321
|
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
3322
|
+
// Skip if baseResolved is an array (OR expression)
|
|
3323
|
+
if (Array.isArray(baseResolved))
|
|
3324
|
+
continue;
|
|
2857
3325
|
// Only resolve if the base resolved to something useful (contains () or .)
|
|
2858
3326
|
if (baseResolved.includes('()') || baseResolved.includes('.')) {
|
|
2859
3327
|
const newPath = baseResolved + rest;
|
|
@@ -2909,7 +3377,13 @@ export class ScopeDataStructure {
|
|
|
2909
3377
|
rest = '';
|
|
2910
3378
|
}
|
|
2911
3379
|
if (baseVar in equivalentSignatureVariables && baseVar !== varName) {
|
|
2912
|
-
|
|
3380
|
+
// Handle array case (OR expressions) - use first element
|
|
3381
|
+
const rawBaseResolved = equivalentSignatureVariables[baseVar];
|
|
3382
|
+
const baseResolved = Array.isArray(rawBaseResolved)
|
|
3383
|
+
? rawBaseResolved[0]
|
|
3384
|
+
: rawBaseResolved;
|
|
3385
|
+
if (!baseResolved)
|
|
3386
|
+
continue;
|
|
2913
3387
|
// If the base resolves to a hook call, add .functionCallReturnValue
|
|
2914
3388
|
if (baseResolved.endsWith('()')) {
|
|
2915
3389
|
const newPath = baseResolved + '.functionCallReturnValue' + rest;
|
|
@@ -3467,11 +3941,21 @@ export class ScopeDataStructure {
|
|
|
3467
3941
|
perVariableSchemas = undefined;
|
|
3468
3942
|
}
|
|
3469
3943
|
}
|
|
3944
|
+
// Enrich the schema with inferred types by applying fillInSchemaGapsAndUnknowns.
|
|
3945
|
+
// This ensures the serialized schema has the same type inference as getReturnValue().
|
|
3946
|
+
// Without this, evidence like "entities[].analyses: array" becomes "unknown".
|
|
3947
|
+
const enrichedSchema = { ...efc.schema };
|
|
3948
|
+
const tempScopeNode = {
|
|
3949
|
+
name: efc.name,
|
|
3950
|
+
schema: enrichedSchema,
|
|
3951
|
+
equivalencies: efc.equivalencies ?? {},
|
|
3952
|
+
};
|
|
3953
|
+
fillInSchemaGapsAndUnknowns(tempScopeNode, true);
|
|
3470
3954
|
return {
|
|
3471
3955
|
name: efc.name,
|
|
3472
3956
|
callSignature: efc.callSignature,
|
|
3473
3957
|
callScope: efc.callScope,
|
|
3474
|
-
schema:
|
|
3958
|
+
schema: enrichedSchema,
|
|
3475
3959
|
equivalencies: efc.equivalencies
|
|
3476
3960
|
? Object.entries(efc.equivalencies).reduce((acc, [key, vars]) => {
|
|
3477
3961
|
// Clean cyScope from the key as well as variable properties
|