@codeyam/codeyam-cli 0.1.0-staging.323686 → 0.1.0-staging.4684848
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 +6 -6
- package/analyzer-template/packages/ai/index.ts +7 -1
- package/analyzer-template/packages/ai/package.json +2 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +62 -18
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +67 -9
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +409 -50
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +21 -6
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +992 -249
- 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 +31 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +37 -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 +140 -14
- 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 +367 -96
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +33 -15
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +315 -6
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +9 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +49 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +649 -142
- 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/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +24 -4
- 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/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 +89 -9
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +19 -4
- 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 +87 -25
- 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 +571 -74
- 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 +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -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/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 +3 -0
- 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/debugReportsTable.d.ts +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/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/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/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/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/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +108 -2
- package/analyzer-template/project/constructMockCode.ts +90 -10
- 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/background/src/lib/local/createLocalAnalyzer.js +1 -1
- package/background/src/lib/local/createLocalAnalyzer.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/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 +2 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +4 -2
- 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 +31 -20
- 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 +49 -257
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +17 -26
- package/codeyam-cli/src/commands/memory.js.map +1 -1
- 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 +14 -2
- 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/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +9 -0
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +2 -2
- package/codeyam-cli/src/utils/install-skills.js +70 -45
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -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 +1 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -1
- package/codeyam-cli/src/utils/rules/parser.js +2 -25
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -1
- 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 +16 -11
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -1
- package/codeyam-cli/src/utils/serverState.js +37 -10
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -44
- 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 +24 -0
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CQ-wF3Tv.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-DsN1wKrm.js → EntityItem-HdckCi0m.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DLqD3qNt.js → EntityTypeBadge-Dh5RJMOE.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-Ba2JVPzP.js → EntityTypeIcon-BnjjBHJu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-C8lyxW9k.js → InlineSpinner-CUSfu6W5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-aht4aafF.js → InteractivePreview-Coll1aD6.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CVtiBnY5.js → LibraryFunctionPreview-lYMY8h-y.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-B0GLXMsr.js → LoadingDots-ay8XeA59.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-xgeCVgSM.js → LogViewer-Dpul1_ik.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-OApQuNyq.js → ReportIssueModal-CRBCfV2W.js} +3 -8
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DuDvi0jm.js → SafeScreenshot-DRTFDNFt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DzccYyI8.js → ScenarioViewer-d6PSFxhS.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-DyFZkK0l.js → TruncatedFilePath-DDEOQ6Iw.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{_index-BwqWJOgH.js → _index-CkziGg5F.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BwavGCpm.js → activity.(_tab)-B2v1pm9w.js} +6 -11
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-BXIaK8Md.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-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.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-qbapxy6o.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-Cx24_aWc.js → chevron-down-C-mKrwr1.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-CXRTFQ3F.js → chunk-JZWAC4HX-BAvUl1nT.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BOARzkeR.js → circle-check-DlrT-SzI.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-clIxnCqQ.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-BdhJEx6B.js → createLucideIcon-B931Etud.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BBnGWYga.js → dev.empty-BoPM6KnE.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-oVRMh9Hl.js +16 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js → entity._sha.scenarios._scenarioId.fullscreen-BjyzwQ7H.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D1T4TGjf.js → entity._sha_.create-scenario-DxuyDmZA.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CTBG2mmz.js → entity._sha_.edit._scenarioId-DESSZGQp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CS2cb_eZ.js → entry.client-D5Yb90Ad.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DMJ7zii9.js → fileTableUtils-DuObVYgh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{files-CJ6lTdTA.js → files-CDfz4Y-i.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{git-CPTZZ-JZ.js → git-D6jOlDQw.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-CKT08Djd.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-B1h680n5.js → index-DvOt1KIt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-lzqtyFU8.js → index-WfQFdoWK.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-BbGyC1RY.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-B7B9V-bu.js → loader-circle-Bb7Y9k5O.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-fd06e67a.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-BXebUPaL.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-DaAHX2on.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-CvNE9MaT.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-CxXUmBSd.js → search-DIqAPIrO.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-DCIzBZM9.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-DwFIBT09.js → simulations-C6n_fNQY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/terminal-CmPsszJy.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-B6LgvRJg.js → triangle-alert-Beg-oV50.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-C1v1PQzo.js → useCustomSizes-D7TLbP3M.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-aSv48UbS.js → useLastLogLine-Ce5rnai3.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DYxHZQuP.js → useReportContext-B4D3wj27.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-mBRpZPiu.js → useToast-BDt_-DnY.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-DVzYx8PN.js → index-DDr9Cp9M.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-DjwiujaU.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:debug.md → codeyam-debug.md} +1 -1
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +19 -20
- package/codeyam-cli/templates/codeyam-memory.md +392 -0
- package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
- package/codeyam-cli/templates/{codeyam:setup.md → codeyam-setup.md} +13 -1
- package/codeyam-cli/templates/{codeyam:sim.md → codeyam-sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam:test.md → codeyam-test.md} +1 -1
- package/codeyam-cli/templates/{codeyam:verify.md → codeyam-verify.md} +1 -1
- 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 +132 -0
- package/package.json +10 -10
- package/packages/ai/index.js +3 -2
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +50 -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/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 +317 -44
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +763 -171
- 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 +33 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +36 -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 +122 -12
- 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 +309 -84
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructureChunking.js +26 -11
- package/packages/ai/src/lib/dataStructureChunking.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 +227 -4
- 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 +26 -4
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +447 -80
- 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/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.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/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- 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/generateEntityScenarioDataGenerator.js +17 -2
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.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/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 +65 -7
- 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/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 +75 -21
- 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 +478 -54
- 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 +3 -0
- package/packages/database/src/lib/kysely/db.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/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/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -76
- package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-BJUiQqZF.js +0 -23
- package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-7522edd4.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-yxFcrxBX.js +0 -92
- package/codeyam-cli/src/webserver/build/client/assets/root-eVAaavTS.js +0 -62
- package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-4Cr0uToj.js +0 -257
- package/codeyam-cli/templates/codeyam:diagnose.md +0 -803
- package/codeyam-cli/templates/codeyam:memory.md +0 -462
- package/codeyam-cli/templates/codeyam:new-rule.md +0 -13
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { splitOutsideParenthesesAndArrays, joinParenthesesAndArrays, } from "../../../../../../packages/ai/index.js";
|
|
2
2
|
import { cleanKnownObjectFunctionsFromMapping } from "../../../../../../packages/ai/index.js";
|
|
3
|
+
import { transformationTracer } from "./TransformationTracer.js";
|
|
3
4
|
function cleanFunctionName(functionName) {
|
|
4
5
|
return functionName?.split('<')[0];
|
|
5
6
|
}
|
|
@@ -24,6 +25,50 @@ function getTypeParameter(functionName) {
|
|
|
24
25
|
}
|
|
25
26
|
return null;
|
|
26
27
|
}
|
|
28
|
+
// Primitive types that should not have child paths
|
|
29
|
+
const PRIMITIVE_TYPES = new Set([
|
|
30
|
+
'number',
|
|
31
|
+
'string',
|
|
32
|
+
'boolean',
|
|
33
|
+
'null',
|
|
34
|
+
'undefined',
|
|
35
|
+
]);
|
|
36
|
+
// Check if a type string represents a primitive type
|
|
37
|
+
// Handles union types like "string | undefined" or "number | null"
|
|
38
|
+
function isPrimitiveType(typeStr) {
|
|
39
|
+
if (PRIMITIVE_TYPES.has(typeStr)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
// Check union types - if ALL parts of the union are primitives, it's primitive
|
|
43
|
+
// e.g., "string | undefined" -> ["string", "undefined"] -> both are primitive -> true
|
|
44
|
+
// e.g., "object | null" -> ["object", "null"] -> object is not primitive -> false
|
|
45
|
+
if (typeStr.includes('|')) {
|
|
46
|
+
const parts = typeStr.split('|').map((p) => p.trim());
|
|
47
|
+
return parts.every((part) => PRIMITIVE_TYPES.has(part));
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// Extract signature index from a path like "signature[0]" or "signature[0].foo"
|
|
52
|
+
// Returns the index number or undefined if not a signature path
|
|
53
|
+
function extractSignatureIndex(path) {
|
|
54
|
+
const match = path.match(/^signature\[(\d+)\]/);
|
|
55
|
+
return match ? parseInt(match[1], 10) : undefined;
|
|
56
|
+
}
|
|
57
|
+
// Check if a new schema path would go through a primitive type
|
|
58
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', then
|
|
59
|
+
// 'entities[].scenarioCount.sha' would go through a primitive and should be rejected
|
|
60
|
+
function wouldGoThroughPrimitive(newPath, schema) {
|
|
61
|
+
const pathParts = splitOutsideParenthesesAndArrays(newPath);
|
|
62
|
+
// Check each prefix of the path (excluding the full path itself)
|
|
63
|
+
for (let i = 1; i < pathParts.length; i++) {
|
|
64
|
+
const prefixPath = joinParenthesesAndArrays(pathParts.slice(0, i));
|
|
65
|
+
const prefixType = schema[prefixPath];
|
|
66
|
+
if (prefixType && isPrimitiveType(prefixType)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
27
72
|
// Check if schemaPathPart matches or is a function call variant of pathPart
|
|
28
73
|
// e.g., 'isEntityBeingAnalyzed(entity.sha)' matches 'isEntityBeingAnalyzed'
|
|
29
74
|
function pathPartMatches(pathPart, schemaPathPart) {
|
|
@@ -39,11 +84,13 @@ function pathPartMatches(pathPart, schemaPathPart) {
|
|
|
39
84
|
function bestValueFromOptions(options) {
|
|
40
85
|
options = options.filter(Boolean);
|
|
41
86
|
const known = options.find((o) => !o.includes('unknown'));
|
|
42
|
-
if (known)
|
|
87
|
+
if (known) {
|
|
43
88
|
return known;
|
|
89
|
+
}
|
|
44
90
|
const notUnknown = options.find((o) => o !== 'unknown');
|
|
45
|
-
if (notUnknown)
|
|
91
|
+
if (notUnknown) {
|
|
46
92
|
return notUnknown;
|
|
93
|
+
}
|
|
47
94
|
return options[0] ?? 'unknown';
|
|
48
95
|
}
|
|
49
96
|
export default function mergeInDependentDataStructure({ importedExports, dependentAnalyses, rootScopeName, dataStructure, dependencySchemas, }) {
|
|
@@ -88,8 +135,32 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
88
135
|
}
|
|
89
136
|
}
|
|
90
137
|
let equivalentSchemaPaths = [];
|
|
138
|
+
// O(1) index for findOrCreateEquivalentSchemaPathsEntry.
|
|
139
|
+
// Maps "(rootPath)::(normalizedFuncName)" → the entry containing that root.
|
|
140
|
+
// This replaces the O(E) linear search that was causing O(E²) gather performance.
|
|
141
|
+
const espIndex = new Map();
|
|
142
|
+
const espIndexKey = (path, functionName) => {
|
|
143
|
+
const normalized = cleanFunctionName(functionName);
|
|
144
|
+
const funcKey = normalized === rootScopeName ? '__self__' : normalized || '__self__';
|
|
145
|
+
return `${path}::${funcKey}`;
|
|
146
|
+
};
|
|
147
|
+
const updateEspIndex = (entry) => {
|
|
148
|
+
for (const root of entry.equivalentRoots) {
|
|
149
|
+
const funcName = root.function?.name ?? rootScopeName;
|
|
150
|
+
espIndex.set(espIndexKey(root.schemaRootPath, funcName), entry);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
// Pre-build a lookup map from cleaned function name to dependency for O(1) lookups.
|
|
154
|
+
// This avoids O(n) linear search in findRelevantDependency which was causing O(n²) performance.
|
|
155
|
+
const dependencyByCleanedName = new Map();
|
|
156
|
+
for (const dep of importedExports) {
|
|
157
|
+
const cleanedName = cleanFunctionName(dep.name);
|
|
158
|
+
if (!dependencyByCleanedName.has(cleanedName)) {
|
|
159
|
+
dependencyByCleanedName.set(cleanedName, dep);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
91
162
|
const findRelevantDependency = (functionName) => {
|
|
92
|
-
return
|
|
163
|
+
return dependencyByCleanedName.get(cleanFunctionName(functionName));
|
|
93
164
|
};
|
|
94
165
|
const findRelevantDependentDataStructure = (functionName) => {
|
|
95
166
|
const dependency = findRelevantDependency(functionName);
|
|
@@ -117,8 +188,8 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
117
188
|
});
|
|
118
189
|
return mergedDataStructure.dependencySchemas[filePath][name];
|
|
119
190
|
};
|
|
120
|
-
const cleanSchema = (schema) => {
|
|
121
|
-
cleanKnownObjectFunctionsFromMapping
|
|
191
|
+
const cleanSchema = (schema, context) => {
|
|
192
|
+
transformationTracer.traceSchemaTransform(rootScopeName, 'cleanKnownObjectFunctionsFromMapping', schema, cleanKnownObjectFunctionsFromMapping, context);
|
|
122
193
|
};
|
|
123
194
|
const translatePath = (path, dependencyName) => {
|
|
124
195
|
if (path.startsWith(dependencyName)) {
|
|
@@ -158,6 +229,41 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
158
229
|
const gatherAllEquivalentSchemaPaths = (functionName, sourceAndUsageEquivalencies, dataStructure) => {
|
|
159
230
|
if (!sourceAndUsageEquivalencies)
|
|
160
231
|
return;
|
|
232
|
+
const normalizedSchemaCache = new Map();
|
|
233
|
+
const getSchemaIndex = (schema) => {
|
|
234
|
+
if (!schema)
|
|
235
|
+
return { byFirstPart: new Map() };
|
|
236
|
+
const cached = normalizedSchemaCache.get(schema);
|
|
237
|
+
if (cached)
|
|
238
|
+
return cached;
|
|
239
|
+
const byFirstPart = new Map();
|
|
240
|
+
for (const path in schema) {
|
|
241
|
+
let parts = splitOutsideParenthesesAndArrays(path);
|
|
242
|
+
if (parts[0].startsWith(functionName)) {
|
|
243
|
+
const baseName = cleanFunctionName(parts[0]);
|
|
244
|
+
if (!functionsWithMultipleTypeParams.has(baseName)) {
|
|
245
|
+
parts =
|
|
246
|
+
parts[1] === 'functionCallReturnValue'
|
|
247
|
+
? ['returnValue', ...parts.slice(2)]
|
|
248
|
+
: parts.slice(1);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const entry = { path, parts };
|
|
252
|
+
// Index by the base of the first part (before any function call args)
|
|
253
|
+
const firstPart = parts[0] ?? '';
|
|
254
|
+
const parenIdx = firstPart.indexOf('(');
|
|
255
|
+
const firstPartBase = parenIdx >= 0 ? firstPart.slice(0, parenIdx) : firstPart;
|
|
256
|
+
let bucket = byFirstPart.get(firstPartBase);
|
|
257
|
+
if (!bucket) {
|
|
258
|
+
bucket = [];
|
|
259
|
+
byFirstPart.set(firstPartBase, bucket);
|
|
260
|
+
}
|
|
261
|
+
bucket.push(entry);
|
|
262
|
+
}
|
|
263
|
+
const result = { byFirstPart };
|
|
264
|
+
normalizedSchemaCache.set(schema, result);
|
|
265
|
+
return result;
|
|
266
|
+
};
|
|
161
267
|
const findOrCreateEquivalentSchemaPathsEntry = (allPaths) => {
|
|
162
268
|
const equivalentRoots = allPaths
|
|
163
269
|
.filter((p) => p.functionName === rootScopeName ||
|
|
@@ -169,19 +275,93 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
169
275
|
: findRelevantDependency(p.functionName),
|
|
170
276
|
}));
|
|
171
277
|
let equivalentSchemaPathsEntry;
|
|
278
|
+
// Collect the signature indices from the new roots we want to add
|
|
279
|
+
const newRootSignatureIndices = new Set();
|
|
280
|
+
for (const root of equivalentRoots) {
|
|
281
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
282
|
+
if (idx !== undefined) {
|
|
283
|
+
newRootSignatureIndices.add(idx);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// Use espIndex Map for O(1) lookup instead of O(E) linear search.
|
|
287
|
+
// Falls back to linear search only when Map hit has a signature index conflict.
|
|
172
288
|
for (const pathInfo of allPaths) {
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
289
|
+
if (equivalentSchemaPathsEntry)
|
|
290
|
+
break;
|
|
291
|
+
const candidate = espIndex.get(espIndexKey(pathInfo.path, pathInfo.functionName));
|
|
292
|
+
if (!candidate)
|
|
293
|
+
continue;
|
|
294
|
+
// Verify no signature index conflict with the candidate entry
|
|
295
|
+
if (newRootSignatureIndices.size > 0) {
|
|
296
|
+
const existingIndicesByFunction = new Map();
|
|
297
|
+
for (const er of candidate.equivalentRoots) {
|
|
298
|
+
const funcKey = er.function
|
|
299
|
+
? `${er.function.name}::${er.function.filePath}`
|
|
300
|
+
: '__self__';
|
|
301
|
+
const idx = extractSignatureIndex(er.schemaRootPath);
|
|
302
|
+
if (idx !== undefined) {
|
|
303
|
+
if (!existingIndicesByFunction.has(funcKey)) {
|
|
304
|
+
existingIndicesByFunction.set(funcKey, new Set());
|
|
305
|
+
}
|
|
306
|
+
existingIndicesByFunction.get(funcKey).add(idx);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
let hasConflict = false;
|
|
310
|
+
for (const newRoot of equivalentRoots) {
|
|
311
|
+
const funcKey = newRoot.function
|
|
312
|
+
? `${newRoot.function.name}::${newRoot.function.filePath}`
|
|
313
|
+
: '__self__';
|
|
314
|
+
const newIdx = extractSignatureIndex(newRoot.schemaRootPath);
|
|
315
|
+
if (newIdx !== undefined) {
|
|
316
|
+
const existingIndices = existingIndicesByFunction.get(funcKey);
|
|
317
|
+
if (existingIndices && existingIndices.size > 0) {
|
|
318
|
+
if (!existingIndices.has(newIdx)) {
|
|
319
|
+
hasConflict = true;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (hasConflict)
|
|
326
|
+
continue;
|
|
180
327
|
}
|
|
328
|
+
equivalentSchemaPathsEntry = candidate;
|
|
181
329
|
}
|
|
182
330
|
if (!equivalentSchemaPathsEntry) {
|
|
331
|
+
// Before creating a new entry, filter out roots that have conflicting
|
|
332
|
+
// signature indices from the same function. An entry should never contain
|
|
333
|
+
// roots with different signature indices from the same function.
|
|
334
|
+
// This prevents the bug where signature[1], signature[2], signature[4]
|
|
335
|
+
// all get merged together due to incorrect sourceEquivalencies.
|
|
336
|
+
let filteredRoots = equivalentRoots;
|
|
337
|
+
if (newRootSignatureIndices.size > 1) {
|
|
338
|
+
// There are multiple signature indices - we need to filter to keep only
|
|
339
|
+
// one consistent set. We'll keep the roots that match the PRIMARY index
|
|
340
|
+
// (the first signature index we encounter from self, or the lowest index).
|
|
341
|
+
// First, determine the primary index - prefer the self root's index
|
|
342
|
+
let primaryIndex;
|
|
343
|
+
for (const root of equivalentRoots) {
|
|
344
|
+
if (!root.function) {
|
|
345
|
+
// This is a self root
|
|
346
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
347
|
+
if (idx !== undefined) {
|
|
348
|
+
primaryIndex = idx;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// If no self root has a signature index, use the lowest index
|
|
354
|
+
if (primaryIndex === undefined) {
|
|
355
|
+
primaryIndex = Math.min(...newRootSignatureIndices);
|
|
356
|
+
}
|
|
357
|
+
// Filter roots: keep if no signature index OR signature index matches primary
|
|
358
|
+
filteredRoots = equivalentRoots.filter((root) => {
|
|
359
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
360
|
+
return idx === undefined || idx === primaryIndex;
|
|
361
|
+
});
|
|
362
|
+
}
|
|
183
363
|
equivalentSchemaPathsEntry = {
|
|
184
|
-
equivalentRoots,
|
|
364
|
+
equivalentRoots: filteredRoots,
|
|
185
365
|
equivalentPostfixes: {},
|
|
186
366
|
};
|
|
187
367
|
equivalentSchemaPaths.push(equivalentSchemaPathsEntry);
|
|
@@ -189,10 +369,18 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
189
369
|
else {
|
|
190
370
|
equivalentSchemaPathsEntry.equivalentRoots.push(...equivalentRoots);
|
|
191
371
|
}
|
|
372
|
+
// Deduplicate roots using a Set for O(n) instead of O(n²)
|
|
373
|
+
const seenRoots = new Set();
|
|
192
374
|
equivalentSchemaPathsEntry.equivalentRoots =
|
|
193
|
-
equivalentSchemaPathsEntry.equivalentRoots.filter((er
|
|
194
|
-
|
|
195
|
-
|
|
375
|
+
equivalentSchemaPathsEntry.equivalentRoots.filter((er) => {
|
|
376
|
+
const key = er.schemaRootPath + '::' + (er.function?.name ?? '');
|
|
377
|
+
if (seenRoots.has(key))
|
|
378
|
+
return false;
|
|
379
|
+
seenRoots.add(key);
|
|
380
|
+
return true;
|
|
381
|
+
});
|
|
382
|
+
// Keep the espIndex in sync after adding/deduplicating roots
|
|
383
|
+
updateEspIndex(equivalentSchemaPathsEntry);
|
|
196
384
|
return equivalentSchemaPathsEntry;
|
|
197
385
|
};
|
|
198
386
|
// Helper to extract function name from a path that starts with a function call.
|
|
@@ -248,6 +436,8 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
248
436
|
p.functionName === rootScopeName ||
|
|
249
437
|
p.functionName === effectiveFunctionName);
|
|
250
438
|
const derivedBasePaths = [];
|
|
439
|
+
const allPathSet = new Set(allPaths.map((p) => p.path));
|
|
440
|
+
const derivedBasePathSet = new Set();
|
|
251
441
|
// For each child path, find its equivalent parent path and derive bases
|
|
252
442
|
for (const childPathInfo of childPaths) {
|
|
253
443
|
const childParts = splitOutsideParenthesesAndArrays(childPathInfo.path);
|
|
@@ -296,23 +486,23 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
296
486
|
parentHasArrayIterator &&
|
|
297
487
|
!childHasArrayIterator &&
|
|
298
488
|
!childBaseIsGenericSignature) {
|
|
299
|
-
// Add child base if not already present
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (!childBaseExists) {
|
|
489
|
+
// Add child base if not already present (O(1) Set lookup)
|
|
490
|
+
if (!allPathSet.has(childBase) &&
|
|
491
|
+
!derivedBasePathSet.has(childBase)) {
|
|
303
492
|
derivedBasePaths.push({
|
|
304
493
|
path: childBase,
|
|
305
494
|
functionName: childPathInfo.functionName,
|
|
306
495
|
});
|
|
496
|
+
derivedBasePathSet.add(childBase);
|
|
307
497
|
}
|
|
308
|
-
// Add parent base if not already present
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (!parentBaseExists) {
|
|
498
|
+
// Add parent base if not already present (O(1) Set lookup)
|
|
499
|
+
if (!allPathSet.has(parentBase) &&
|
|
500
|
+
!derivedBasePathSet.has(parentBase)) {
|
|
312
501
|
derivedBasePaths.push({
|
|
313
502
|
path: parentBase,
|
|
314
503
|
functionName: parentPathInfo.functionName,
|
|
315
504
|
});
|
|
505
|
+
derivedBasePathSet.add(parentBase);
|
|
316
506
|
}
|
|
317
507
|
}
|
|
318
508
|
}
|
|
@@ -321,6 +511,25 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
321
511
|
}
|
|
322
512
|
allPaths.push(...derivedBasePaths);
|
|
323
513
|
const entry = findOrCreateEquivalentSchemaPathsEntry(allPaths);
|
|
514
|
+
// Trace equivalency gathering - helps debug why paths may not be connected
|
|
515
|
+
if (allPaths.length > 1) {
|
|
516
|
+
transformationTracer.operation(rootScopeName, {
|
|
517
|
+
operation: 'gatherEquivalency',
|
|
518
|
+
stage: 'gathering',
|
|
519
|
+
path: translatedPath,
|
|
520
|
+
context: {
|
|
521
|
+
sourceFunction: functionName,
|
|
522
|
+
equivalentPaths: allPaths.map((p) => ({
|
|
523
|
+
path: p.path,
|
|
524
|
+
function: p.functionName,
|
|
525
|
+
})),
|
|
526
|
+
equivalentRoots: entry.equivalentRoots.map((r) => ({
|
|
527
|
+
path: r.schemaRootPath,
|
|
528
|
+
function: r.function?.name,
|
|
529
|
+
})),
|
|
530
|
+
},
|
|
531
|
+
});
|
|
532
|
+
}
|
|
324
533
|
for (const equivalentRoot of entry.equivalentRoots) {
|
|
325
534
|
const dataStructures = equivalentRoot.function &&
|
|
326
535
|
equivalentRoot.function.name !== rootScopeName
|
|
@@ -349,18 +558,16 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
349
558
|
pathParts = pathParts.slice(1);
|
|
350
559
|
}
|
|
351
560
|
for (const schema of schemas) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
}
|
|
561
|
+
// Use pre-computed index to only iterate schema entries whose
|
|
562
|
+
// normalized first part matches pathParts[0], instead of all entries.
|
|
563
|
+
const schemaIndex = getSchemaIndex(schema);
|
|
564
|
+
const lookupPart = pathParts[0] ?? '';
|
|
565
|
+
const lookupParenIdx = lookupPart.indexOf('(');
|
|
566
|
+
const lookupBase = lookupParenIdx >= 0
|
|
567
|
+
? lookupPart.slice(0, lookupParenIdx)
|
|
568
|
+
: lookupPart;
|
|
569
|
+
const candidates = schemaIndex.byFirstPart.get(lookupBase) || [];
|
|
570
|
+
for (const { path: schemaPath, parts: schemaPathParts, } of candidates) {
|
|
364
571
|
if (schemaPathParts.length < pathParts.length)
|
|
365
572
|
continue;
|
|
366
573
|
// Check if all path parts match (allowing function call variants)
|
|
@@ -419,13 +626,27 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
419
626
|
else {
|
|
420
627
|
// Regular exact match - use the standard postfix logic
|
|
421
628
|
const postfix = joinParenthesesAndArrays(schemaPathParts.slice(matchedUpToIndex));
|
|
422
|
-
entry.equivalentPostfixes[postfix]
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
629
|
+
const previousValue = entry.equivalentPostfixes[postfix];
|
|
630
|
+
const newValue = schema[schemaPath];
|
|
631
|
+
entry.equivalentPostfixes[postfix] = previousValue
|
|
632
|
+
? bestValueFromOptions([previousValue, newValue])
|
|
633
|
+
: newValue;
|
|
634
|
+
// Trace postfix gathering - shows where type info comes from
|
|
635
|
+
if (entry.equivalentPostfixes[postfix] !== previousValue) {
|
|
636
|
+
transformationTracer.operation(rootScopeName, {
|
|
637
|
+
operation: 'gatherPostfix',
|
|
638
|
+
stage: 'gathering',
|
|
639
|
+
path: postfix || '(root)',
|
|
640
|
+
before: previousValue,
|
|
641
|
+
after: entry.equivalentPostfixes[postfix],
|
|
642
|
+
context: {
|
|
643
|
+
sourceSchemaPath: schemaPath,
|
|
644
|
+
sourceFunction: equivalentRoot.function?.name || rootScopeName,
|
|
645
|
+
equivalentRootPath: equivalentRoot.schemaRootPath,
|
|
646
|
+
rawValue: newValue,
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
}
|
|
429
650
|
}
|
|
430
651
|
}
|
|
431
652
|
}
|
|
@@ -457,10 +678,14 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
457
678
|
const entry = findOrCreateEquivalentSchemaPathsEntry([
|
|
458
679
|
{ path: translatedBasePath, functionName: functionName },
|
|
459
680
|
]);
|
|
460
|
-
|
|
681
|
+
const newRoot = {
|
|
461
682
|
schemaRootPath: translatedBasePath,
|
|
462
683
|
function: findRelevantDependency(functionName),
|
|
463
|
-
}
|
|
684
|
+
};
|
|
685
|
+
entry.equivalentRoots.push(newRoot);
|
|
686
|
+
// Update index for the newly added root
|
|
687
|
+
const newRootFuncName = newRoot.function?.name ?? rootScopeName;
|
|
688
|
+
espIndex.set(espIndexKey(newRoot.schemaRootPath, newRootFuncName), entry);
|
|
464
689
|
const basePathParts = splitOutsideParenthesesAndArrays(basePath);
|
|
465
690
|
for (const schemaPath in dataStructure.returnValueSchema) {
|
|
466
691
|
const schemaPathParts = splitOutsideParenthesesAndArrays(schemaPath);
|
|
@@ -474,12 +699,13 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
474
699
|
continue;
|
|
475
700
|
}
|
|
476
701
|
const postfix = joinParenthesesAndArrays(schemaPathParts.slice(basePathParts.length));
|
|
477
|
-
|
|
702
|
+
const newValue = entry.equivalentPostfixes[postfix]
|
|
478
703
|
? bestValueFromOptions([
|
|
479
704
|
entry.equivalentPostfixes[postfix],
|
|
480
705
|
dataStructure.returnValueSchema[schemaPath],
|
|
481
706
|
])
|
|
482
707
|
: dataStructure.returnValueSchema[schemaPath];
|
|
708
|
+
entry.equivalentPostfixes[postfix] = newValue;
|
|
483
709
|
}
|
|
484
710
|
}
|
|
485
711
|
}
|
|
@@ -518,6 +744,8 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
518
744
|
}
|
|
519
745
|
const findEquivalentSchemaPathEntry = (schemaSubPath, equivalentRootFunction) => {
|
|
520
746
|
let postfix;
|
|
747
|
+
// Get the signature index we're looking for (if any)
|
|
748
|
+
const lookingForSignatureIndex = extractSignatureIndex(schemaSubPath);
|
|
521
749
|
const equivalentEntry = mergedEquivalentSchemaPaths.find((esp) => esp.equivalentRoots.some((er) => {
|
|
522
750
|
if ((schemaSubPath.startsWith('returnValue') ||
|
|
523
751
|
schemaSubPath.startsWith('signature[')) &&
|
|
@@ -526,6 +754,26 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
526
754
|
return false;
|
|
527
755
|
}
|
|
528
756
|
if (schemaSubPath === er.schemaRootPath) {
|
|
757
|
+
// Additional check: if we're looking for a signature path, make sure
|
|
758
|
+
// the entry doesn't already have DIFFERENT signature indices.
|
|
759
|
+
// This prevents entries with signature[1], signature[2], signature[4]
|
|
760
|
+
// from all being merged together.
|
|
761
|
+
if (lookingForSignatureIndex !== undefined) {
|
|
762
|
+
const hasConflictingSignatureIndex = esp.equivalentRoots.some((otherRoot) => {
|
|
763
|
+
// Only check roots from the same function
|
|
764
|
+
if (otherRoot.function?.name !== equivalentRootFunction?.name ||
|
|
765
|
+
otherRoot.function?.filePath !==
|
|
766
|
+
equivalentRootFunction?.filePath) {
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
const otherIndex = extractSignatureIndex(otherRoot.schemaRootPath);
|
|
770
|
+
return (otherIndex !== undefined &&
|
|
771
|
+
otherIndex !== lookingForSignatureIndex);
|
|
772
|
+
});
|
|
773
|
+
if (hasConflictingSignatureIndex) {
|
|
774
|
+
return false;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
529
777
|
postfix = er.postfix;
|
|
530
778
|
return true;
|
|
531
779
|
}
|
|
@@ -611,8 +859,46 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
611
859
|
}
|
|
612
860
|
}
|
|
613
861
|
equivalentSchemaPaths = mergeAllEquivalentSchemaPaths();
|
|
862
|
+
// Collect schemas that need cleaning — batch the calls for the end instead of
|
|
863
|
+
// calling cleanSchema inside the inner root loop (which was O(roots * schemaSize)).
|
|
864
|
+
const schemasToClean = new Set();
|
|
614
865
|
for (const esp of equivalentSchemaPaths) {
|
|
615
|
-
|
|
866
|
+
// Pre-compute which postfixes have children to avoid O(n²) lookups in the inner loop.
|
|
867
|
+
// A postfix "has children" if there are other postfixes that extend it.
|
|
868
|
+
const postfixesWithChildren = new Set();
|
|
869
|
+
const postfixKeys = Object.keys(esp.equivalentPostfixes);
|
|
870
|
+
// Check for empty postfix having children (any other postfixes exist)
|
|
871
|
+
if (postfixKeys.length > 1 && '' in esp.equivalentPostfixes) {
|
|
872
|
+
postfixesWithChildren.add('');
|
|
873
|
+
}
|
|
874
|
+
// Check for array element postfixes having children using a prefix set.
|
|
875
|
+
// This avoids O(n²) scans across large postfix lists.
|
|
876
|
+
// e.g., 'currentEntities[]' has children if a path like 'currentEntities[].sha' exists.
|
|
877
|
+
const postfixPrefixSet = new Set();
|
|
878
|
+
for (const postfixPath of postfixKeys) {
|
|
879
|
+
if (!postfixPath)
|
|
880
|
+
continue;
|
|
881
|
+
const parts = splitOutsideParenthesesAndArrays(postfixPath);
|
|
882
|
+
for (let i = 1; i < parts.length; i++) {
|
|
883
|
+
postfixPrefixSet.add(joinParenthesesAndArrays(parts.slice(0, i)));
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
for (const postfixPath of postfixKeys) {
|
|
887
|
+
if (postfixPath.endsWith('[]') && postfixPrefixSet.has(postfixPath)) {
|
|
888
|
+
postfixesWithChildren.add(postfixPath);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
// Deduplicate equivalentRoots that would write to the same schema paths.
|
|
892
|
+
// Roots with the same (function, schemaRootPath, postfix) are redundant.
|
|
893
|
+
const seenRootKeys = new Set();
|
|
894
|
+
const uniqueRoots = esp.equivalentRoots.filter((root) => {
|
|
895
|
+
const key = `${root.function?.filePath ?? ''}::${root.function?.name ?? ''}::${root.schemaRootPath}::${root.postfix ?? ''}`;
|
|
896
|
+
if (seenRootKeys.has(key))
|
|
897
|
+
return false;
|
|
898
|
+
seenRootKeys.add(key);
|
|
899
|
+
return true;
|
|
900
|
+
});
|
|
901
|
+
for (const equivalentRoot of uniqueRoots) {
|
|
616
902
|
let merged;
|
|
617
903
|
if (equivalentRoot.function) {
|
|
618
904
|
merged = findOrCreateDependentSchemas(equivalentRoot.function);
|
|
@@ -628,9 +914,21 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
628
914
|
for (const [postfixPath, postfixValue] of Object.entries(esp.equivalentPostfixes)) {
|
|
629
915
|
let relevantPostfix = postfixPath;
|
|
630
916
|
if (equivalentRoot.postfix) {
|
|
917
|
+
// Check if postfixPath starts with equivalentRoot.postfix at a path boundary.
|
|
918
|
+
// Must ensure exact path part match - "entityCode" should NOT match "entity" prefix.
|
|
919
|
+
// Valid: "entity.foo" starts with "entity" (boundary at '.')
|
|
920
|
+
// Valid: "entity[0]" starts with "entity" (boundary at '[')
|
|
921
|
+
// Invalid: "entityCode" starts with "entity" (no boundary, different property)
|
|
631
922
|
if (!postfixPath.startsWith(equivalentRoot.postfix)) {
|
|
632
923
|
continue;
|
|
633
924
|
}
|
|
925
|
+
// Additional check: ensure the match is at a path boundary
|
|
926
|
+
const nextChar = postfixPath[equivalentRoot.postfix.length];
|
|
927
|
+
if (nextChar !== undefined && nextChar !== '.' && nextChar !== '[') {
|
|
928
|
+
// The postfixPath continues with more characters that aren't a path separator.
|
|
929
|
+
// This means "entity" matched "entityCode" which is wrong - they're different properties.
|
|
930
|
+
continue;
|
|
931
|
+
}
|
|
634
932
|
const postFixPathParts = splitOutsideParenthesesAndArrays(postfixPath);
|
|
635
933
|
const equivalentRootPostFixParts = splitOutsideParenthesesAndArrays(equivalentRoot.postfix);
|
|
636
934
|
relevantPostfix = joinParenthesesAndArrays(postFixPathParts.slice(equivalentRootPostFixParts.length));
|
|
@@ -639,11 +937,87 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
639
937
|
equivalentRoot.schemaRootPath,
|
|
640
938
|
relevantPostfix,
|
|
641
939
|
]);
|
|
940
|
+
// Skip paths that would go through a primitive type
|
|
941
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', skip 'entities[].scenarioCount.sha'
|
|
942
|
+
if (wouldGoThroughPrimitive(newSchemaPath, schema)) {
|
|
943
|
+
transformationTracer.operation(rootScopeName, {
|
|
944
|
+
operation: 'skipPrimitivePath',
|
|
945
|
+
stage: 'merged',
|
|
946
|
+
path: newSchemaPath,
|
|
947
|
+
context: {
|
|
948
|
+
reason: 'would go through primitive type',
|
|
949
|
+
postfixValue,
|
|
950
|
+
},
|
|
951
|
+
});
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
// Skip setting primitive type when there are child postfixes that indicate structure.
|
|
955
|
+
// This prevents downgrading an object/array element to a primitive type.
|
|
956
|
+
// Uses pre-computed postfixesWithChildren Set for O(1) lookup instead of O(n) iteration.
|
|
957
|
+
const hasChildPostfixes = (relevantPostfix === '' || relevantPostfix.endsWith('[]')) &&
|
|
958
|
+
postfixesWithChildren.has(postfixPath);
|
|
959
|
+
if (PRIMITIVE_TYPES.has(postfixValue) && hasChildPostfixes) {
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
// Don't overwrite a more specific type with a less specific one
|
|
963
|
+
// This can happen when nested roots share entries with their parent roots
|
|
964
|
+
const existingType = schema[newSchemaPath];
|
|
965
|
+
if (existingType) {
|
|
966
|
+
// Don't overwrite a primitive type with 'object' or 'array'
|
|
967
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', don't overwrite with 'object'
|
|
968
|
+
if (PRIMITIVE_TYPES.has(existingType) &&
|
|
969
|
+
(postfixValue === 'object' || postfixValue === 'array')) {
|
|
970
|
+
transformationTracer.operation(rootScopeName, {
|
|
971
|
+
operation: 'skipTypeDowngrade',
|
|
972
|
+
stage: 'merged',
|
|
973
|
+
path: newSchemaPath,
|
|
974
|
+
context: {
|
|
975
|
+
reason: 'would overwrite primitive with object/array',
|
|
976
|
+
existingType,
|
|
977
|
+
newType: postfixValue,
|
|
978
|
+
},
|
|
979
|
+
});
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
// Don't overwrite a complex/union type with a primitive
|
|
983
|
+
// e.g., if schema has 'scenarios[]': 'Scenario | null', don't overwrite with 'string'
|
|
984
|
+
if (!PRIMITIVE_TYPES.has(existingType) &&
|
|
985
|
+
PRIMITIVE_TYPES.has(postfixValue)) {
|
|
986
|
+
transformationTracer.operation(rootScopeName, {
|
|
987
|
+
operation: 'skipTypeDowngrade',
|
|
988
|
+
stage: 'merged',
|
|
989
|
+
path: newSchemaPath,
|
|
990
|
+
context: {
|
|
991
|
+
reason: 'would overwrite complex type with primitive',
|
|
992
|
+
existingType,
|
|
993
|
+
newType: postfixValue,
|
|
994
|
+
},
|
|
995
|
+
});
|
|
996
|
+
continue;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
// Log the successful postfix merge
|
|
1000
|
+
transformationTracer.operation(rootScopeName, {
|
|
1001
|
+
operation: 'mergePostfix',
|
|
1002
|
+
stage: 'merged',
|
|
1003
|
+
path: newSchemaPath,
|
|
1004
|
+
before: existingType,
|
|
1005
|
+
after: postfixValue,
|
|
1006
|
+
context: {
|
|
1007
|
+
schemaRootPath: equivalentRoot.schemaRootPath,
|
|
1008
|
+
postfix: relevantPostfix,
|
|
1009
|
+
dependency: equivalentRoot.function?.name,
|
|
1010
|
+
},
|
|
1011
|
+
});
|
|
642
1012
|
schema[newSchemaPath] = postfixValue;
|
|
643
1013
|
}
|
|
644
|
-
|
|
1014
|
+
schemasToClean.add(schema);
|
|
645
1015
|
}
|
|
646
1016
|
}
|
|
1017
|
+
// Batch-clean all modified schemas once (instead of once per root per ESP entry)
|
|
1018
|
+
for (const schema of schemasToClean) {
|
|
1019
|
+
cleanSchema(schema, { stage: 'afterMergePostfix' });
|
|
1020
|
+
}
|
|
647
1021
|
// Propagate equivalency-derived attributes to generic function call variants.
|
|
648
1022
|
// When attributes are traced via equivalencies (e.g., fileComparisons from buildDataMap.signature[2]),
|
|
649
1023
|
// they get written to non-generic paths (returnValue.data.x or funcName().functionCallReturnValue.data.x).
|
|
@@ -740,6 +1114,14 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
740
1114
|
// e.g., returnValue[].label -> getOptions().functionCallReturnValue[].label
|
|
741
1115
|
normalizedPath = path.replace(/^returnValue/, `${dependency.name}().functionCallReturnValue`);
|
|
742
1116
|
}
|
|
1117
|
+
transformationTracer.operation(rootScopeName, {
|
|
1118
|
+
operation: 'normalizeReturnValuePath',
|
|
1119
|
+
stage: 'merged',
|
|
1120
|
+
path: normalizedPath,
|
|
1121
|
+
before: path,
|
|
1122
|
+
after: normalizedPath,
|
|
1123
|
+
context: { dependency: dependency.name, value },
|
|
1124
|
+
});
|
|
743
1125
|
depSchema.returnValueSchema[normalizedPath] = value;
|
|
744
1126
|
}
|
|
745
1127
|
// Now copy paths from the source schema (dependencySchemas)
|
|
@@ -806,7 +1188,10 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
806
1188
|
}
|
|
807
1189
|
}
|
|
808
1190
|
}
|
|
809
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1191
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1192
|
+
stage: 'afterMockedDependencyMerge',
|
|
1193
|
+
dependency: dependency.name,
|
|
1194
|
+
});
|
|
810
1195
|
// Pull signature requirements from downstream functions into the mocked return value.
|
|
811
1196
|
// When a mocked function's return flows into another function's signature (via usageEquivalencies),
|
|
812
1197
|
// we need to include that function's signature requirements in the mock.
|
|
@@ -871,7 +1256,10 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
871
1256
|
}
|
|
872
1257
|
}
|
|
873
1258
|
}
|
|
874
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1259
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1260
|
+
stage: 'afterSignatureRequirementsMerge',
|
|
1261
|
+
dependency: dependency.name,
|
|
1262
|
+
});
|
|
875
1263
|
}
|
|
876
1264
|
// Process the input dependencySchemas FIRST (before child dependentAnalyses).
|
|
877
1265
|
// This ensures the parent entity's direct usage of dependencies takes precedence.
|
|
@@ -907,7 +1295,38 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
907
1295
|
// from the copied schema. Without this, method call paths on primitives like
|
|
908
1296
|
// "projectSlug.replace(...)" would cause convertDotNotation to create nested
|
|
909
1297
|
// object structures instead of preserving the primitive type.
|
|
910
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1298
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1299
|
+
stage: 'afterDependencySchemaCopy',
|
|
1300
|
+
filePath,
|
|
1301
|
+
dependency: name,
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
// TYPE REFINEMENT: Check if dependentAnalyses has a more specific type for this dependency.
|
|
1305
|
+
// When a parent passes `entity.filePath` (string | undefined) to a child component
|
|
1306
|
+
// that requires `filePath: string`, we should use the child's more specific type.
|
|
1307
|
+
// This prevents mock data from having undefined values for required props.
|
|
1308
|
+
//
|
|
1309
|
+
// This runs REGARDLESS of whether equivalencies already processed the schema,
|
|
1310
|
+
// because equivalencies copy the parent's type (string | undefined), not the child's
|
|
1311
|
+
// required type (string).
|
|
1312
|
+
const depSchema = findOrCreateDependentSchemas({ filePath, name });
|
|
1313
|
+
const childAnalysis = dependentAnalyses[filePath]?.[name];
|
|
1314
|
+
const childSignatureSchema = childAnalysis?.metadata?.mergedDataStructure?.signatureSchema;
|
|
1315
|
+
if (childSignatureSchema) {
|
|
1316
|
+
for (const path in depSchema.signatureSchema) {
|
|
1317
|
+
const parentType = depSchema.signatureSchema[path];
|
|
1318
|
+
const childType = childSignatureSchema[path];
|
|
1319
|
+
if (parentType && childType) {
|
|
1320
|
+
// Check if parent has optional type and child has required type
|
|
1321
|
+
const parentIsOptional = parentType.includes('| undefined') ||
|
|
1322
|
+
parentType.includes('| null');
|
|
1323
|
+
const childIsOptional = childType.includes('| undefined') || childType.includes('| null');
|
|
1324
|
+
// If child requires a more specific type (not optional), use it
|
|
1325
|
+
if (parentIsOptional && !childIsOptional) {
|
|
1326
|
+
depSchema.signatureSchema[path] = childType;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
911
1330
|
}
|
|
912
1331
|
// For functions with multiple different type parameters, also create separate entries
|
|
913
1332
|
// for each type-parameterized variant. This allows gatherDataForMocks to look up
|
|
@@ -939,7 +1358,12 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
939
1358
|
srcSchema.returnValueSchema[path];
|
|
940
1359
|
}
|
|
941
1360
|
}
|
|
942
|
-
cleanSchema(variantSchema.returnValueSchema
|
|
1361
|
+
cleanSchema(variantSchema.returnValueSchema, {
|
|
1362
|
+
stage: 'afterTypeVariantCopy',
|
|
1363
|
+
filePath,
|
|
1364
|
+
dependency: name,
|
|
1365
|
+
variant,
|
|
1366
|
+
});
|
|
943
1367
|
}
|
|
944
1368
|
}
|
|
945
1369
|
}
|
|
@@ -990,8 +1414,8 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
990
1414
|
// Merge in the nested dependency schemas
|
|
991
1415
|
for (const path in nestedDepSchema.returnValueSchema) {
|
|
992
1416
|
if (!(path in targetDepSchema.returnValueSchema)) {
|
|
993
|
-
|
|
994
|
-
|
|
1417
|
+
const value = nestedDepSchema.returnValueSchema[path];
|
|
1418
|
+
targetDepSchema.returnValueSchema[path] = value;
|
|
995
1419
|
}
|
|
996
1420
|
}
|
|
997
1421
|
for (const path in nestedDepSchema.signatureSchema) {
|