@codeyam/codeyam-cli 0.1.0-staging.c90f8c9 → 0.1.0-staging.c9dc00c
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 +837 -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/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +14 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- 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 +12 -0
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -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 +11 -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/kysely/tables/labsRequestsTable.d.ts +23 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/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.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.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/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/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 +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/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 +7 -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 +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/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 +60 -12
- package/analyzer-template/project/writeSimpleRoot.ts +21 -11
- package/analyzer-template/scripts/comboWorkerLoop.cjs +98 -50
- package/background/src/lib/local/createLocalAnalyzer.js +1 -1
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- 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 +60 -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 +4 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +2 -0
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +2 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -1
- package/codeyam-cli/src/commands/debug.js +9 -5
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +14 -4
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +42 -184
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +264 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +2 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- package/codeyam-cli/src/commands/test-startup.js +2 -0
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +2 -0
- package/codeyam-cli/src/commands/verify.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -86
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +4 -0
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +71 -46
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +48 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +4 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +378 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +115 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +6 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +83 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +20 -43
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +15 -3
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +31 -0
- package/codeyam-cli/src/webserver/backgroundServer.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-CN61MOMa.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-survey-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.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-EVn6Z9pz.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-CmBYA0PH.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-aa4ff97b.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-BSlqS1QA.js +81 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-DVAbJY8B.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-BK-cnzp-.js +1 -0
- 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-Cz2RkDCa.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CUVsWicu.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 +195 -496
- package/codeyam-cli/templates/codeyam:memory.md +403 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +2 -2
- package/codeyam-cli/templates/codeyam:setup.md +12 -0
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
- package/codeyam-cli/templates/rules-instructions.md +136 -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 +654 -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/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +11 -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/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- 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 +9 -0
- package/packages/database/src/lib/loadCommits.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/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -76
- 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/client/assets/settings-CS5f3WzT.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-uNNbimct.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-B08qC4Y7.js +0 -257
- package/codeyam-cli/templates/codeyam:power-rules.md +0 -449
- /package/codeyam-cli/src/webserver/build/client/assets/{api.rules-l0sNRNKZ.js → api.agent-transcripts-l0sNRNKZ.js} +0 -0
|
@@ -82,6 +82,8 @@
|
|
|
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';
|
|
85
87
|
|
|
86
88
|
/**
|
|
87
89
|
* Patterns that indicate recursive type structures in schema paths.
|
|
@@ -150,7 +152,7 @@ export interface ScopeInfo {
|
|
|
150
152
|
[childComponentName: string]: Array<{
|
|
151
153
|
path: string;
|
|
152
154
|
conditionType: 'truthiness' | 'comparison';
|
|
153
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
155
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
154
156
|
isNegated?: boolean;
|
|
155
157
|
}>;
|
|
156
158
|
};
|
|
@@ -332,6 +334,19 @@ export function resetScopeDataStructureMetrics() {
|
|
|
332
334
|
followEquivalenciesEarlyExitPhase1Count = 0;
|
|
333
335
|
followEquivalenciesWithWorkCount = 0;
|
|
334
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
|
+
}
|
|
335
350
|
}
|
|
336
351
|
|
|
337
352
|
// Performance: Pre-computed Sets for equivalency reason filtering (O(1) vs O(n))
|
|
@@ -409,7 +424,7 @@ export class ScopeDataStructure {
|
|
|
409
424
|
path: string;
|
|
410
425
|
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
411
426
|
comparedValues?: string[];
|
|
412
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
427
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
413
428
|
}>
|
|
414
429
|
> = {};
|
|
415
430
|
|
|
@@ -784,6 +799,11 @@ export class ScopeDataStructure {
|
|
|
784
799
|
return;
|
|
785
800
|
}
|
|
786
801
|
|
|
802
|
+
// PERF: Early exit for paths with repeated function-call signature patterns
|
|
803
|
+
if (this.hasExcessivePatternRepetition(path)) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
|
|
787
807
|
// Update chain metadata for database tracking
|
|
788
808
|
if (equivalencyValueChain.length > 0) {
|
|
789
809
|
equivalencyValueChain[equivalencyValueChain.length - 1].addToSchemaId =
|
|
@@ -1471,6 +1491,15 @@ export class ScopeDataStructure {
|
|
|
1471
1491
|
|
|
1472
1492
|
const bestValue = selectBestValue(value1, value2);
|
|
1473
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
|
+
|
|
1474
1503
|
scopeNode.schema[schemaPath] = bestValue;
|
|
1475
1504
|
equivalentScopeNode.schema[equivalentSchemaPath] = bestValue;
|
|
1476
1505
|
} else if (
|
|
@@ -1484,6 +1513,11 @@ export class ScopeDataStructure {
|
|
|
1484
1513
|
...remainingSchemaPathParts,
|
|
1485
1514
|
]);
|
|
1486
1515
|
|
|
1516
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
1517
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
1518
|
+
continue;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1487
1521
|
equivalentScopeNode.schema[newEquivalentPath] =
|
|
1488
1522
|
scopeNode.schema[schemaPath];
|
|
1489
1523
|
}
|
|
@@ -1603,6 +1637,23 @@ export class ScopeDataStructure {
|
|
|
1603
1637
|
}
|
|
1604
1638
|
}
|
|
1605
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
|
+
|
|
1606
1657
|
// For longer paths, detect any repeated multi-part segments we haven't explicitly listed
|
|
1607
1658
|
const pathParts = this.splitPath(path);
|
|
1608
1659
|
if (pathParts.length <= 6) {
|
|
@@ -1635,17 +1686,26 @@ export class ScopeDataStructure {
|
|
|
1635
1686
|
private setInstantiatedVariables(scopeNode: ScopeNode) {
|
|
1636
1687
|
let instantiatedVariables = scopeNode.analysis?.instantiatedVariables ?? [];
|
|
1637
1688
|
|
|
1638
|
-
for (const [path,
|
|
1689
|
+
for (const [path, rawEquivalentPath] of Object.entries(
|
|
1639
1690
|
scopeNode.analysis.isolatedEquivalentVariables ?? {},
|
|
1640
1691
|
)) {
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
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
|
+
}
|
|
1644
1703
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1704
|
+
if (equivalentPath.startsWith('signature[')) {
|
|
1705
|
+
const equivalentPathParts = this.splitPath(equivalentPath);
|
|
1706
|
+
instantiatedVariables.push(equivalentPathParts[0]);
|
|
1707
|
+
instantiatedVariables.push(path);
|
|
1708
|
+
}
|
|
1649
1709
|
}
|
|
1650
1710
|
|
|
1651
1711
|
const duplicateInstantiated = instantiatedVariables.find(
|
|
@@ -1658,9 +1718,14 @@ export class ScopeDataStructure {
|
|
|
1658
1718
|
}
|
|
1659
1719
|
}
|
|
1660
1720
|
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
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
|
+
});
|
|
1664
1729
|
|
|
1665
1730
|
scopeNode.instantiatedVariables = instantiatedVariables;
|
|
1666
1731
|
|
|
@@ -1681,13 +1746,19 @@ export class ScopeDataStructure {
|
|
|
1681
1746
|
...parentScopeNode.instantiatedVariables.filter(
|
|
1682
1747
|
(v) => !v.startsWith('signature[') && !v.startsWith('returnValue'),
|
|
1683
1748
|
),
|
|
1684
|
-
].filter(
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
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
|
+
});
|
|
1689
1760
|
|
|
1690
|
-
scopeNode.parentInstantiatedVariables =
|
|
1761
|
+
scopeNode.parentInstantiatedVariables = dedupedParentInstantiatedVariables;
|
|
1691
1762
|
}
|
|
1692
1763
|
|
|
1693
1764
|
private trackFunctionCalls(scopeNode: ScopeNode) {
|
|
@@ -1703,172 +1774,198 @@ export class ScopeDataStructure {
|
|
|
1703
1774
|
const { isolatedStructure, isolatedEquivalentVariables } =
|
|
1704
1775
|
scopeNode.analysis;
|
|
1705
1776
|
|
|
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]));
|
|
1781
|
+
|
|
1706
1782
|
const allPaths = Array.from(
|
|
1707
1783
|
new Set([
|
|
1708
1784
|
...Object.keys(isolatedStructure || {}),
|
|
1709
1785
|
...Object.keys(isolatedEquivalentVariables || {}),
|
|
1710
|
-
...
|
|
1786
|
+
...flattenedEquivValues,
|
|
1711
1787
|
]),
|
|
1712
1788
|
);
|
|
1713
1789
|
|
|
1714
1790
|
for (let path in isolatedEquivalentVariables) {
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
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
|
+
);
|
|
1736
1825
|
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
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;
|
|
1744
1844
|
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
if (
|
|
1765
|
-
rootVariable &&
|
|
1766
|
-
!isSelfReferentialReassignment &&
|
|
1767
|
-
scopeNode.parentInstantiatedVariables?.includes(rootVariable)
|
|
1768
|
-
) {
|
|
1769
|
-
// Find the parent scope where this variable is defined
|
|
1770
|
-
for (const parentScopeName of scopeNode.tree || []) {
|
|
1771
|
-
const parentScope = this.scopeNodes[parentScopeName];
|
|
1772
|
-
if (parentScope?.instantiatedVariables?.includes(rootVariable)) {
|
|
1773
|
-
// Add the equivalency to the parent scope as well
|
|
1774
|
-
this.addEquivalency(
|
|
1775
|
-
path,
|
|
1776
|
-
equivalentValue,
|
|
1777
|
-
scopeNode.name, // The equivalent path's scope remains the child scope
|
|
1778
|
-
parentScope, // But store it in the parent scope's equivalencies
|
|
1779
|
-
'propagated parent-variable equivalency',
|
|
1780
|
-
);
|
|
1781
|
-
break;
|
|
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
|
+
}
|
|
1782
1864
|
}
|
|
1783
1865
|
}
|
|
1784
|
-
}
|
|
1785
1866
|
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
|
|
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 + '[',
|
|
1819
1900
|
);
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
this.isValidPath(newEquivalentValue)
|
|
1824
|
-
) {
|
|
1825
|
-
this.addEquivalency(
|
|
1826
|
-
newPath,
|
|
1827
|
-
newEquivalentValue,
|
|
1828
|
-
checkScope.name, // Use the scope where the sub-property was found
|
|
1829
|
-
scopeNode,
|
|
1830
|
-
'propagated sub-property equivalency',
|
|
1901
|
+
if (matchesDot || matchesBracket) {
|
|
1902
|
+
const subPropertyPath = subPath.substring(
|
|
1903
|
+
equivalentValue.length,
|
|
1831
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
|
+
}
|
|
1832
1927
|
}
|
|
1833
|
-
}
|
|
1834
1928
|
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
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
|
+
}
|
|
1848
1945
|
}
|
|
1849
1946
|
}
|
|
1850
1947
|
}
|
|
1851
|
-
}
|
|
1852
1948
|
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
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
|
+
);
|
|
1862
1958
|
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
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
|
+
}
|
|
1867
1963
|
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
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
|
+
}
|
|
1872
1969
|
}
|
|
1873
1970
|
}
|
|
1874
1971
|
}
|
|
@@ -2049,9 +2146,18 @@ export class ScopeDataStructure {
|
|
|
2049
2146
|
const checkScope = this.scopeNodes[scopeName];
|
|
2050
2147
|
if (!checkScope?.analysis?.isolatedEquivalentVariables) continue;
|
|
2051
2148
|
|
|
2052
|
-
const
|
|
2149
|
+
const rawFunctionRef =
|
|
2053
2150
|
checkScope.analysis.isolatedEquivalentVariables[functionName];
|
|
2054
|
-
|
|
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') {
|
|
2055
2161
|
callbackScopeName = functionRef.slice(0, -1);
|
|
2056
2162
|
break;
|
|
2057
2163
|
}
|
|
@@ -2079,19 +2185,24 @@ export class ScopeDataStructure {
|
|
|
2079
2185
|
|
|
2080
2186
|
const isolatedVars = callbackScope.analysis.isolatedEquivalentVariables;
|
|
2081
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
|
+
|
|
2082
2194
|
// First, check if returnValue is an alias to another variable (e.g., returnValue = intermediate)
|
|
2083
2195
|
// If so, we need to look for that variable's sub-properties too
|
|
2084
2196
|
const returnValueAlias =
|
|
2085
|
-
typeof
|
|
2086
|
-
|
|
2087
|
-
? isolatedVars.returnValue
|
|
2197
|
+
typeof firstReturnValue === 'string' && !firstReturnValue.includes('.')
|
|
2198
|
+
? firstReturnValue
|
|
2088
2199
|
: undefined;
|
|
2089
2200
|
|
|
2090
2201
|
// Pattern 3: Object.keys(X).reduce() - the reduce result has the same sub-properties as X
|
|
2091
2202
|
// When returnValue = "Object.keys(source).reduce(...).functionCallReturnValue", look for source.* sub-properties
|
|
2092
2203
|
let reduceSourceVar: string | undefined;
|
|
2093
|
-
if (typeof
|
|
2094
|
-
const reduceMatch =
|
|
2204
|
+
if (typeof firstReturnValue === 'string') {
|
|
2205
|
+
const reduceMatch = firstReturnValue.match(
|
|
2095
2206
|
/^Object\.keys\((\w+)\)\.reduce\(.*\)\.functionCallReturnValue$/,
|
|
2096
2207
|
);
|
|
2097
2208
|
if (reduceMatch) {
|
|
@@ -2099,7 +2210,14 @@ export class ScopeDataStructure {
|
|
|
2099
2210
|
}
|
|
2100
2211
|
}
|
|
2101
2212
|
|
|
2102
|
-
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
|
+
|
|
2103
2221
|
// Check for direct returnValue.* sub-properties
|
|
2104
2222
|
const isReturnValueSub =
|
|
2105
2223
|
subPath.startsWith('returnValue.') ||
|
|
@@ -2117,57 +2235,59 @@ export class ScopeDataStructure {
|
|
|
2117
2235
|
(subPath.startsWith(reduceSourceVar + '.') ||
|
|
2118
2236
|
subPath.startsWith(reduceSourceVar + '['));
|
|
2119
2237
|
|
|
2120
|
-
if (
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
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
|
+
);
|
|
2143
2262
|
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
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;
|
|
2152
2271
|
|
|
2153
|
-
|
|
2154
|
-
|
|
2272
|
+
if (!newEquivalentValue || !this.isValidPath(newEquivalentValue))
|
|
2273
|
+
continue;
|
|
2155
2274
|
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2275
|
+
this.addEquivalency(
|
|
2276
|
+
newPath,
|
|
2277
|
+
newEquivalentValue,
|
|
2278
|
+
equivalentScopeName,
|
|
2279
|
+
scopeNode,
|
|
2280
|
+
'propagated function call return sub-property equivalency',
|
|
2281
|
+
);
|
|
2163
2282
|
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2283
|
+
// Ensure the database entry has the usage path
|
|
2284
|
+
this.addUsageToEquivalencyDatabaseEntry(
|
|
2285
|
+
newPath,
|
|
2286
|
+
newEquivalentValue,
|
|
2287
|
+
equivalentScopeName,
|
|
2288
|
+
scopeNode.name,
|
|
2289
|
+
);
|
|
2290
|
+
}
|
|
2171
2291
|
}
|
|
2172
2292
|
}
|
|
2173
2293
|
|
|
@@ -2207,8 +2327,15 @@ export class ScopeDataStructure {
|
|
|
2207
2327
|
const parentScope = this.scopeNodes[parentScopeName];
|
|
2208
2328
|
if (!parentScope?.analysis?.isolatedEquivalentVariables) continue;
|
|
2209
2329
|
|
|
2210
|
-
const
|
|
2330
|
+
const rawRootEquiv =
|
|
2211
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');
|
|
2212
2339
|
if (typeof rootEquiv === 'string') {
|
|
2213
2340
|
return {
|
|
2214
2341
|
resolvedPath: cleanPath(rootEquiv + restOfPath, allPaths),
|
|
@@ -2483,6 +2610,7 @@ export class ScopeDataStructure {
|
|
|
2483
2610
|
relevantSubPathParts.every((part, i) => part === schemaPathParts[i]) &&
|
|
2484
2611
|
equivalentValue.scopeNodeName === scopeNode.name
|
|
2485
2612
|
) {
|
|
2613
|
+
// DEBUG
|
|
2486
2614
|
continue;
|
|
2487
2615
|
}
|
|
2488
2616
|
|
|
@@ -2669,6 +2797,8 @@ export class ScopeDataStructure {
|
|
|
2669
2797
|
usageEquivalency.scopeNodeName,
|
|
2670
2798
|
) as ScopeNode;
|
|
2671
2799
|
|
|
2800
|
+
if (!usageScopeNode) continue;
|
|
2801
|
+
|
|
2672
2802
|
// Guard against infinite recursion by tracking which paths we've already
|
|
2673
2803
|
// added from addComplexSourcePathVariables
|
|
2674
2804
|
if (
|
|
@@ -2748,6 +2878,8 @@ export class ScopeDataStructure {
|
|
|
2748
2878
|
usageEquivalency.scopeNodeName,
|
|
2749
2879
|
) as ScopeNode;
|
|
2750
2880
|
|
|
2881
|
+
if (!usageScopeNode) continue;
|
|
2882
|
+
|
|
2751
2883
|
// This is put in place to avoid propagating array functions like 'filter' through complex equivalencies
|
|
2752
2884
|
// but may cause problems if the funtion call is not on a known object (e.g. string or array)
|
|
2753
2885
|
if (
|
|
@@ -2874,10 +3006,105 @@ export class ScopeDataStructure {
|
|
|
2874
3006
|
this.intermediatesOrderIndex.set(pathId, databaseEntry);
|
|
2875
3007
|
|
|
2876
3008
|
if (intermediateIndex === 0) {
|
|
2877
|
-
|
|
3009
|
+
let isValidSourceCandidate =
|
|
2878
3010
|
pathInfo.schemaPath.startsWith('signature[') ||
|
|
2879
3011
|
pathInfo.schemaPath.includes('functionCallReturnValue');
|
|
2880
|
-
|
|
3012
|
+
|
|
3013
|
+
// Check if path STARTS with a spread pattern like [...var]
|
|
3014
|
+
// This handles cases like [...files][][0] or [...files].sort(...).functionCallReturnValue[][0]
|
|
3015
|
+
// where the spread source variable needs to be resolved to a signature path.
|
|
3016
|
+
// We do this REGARDLESS of isValidSourceCandidate because even paths containing
|
|
3017
|
+
// functionCallReturnValue may need spread resolution to trace back to the signature.
|
|
3018
|
+
const spreadMatch = pathInfo.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
3019
|
+
if (spreadMatch) {
|
|
3020
|
+
const spreadVar = spreadMatch[1];
|
|
3021
|
+
const spreadPattern = spreadMatch[0]; // The full [...var] match
|
|
3022
|
+
const scopeNode = this.scopeNodes[pathInfo.scopeNodeName];
|
|
3023
|
+
|
|
3024
|
+
if (scopeNode?.equivalencies) {
|
|
3025
|
+
// Follow the equivalency chain to find a signature path
|
|
3026
|
+
// e.g., files (cyScope1) → files (root) → signature[0].files
|
|
3027
|
+
const resolveToSignature = (
|
|
3028
|
+
varName: string,
|
|
3029
|
+
currentScopeName: string,
|
|
3030
|
+
visited: Set<string>,
|
|
3031
|
+
): { schemaPath: string; scopeNodeName: string } | null => {
|
|
3032
|
+
const visitKey = `${currentScopeName}::${varName}`;
|
|
3033
|
+
if (visited.has(visitKey)) return null;
|
|
3034
|
+
visited.add(visitKey);
|
|
3035
|
+
|
|
3036
|
+
const currentScope = this.scopeNodes[currentScopeName];
|
|
3037
|
+
if (!currentScope?.equivalencies) return null;
|
|
3038
|
+
|
|
3039
|
+
const varEquivs = currentScope.equivalencies[varName];
|
|
3040
|
+
if (!varEquivs) return null;
|
|
3041
|
+
|
|
3042
|
+
// First check if any equivalency directly points to a signature path
|
|
3043
|
+
const signatureEquiv = varEquivs.find((eq) =>
|
|
3044
|
+
eq.schemaPath.startsWith('signature['),
|
|
3045
|
+
);
|
|
3046
|
+
if (signatureEquiv) {
|
|
3047
|
+
return signatureEquiv;
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
// Otherwise, follow the chain to other scopes
|
|
3051
|
+
for (const equiv of varEquivs) {
|
|
3052
|
+
// If the equivalency points to the same variable in a different scope,
|
|
3053
|
+
// follow the chain
|
|
3054
|
+
if (
|
|
3055
|
+
equiv.schemaPath === varName &&
|
|
3056
|
+
equiv.scopeNodeName !== currentScopeName
|
|
3057
|
+
) {
|
|
3058
|
+
const result = resolveToSignature(
|
|
3059
|
+
varName,
|
|
3060
|
+
equiv.scopeNodeName,
|
|
3061
|
+
visited,
|
|
3062
|
+
);
|
|
3063
|
+
if (result) return result;
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
return null;
|
|
3068
|
+
};
|
|
3069
|
+
|
|
3070
|
+
const signatureEquiv = resolveToSignature(
|
|
3071
|
+
spreadVar,
|
|
3072
|
+
pathInfo.scopeNodeName,
|
|
3073
|
+
new Set(),
|
|
3074
|
+
);
|
|
3075
|
+
if (signatureEquiv) {
|
|
3076
|
+
// Replace ONLY the [...var] part with the resolved signature path
|
|
3077
|
+
// This preserves any suffix like .sort(...).functionCallReturnValue[][0]
|
|
3078
|
+
const resolvedPath = pathInfo.schemaPath.replace(
|
|
3079
|
+
spreadPattern,
|
|
3080
|
+
signatureEquiv.schemaPath,
|
|
3081
|
+
);
|
|
3082
|
+
// Add the resolved path as a source candidate
|
|
3083
|
+
if (
|
|
3084
|
+
!databaseEntry.sourceCandidates.some(
|
|
3085
|
+
(sc) =>
|
|
3086
|
+
sc.schemaPath === resolvedPath &&
|
|
3087
|
+
sc.scopeNodeName === pathInfo.scopeNodeName,
|
|
3088
|
+
)
|
|
3089
|
+
) {
|
|
3090
|
+
databaseEntry.sourceCandidates.push({
|
|
3091
|
+
scopeNodeName: pathInfo.scopeNodeName,
|
|
3092
|
+
schemaPath: resolvedPath,
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
isValidSourceCandidate = true;
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
if (
|
|
3101
|
+
isValidSourceCandidate &&
|
|
3102
|
+
!databaseEntry.sourceCandidates.some(
|
|
3103
|
+
(sc) =>
|
|
3104
|
+
sc.schemaPath === pathInfo.schemaPath &&
|
|
3105
|
+
sc.scopeNodeName === pathInfo.scopeNodeName,
|
|
3106
|
+
)
|
|
3107
|
+
) {
|
|
2881
3108
|
databaseEntry.sourceCandidates.push(pathInfo);
|
|
2882
3109
|
}
|
|
2883
3110
|
} else {
|
|
@@ -3105,6 +3332,14 @@ export class ScopeDataStructure {
|
|
|
3105
3332
|
}
|
|
3106
3333
|
}
|
|
3107
3334
|
|
|
3335
|
+
// Ensure parameter-to-signature equivalencies are fully propagated.
|
|
3336
|
+
// When a parameter variable (e.g., `node`) is equivalenced to `signature[N]`,
|
|
3337
|
+
// all sub-paths of that variable should also appear under `signature[N]`.
|
|
3338
|
+
// This handles cases where the sub-path was added to the schema via a propagation
|
|
3339
|
+
// chain that already included the variable↔signature equivalency, causing the
|
|
3340
|
+
// cycle detection to prevent the reverse mapping.
|
|
3341
|
+
this.propagateParameterToSignaturePaths(scopeNode);
|
|
3342
|
+
|
|
3108
3343
|
fillInSchemaGapsAndUnknowns(scopeNode, fillInUnknowns);
|
|
3109
3344
|
|
|
3110
3345
|
if (final) {
|
|
@@ -3119,6 +3354,50 @@ export class ScopeDataStructure {
|
|
|
3119
3354
|
}
|
|
3120
3355
|
}
|
|
3121
3356
|
|
|
3357
|
+
/**
|
|
3358
|
+
* For each equivalency where a simple variable maps to signature[N],
|
|
3359
|
+
* ensure all sub-paths of that variable are reflected under signature[N].
|
|
3360
|
+
*/
|
|
3361
|
+
private propagateParameterToSignaturePaths(scopeNode: ScopeNode) {
|
|
3362
|
+
// Find variable → signature[N] equivalencies
|
|
3363
|
+
for (const [varName, equivalencies] of Object.entries(
|
|
3364
|
+
scopeNode.equivalencies,
|
|
3365
|
+
)) {
|
|
3366
|
+
// Only process simple variable names (no dots, brackets, or parens)
|
|
3367
|
+
if (
|
|
3368
|
+
varName.includes('.') ||
|
|
3369
|
+
varName.includes('[') ||
|
|
3370
|
+
varName.includes('(')
|
|
3371
|
+
) {
|
|
3372
|
+
continue;
|
|
3373
|
+
}
|
|
3374
|
+
|
|
3375
|
+
for (const equiv of equivalencies) {
|
|
3376
|
+
if (
|
|
3377
|
+
equiv.scopeNodeName === scopeNode.name &&
|
|
3378
|
+
equiv.schemaPath.startsWith('signature[')
|
|
3379
|
+
) {
|
|
3380
|
+
const signaturePath = equiv.schemaPath;
|
|
3381
|
+
const varPrefix = varName + '.';
|
|
3382
|
+
const varBracketPrefix = varName + '[';
|
|
3383
|
+
|
|
3384
|
+
// Find all schema keys starting with the variable
|
|
3385
|
+
for (const key in scopeNode.schema) {
|
|
3386
|
+
if (key.startsWith(varPrefix) || key.startsWith(varBracketPrefix)) {
|
|
3387
|
+
const suffix = key.slice(varName.length);
|
|
3388
|
+
const sigKey = signaturePath + suffix;
|
|
3389
|
+
|
|
3390
|
+
// Only add if the signature path doesn't already exist
|
|
3391
|
+
if (!scopeNode.schema[sigKey]) {
|
|
3392
|
+
scopeNode.schema[sigKey] = scopeNode.schema[key];
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3122
3401
|
private filterAndConvertSchema({
|
|
3123
3402
|
filterPath,
|
|
3124
3403
|
newPath,
|
|
@@ -3205,6 +3484,9 @@ export class ScopeDataStructure {
|
|
|
3205
3484
|
equivalentValueSchemaPathParts.length,
|
|
3206
3485
|
),
|
|
3207
3486
|
]);
|
|
3487
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
3488
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
3489
|
+
if (this.hasExcessivePatternRepetition(newKey)) continue;
|
|
3208
3490
|
resolvedSchema[newKey] = value;
|
|
3209
3491
|
}
|
|
3210
3492
|
}
|
|
@@ -3227,6 +3509,8 @@ export class ScopeDataStructure {
|
|
|
3227
3509
|
if (!subSchema) continue;
|
|
3228
3510
|
|
|
3229
3511
|
for (const resolvedKey in subSchema) {
|
|
3512
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
3513
|
+
if (this.hasExcessivePatternRepetition(resolvedKey)) continue;
|
|
3230
3514
|
if (
|
|
3231
3515
|
!resolvedSchema[resolvedKey] ||
|
|
3232
3516
|
subSchema[resolvedKey] === 'unknown'
|
|
@@ -3464,18 +3748,171 @@ export class ScopeDataStructure {
|
|
|
3464
3748
|
return {};
|
|
3465
3749
|
}
|
|
3466
3750
|
|
|
3751
|
+
// Collect all descendant scope names (including the scope itself)
|
|
3752
|
+
// This ensures we include external calls from nested scopes like cyScope2
|
|
3753
|
+
const getAllDescendantScopeNames = (
|
|
3754
|
+
node: import('./helpers/ScopeTreeManager').ScopeTreeNode,
|
|
3755
|
+
): Set<string> => {
|
|
3756
|
+
const names = new Set<string>([node.name]);
|
|
3757
|
+
for (const child of node.children) {
|
|
3758
|
+
for (const name of getAllDescendantScopeNames(child)) {
|
|
3759
|
+
names.add(name);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
return names;
|
|
3763
|
+
};
|
|
3764
|
+
|
|
3765
|
+
const treeNode = this.scopeTreeManager.findNode(scopeNode.name);
|
|
3766
|
+
const descendantScopeNames = treeNode
|
|
3767
|
+
? getAllDescendantScopeNames(treeNode)
|
|
3768
|
+
: new Set<string>([scopeNode.name]);
|
|
3769
|
+
|
|
3770
|
+
// Get all external function calls made from this scope or any descendant scope
|
|
3771
|
+
// This allows us to include prop equivalencies from JSX components
|
|
3772
|
+
// that were rendered in nested scopes (e.g., FileTableRow called from cyScope2)
|
|
3773
|
+
const externalCallsFromScope = this.externalFunctionCalls.filter((efc) =>
|
|
3774
|
+
descendantScopeNames.has(efc.callScope),
|
|
3775
|
+
);
|
|
3776
|
+
const externalCallNames = new Set(
|
|
3777
|
+
externalCallsFromScope.map((efc) => efc.name),
|
|
3778
|
+
);
|
|
3779
|
+
|
|
3780
|
+
// Helper to check if a usage belongs to this scope (directly, via descendant, or via external call)
|
|
3781
|
+
const usageMatchesScope = (usage: { scopeNodeName: string }) =>
|
|
3782
|
+
descendantScopeNames.has(usage.scopeNodeName) ||
|
|
3783
|
+
externalCallNames.has(usage.scopeNodeName);
|
|
3784
|
+
|
|
3467
3785
|
const entries = this.equivalencyDatabase.filter((entry) =>
|
|
3468
|
-
entry.usages.some(
|
|
3786
|
+
entry.usages.some(usageMatchesScope),
|
|
3469
3787
|
);
|
|
3788
|
+
|
|
3789
|
+
// Helper to resolve a source candidate through equivalency chains to find signature paths
|
|
3790
|
+
const resolveToSignature = (
|
|
3791
|
+
source: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>,
|
|
3792
|
+
visited: Set<string>,
|
|
3793
|
+
): Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] => {
|
|
3794
|
+
const visitKey = `${source.scopeNodeName}::${source.schemaPath}`;
|
|
3795
|
+
if (visited.has(visitKey)) return [];
|
|
3796
|
+
visited.add(visitKey);
|
|
3797
|
+
|
|
3798
|
+
// If already a signature path, return as-is
|
|
3799
|
+
if (source.schemaPath.startsWith('signature[')) {
|
|
3800
|
+
return [source];
|
|
3801
|
+
}
|
|
3802
|
+
|
|
3803
|
+
const currentScope = this.scopeNodes[source.scopeNodeName];
|
|
3804
|
+
if (!currentScope?.equivalencies) return [source];
|
|
3805
|
+
|
|
3806
|
+
// Check for direct equivalencies FIRST (full path match)
|
|
3807
|
+
// This ensures paths like "useMemo(...).functionCallReturnValue" follow to "cyScope1::returnValue"
|
|
3808
|
+
// before prefix matching tries "useMemo(...)" which goes to the useMemo scope
|
|
3809
|
+
const directEquivs = currentScope.equivalencies[source.schemaPath];
|
|
3810
|
+
if (directEquivs?.length > 0) {
|
|
3811
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3812
|
+
[];
|
|
3813
|
+
for (const equiv of directEquivs) {
|
|
3814
|
+
const resolved = resolveToSignature(
|
|
3815
|
+
{
|
|
3816
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
3817
|
+
schemaPath: equiv.schemaPath,
|
|
3818
|
+
},
|
|
3819
|
+
visited,
|
|
3820
|
+
);
|
|
3821
|
+
results.push(...resolved);
|
|
3822
|
+
}
|
|
3823
|
+
if (results.length > 0) return results;
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
// Handle spread patterns like [...items].sort().functionCallReturnValue
|
|
3827
|
+
// Extract the spread variable and resolve it through the equivalency chain
|
|
3828
|
+
const spreadMatch = source.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
3829
|
+
if (spreadMatch) {
|
|
3830
|
+
const spreadVar = spreadMatch[1];
|
|
3831
|
+
const spreadPattern = spreadMatch[0];
|
|
3832
|
+
const varEquivs = currentScope.equivalencies[spreadVar];
|
|
3833
|
+
|
|
3834
|
+
if (varEquivs?.length > 0) {
|
|
3835
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3836
|
+
[];
|
|
3837
|
+
for (const equiv of varEquivs) {
|
|
3838
|
+
// Follow the variable equivalency and then resolve from there
|
|
3839
|
+
const resolvedVar = resolveToSignature(
|
|
3840
|
+
{
|
|
3841
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
3842
|
+
schemaPath: equiv.schemaPath,
|
|
3843
|
+
},
|
|
3844
|
+
visited,
|
|
3845
|
+
);
|
|
3846
|
+
// For each resolved variable path, create the full path with array element suffix
|
|
3847
|
+
for (const rv of resolvedVar) {
|
|
3848
|
+
if (rv.schemaPath.startsWith('signature[')) {
|
|
3849
|
+
// Get the suffix after the spread pattern
|
|
3850
|
+
let suffix = source.schemaPath.slice(spreadPattern.length);
|
|
3851
|
+
|
|
3852
|
+
// Clean the suffix: strip array method chains like .sort(...).functionCallReturnValue[]
|
|
3853
|
+
// These don't change the data identity, just transform it.
|
|
3854
|
+
// Keep only the final element access parts like [0], [1], etc.
|
|
3855
|
+
// Pattern: strip everything from a method call up through functionCallReturnValue[]
|
|
3856
|
+
suffix = suffix.replace(
|
|
3857
|
+
/\.\w+\([^)]*\)\.functionCallReturnValue\[\]/g,
|
|
3858
|
+
'',
|
|
3859
|
+
);
|
|
3860
|
+
// Also handle simpler case without nested parens
|
|
3861
|
+
suffix = suffix.replace(
|
|
3862
|
+
/\.sort\(\w*\(\)\)\.functionCallReturnValue\[\]/g,
|
|
3863
|
+
'',
|
|
3864
|
+
);
|
|
3865
|
+
|
|
3866
|
+
// Add [] to indicate array element access from the spread
|
|
3867
|
+
const resolvedPath = rv.schemaPath + '[]' + suffix;
|
|
3868
|
+
results.push({
|
|
3869
|
+
scopeNodeName: rv.scopeNodeName,
|
|
3870
|
+
schemaPath: resolvedPath,
|
|
3871
|
+
});
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
if (results.length > 0) return results;
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3879
|
+
// Try to find prefix equivalencies that can resolve this path
|
|
3880
|
+
// For path like "cyScope3().signature[0][0]", check "cyScope3().signature[0]", etc.
|
|
3881
|
+
const pathParts = this.splitPath(source.schemaPath);
|
|
3882
|
+
for (let i = pathParts.length - 1; i > 0; i--) {
|
|
3883
|
+
const prefix = this.joinPathParts(pathParts.slice(0, i));
|
|
3884
|
+
const suffix = this.joinPathParts(pathParts.slice(i));
|
|
3885
|
+
const prefixEquivs = currentScope.equivalencies[prefix];
|
|
3886
|
+
|
|
3887
|
+
if (prefixEquivs?.length > 0) {
|
|
3888
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3889
|
+
[];
|
|
3890
|
+
for (const equiv of prefixEquivs) {
|
|
3891
|
+
const newPath = this.joinPathParts([equiv.schemaPath, suffix]);
|
|
3892
|
+
const resolved = resolveToSignature(
|
|
3893
|
+
{ scopeNodeName: equiv.scopeNodeName, schemaPath: newPath },
|
|
3894
|
+
visited,
|
|
3895
|
+
);
|
|
3896
|
+
results.push(...resolved);
|
|
3897
|
+
}
|
|
3898
|
+
if (results.length > 0) return results;
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
|
|
3902
|
+
return [source];
|
|
3903
|
+
};
|
|
3904
|
+
|
|
3470
3905
|
return entries.reduce(
|
|
3471
3906
|
(acc, entry) => {
|
|
3472
3907
|
if (entry.sourceCandidates.length === 0) return acc;
|
|
3473
|
-
const usages = entry.usages.filter(
|
|
3474
|
-
(u) => u.scopeNodeName === scopeNode.name,
|
|
3475
|
-
);
|
|
3908
|
+
const usages = entry.usages.filter(usageMatchesScope);
|
|
3476
3909
|
for (const usage of usages) {
|
|
3477
3910
|
acc[usage.schemaPath] ||= [];
|
|
3478
|
-
|
|
3911
|
+
// Resolve each source candidate through the equivalency chain
|
|
3912
|
+
for (const source of entry.sourceCandidates) {
|
|
3913
|
+
const resolvedSources = resolveToSignature(source, new Set());
|
|
3914
|
+
acc[usage.schemaPath].push(...resolvedSources);
|
|
3915
|
+
}
|
|
3479
3916
|
}
|
|
3480
3917
|
return acc;
|
|
3481
3918
|
},
|
|
@@ -3588,6 +4025,54 @@ export class ScopeDataStructure {
|
|
|
3588
4025
|
}
|
|
3589
4026
|
}
|
|
3590
4027
|
|
|
4028
|
+
// Enrich schema with deeply nested paths from internal function call scopes.
|
|
4029
|
+
// When a function call like traverse(tree) exists, and traverse's scope has
|
|
4030
|
+
// signature[0].children[path][entityName] (from propagateParameterToSignaturePaths),
|
|
4031
|
+
// we need to map those paths back to the argument variable (tree) in this scope.
|
|
4032
|
+
// This handles cases where cycle detection prevented the equivalency chain from
|
|
4033
|
+
// propagating deep paths during Phase 2 batch queue processing.
|
|
4034
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
4035
|
+
// Look for keys matching function call pattern: funcName(...).signature[N]
|
|
4036
|
+
const funcCallMatch = equivalenceKey.match(
|
|
4037
|
+
/^([^(]+)\(.*?\)\.(signature\[\d+\])$/,
|
|
4038
|
+
);
|
|
4039
|
+
if (!funcCallMatch) continue;
|
|
4040
|
+
|
|
4041
|
+
const calledFunctionName = funcCallMatch[1];
|
|
4042
|
+
const signatureParam = funcCallMatch[2]; // e.g., "signature[0]"
|
|
4043
|
+
|
|
4044
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
4045
|
+
if (equivalenceValue.scopeNodeName !== scopeName) continue;
|
|
4046
|
+
|
|
4047
|
+
const targetVariable = equivalenceValue.schemaPath;
|
|
4048
|
+
|
|
4049
|
+
// Get the called function's schema (includes propagated parameter paths)
|
|
4050
|
+
const childSchema = this.getSchema({
|
|
4051
|
+
scopeName: calledFunctionName,
|
|
4052
|
+
});
|
|
4053
|
+
if (!childSchema) continue;
|
|
4054
|
+
|
|
4055
|
+
// Map child function's signature paths to parent variable paths
|
|
4056
|
+
const sigPrefix = signatureParam + '.';
|
|
4057
|
+
const sigBracketPrefix = signatureParam + '[';
|
|
4058
|
+
for (const childKey in childSchema) {
|
|
4059
|
+
let suffix: string | null = null;
|
|
4060
|
+
if (childKey.startsWith(sigPrefix)) {
|
|
4061
|
+
suffix = childKey.slice(signatureParam.length);
|
|
4062
|
+
} else if (childKey.startsWith(sigBracketPrefix)) {
|
|
4063
|
+
suffix = childKey.slice(signatureParam.length);
|
|
4064
|
+
}
|
|
4065
|
+
|
|
4066
|
+
if (suffix !== null) {
|
|
4067
|
+
const parentKey = targetVariable + suffix;
|
|
4068
|
+
if (!schema[parentKey]) {
|
|
4069
|
+
schema[parentKey] = childSchema[childKey];
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
|
|
3591
4076
|
// Propagate nested paths from variables to their signature equivalents
|
|
3592
4077
|
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
3593
4078
|
// signature[0].workouts[].title
|
|
@@ -3860,10 +4345,32 @@ export class ScopeDataStructure {
|
|
|
3860
4345
|
return scopeText;
|
|
3861
4346
|
}
|
|
3862
4347
|
|
|
3863
|
-
getEquivalentSignatureVariables() {
|
|
4348
|
+
getEquivalentSignatureVariables(): Record<string, string | string[]> {
|
|
3864
4349
|
const scopeNode = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
3865
4350
|
|
|
3866
|
-
const equivalentSignatureVariables: Record<string, string> = {};
|
|
4351
|
+
const equivalentSignatureVariables: Record<string, string | string[]> = {};
|
|
4352
|
+
|
|
4353
|
+
// Helper to add equivalencies - accumulates into array if multiple values for same key
|
|
4354
|
+
// This is critical for OR expressions like `x = a || b` where x should map to both a and b
|
|
4355
|
+
const addEquivalency = (key: string, value: string) => {
|
|
4356
|
+
const existing = equivalentSignatureVariables[key];
|
|
4357
|
+
if (existing === undefined) {
|
|
4358
|
+
// First value - store as string
|
|
4359
|
+
equivalentSignatureVariables[key] = value;
|
|
4360
|
+
} else if (typeof existing === 'string') {
|
|
4361
|
+
if (existing !== value) {
|
|
4362
|
+
// Second different value - convert to array
|
|
4363
|
+
equivalentSignatureVariables[key] = [existing, value];
|
|
4364
|
+
}
|
|
4365
|
+
// Same value - no change needed
|
|
4366
|
+
} else {
|
|
4367
|
+
// Already an array - add if not already present
|
|
4368
|
+
if (!existing.includes(value)) {
|
|
4369
|
+
existing.push(value);
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
};
|
|
4373
|
+
|
|
3867
4374
|
for (const [path, equivalentValues] of Object.entries(
|
|
3868
4375
|
scopeNode.equivalencies,
|
|
3869
4376
|
)) {
|
|
@@ -3872,7 +4379,7 @@ export class ScopeDataStructure {
|
|
|
3872
4379
|
// Maps local variable names to their signature paths
|
|
3873
4380
|
// e.g., "propValue" -> "signature[0].prop"
|
|
3874
4381
|
if (path.startsWith('signature[')) {
|
|
3875
|
-
|
|
4382
|
+
addEquivalency(equivalentValue.schemaPath, path);
|
|
3876
4383
|
}
|
|
3877
4384
|
|
|
3878
4385
|
// Case 2: Hook variable equivalencies (new behavior)
|
|
@@ -3906,7 +4413,7 @@ export class ScopeDataStructure {
|
|
|
3906
4413
|
hookCallPath = dbEntry.sourceCandidates[0].schemaPath;
|
|
3907
4414
|
}
|
|
3908
4415
|
}
|
|
3909
|
-
|
|
4416
|
+
addEquivalency(path, hookCallPath);
|
|
3910
4417
|
}
|
|
3911
4418
|
}
|
|
3912
4419
|
|
|
@@ -3920,10 +4427,8 @@ export class ScopeDataStructure {
|
|
|
3920
4427
|
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
3921
4428
|
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
3922
4429
|
) {
|
|
3923
|
-
//
|
|
3924
|
-
|
|
3925
|
-
equivalentSignatureVariables[path] = equivalentValue.schemaPath;
|
|
3926
|
-
}
|
|
4430
|
+
// Add equivalency (will accumulate if multiple values for OR expressions)
|
|
4431
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3927
4432
|
}
|
|
3928
4433
|
|
|
3929
4434
|
// Case 4: Child component prop mappings (Fix 22)
|
|
@@ -3936,7 +4441,7 @@ export class ScopeDataStructure {
|
|
|
3936
4441
|
path.includes('().signature[') &&
|
|
3937
4442
|
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable, not a function call
|
|
3938
4443
|
) {
|
|
3939
|
-
|
|
4444
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3940
4445
|
}
|
|
3941
4446
|
|
|
3942
4447
|
// Case 5: Destructured function parameters (Fix 25)
|
|
@@ -3951,7 +4456,7 @@ export class ScopeDataStructure {
|
|
|
3951
4456
|
!path.includes('.') && // path is a simple identifier (destructured prop name)
|
|
3952
4457
|
equivalentValue.schemaPath.startsWith('signature[') // schemaPath IS a signature path
|
|
3953
4458
|
) {
|
|
3954
|
-
|
|
4459
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3955
4460
|
}
|
|
3956
4461
|
|
|
3957
4462
|
// Case 7: Method calls on variables that result in .functionCallReturnValue (Fix 33)
|
|
@@ -3965,8 +4470,7 @@ export class ScopeDataStructure {
|
|
|
3965
4470
|
if (
|
|
3966
4471
|
!path.includes('.') && // path is a simple identifier
|
|
3967
4472
|
equivalentValue.schemaPath.endsWith('.functionCallReturnValue') && // ends with function return
|
|
3968
|
-
equivalentValue.schemaPath.includes('.')
|
|
3969
|
-
!(path in equivalentSignatureVariables) // not already captured
|
|
4473
|
+
equivalentValue.schemaPath.includes('.') // has property access (method call)
|
|
3970
4474
|
) {
|
|
3971
4475
|
// Check if this looks like a method call on a variable (not a hook call)
|
|
3972
4476
|
// Hook calls look like: hookName() or hookName<T>()
|
|
@@ -3980,7 +4484,7 @@ export class ScopeDataStructure {
|
|
|
3980
4484
|
const parenPos = hookCallPath.indexOf('(');
|
|
3981
4485
|
if (dotBeforeParen !== -1 && dotBeforeParen < parenPos) {
|
|
3982
4486
|
// This is a method call like "splat.split('/')", not a hook call
|
|
3983
|
-
|
|
4487
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
3984
4488
|
}
|
|
3985
4489
|
}
|
|
3986
4490
|
}
|
|
@@ -4011,8 +4515,9 @@ export class ScopeDataStructure {
|
|
|
4011
4515
|
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable
|
|
4012
4516
|
) {
|
|
4013
4517
|
// Only add if not already present from the root scope
|
|
4518
|
+
// Root scope values take precedence over child scope values
|
|
4014
4519
|
if (!(path in equivalentSignatureVariables)) {
|
|
4015
|
-
|
|
4520
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4016
4521
|
}
|
|
4017
4522
|
}
|
|
4018
4523
|
}
|
|
@@ -4024,12 +4529,83 @@ export class ScopeDataStructure {
|
|
|
4024
4529
|
// We need multiple passes because resolutions can depend on each other
|
|
4025
4530
|
const maxIterations = 5; // Prevent infinite loops
|
|
4026
4531
|
|
|
4532
|
+
// Helper function to resolve a single source path using equivalencies
|
|
4533
|
+
const resolveSourcePath = (
|
|
4534
|
+
sourcePath: string,
|
|
4535
|
+
equivMap: Record<string, string | string[]>,
|
|
4536
|
+
): string | null => {
|
|
4537
|
+
// Extract base variable from the path
|
|
4538
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4539
|
+
const bracketIndex = sourcePath.indexOf('[');
|
|
4540
|
+
|
|
4541
|
+
let baseVar: string;
|
|
4542
|
+
let rest: string;
|
|
4543
|
+
|
|
4544
|
+
if (dotIndex === -1 && bracketIndex === -1) {
|
|
4545
|
+
baseVar = sourcePath;
|
|
4546
|
+
rest = '';
|
|
4547
|
+
} else if (dotIndex === -1) {
|
|
4548
|
+
baseVar = sourcePath.slice(0, bracketIndex);
|
|
4549
|
+
rest = sourcePath.slice(bracketIndex);
|
|
4550
|
+
} else if (bracketIndex === -1) {
|
|
4551
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
4552
|
+
rest = sourcePath.slice(dotIndex);
|
|
4553
|
+
} else {
|
|
4554
|
+
const firstIndex = Math.min(dotIndex, bracketIndex);
|
|
4555
|
+
baseVar = sourcePath.slice(0, firstIndex);
|
|
4556
|
+
rest = sourcePath.slice(firstIndex);
|
|
4557
|
+
}
|
|
4558
|
+
|
|
4559
|
+
// Look up the base variable in equivalencies
|
|
4560
|
+
if (baseVar in equivMap && equivMap[baseVar] !== sourcePath) {
|
|
4561
|
+
const baseResolved = equivMap[baseVar];
|
|
4562
|
+
// Skip if baseResolved is an array (handle later)
|
|
4563
|
+
if (Array.isArray(baseResolved)) return null;
|
|
4564
|
+
// If it resolves to a signature path, build the full resolved path
|
|
4565
|
+
if (
|
|
4566
|
+
baseResolved.startsWith('signature[') ||
|
|
4567
|
+
baseResolved.includes('()')
|
|
4568
|
+
) {
|
|
4569
|
+
if (baseResolved.endsWith('()')) {
|
|
4570
|
+
return baseResolved + '.functionCallReturnValue' + rest;
|
|
4571
|
+
}
|
|
4572
|
+
return baseResolved + rest;
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
return null;
|
|
4576
|
+
};
|
|
4577
|
+
|
|
4027
4578
|
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
4028
4579
|
let changed = false;
|
|
4029
4580
|
|
|
4030
|
-
for (const [varName,
|
|
4581
|
+
for (const [varName, sourcePathOrArray] of Object.entries(
|
|
4031
4582
|
equivalentSignatureVariables,
|
|
4032
4583
|
)) {
|
|
4584
|
+
// Handle arrays (OR expressions) by resolving each element
|
|
4585
|
+
if (Array.isArray(sourcePathOrArray)) {
|
|
4586
|
+
const resolvedArray: string[] = [];
|
|
4587
|
+
let arrayChanged = false;
|
|
4588
|
+
for (const sourcePath of sourcePathOrArray) {
|
|
4589
|
+
// Try to resolve this path using transitive resolution
|
|
4590
|
+
const resolved = resolveSourcePath(
|
|
4591
|
+
sourcePath,
|
|
4592
|
+
equivalentSignatureVariables,
|
|
4593
|
+
);
|
|
4594
|
+
if (resolved && resolved !== sourcePath) {
|
|
4595
|
+
resolvedArray.push(resolved);
|
|
4596
|
+
arrayChanged = true;
|
|
4597
|
+
} else {
|
|
4598
|
+
resolvedArray.push(sourcePath);
|
|
4599
|
+
}
|
|
4600
|
+
}
|
|
4601
|
+
if (arrayChanged) {
|
|
4602
|
+
equivalentSignatureVariables[varName] = resolvedArray;
|
|
4603
|
+
changed = true;
|
|
4604
|
+
}
|
|
4605
|
+
continue;
|
|
4606
|
+
}
|
|
4607
|
+
const sourcePath = sourcePathOrArray;
|
|
4608
|
+
|
|
4033
4609
|
// Skip if already fully resolved (contains function call syntax)
|
|
4034
4610
|
// BUT first check for computed value patterns that need resolution (Fix 28)
|
|
4035
4611
|
// AND method call patterns that need base variable resolution (Fix 33)
|
|
@@ -4091,6 +4667,8 @@ export class ScopeDataStructure {
|
|
|
4091
4667
|
baseVar !== varName
|
|
4092
4668
|
) {
|
|
4093
4669
|
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
4670
|
+
// Skip if baseResolved is an array (OR expression)
|
|
4671
|
+
if (Array.isArray(baseResolved)) continue;
|
|
4094
4672
|
// Only resolve if the base resolved to something useful (contains () or .)
|
|
4095
4673
|
if (baseResolved.includes('()') || baseResolved.includes('.')) {
|
|
4096
4674
|
const newPath = baseResolved + rest;
|
|
@@ -4155,7 +4733,12 @@ export class ScopeDataStructure {
|
|
|
4155
4733
|
}
|
|
4156
4734
|
|
|
4157
4735
|
if (baseVar in equivalentSignatureVariables && baseVar !== varName) {
|
|
4158
|
-
|
|
4736
|
+
// Handle array case (OR expressions) - use first element
|
|
4737
|
+
const rawBaseResolved = equivalentSignatureVariables[baseVar];
|
|
4738
|
+
const baseResolved = Array.isArray(rawBaseResolved)
|
|
4739
|
+
? rawBaseResolved[0]
|
|
4740
|
+
: rawBaseResolved;
|
|
4741
|
+
if (!baseResolved) continue;
|
|
4159
4742
|
// If the base resolves to a hook call, add .functionCallReturnValue
|
|
4160
4743
|
if (baseResolved.endsWith('()')) {
|
|
4161
4744
|
const newPath = baseResolved + '.functionCallReturnValue' + rest;
|
|
@@ -4375,7 +4958,7 @@ export class ScopeDataStructure {
|
|
|
4375
4958
|
path: string;
|
|
4376
4959
|
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
4377
4960
|
comparedValues?: string[];
|
|
4378
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
4961
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
4379
4962
|
}>
|
|
4380
4963
|
>,
|
|
4381
4964
|
): void {
|
|
@@ -4899,11 +5482,22 @@ export class ScopeDataStructure {
|
|
|
4899
5482
|
}
|
|
4900
5483
|
}
|
|
4901
5484
|
|
|
5485
|
+
// Enrich the schema with inferred types by applying fillInSchemaGapsAndUnknowns.
|
|
5486
|
+
// This ensures the serialized schema has the same type inference as getReturnValue().
|
|
5487
|
+
// Without this, evidence like "entities[].analyses: array" becomes "unknown".
|
|
5488
|
+
const enrichedSchema = { ...efc.schema };
|
|
5489
|
+
const tempScopeNode = {
|
|
5490
|
+
name: efc.name,
|
|
5491
|
+
schema: enrichedSchema,
|
|
5492
|
+
equivalencies: efc.equivalencies ?? {},
|
|
5493
|
+
};
|
|
5494
|
+
fillInSchemaGapsAndUnknowns(tempScopeNode, true);
|
|
5495
|
+
|
|
4902
5496
|
return {
|
|
4903
5497
|
name: efc.name,
|
|
4904
5498
|
callSignature: efc.callSignature,
|
|
4905
5499
|
callScope: efc.callScope,
|
|
4906
|
-
schema:
|
|
5500
|
+
schema: enrichedSchema,
|
|
4907
5501
|
equivalencies: efc.equivalencies
|
|
4908
5502
|
? Object.entries(efc.equivalencies).reduce(
|
|
4909
5503
|
(acc, [key, vars]) => {
|