@codeyam/codeyam-cli 0.1.0-staging.1669d45 → 0.1.0-staging.2a88920
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +5 -5
- package/analyzer-template/packages/ai/index.ts +15 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +87 -51
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +98 -9
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +139 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +6 -126
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +555 -28
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +88 -7
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +198 -34
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +772 -243
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +205 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +10 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +43 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +122 -15
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +160 -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 +319 -88
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +642 -7
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +35 -6
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +383 -6
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1299 -51
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- 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/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +23 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +179 -45
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +26 -4
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
- 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/analysisContext.ts +44 -4
- 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 +30 -19
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +14 -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 +33 -10
- 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/enrichArrayTypesFromChildSignatures.ts +189 -76
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +29 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +77 -9
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +118 -10
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +276 -17
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/package.json +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +8 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +8 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +25 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +56 -6
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/types/index.ts +1 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +25 -0
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +70 -6
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/index.d.ts +1 -1
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +25 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +56 -6
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +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 +367 -37
- 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 +18 -7
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +71 -6
- package/analyzer-template/project/reconcileMockDataKeys.ts +152 -9
- package/analyzer-template/project/runAnalysis.ts +4 -0
- package/analyzer-template/project/start.ts +35 -11
- package/analyzer-template/project/writeMockDataTsx.ts +127 -4
- package/analyzer-template/project/writeScenarioComponents.ts +101 -8
- package/analyzer-template/scripts/comboWorkerLoop.cjs +98 -50
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +5 -0
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +5 -0
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +300 -7
- 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 +7 -5
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +58 -6
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +126 -9
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +3 -0
- package/background/src/lib/virtualized/project/runAnalysis.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 +101 -4
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +57 -8
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/codeyam-cli/src/cli.js +2 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/debug.js +7 -5
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +273 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +4 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +21 -2
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +42 -6
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +1 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +6 -0
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/rules/index.js +5 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +106 -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/staleness.js +132 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +2 -0
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +7 -3
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +40 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-DsN1wKrm.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-COi5OvsN.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-BwdQv49w.js → EntityTypeIcon-Ba2JVPzP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-CEleMv_j.js → InlineSpinner-C8lyxW9k.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-D68KarMg.js → InteractivePreview-aht4aafF.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-L75Wvqgw.js → LibraryFunctionPreview-CVtiBnY5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-C53WM8qn.js → LoadingDots-B0GLXMsr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CrNkmy4i.js → LogViewer-xgeCVgSM.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-OApQuNyq.js +16 -0
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-CQifa1n-.js → SafeScreenshot-DuDvi0jm.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-CyaBFX7l.js → ScenarioViewer-DzccYyI8.js} +3 -13
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-D36O1rzU.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-BwqWJOgH.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BwavGCpm.js +32 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-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.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-DgTPh8H-.js → chevron-down-Cx24_aWc.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-DdQKK6on.js → chunk-EPOLDU6W-CXRTFQ3F.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-Dmr2bb1R.js → circle-check-BOARzkeR.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-Do4ZLUYa.js → createLucideIcon-BdhJEx6B.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BBnGWYga.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CbdFyxZh.js → entity._sha._-BJUiQqZF.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-B4iCfs5M.js → entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-wDWZZO1W.js → entity._sha_.create-scenario-D1T4TGjf.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMbl7MeQ.js → entity._sha_.edit._scenarioId-CTBG2mmz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-5wRKRIH9.js → entry.client-CS2cb_eZ.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DD3SDH7t.js → fileTableUtils-DMJ7zii9.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-CJ6lTdTA.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{git-zXjT7J0G.js → git-CPTZZ-JZ.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-DLbXwndH.js → index-B1h680n5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-gPZ-lad1.js → index-lzqtyFU8.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-BsPXJ81F.js → loader-circle-B7B9V-bu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-a78b90a2.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory--GCbFsBE.js +92 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-eVAaavTS.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-P2FKIUql.js → search-CxXUmBSd.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{settings-B2eDuBj8.js → settings-CS5f3WzT.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-L18M6-kN.js → simulations-DwFIBT09.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-BDz7kbVA.js → triangle-alert-B6LgvRJg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-29dDmbH8.js → useCustomSizes-C1v1PQzo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BUm0UVJm.js → useLastLogLine-aSv48UbS.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-CkIOKTrZ.js → useReportContext-DYxHZQuP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-KKw5kTn-.js → useToast-mBRpZPiu.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-BM6TDT1Y.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-dYC34MHw.js +257 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/codeyam-memory-hook.sh +200 -0
- package/codeyam-cli/templates/codeyam:debug.md +47 -3
- package/codeyam-cli/templates/codeyam:diagnose.md +203 -25
- package/codeyam-cli/templates/codeyam:memory.md +341 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +160 -0
- package/codeyam-cli/templates/rules-instructions.md +93 -0
- package/package.json +8 -5
- package/packages/ai/index.js +7 -3
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +70 -29
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +78 -8
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/methodSemantics.js +109 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +1 -102
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +440 -27
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +161 -30
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +589 -166
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +179 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +7 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +41 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +104 -11
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +159 -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 +265 -79
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +111 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateEntityScenarioData.js +525 -8
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +26 -2
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +281 -4
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +946 -42
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- 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/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +15 -7
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +155 -41
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +7 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +94 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/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/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.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 +21 -9
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +14 -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 +31 -10
- 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/enrichArrayTypesFromChildSignatures.js +160 -68
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +25 -8
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +71 -9
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +57 -9
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +233 -9
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/database/src/lib/kysely/db.js +8 -1
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/loadAnalyses.js +45 -2
- package/packages/database/src/lib/loadAnalyses.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-vauWK972.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DzJRkCkr.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/_index-Be83mo_j.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BN6wu6Y-.js +0 -37
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Bn6aCAy_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-DKyMFI90.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-DTTQ3gY7.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-22590fcf.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-BsAarjAM.js +0 -57
- package/codeyam-cli/src/webserver/build/server/assets/index-BND5I5fv.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CFXnd7MG.js +0 -228
|
@@ -39,6 +39,203 @@ export class MuiManager implements EquivalencyManager {
|
|
|
39
39
|
|
|
40
40
|
// Also check if this scope is inside a DataGrid callback and propagate row property accesses
|
|
41
41
|
this.propagateFromChildScope(scopeNode, scopeDataStructure);
|
|
42
|
+
|
|
43
|
+
// NOTE: processGridApiContext, processCreateTheme, and processGridSelector
|
|
44
|
+
// are now called from finalize() instead of here.
|
|
45
|
+
// This is because external function calls are only added AFTER postProcess()
|
|
46
|
+
// runs (in trackFunctionCalls), so getExternalFunctionCallInfo() would return
|
|
47
|
+
// undefined during postProcess(). See Issue 23.
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Handle useGridApiContext() calls by adding the expected apiRef structure to the schema.
|
|
52
|
+
*
|
|
53
|
+
* useGridApiContext() returns an apiRef that has internal state used by useGridSelector.
|
|
54
|
+
* When useGridSelector(apiRef, selector) is called, it accesses apiRef.current.state
|
|
55
|
+
* to extract data like filterModel, sortModel, etc.
|
|
56
|
+
*
|
|
57
|
+
* We add the state structure directly to the external function call's schema
|
|
58
|
+
* to ensure mocks include the necessary paths.
|
|
59
|
+
*/
|
|
60
|
+
private processGridApiContext(
|
|
61
|
+
_scopeNode: ScopeNode,
|
|
62
|
+
scopeDataStructure: ScopeDataStructure,
|
|
63
|
+
) {
|
|
64
|
+
// Find the external function call for useGridApiContext
|
|
65
|
+
const gridApiContextCall =
|
|
66
|
+
scopeDataStructure.getExternalFunctionCallInfo('useGridApiContext');
|
|
67
|
+
|
|
68
|
+
if (!gridApiContextCall) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Add the state structure that useGridSelector needs to the external function call's schema
|
|
73
|
+
// useGridSelector reads from apiRef.current.state internally
|
|
74
|
+
// gridFilterModelSelector reads state.filter.filterModel
|
|
75
|
+
const basePath = 'useGridApiContext().functionCallReturnValue.current';
|
|
76
|
+
const statePaths: Record<string, string> = {
|
|
77
|
+
[`${basePath}.state`]: 'object',
|
|
78
|
+
[`${basePath}.state.filter`]: 'object',
|
|
79
|
+
[`${basePath}.state.filter.filterModel`]: 'object',
|
|
80
|
+
[`${basePath}.state.filter.filterModel.items`]: 'array',
|
|
81
|
+
// Also add common state paths that might be needed by other selectors
|
|
82
|
+
[`${basePath}.state.sorting`]: 'object',
|
|
83
|
+
[`${basePath}.state.sorting.sortModel`]: 'array',
|
|
84
|
+
[`${basePath}.state.pagination`]: 'object',
|
|
85
|
+
[`${basePath}.state.pagination.paginationModel`]: 'object',
|
|
86
|
+
[`${basePath}.state.pagination.paginationModel.page`]: 'number',
|
|
87
|
+
[`${basePath}.state.pagination.paginationModel.pageSize`]: 'number',
|
|
88
|
+
[`${basePath}.state.rows`]: 'object',
|
|
89
|
+
[`${basePath}.state.rows.dataRowIds`]: 'array',
|
|
90
|
+
[`${basePath}.state.columns`]: 'object',
|
|
91
|
+
[`${basePath}.state.columns.all`]: 'array',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Add each path to the external function call's schema if it doesn't exist
|
|
95
|
+
for (const [path, type] of Object.entries(statePaths)) {
|
|
96
|
+
if (!gridApiContextCall.schema[path]) {
|
|
97
|
+
gridApiContextCall.schema[path] = type;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Handle createTheme() calls by adding required MUI theme properties to the schema.
|
|
104
|
+
*
|
|
105
|
+
* MUI's ThemeProvider and related components check for specific properties:
|
|
106
|
+
* - `'$$material' in theme` - validates it's a MUI theme object
|
|
107
|
+
* - `'colorSchemes' in theme` - checks for color scheme support (MUI v6+)
|
|
108
|
+
*
|
|
109
|
+
* Without these properties, ThemeProvider throws:
|
|
110
|
+
* "TypeError: Cannot use 'in' operator to search for '$$material' in object"
|
|
111
|
+
* "TypeError: Cannot use 'in' operator to search for 'colorSchemes' in true"
|
|
112
|
+
*
|
|
113
|
+
* We add these properties to the createTheme return value schema
|
|
114
|
+
* to ensure mocks include the necessary properties.
|
|
115
|
+
*/
|
|
116
|
+
private processCreateTheme(
|
|
117
|
+
_scopeNode: ScopeNode,
|
|
118
|
+
scopeDataStructure: ScopeDataStructure,
|
|
119
|
+
) {
|
|
120
|
+
// Find the external function call for createTheme
|
|
121
|
+
const createThemeCall =
|
|
122
|
+
scopeDataStructure.getExternalFunctionCallInfo('createTheme');
|
|
123
|
+
|
|
124
|
+
if (!createThemeCall) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Use the actual call signature to construct the path
|
|
129
|
+
// createTheme can be called with various arguments:
|
|
130
|
+
// - createTheme()
|
|
131
|
+
// - createTheme(options)
|
|
132
|
+
// - createTheme(getTheme(false), { components: {} })
|
|
133
|
+
const callSignature = createThemeCall.callSignature;
|
|
134
|
+
const basePath = `${callSignature}.functionCallReturnValue`;
|
|
135
|
+
|
|
136
|
+
// Add required MUI theme properties
|
|
137
|
+
const themeProperties: Record<string, string> = {
|
|
138
|
+
[`${basePath}.$$material`]: 'boolean',
|
|
139
|
+
[`${basePath}.colorSchemes`]: 'object',
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
for (const [path, type] of Object.entries(themeProperties)) {
|
|
143
|
+
if (!createThemeCall.schema[path]) {
|
|
144
|
+
createThemeCall.schema[path] = type;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Handle useGridSelector(apiRef, selector) calls by adding return value schema.
|
|
151
|
+
*
|
|
152
|
+
* useGridSelector is a MUI X Data Grid hook that extracts data from the grid's
|
|
153
|
+
* internal state using a selector function. It's unique because:
|
|
154
|
+
* 1. It takes arguments (apiRef and selector), so it's not automatically mocked
|
|
155
|
+
* 2. But its return value depends on which selector is used
|
|
156
|
+
* 3. The selector reads from apiRef.current.state
|
|
157
|
+
*
|
|
158
|
+
* Common selectors and their return types:
|
|
159
|
+
* - gridFilterModelSelector -> { items: GridFilterItem[] }
|
|
160
|
+
* - gridSortModelSelector -> GridSortItem[]
|
|
161
|
+
* - gridPaginationModelSelector -> { page: number, pageSize: number }
|
|
162
|
+
* - gridRowCountSelector -> number
|
|
163
|
+
*
|
|
164
|
+
* We detect which selector is used from the call signature and add the
|
|
165
|
+
* appropriate return value schema.
|
|
166
|
+
*/
|
|
167
|
+
private processGridSelector(
|
|
168
|
+
_scopeNode: ScopeNode,
|
|
169
|
+
scopeDataStructure: ScopeDataStructure,
|
|
170
|
+
) {
|
|
171
|
+
// Find external function calls for useGridSelector
|
|
172
|
+
const gridSelectorCall =
|
|
173
|
+
scopeDataStructure.getExternalFunctionCallInfo('useGridSelector');
|
|
174
|
+
|
|
175
|
+
if (!gridSelectorCall) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const callSignature = gridSelectorCall.callSignature;
|
|
180
|
+
const basePath = `${callSignature}.functionCallReturnValue`;
|
|
181
|
+
|
|
182
|
+
// Determine which selector is being used and add appropriate schema
|
|
183
|
+
if (callSignature.includes('gridFilterModelSelector')) {
|
|
184
|
+
// gridFilterModelSelector returns { items: GridFilterItem[] }
|
|
185
|
+
const filterPaths: Record<string, string> = {
|
|
186
|
+
[basePath]: 'object',
|
|
187
|
+
[`${basePath}.items`]: 'array',
|
|
188
|
+
[`${basePath}.items[]`]: 'object',
|
|
189
|
+
[`${basePath}.items[].field`]: 'string',
|
|
190
|
+
[`${basePath}.items[].operator`]: 'string',
|
|
191
|
+
[`${basePath}.items[].value`]: 'array',
|
|
192
|
+
[`${basePath}.items[].value[]`]: 'string',
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
for (const [path, type] of Object.entries(filterPaths)) {
|
|
196
|
+
if (!gridSelectorCall.schema[path]) {
|
|
197
|
+
gridSelectorCall.schema[path] = type;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} else if (callSignature.includes('gridSortModelSelector')) {
|
|
201
|
+
// gridSortModelSelector returns GridSortItem[]
|
|
202
|
+
const sortPaths: Record<string, string> = {
|
|
203
|
+
[basePath]: 'array',
|
|
204
|
+
[`${basePath}[]`]: 'object',
|
|
205
|
+
[`${basePath}[].field`]: 'string',
|
|
206
|
+
[`${basePath}[].sort`]: 'string',
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
for (const [path, type] of Object.entries(sortPaths)) {
|
|
210
|
+
if (!gridSelectorCall.schema[path]) {
|
|
211
|
+
gridSelectorCall.schema[path] = type;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} else if (callSignature.includes('gridPaginationModelSelector')) {
|
|
215
|
+
// gridPaginationModelSelector returns { page: number, pageSize: number }
|
|
216
|
+
const paginationPaths: Record<string, string> = {
|
|
217
|
+
[basePath]: 'object',
|
|
218
|
+
[`${basePath}.page`]: 'number',
|
|
219
|
+
[`${basePath}.pageSize`]: 'number',
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
for (const [path, type] of Object.entries(paginationPaths)) {
|
|
223
|
+
if (!gridSelectorCall.schema[path]) {
|
|
224
|
+
gridSelectorCall.schema[path] = type;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} else if (callSignature.includes('gridRowCountSelector')) {
|
|
228
|
+
// gridRowCountSelector returns number
|
|
229
|
+
if (!gridSelectorCall.schema[basePath]) {
|
|
230
|
+
gridSelectorCall.schema[basePath] = 'number';
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
// Unknown selector - add generic object return type
|
|
234
|
+
// This ensures the hook is at least mocked with some structure
|
|
235
|
+
if (!gridSelectorCall.schema[basePath]) {
|
|
236
|
+
gridSelectorCall.schema[basePath] = 'object';
|
|
237
|
+
}
|
|
238
|
+
}
|
|
42
239
|
}
|
|
43
240
|
|
|
44
241
|
private processDataGridCallbacks(
|
|
@@ -662,6 +859,14 @@ export class MuiManager implements EquivalencyManager {
|
|
|
662
859
|
}
|
|
663
860
|
|
|
664
861
|
finalize(_scopeNode: ScopeNode, scopeDataStructure: ScopeDataStructure) {
|
|
862
|
+
// Process external function call schemas ONCE (not per-scope) since they
|
|
863
|
+
// are global. These were moved from postProcess() because external function
|
|
864
|
+
// calls are only available AFTER postProcess() runs (in trackFunctionCalls).
|
|
865
|
+
// See Issue 23.
|
|
866
|
+
this.processGridApiContext(_scopeNode, scopeDataStructure);
|
|
867
|
+
this.processCreateTheme(_scopeNode, scopeDataStructure);
|
|
868
|
+
this.processGridSelector(_scopeNode, scopeDataStructure);
|
|
869
|
+
|
|
665
870
|
// Iterate through all scopes (finalize is only called on root)
|
|
666
871
|
for (const [scopeName, scopeNode] of Object.entries(
|
|
667
872
|
scopeDataStructure.scopeNodes,
|
|
@@ -239,10 +239,18 @@ export class ReactFrameworkManager implements EquivalencyManager {
|
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
// Get the initial value path (what signature[0] is equivalent to)
|
|
243
|
+
const initialValuePath = equivalentValues[0].schemaPath;
|
|
244
|
+
const initialValueScopeName = equivalentValues[0].scopeNodeName;
|
|
245
|
+
|
|
246
|
+
// Note: Callback scope tracing (for useState(() => { return prop; }))
|
|
247
|
+
// is handled in getEquivalentSignatureVariables() where the full
|
|
248
|
+
// equivalency database is available for deep tracing.
|
|
249
|
+
|
|
242
250
|
scopeDataStructure.addEquivalency(
|
|
243
251
|
relevantUseStateInfo.value,
|
|
244
|
-
|
|
245
|
-
|
|
252
|
+
initialValuePath,
|
|
253
|
+
initialValueScopeName,
|
|
246
254
|
scopeNode,
|
|
247
255
|
'useState value equivalency',
|
|
248
256
|
);
|
|
@@ -41,6 +41,7 @@ export interface BatchProcessorStats {
|
|
|
41
41
|
|
|
42
42
|
export class BatchSchemaProcessor {
|
|
43
43
|
private workQueue: WorkItem[] = [];
|
|
44
|
+
private queueIndex = 0;
|
|
44
45
|
private stats: BatchProcessorStats = {
|
|
45
46
|
itemsProcessed: 0,
|
|
46
47
|
itemsSkipped: 0, // Kept for API compatibility, always 0
|
|
@@ -71,17 +72,28 @@ export class BatchSchemaProcessor {
|
|
|
71
72
|
* Check if there are more items to process.
|
|
72
73
|
*/
|
|
73
74
|
hasWork(): boolean {
|
|
74
|
-
return this.workQueue.length
|
|
75
|
+
return this.queueIndex < this.workQueue.length;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
/**
|
|
78
79
|
* Get the next work item from the queue.
|
|
79
80
|
*/
|
|
80
81
|
getNextWork(): WorkItem | undefined {
|
|
81
|
-
|
|
82
|
+
if (this.queueIndex >= this.workQueue.length) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const item = this.workQueue[this.queueIndex++];
|
|
82
87
|
if (item) {
|
|
83
88
|
this.stats.itemsProcessed++;
|
|
84
89
|
}
|
|
90
|
+
|
|
91
|
+
// Once we've consumed the queue, reset to avoid unbounded growth
|
|
92
|
+
if (this.queueIndex >= this.workQueue.length) {
|
|
93
|
+
this.workQueue = [];
|
|
94
|
+
this.queueIndex = 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
return item;
|
|
86
98
|
}
|
|
87
99
|
|
|
@@ -122,6 +134,7 @@ export class BatchSchemaProcessor {
|
|
|
122
134
|
*/
|
|
123
135
|
reset(): void {
|
|
124
136
|
this.workQueue = [];
|
|
137
|
+
this.queueIndex = 0;
|
|
125
138
|
this.stats = {
|
|
126
139
|
itemsProcessed: 0,
|
|
127
140
|
itemsSkipped: 0,
|
|
@@ -134,6 +147,6 @@ export class BatchSchemaProcessor {
|
|
|
134
147
|
* Get current queue size (for debugging/monitoring).
|
|
135
148
|
*/
|
|
136
149
|
getQueueSize(): number {
|
|
137
|
-
return this.workQueue.length;
|
|
150
|
+
return this.workQueue.length - this.queueIndex;
|
|
138
151
|
}
|
|
139
152
|
}
|
|
@@ -117,9 +117,10 @@ export class ScopeTreeManager {
|
|
|
117
117
|
*/
|
|
118
118
|
findNode(name: string): ScopeTreeNode | undefined {
|
|
119
119
|
const queue: ScopeTreeNode[] = [this.tree];
|
|
120
|
+
let index = 0;
|
|
120
121
|
|
|
121
|
-
while (queue.length
|
|
122
|
-
const node = queue
|
|
122
|
+
while (index < queue.length) {
|
|
123
|
+
const node = queue[index++]!;
|
|
123
124
|
if (node.name === name) {
|
|
124
125
|
return node;
|
|
125
126
|
}
|
|
@@ -135,9 +136,10 @@ export class ScopeTreeManager {
|
|
|
135
136
|
getAllNames(): string[] {
|
|
136
137
|
const names: string[] = [];
|
|
137
138
|
const queue: ScopeTreeNode[] = [this.tree];
|
|
139
|
+
let index = 0;
|
|
138
140
|
|
|
139
|
-
while (queue.length
|
|
140
|
-
const node = queue
|
|
141
|
+
while (index < queue.length) {
|
|
142
|
+
const node = queue[index++]!;
|
|
141
143
|
names.push(node.name);
|
|
142
144
|
queue.push(...node.children);
|
|
143
145
|
}
|
package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts
CHANGED
|
@@ -35,6 +35,47 @@ const getParts = (path: string): string[] => {
|
|
|
35
35
|
return parts;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
function buildPrefixParts(parts: string[]): string[] {
|
|
39
|
+
if (parts.length === 0) return [];
|
|
40
|
+
const prefixes = new Array(parts.length);
|
|
41
|
+
let current = '';
|
|
42
|
+
for (let i = 0; i < parts.length; i++) {
|
|
43
|
+
const part = parts[i];
|
|
44
|
+
if (i === 0) {
|
|
45
|
+
current = part;
|
|
46
|
+
} else if (part.startsWith('[') || part.startsWith('(')) {
|
|
47
|
+
current += part;
|
|
48
|
+
} else {
|
|
49
|
+
current += `.${part}`;
|
|
50
|
+
}
|
|
51
|
+
prefixes[i] = current;
|
|
52
|
+
}
|
|
53
|
+
return prefixes;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Clear the module-level cache.
|
|
58
|
+
* Call this between entity analyses to prevent unbounded memory growth.
|
|
59
|
+
*/
|
|
60
|
+
export function clearCleanKnownObjectFunctionsCache(): {
|
|
61
|
+
count: number;
|
|
62
|
+
estimatedBytes: number;
|
|
63
|
+
} {
|
|
64
|
+
let totalBytes = 0;
|
|
65
|
+
for (const [key, value] of partsCache) {
|
|
66
|
+
// Key is a string, value is string[] - estimate UTF-16 encoding (2 bytes per char)
|
|
67
|
+
totalBytes += key.length * 2;
|
|
68
|
+
for (const part of value) {
|
|
69
|
+
totalBytes += part.length * 2;
|
|
70
|
+
}
|
|
71
|
+
// Add overhead for array and Map entry (~50 bytes per entry)
|
|
72
|
+
totalBytes += 50;
|
|
73
|
+
}
|
|
74
|
+
const count = partsCache.size;
|
|
75
|
+
partsCache.clear();
|
|
76
|
+
return { count, estimatedBytes: totalBytes };
|
|
77
|
+
}
|
|
78
|
+
|
|
38
79
|
/** pre-compute the prototype-method sets once per module load */
|
|
39
80
|
const protoMethodSets: Record<PrimitiveKind, Set<string>> = {
|
|
40
81
|
array: new Set(
|
|
@@ -110,6 +151,7 @@ function scrub(
|
|
|
110
151
|
|
|
111
152
|
for (const keyPath of sortedKeys) {
|
|
112
153
|
const keyParts = getParts(keyPath);
|
|
154
|
+
const prefixParts = buildPrefixParts(keyParts);
|
|
113
155
|
|
|
114
156
|
if (
|
|
115
157
|
IGNORE_CLASSES_AND_OBJECTS.find(
|
|
@@ -122,7 +164,7 @@ function scrub(
|
|
|
122
164
|
|
|
123
165
|
// walk back through the prefixes: foo.bar.baz.qux → foo.bar.baz → foo.bar …
|
|
124
166
|
for (let cut = keyParts.length - 1; cut > 0; --cut) {
|
|
125
|
-
const prefix =
|
|
167
|
+
const prefix = prefixParts[cut - 1];
|
|
126
168
|
const rootKind = rootTable.get(prefix);
|
|
127
169
|
if (!rootKind) continue;
|
|
128
170
|
|
package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts
CHANGED
|
@@ -119,6 +119,17 @@ const stringMethodsSet = new Set([
|
|
|
119
119
|
]);
|
|
120
120
|
export const allMethodsSet = new Set([...arrayMethodsSet, ...stringMethodsSet]);
|
|
121
121
|
|
|
122
|
+
// Methods that exist in both stringMethodsSet and arrayMethodsSet.
|
|
123
|
+
// When ONLY these methods are called on an object, we can't determine if it's a string or array.
|
|
124
|
+
// Don't infer 'string' type from these alone - leave as 'unknown' for other type resolution.
|
|
125
|
+
const stringArrayAmbiguousMethodsSet = new Set([
|
|
126
|
+
'includes', // exists in both String.includes() and Array.includes()
|
|
127
|
+
'indexOf', // exists in both String.indexOf() and Array.indexOf()
|
|
128
|
+
'lastIndexOf', // exists in both String.lastIndexOf() and Array.lastIndexOf()
|
|
129
|
+
'concat', // exists in both String.concat() and Array.concat()
|
|
130
|
+
'slice', // exists in both String.slice() and Array.slice()
|
|
131
|
+
]);
|
|
132
|
+
|
|
122
133
|
const signatureKeyWord = 'signature';
|
|
123
134
|
const returnValueKeyWord = 'functionCallReturnValue';
|
|
124
135
|
|
|
@@ -140,21 +151,63 @@ function cachedSplit(str: string): string[] {
|
|
|
140
151
|
return parts;
|
|
141
152
|
}
|
|
142
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Clear the module-level cache.
|
|
156
|
+
* Call this between entity analyses to prevent unbounded memory growth.
|
|
157
|
+
*/
|
|
158
|
+
export function clearCleanNonObjectFunctionsCache(): {
|
|
159
|
+
count: number;
|
|
160
|
+
estimatedBytes: number;
|
|
161
|
+
} {
|
|
162
|
+
let totalBytes = 0;
|
|
163
|
+
for (const [key, value] of splitCache) {
|
|
164
|
+
// Key is a string, value is string[] - estimate UTF-16 encoding (2 bytes per char)
|
|
165
|
+
totalBytes += key.length * 2;
|
|
166
|
+
for (const part of value) {
|
|
167
|
+
totalBytes += part.length * 2;
|
|
168
|
+
}
|
|
169
|
+
// Add overhead for array and Map entry (~50 bytes per entry)
|
|
170
|
+
totalBytes += 50;
|
|
171
|
+
}
|
|
172
|
+
const count = splitCache.size;
|
|
173
|
+
splitCache.clear();
|
|
174
|
+
return { count, estimatedBytes: totalBytes };
|
|
175
|
+
}
|
|
176
|
+
|
|
143
177
|
// --- Prefix Index for O(1) lookup in subPathIsFromKnownObject ---
|
|
144
178
|
// Maps parent prefix -> array of last parts (method names without parens)
|
|
145
179
|
type PrefixIndex = Map<string, string[]>;
|
|
146
180
|
|
|
181
|
+
function buildPrefixPartsWithRoot(parts: string[]): string[] {
|
|
182
|
+
const prefixes = new Array(parts.length + 1);
|
|
183
|
+
prefixes[0] = '';
|
|
184
|
+
let current = '';
|
|
185
|
+
for (let i = 0; i < parts.length; i++) {
|
|
186
|
+
const part = parts[i];
|
|
187
|
+
if (i === 0) {
|
|
188
|
+
current = part;
|
|
189
|
+
} else if (part.startsWith('[') || part.startsWith('(')) {
|
|
190
|
+
current += part;
|
|
191
|
+
} else {
|
|
192
|
+
current += `.${part}`;
|
|
193
|
+
}
|
|
194
|
+
prefixes[i + 1] = current;
|
|
195
|
+
}
|
|
196
|
+
return prefixes;
|
|
197
|
+
}
|
|
198
|
+
|
|
147
199
|
function buildPrefixIndex(allPaths: string[]): PrefixIndex {
|
|
148
200
|
const index: PrefixIndex = new Map();
|
|
149
201
|
|
|
150
202
|
for (const path of allPaths) {
|
|
151
203
|
const parts = cachedSplit(path);
|
|
152
204
|
if (parts.length < 1) continue;
|
|
205
|
+
const prefixes = buildPrefixPartsWithRoot(parts);
|
|
153
206
|
|
|
154
207
|
// For each possible prefix length, add the last part to that prefix's entry
|
|
155
208
|
// This allows lookup at any depth
|
|
156
209
|
for (let prefixLen = 0; prefixLen < parts.length; prefixLen++) {
|
|
157
|
-
const prefix =
|
|
210
|
+
const prefix = prefixes[prefixLen];
|
|
158
211
|
const lastPart = parts[prefixLen]?.split('(')?.[0];
|
|
159
212
|
if (lastPart) {
|
|
160
213
|
let existing = index.get(prefix);
|
|
@@ -697,7 +750,14 @@ function handleFunctionMapping(
|
|
|
697
750
|
allProperties.every((prop) => stringMethodsSet.has(getMethodName(prop)))
|
|
698
751
|
) {
|
|
699
752
|
if (allProperties.every((prop) => isValidStringMethod(prop))) {
|
|
700
|
-
|
|
753
|
+
// Don't infer string if ALL methods are ambiguous between string and array
|
|
754
|
+
// (like includes, indexOf, concat, slice - these exist on both types)
|
|
755
|
+
const hasOnlyStringArrayAmbiguousMethods = allProperties.every(
|
|
756
|
+
(prop) => stringArrayAmbiguousMethodsSet.has(getMethodName(prop)),
|
|
757
|
+
);
|
|
758
|
+
if (!hasOnlyStringArrayAmbiguousMethods) {
|
|
759
|
+
keyMapping[previousPath] = 'string';
|
|
760
|
+
}
|
|
701
761
|
} else {
|
|
702
762
|
return false;
|
|
703
763
|
}
|
|
@@ -718,19 +778,36 @@ function handleFunctionMapping(
|
|
|
718
778
|
|
|
719
779
|
// Don't add [] element for ambiguous methods without other array evidence
|
|
720
780
|
// Also don't add [] if the path was already identified as a string type
|
|
781
|
+
// Also don't add [] if the method is ambiguous between string and array (like includes)
|
|
721
782
|
const methodName = getMethodName(lastPart);
|
|
722
783
|
const isAmbiguousMethod = ambiguousArrayMethodsSet.has(methodName);
|
|
784
|
+
const isStringArrayAmbiguous =
|
|
785
|
+
stringArrayAmbiguousMethodsSet.has(methodName);
|
|
723
786
|
const isStringType = keyMapping[previousPath] === 'string';
|
|
724
787
|
if (
|
|
725
788
|
!isValidFunctionCall(previousPart) &&
|
|
726
789
|
arrayMethodsSet.has(methodName) &&
|
|
727
790
|
!keyMapping[previousPath + '[]'] &&
|
|
728
791
|
!isAmbiguousMethod &&
|
|
792
|
+
!isStringArrayAmbiguous &&
|
|
729
793
|
!isStringType
|
|
730
794
|
) {
|
|
731
795
|
keyMapping[previousPath + '[]'] = 'unknown';
|
|
732
796
|
}
|
|
733
797
|
|
|
798
|
+
// For primitive-returning methods (like includes, indexOf, some, every),
|
|
799
|
+
// also delete the .functionCallReturnValue children since the return value
|
|
800
|
+
// is just a primitive (boolean/number) and not useful data.
|
|
801
|
+
// For other methods (like filter, map), keep children for transformation.
|
|
802
|
+
const isPrimitiveReturning = primitiveReturningMethodsSet.has(methodName);
|
|
803
|
+
if (isPrimitiveReturning) {
|
|
804
|
+
for (const otherPath of Object.keys(keyMapping)) {
|
|
805
|
+
if (otherPath.startsWith(path + '.')) {
|
|
806
|
+
delete keyMapping[otherPath];
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
734
811
|
delete keyMapping[path];
|
|
735
812
|
return true;
|
|
736
813
|
}
|
|
@@ -956,14 +1033,34 @@ function clearAttributes(
|
|
|
956
1033
|
}
|
|
957
1034
|
}
|
|
958
1035
|
|
|
1036
|
+
// Track paths that have primitive-returning method calls (like includes, some, every)
|
|
1037
|
+
// These need cleanup even if we can't determine the base type
|
|
1038
|
+
const pathsWithPrimitiveReturningMethods = new Set<string>();
|
|
1039
|
+
|
|
959
1040
|
for (const key in functionCallsOnObjects) {
|
|
960
1041
|
const functionCalls = functionCallsOnObjects[key];
|
|
1042
|
+
|
|
1043
|
+
// Check if any method calls are primitive-returning
|
|
1044
|
+
const hasPrimitiveReturningMethods = functionCalls.some((f) =>
|
|
1045
|
+
primitiveReturningMethodsSet.has(getMethodName(f)),
|
|
1046
|
+
);
|
|
1047
|
+
if (hasPrimitiveReturningMethods) {
|
|
1048
|
+
pathsWithPrimitiveReturningMethods.add(key);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
961
1051
|
if (
|
|
962
1052
|
functionCalls.every(
|
|
963
1053
|
(f) => stringMethodsSet.has(getMethodName(f)) && isValidStringMethod(f),
|
|
964
1054
|
)
|
|
965
1055
|
) {
|
|
966
|
-
|
|
1056
|
+
// Don't infer string if ALL methods are ambiguous between string and array
|
|
1057
|
+
// (like includes, indexOf, concat, slice - these exist on both types)
|
|
1058
|
+
const hasOnlyStringArrayAmbiguousMethods = functionCalls.every((f) =>
|
|
1059
|
+
stringArrayAmbiguousMethodsSet.has(getMethodName(f)),
|
|
1060
|
+
);
|
|
1061
|
+
if (!hasOnlyStringArrayAmbiguousMethods) {
|
|
1062
|
+
mapping[key] = 'string';
|
|
1063
|
+
}
|
|
967
1064
|
} else if (
|
|
968
1065
|
functionCalls.every(
|
|
969
1066
|
(f) => arrayMethodsSet.has(getMethodName(f)) && isValidArrayMethod(f),
|
|
@@ -1000,29 +1097,39 @@ function clearAttributes(
|
|
|
1000
1097
|
}
|
|
1001
1098
|
}
|
|
1002
1099
|
|
|
1100
|
+
// Also add paths with primitive-returning method calls (like includes, some, every)
|
|
1101
|
+
// to knownBasePaths so their method call paths get cleaned up, even if we couldn't
|
|
1102
|
+
// determine the base type (e.g., when only ambiguous methods like includes are used)
|
|
1103
|
+
for (const path of pathsWithPrimitiveReturningMethods) {
|
|
1104
|
+
knownBasePaths.add(path);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// OPTIMIZATION: Instead of O(keys × basePaths), use O(keys × keyDepth) where keyDepth is small
|
|
1108
|
+
// For each key, find all its prefixes and check if any is a known basePath (O(1) Set lookup)
|
|
1003
1109
|
for (const key in mapping) {
|
|
1004
1110
|
const keyParts = cachedSplit(key);
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
)
|
|
1012
|
-
|
|
1111
|
+
if (keyParts.length <= 1) continue; // No possible parent basePath
|
|
1112
|
+
|
|
1113
|
+
// Check each prefix of the key to see if it's a known basePath
|
|
1114
|
+
// Start from shortest prefix (most likely to match) for early exit
|
|
1115
|
+
for (let prefixLen = 1; prefixLen < keyParts.length; prefixLen++) {
|
|
1116
|
+
const prefix = joinParenthesesAndArrays(keyParts.slice(0, prefixLen));
|
|
1117
|
+
if (!knownBasePaths.has(prefix)) continue;
|
|
1118
|
+
|
|
1119
|
+
// Found a matching basePath - now check the conditions
|
|
1120
|
+
const basePath = prefix;
|
|
1121
|
+
|
|
1013
1122
|
// Preserve functionCallReturnValue for non-string types, UNLESS
|
|
1014
1123
|
// the method is a primitive-returning method (like some, every, includes, indexOf)
|
|
1015
1124
|
// whose return values are not mockable
|
|
1016
|
-
const methodPart = keyParts[
|
|
1125
|
+
const methodPart = keyParts[prefixLen];
|
|
1017
1126
|
const methodName = methodPart?.split('(')[0];
|
|
1018
1127
|
const isPrimitiveReturning = primitiveReturningMethodsSet.has(
|
|
1019
1128
|
methodName ?? '',
|
|
1020
1129
|
);
|
|
1021
1130
|
if (
|
|
1022
1131
|
mapping[basePath] !== 'string' &&
|
|
1023
|
-
keyParts[
|
|
1024
|
-
'functionCallReturnValue',
|
|
1025
|
-
) &&
|
|
1132
|
+
keyParts[prefixLen + 1]?.startsWith('functionCallReturnValue') &&
|
|
1026
1133
|
!isPrimitiveReturning
|
|
1027
1134
|
)
|
|
1028
1135
|
continue;
|