@codeyam/codeyam-cli 0.1.0-staging.1669d45 → 0.1.0-staging.323686
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 +3 -3
- package/analyzer-template/packages/ai/index.ts +9 -1
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +48 -34
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +31 -0
- 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 +277 -8
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +73 -1
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +198 -34
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +108 -1
- 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/cleanKnownObjectFunctions.ts +23 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +87 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +32 -7
- 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 +626 -6
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +26 -1
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +375 -6
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1003 -45
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- 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 +154 -32
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +22 -1
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +10 -13
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -7
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +142 -73
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +42 -5
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +77 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/aws/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +8 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +8 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/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 +51 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.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/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 +64 -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 +51 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.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 +314 -29
- 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 +114 -2
- 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 +255 -4
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +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 +89 -2
- 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/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 +20 -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-7522edd4.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-yxFcrxBX.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-DVzYx8PN.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-4Cr0uToj.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 +462 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
- package/package.json +8 -5
- package/packages/ai/index.js +5 -2
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +41 -17
- 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 +24 -0
- 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 +228 -11
- 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 +86 -1
- 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/cleanKnownObjectFunctions.js +19 -0
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +70 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +29 -7
- 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 +510 -7
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +19 -1
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +273 -4
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +738 -40
- 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/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 +131 -27
- 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/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +8 -4
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.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/validateDependencyAnalyses.js +31 -7
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +116 -66
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +37 -5
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +65 -0
- 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/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
|
@@ -12,6 +12,78 @@
|
|
|
12
12
|
* - compound conditionals → one flow with all conditions (only if ALL paths controllable)
|
|
13
13
|
*/
|
|
14
14
|
import resolvePathToControllable from "./resolvePathToControllable.js";
|
|
15
|
+
import cleanPathOfNonTransformingFunctions from "./dataStructure/helpers/cleanPathOfNonTransformingFunctions.js";
|
|
16
|
+
/**
|
|
17
|
+
* Recursively expands a derived variable to its leaf data sources.
|
|
18
|
+
*
|
|
19
|
+
* For OR expressions like `isAnalyzing = a || b || c`:
|
|
20
|
+
* - Returns all source paths [a, b, c] so they can all be set appropriately
|
|
21
|
+
*
|
|
22
|
+
* For nested derivations like `isAnalyzing = isInCurrentRun || isInQueue`:
|
|
23
|
+
* - Where `isInCurrentRun` is derived from `currentRun.entityShas.includes(x)`
|
|
24
|
+
* - Returns the final data sources: [currentRun.entityShas, queueState.jobs]
|
|
25
|
+
*
|
|
26
|
+
* @param path The variable path to expand
|
|
27
|
+
* @param conditionalUsages All conditional usages (to look up derivedFrom info)
|
|
28
|
+
* @param attributesMap Map of controllable paths
|
|
29
|
+
* @param equivalentSignatureVariables Variable-to-path mappings
|
|
30
|
+
* @param fullToShortPathMap Full-to-short path mappings
|
|
31
|
+
* @param visited Set of already-visited paths (prevents infinite recursion)
|
|
32
|
+
* @param derivedVariables Optional map of all derived variables (for intermediate tracing)
|
|
33
|
+
* @returns Array of resolved source paths that are controllable
|
|
34
|
+
*/
|
|
35
|
+
function expandDerivedVariableToSources(path, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, visited = new Set(), derivedVariables) {
|
|
36
|
+
// Prevent infinite recursion
|
|
37
|
+
if (visited.has(path)) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
visited.add(path);
|
|
41
|
+
// First, check if this path is directly controllable
|
|
42
|
+
const directResolution = resolvePathToControllable(path, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
43
|
+
if (directResolution.isControllable && directResolution.resolvedPath) {
|
|
44
|
+
return [{ path: directResolution.resolvedPath }];
|
|
45
|
+
}
|
|
46
|
+
// Look up derivedFrom info for this path
|
|
47
|
+
// First check conditionalUsages, then fall back to derivedVariables
|
|
48
|
+
const usage = conditionalUsages[path]?.[0];
|
|
49
|
+
let derivedFrom = usage?.derivedFrom;
|
|
50
|
+
// CRITICAL: If not found in conditionalUsages, check derivedVariables
|
|
51
|
+
// This handles intermediate derived variables like `isInCurrentRun` that aren't
|
|
52
|
+
// directly used in conditionals but ARE derived from data sources
|
|
53
|
+
if (!derivedFrom && derivedVariables?.[path]) {
|
|
54
|
+
derivedFrom = derivedVariables[path];
|
|
55
|
+
}
|
|
56
|
+
if (!derivedFrom) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const { operation, sourcePath, sourcePaths } = derivedFrom;
|
|
60
|
+
// For OR/AND operations, recursively expand all source paths
|
|
61
|
+
if ((operation === 'or' || operation === 'and') && sourcePaths) {
|
|
62
|
+
const allSources = [];
|
|
63
|
+
for (const sp of sourcePaths) {
|
|
64
|
+
const expanded = expandDerivedVariableToSources(sp, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, visited, derivedVariables);
|
|
65
|
+
// Add all expanded sources
|
|
66
|
+
for (const source of expanded) {
|
|
67
|
+
// Avoid duplicates
|
|
68
|
+
if (!allSources.some((s) => s.path === source.path)) {
|
|
69
|
+
allSources.push(source);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return allSources;
|
|
74
|
+
}
|
|
75
|
+
// For single-source operations (arrayIncludes, arraySome, notNull, etc.)
|
|
76
|
+
if (sourcePath) {
|
|
77
|
+
// Try to resolve the source path directly
|
|
78
|
+
const sourceResolution = resolvePathToControllable(sourcePath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
79
|
+
if (sourceResolution.isControllable && sourceResolution.resolvedPath) {
|
|
80
|
+
return [{ path: sourceResolution.resolvedPath, operation }];
|
|
81
|
+
}
|
|
82
|
+
// If not directly resolvable, recursively expand
|
|
83
|
+
return expandDerivedVariableToSources(sourcePath, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, visited, derivedVariables);
|
|
84
|
+
}
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
15
87
|
/**
|
|
16
88
|
* Clean up sourceDataPath by removing redundant scope prefixes.
|
|
17
89
|
*
|
|
@@ -59,6 +131,47 @@ function cleanSourceDataPath(sourceDataPath) {
|
|
|
59
131
|
}
|
|
60
132
|
return actualPath;
|
|
61
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Strip .length suffix from a path if present.
|
|
136
|
+
*
|
|
137
|
+
* When we have a path like "items.length", the controllable attribute is "items"
|
|
138
|
+
* (the array), not "items.length". The length is derived from the array contents.
|
|
139
|
+
*
|
|
140
|
+
* This ensures that execution flows reference the actual controllable attribute
|
|
141
|
+
* rather than the derived .length property.
|
|
142
|
+
*/
|
|
143
|
+
function stripLengthSuffix(path) {
|
|
144
|
+
if (path.endsWith('.length')) {
|
|
145
|
+
return path.slice(0, -7); // Remove ".length" (7 characters)
|
|
146
|
+
}
|
|
147
|
+
return path;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Extract the controllable base path from a path that may contain method calls.
|
|
151
|
+
*
|
|
152
|
+
* This handles complex expressions like:
|
|
153
|
+
* - `scenarios.filter((s) => s.active).length` → `scenarios`
|
|
154
|
+
* - `users.some((u) => u.role === 'admin')` → `users`
|
|
155
|
+
* - `items.map(x => x.name).join(', ')` → `items`
|
|
156
|
+
*
|
|
157
|
+
* The controllable base is the path that can be mocked - we can control
|
|
158
|
+
* what `scenarios` contains, but we can't control what `.filter()` returns.
|
|
159
|
+
*
|
|
160
|
+
* @param path - The path that may contain method calls
|
|
161
|
+
* @returns The controllable base path with method calls stripped
|
|
162
|
+
*/
|
|
163
|
+
function extractControllableBase(path) {
|
|
164
|
+
// First strip .length suffix if present
|
|
165
|
+
const pathWithoutLength = stripLengthSuffix(path);
|
|
166
|
+
// Use cleanPathOfNonTransformingFunctions to strip method calls like .filter(), .some()
|
|
167
|
+
const cleanedPath = cleanPathOfNonTransformingFunctions(pathWithoutLength);
|
|
168
|
+
// If the cleaned path is different, return it
|
|
169
|
+
if (cleanedPath !== pathWithoutLength) {
|
|
170
|
+
return cleanedPath;
|
|
171
|
+
}
|
|
172
|
+
// Otherwise, return the path with just .length stripped
|
|
173
|
+
return pathWithoutLength;
|
|
174
|
+
}
|
|
62
175
|
/**
|
|
63
176
|
* Find a path in attributesMap, using fullToShortPathMap to verify the path is controllable.
|
|
64
177
|
*
|
|
@@ -173,6 +286,12 @@ function inferValueType(value) {
|
|
|
173
286
|
/**
|
|
174
287
|
* Generate flows from a single conditional usage.
|
|
175
288
|
* Sets impact to 'high' if the conditional controls JSX rendering.
|
|
289
|
+
*
|
|
290
|
+
* When the usage has a `constraintExpression`, it represents a complex expression
|
|
291
|
+
* that can't be simply resolved (e.g., `scenarios.filter(x => x.active).length > 1`).
|
|
292
|
+
* In this case:
|
|
293
|
+
* - `attributePath` is set to the controllable base (e.g., `scenarios`)
|
|
294
|
+
* - `constraint` is set to the full expression for LLM reasoning
|
|
176
295
|
*/
|
|
177
296
|
function generateFlowsFromUsage(usage, resolvedPath) {
|
|
178
297
|
const flows = [];
|
|
@@ -182,6 +301,13 @@ function generateFlowsFromUsage(usage, resolvedPath) {
|
|
|
182
301
|
const impact = usage.controlsJsxRendering
|
|
183
302
|
? 'high'
|
|
184
303
|
: 'medium';
|
|
304
|
+
// When there's a constraintExpression, use the controllable base for attributePath
|
|
305
|
+
// and pass through the constraint for LLM reasoning
|
|
306
|
+
const hasConstraint = !!usage.constraintExpression;
|
|
307
|
+
const attributePath = hasConstraint
|
|
308
|
+
? extractControllableBase(resolvedPath)
|
|
309
|
+
: stripLengthSuffix(resolvedPath);
|
|
310
|
+
const constraint = usage.constraintExpression;
|
|
185
311
|
if (usage.conditionType === 'truthiness') {
|
|
186
312
|
// Generate both truthy and falsy flows
|
|
187
313
|
const isNegated = usage.isNegated ?? false;
|
|
@@ -192,10 +318,11 @@ function generateFlowsFromUsage(usage, resolvedPath) {
|
|
|
192
318
|
description: `When ${baseName.toLowerCase()} is ${isNegated ? 'falsy' : 'truthy'}`,
|
|
193
319
|
requiredValues: [
|
|
194
320
|
{
|
|
195
|
-
attributePath
|
|
321
|
+
attributePath,
|
|
196
322
|
value: isNegated ? 'falsy' : 'truthy',
|
|
197
323
|
comparison: isNegated ? 'falsy' : 'truthy',
|
|
198
324
|
valueType: 'boolean',
|
|
325
|
+
constraint,
|
|
199
326
|
},
|
|
200
327
|
],
|
|
201
328
|
impact,
|
|
@@ -214,10 +341,11 @@ function generateFlowsFromUsage(usage, resolvedPath) {
|
|
|
214
341
|
description: `When ${baseName.toLowerCase()} is ${isNegated ? 'truthy' : 'falsy'}`,
|
|
215
342
|
requiredValues: [
|
|
216
343
|
{
|
|
217
|
-
attributePath
|
|
344
|
+
attributePath,
|
|
218
345
|
value: isNegated ? 'truthy' : 'falsy',
|
|
219
346
|
comparison: isNegated ? 'truthy' : 'falsy',
|
|
220
347
|
valueType: 'boolean',
|
|
348
|
+
constraint,
|
|
221
349
|
},
|
|
222
350
|
],
|
|
223
351
|
impact,
|
|
@@ -241,10 +369,11 @@ function generateFlowsFromUsage(usage, resolvedPath) {
|
|
|
241
369
|
description: `When ${baseName.toLowerCase()} equals "${value}"`,
|
|
242
370
|
requiredValues: [
|
|
243
371
|
{
|
|
244
|
-
attributePath
|
|
372
|
+
attributePath,
|
|
245
373
|
value: value,
|
|
246
374
|
comparison: 'equals',
|
|
247
375
|
valueType: inferValueType(value),
|
|
376
|
+
constraint,
|
|
248
377
|
},
|
|
249
378
|
],
|
|
250
379
|
impact,
|
|
@@ -293,7 +422,7 @@ function generateFlowFromCompound(compound, resolvedPaths) {
|
|
|
293
422
|
comparison = 'equals';
|
|
294
423
|
}
|
|
295
424
|
requiredValues.push({
|
|
296
|
-
attributePath: resolvedPath,
|
|
425
|
+
attributePath: stripLengthSuffix(resolvedPath),
|
|
297
426
|
value,
|
|
298
427
|
comparison,
|
|
299
428
|
valueType: inferValueType(value),
|
|
@@ -321,6 +450,48 @@ function generateFlowFromCompound(compound, resolvedPaths) {
|
|
|
321
450
|
codeSnippet: compound.sourceLocation.codeSnippet,
|
|
322
451
|
};
|
|
323
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Expand a compound conditional with OR groups into multiple condition sets.
|
|
455
|
+
*
|
|
456
|
+
* For a compound like `A && (B || C)`:
|
|
457
|
+
* - Conditions: [{ path: 'A' }, { path: 'B', orGroupId: 'or_xxx' }, { path: 'C', orGroupId: 'or_xxx' }]
|
|
458
|
+
* - Returns: [[A, B], [A, C]] - two sets of conditions
|
|
459
|
+
*
|
|
460
|
+
* For multiple OR groups like `A && (B || C) && (D || E)`:
|
|
461
|
+
* - Returns: [[A, B, D], [A, B, E], [A, C, D], [A, C, E]]
|
|
462
|
+
*/
|
|
463
|
+
function expandOrGroups(conditions) {
|
|
464
|
+
// Separate conditions into mandatory (no orGroupId) and OR groups
|
|
465
|
+
const mandatory = conditions.filter((c) => !c.orGroupId);
|
|
466
|
+
const orGroups = new Map();
|
|
467
|
+
for (const condition of conditions) {
|
|
468
|
+
if (condition.orGroupId) {
|
|
469
|
+
const group = orGroups.get(condition.orGroupId) ?? [];
|
|
470
|
+
group.push(condition);
|
|
471
|
+
orGroups.set(condition.orGroupId, group);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
// If no OR groups, return the original conditions
|
|
475
|
+
if (orGroups.size === 0) {
|
|
476
|
+
return [conditions];
|
|
477
|
+
}
|
|
478
|
+
// Generate all combinations by picking one condition from each OR group
|
|
479
|
+
const groupArrays = Array.from(orGroups.values());
|
|
480
|
+
const combinations = [];
|
|
481
|
+
function generateCombinations(index, current) {
|
|
482
|
+
if (index === groupArrays.length) {
|
|
483
|
+
// We've picked one from each OR group - combine with mandatory conditions
|
|
484
|
+
combinations.push([...mandatory, ...current]);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
// Pick each option from the current OR group
|
|
488
|
+
for (const option of groupArrays[index]) {
|
|
489
|
+
generateCombinations(index + 1, [...current, option]);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
generateCombinations(0, []);
|
|
493
|
+
return combinations;
|
|
494
|
+
}
|
|
324
495
|
/**
|
|
325
496
|
* Generate execution flows from conditional usages using pure static analysis.
|
|
326
497
|
*
|
|
@@ -408,7 +579,7 @@ function translateChildPathToParent(childPath, childEquivalentSignatureVariables
|
|
|
408
579
|
return result;
|
|
409
580
|
}
|
|
410
581
|
export default function generateExecutionFlowsFromConditionals(args) {
|
|
411
|
-
const { conditionalUsages, compoundConditionals, attributesMap, equivalentSignatureVariables, fullToShortPathMap, childComponentData, } = args;
|
|
582
|
+
const { conditionalUsages, compoundConditionals, attributesMap, equivalentSignatureVariables, fullToShortPathMap, childComponentData, derivedVariables, } = args;
|
|
412
583
|
const flows = [];
|
|
413
584
|
const seenFlowIds = new Set();
|
|
414
585
|
// Track normalized resolved paths to prevent duplicate flows
|
|
@@ -454,7 +625,7 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
454
625
|
// This handles cases like: const hasAnalysis = analysis !== null
|
|
455
626
|
// where hasAnalysis is not in attributesMap but analysis is
|
|
456
627
|
if (!resolvedPath && usage.derivedFrom) {
|
|
457
|
-
const { sourcePath, sourcePaths } = usage.derivedFrom;
|
|
628
|
+
const { operation, sourcePath, sourcePaths, comparedValue } = usage.derivedFrom;
|
|
458
629
|
// For single-source derivations (notNull, equals, etc.)
|
|
459
630
|
if (sourcePath) {
|
|
460
631
|
const resolution = resolvePathToControllable(sourcePath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
@@ -462,8 +633,232 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
462
633
|
resolvedPath = resolution.resolvedPath;
|
|
463
634
|
}
|
|
464
635
|
}
|
|
465
|
-
// For
|
|
466
|
-
//
|
|
636
|
+
// For equals/notEquals derivations with comparedValue, generate comparison flows
|
|
637
|
+
// e.g., canEdit derived from user.role === 'admin'
|
|
638
|
+
// When canEdit is used in truthiness check, we need:
|
|
639
|
+
// - Truthy flow: user.role = 'admin' (comparison: 'equals')
|
|
640
|
+
// - Falsy flow: user.role != 'admin' (comparison: 'notEquals')
|
|
641
|
+
if ((operation === 'equals' || operation === 'notEquals') &&
|
|
642
|
+
comparedValue !== undefined &&
|
|
643
|
+
resolvedPath &&
|
|
644
|
+
usage.conditionType === 'truthiness') {
|
|
645
|
+
const baseName = generateNameFromPath(usage.path);
|
|
646
|
+
const impact = usage.controlsJsxRendering
|
|
647
|
+
? 'high'
|
|
648
|
+
: 'medium';
|
|
649
|
+
const isNegated = usage.isNegated ?? false;
|
|
650
|
+
// For equals derivation:
|
|
651
|
+
// - Truthy check (!negated): needs value = comparedValue (equals)
|
|
652
|
+
// - Falsy check (negated): needs value != comparedValue (notEquals)
|
|
653
|
+
// For notEquals derivation: inverse of above
|
|
654
|
+
const isEqualsDerivation = operation === 'equals';
|
|
655
|
+
const truthyNeedsEquals = isEqualsDerivation !== isNegated;
|
|
656
|
+
// Generate truthy flow
|
|
657
|
+
const truthyFlow = {
|
|
658
|
+
id: generateFlowId(usage.path, 'truthy'),
|
|
659
|
+
name: `${baseName} True`,
|
|
660
|
+
description: `When ${baseName.toLowerCase()} is truthy (${resolvedPath} ${truthyNeedsEquals ? '=' : '!='} ${comparedValue})`,
|
|
661
|
+
requiredValues: [
|
|
662
|
+
{
|
|
663
|
+
attributePath: stripLengthSuffix(resolvedPath),
|
|
664
|
+
value: comparedValue,
|
|
665
|
+
comparison: truthyNeedsEquals ? 'equals' : 'notEquals',
|
|
666
|
+
valueType: inferValueType(comparedValue),
|
|
667
|
+
},
|
|
668
|
+
],
|
|
669
|
+
impact,
|
|
670
|
+
sourceLocation: usage.sourceLocation
|
|
671
|
+
? {
|
|
672
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
673
|
+
column: usage.sourceLocation.column,
|
|
674
|
+
}
|
|
675
|
+
: undefined,
|
|
676
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
677
|
+
};
|
|
678
|
+
// Generate falsy flow
|
|
679
|
+
const falsyFlow = {
|
|
680
|
+
id: generateFlowId(usage.path, 'falsy'),
|
|
681
|
+
name: `${baseName} False`,
|
|
682
|
+
description: `When ${baseName.toLowerCase()} is falsy (${resolvedPath} ${truthyNeedsEquals ? '!=' : '='} ${comparedValue})`,
|
|
683
|
+
requiredValues: [
|
|
684
|
+
{
|
|
685
|
+
attributePath: stripLengthSuffix(resolvedPath),
|
|
686
|
+
value: comparedValue,
|
|
687
|
+
comparison: truthyNeedsEquals ? 'notEquals' : 'equals',
|
|
688
|
+
valueType: inferValueType(comparedValue),
|
|
689
|
+
},
|
|
690
|
+
],
|
|
691
|
+
impact,
|
|
692
|
+
sourceLocation: usage.sourceLocation
|
|
693
|
+
? {
|
|
694
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
695
|
+
column: usage.sourceLocation.column,
|
|
696
|
+
}
|
|
697
|
+
: undefined,
|
|
698
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
699
|
+
};
|
|
700
|
+
// Add flows and skip normal flow generation
|
|
701
|
+
if (!seenFlowIds.has(truthyFlow.id)) {
|
|
702
|
+
seenFlowIds.add(truthyFlow.id);
|
|
703
|
+
flows.push(truthyFlow);
|
|
704
|
+
}
|
|
705
|
+
if (!seenFlowIds.has(falsyFlow.id)) {
|
|
706
|
+
seenFlowIds.add(falsyFlow.id);
|
|
707
|
+
flows.push(falsyFlow);
|
|
708
|
+
}
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
// For OR derivations with negation, we need ALL sources to be falsy
|
|
712
|
+
// e.g., !isBusy where isBusy = isRunning || isQueued || isPending
|
|
713
|
+
// For the falsy flow, ALL sources must be falsy
|
|
714
|
+
if (operation === 'or' &&
|
|
715
|
+
usage.conditionType === 'truthiness' &&
|
|
716
|
+
usage.isNegated === true &&
|
|
717
|
+
sourcePaths &&
|
|
718
|
+
sourcePaths.length > 0) {
|
|
719
|
+
// Use expandDerivedVariableToSources to recursively resolve all sources
|
|
720
|
+
const allSources = expandDerivedVariableToSources(usage.path, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, new Set(), derivedVariables);
|
|
721
|
+
if (allSources.length > 0) {
|
|
722
|
+
// Generate a compound-style flow with all sources set to falsy
|
|
723
|
+
const baseName = generateNameFromPath(usage.path);
|
|
724
|
+
const impact = usage.controlsJsxRendering
|
|
725
|
+
? 'high'
|
|
726
|
+
: 'medium';
|
|
727
|
+
const requiredValues = allSources.map((source) => ({
|
|
728
|
+
attributePath: source.path,
|
|
729
|
+
value: 'falsy',
|
|
730
|
+
comparison: 'falsy',
|
|
731
|
+
valueType: 'boolean',
|
|
732
|
+
}));
|
|
733
|
+
// Create a single falsy flow with all sources
|
|
734
|
+
const falsyFlow = {
|
|
735
|
+
id: generateFlowId(usage.path, 'falsy'),
|
|
736
|
+
name: `${baseName} False`,
|
|
737
|
+
description: `When ${baseName.toLowerCase()} is falsy (all sources are falsy)`,
|
|
738
|
+
requiredValues,
|
|
739
|
+
impact,
|
|
740
|
+
sourceLocation: usage.sourceLocation
|
|
741
|
+
? {
|
|
742
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
743
|
+
column: usage.sourceLocation.column,
|
|
744
|
+
}
|
|
745
|
+
: undefined,
|
|
746
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
747
|
+
};
|
|
748
|
+
// Create a truthy flow - for OR, ANY source being truthy is sufficient
|
|
749
|
+
// We use the first resolvable source for the truthy flow
|
|
750
|
+
const firstSource = allSources[0];
|
|
751
|
+
const truthyFlow = {
|
|
752
|
+
id: generateFlowId(usage.path, 'truthy'),
|
|
753
|
+
name: `${baseName} True`,
|
|
754
|
+
description: `When ${baseName.toLowerCase()} is truthy`,
|
|
755
|
+
requiredValues: [
|
|
756
|
+
{
|
|
757
|
+
attributePath: firstSource.path,
|
|
758
|
+
value: 'truthy',
|
|
759
|
+
comparison: 'truthy',
|
|
760
|
+
valueType: 'boolean',
|
|
761
|
+
},
|
|
762
|
+
],
|
|
763
|
+
impact,
|
|
764
|
+
sourceLocation: usage.sourceLocation
|
|
765
|
+
? {
|
|
766
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
767
|
+
column: usage.sourceLocation.column,
|
|
768
|
+
}
|
|
769
|
+
: undefined,
|
|
770
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
771
|
+
};
|
|
772
|
+
// Add both flows (falsy needs all sources, truthy needs one)
|
|
773
|
+
if (!seenFlowIds.has(falsyFlow.id)) {
|
|
774
|
+
seenFlowIds.add(falsyFlow.id);
|
|
775
|
+
flows.push(falsyFlow);
|
|
776
|
+
}
|
|
777
|
+
if (!seenFlowIds.has(truthyFlow.id)) {
|
|
778
|
+
seenFlowIds.add(truthyFlow.id);
|
|
779
|
+
flows.push(truthyFlow);
|
|
780
|
+
}
|
|
781
|
+
// Skip the normal flow generation for this usage
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
// For AND derivations without negation, we need ALL sources to be truthy
|
|
786
|
+
// e.g., isReady where isReady = hasData && isLoaded && isValid
|
|
787
|
+
// For the truthy flow, ALL sources must be truthy
|
|
788
|
+
// For negated AND (!isReady), ANY source being falsy is sufficient (fallback behavior)
|
|
789
|
+
if (operation === 'and' &&
|
|
790
|
+
usage.conditionType === 'truthiness' &&
|
|
791
|
+
usage.isNegated !== true &&
|
|
792
|
+
sourcePaths &&
|
|
793
|
+
sourcePaths.length > 0) {
|
|
794
|
+
// Use expandDerivedVariableToSources to recursively resolve all sources
|
|
795
|
+
const allSources = expandDerivedVariableToSources(usage.path, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, new Set(), derivedVariables);
|
|
796
|
+
if (allSources.length > 0) {
|
|
797
|
+
// Generate a compound-style flow with all sources set to truthy
|
|
798
|
+
const baseName = generateNameFromPath(usage.path);
|
|
799
|
+
const impact = usage.controlsJsxRendering
|
|
800
|
+
? 'high'
|
|
801
|
+
: 'medium';
|
|
802
|
+
const requiredValues = allSources.map((source) => ({
|
|
803
|
+
attributePath: source.path,
|
|
804
|
+
value: 'truthy',
|
|
805
|
+
comparison: 'truthy',
|
|
806
|
+
valueType: 'boolean',
|
|
807
|
+
}));
|
|
808
|
+
// Create a truthy flow with all sources
|
|
809
|
+
const truthyFlow = {
|
|
810
|
+
id: generateFlowId(usage.path, 'truthy'),
|
|
811
|
+
name: `${baseName} True`,
|
|
812
|
+
description: `When ${baseName.toLowerCase()} is truthy (all sources are truthy)`,
|
|
813
|
+
requiredValues,
|
|
814
|
+
impact,
|
|
815
|
+
sourceLocation: usage.sourceLocation
|
|
816
|
+
? {
|
|
817
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
818
|
+
column: usage.sourceLocation.column,
|
|
819
|
+
}
|
|
820
|
+
: undefined,
|
|
821
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
822
|
+
};
|
|
823
|
+
// Create a falsy flow - for AND, ANY source being falsy is sufficient
|
|
824
|
+
// We use the first resolvable source for the falsy flow
|
|
825
|
+
const firstSource = allSources[0];
|
|
826
|
+
const falsyFlow = {
|
|
827
|
+
id: generateFlowId(usage.path, 'falsy'),
|
|
828
|
+
name: `${baseName} False`,
|
|
829
|
+
description: `When ${baseName.toLowerCase()} is falsy`,
|
|
830
|
+
requiredValues: [
|
|
831
|
+
{
|
|
832
|
+
attributePath: firstSource.path,
|
|
833
|
+
value: 'falsy',
|
|
834
|
+
comparison: 'falsy',
|
|
835
|
+
valueType: 'boolean',
|
|
836
|
+
},
|
|
837
|
+
],
|
|
838
|
+
impact,
|
|
839
|
+
sourceLocation: usage.sourceLocation
|
|
840
|
+
? {
|
|
841
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
842
|
+
column: usage.sourceLocation.column,
|
|
843
|
+
}
|
|
844
|
+
: undefined,
|
|
845
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
846
|
+
};
|
|
847
|
+
// Add both flows (truthy needs all sources, falsy needs one)
|
|
848
|
+
if (!seenFlowIds.has(truthyFlow.id)) {
|
|
849
|
+
seenFlowIds.add(truthyFlow.id);
|
|
850
|
+
flows.push(truthyFlow);
|
|
851
|
+
}
|
|
852
|
+
if (!seenFlowIds.has(falsyFlow.id)) {
|
|
853
|
+
seenFlowIds.add(falsyFlow.id);
|
|
854
|
+
flows.push(falsyFlow);
|
|
855
|
+
}
|
|
856
|
+
// Skip the normal flow generation for this usage
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
// For multi-source derivations (or, and) without special handling,
|
|
861
|
+
// try the first resolvable path as a fallback
|
|
467
862
|
if (!resolvedPath && sourcePaths && sourcePaths.length > 0) {
|
|
468
863
|
for (const sp of sourcePaths) {
|
|
469
864
|
const resolution = resolvePathToControllable(sp, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
@@ -501,23 +896,167 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
501
896
|
}
|
|
502
897
|
// Process compound conditionals
|
|
503
898
|
for (const compound of compoundConditionals) {
|
|
504
|
-
//
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if (
|
|
510
|
-
|
|
511
|
-
|
|
899
|
+
// Expand OR groups into separate condition sets
|
|
900
|
+
// For example, `A && (B || C)` becomes [[A, B], [A, C]]
|
|
901
|
+
const expandedConditionSets = expandOrGroups(compound.conditions);
|
|
902
|
+
// Process each expanded condition set as a separate potential flow
|
|
903
|
+
for (const conditionSet of expandedConditionSets) {
|
|
904
|
+
// First, check if ALL paths in this condition set are controllable (or can be expanded to controllable sources)
|
|
905
|
+
const resolvedPaths = new Map();
|
|
906
|
+
// Track expanded sources for derived variables (path -> array of expanded sources)
|
|
907
|
+
const expandedSources = new Map();
|
|
908
|
+
let allControllable = true;
|
|
909
|
+
for (const condition of conditionSet) {
|
|
910
|
+
// Check if this condition path has derivation info
|
|
911
|
+
// First check conditionalUsages, then fall back to derivedVariables
|
|
912
|
+
const usagesForPath = conditionalUsages[condition.path];
|
|
913
|
+
let derivedFromInfo = usagesForPath?.find((u) => u.derivedFrom?.operation)?.derivedFrom;
|
|
914
|
+
// CRITICAL: Also check derivedVariables for intermediate derived variables
|
|
915
|
+
if (!derivedFromInfo && derivedVariables?.[condition.path]) {
|
|
916
|
+
derivedFromInfo = derivedVariables[condition.path];
|
|
917
|
+
}
|
|
918
|
+
if (derivedFromInfo) {
|
|
919
|
+
// This is a derived variable - expand to its sources
|
|
920
|
+
const sources = expandDerivedVariableToSources(condition.path, conditionalUsages, attributesMap, equivalentSignatureVariables, fullToShortPathMap, new Set(), derivedVariables);
|
|
921
|
+
if (sources.length > 0) {
|
|
922
|
+
// Store the expanded sources for this condition
|
|
923
|
+
expandedSources.set(condition.path, sources);
|
|
924
|
+
// Use the first source's path for the resolvedPaths map (for ID generation)
|
|
925
|
+
resolvedPaths.set(condition.path, sources[0].path);
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
// Derived variable but no controllable sources found
|
|
929
|
+
allControllable = false;
|
|
930
|
+
break;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
// Not a derived variable - resolve directly
|
|
935
|
+
const resolution = resolvePathToControllable(condition.path, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
936
|
+
if (!resolution.isControllable || !resolution.resolvedPath) {
|
|
937
|
+
allControllable = false;
|
|
938
|
+
break;
|
|
939
|
+
}
|
|
940
|
+
resolvedPaths.set(condition.path, resolution.resolvedPath);
|
|
941
|
+
}
|
|
512
942
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
943
|
+
// Only create a flow if ALL paths are controllable
|
|
944
|
+
if (allControllable && resolvedPaths.size > 0) {
|
|
945
|
+
// If any conditions were expanded from derived variables, we need to build a custom flow
|
|
946
|
+
if (expandedSources.size > 0) {
|
|
947
|
+
const requiredValues = [];
|
|
948
|
+
for (const condition of conditionSet) {
|
|
949
|
+
const sources = expandedSources.get(condition.path);
|
|
950
|
+
if (sources) {
|
|
951
|
+
// This condition was expanded - add all its sources
|
|
952
|
+
// Determine the required value based on condition type and derivation operation
|
|
953
|
+
const usagesForPath = conditionalUsages[condition.path];
|
|
954
|
+
let expandedDerivedFrom = usagesForPath?.find((u) => u.derivedFrom?.operation)?.derivedFrom;
|
|
955
|
+
// Also check derivedVariables for intermediate derived variables
|
|
956
|
+
if (!expandedDerivedFrom && derivedVariables?.[condition.path]) {
|
|
957
|
+
expandedDerivedFrom = derivedVariables[condition.path];
|
|
958
|
+
}
|
|
959
|
+
const operation = expandedDerivedFrom?.operation;
|
|
960
|
+
for (const source of sources) {
|
|
961
|
+
// For OR-derived truthy: ANY source truthy
|
|
962
|
+
// For AND-derived truthy: ALL sources truthy
|
|
963
|
+
// For negated: inverse
|
|
964
|
+
let value;
|
|
965
|
+
let comparison;
|
|
966
|
+
if (condition.conditionType === 'truthiness') {
|
|
967
|
+
const isNegated = condition.isNegated === true;
|
|
968
|
+
// For OR: truthy needs ANY source truthy, falsy needs ALL sources falsy
|
|
969
|
+
// For AND: truthy needs ALL sources truthy, falsy needs ANY source falsy
|
|
970
|
+
// In compound conditionals, we generate the truthy path by default
|
|
971
|
+
// (the compound expression must be truthy)
|
|
972
|
+
if (operation === 'or') {
|
|
973
|
+
// For OR-derived, truthy means we need at least one source truthy
|
|
974
|
+
// We'll use the first source as truthy (simplification)
|
|
975
|
+
value = isNegated ? 'falsy' : 'truthy';
|
|
976
|
+
}
|
|
977
|
+
else if (operation === 'and') {
|
|
978
|
+
// For AND-derived, truthy means ALL sources truthy
|
|
979
|
+
value = isNegated ? 'falsy' : 'truthy';
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
value = isNegated ? 'falsy' : 'truthy';
|
|
983
|
+
}
|
|
984
|
+
comparison = isNegated ? 'falsy' : 'truthy';
|
|
985
|
+
}
|
|
986
|
+
else {
|
|
987
|
+
value = 'truthy';
|
|
988
|
+
comparison = 'truthy';
|
|
989
|
+
}
|
|
990
|
+
requiredValues.push({
|
|
991
|
+
attributePath: source.path,
|
|
992
|
+
value,
|
|
993
|
+
comparison,
|
|
994
|
+
valueType: 'boolean',
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
// This condition was resolved directly
|
|
1000
|
+
const resolvedPath = resolvedPaths.get(condition.path);
|
|
1001
|
+
if (resolvedPath) {
|
|
1002
|
+
let value;
|
|
1003
|
+
let comparison;
|
|
1004
|
+
if (condition.conditionType === 'truthiness') {
|
|
1005
|
+
value = condition.isNegated ? 'falsy' : 'truthy';
|
|
1006
|
+
comparison = condition.isNegated ? 'falsy' : 'truthy';
|
|
1007
|
+
}
|
|
1008
|
+
else {
|
|
1009
|
+
value =
|
|
1010
|
+
condition.requiredValue?.toString() ??
|
|
1011
|
+
condition.comparedValues?.[0] ??
|
|
1012
|
+
'truthy';
|
|
1013
|
+
comparison = 'equals';
|
|
1014
|
+
}
|
|
1015
|
+
requiredValues.push({
|
|
1016
|
+
attributePath: stripLengthSuffix(resolvedPath),
|
|
1017
|
+
value,
|
|
1018
|
+
comparison,
|
|
1019
|
+
valueType: inferValueType(value),
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
if (requiredValues.length > 0) {
|
|
1025
|
+
const impact = compound.controlsJsxRendering ? 'high' : 'medium';
|
|
1026
|
+
// Generate a combined ID from all paths
|
|
1027
|
+
const pathParts = requiredValues
|
|
1028
|
+
.map((rv) => {
|
|
1029
|
+
const name = generateNameFromPath(rv.attributePath);
|
|
1030
|
+
return name.toLowerCase().replace(/\s+/g, '-');
|
|
1031
|
+
})
|
|
1032
|
+
.join('-and-');
|
|
1033
|
+
const compoundFlow = {
|
|
1034
|
+
id: `${pathParts}-${requiredValues.map((rv) => rv.value).join('-')}`,
|
|
1035
|
+
name: generateNameFromPath(requiredValues[0].attributePath),
|
|
1036
|
+
description: `When ${requiredValues.map((rv) => `${generateNameFromPath(rv.attributePath).toLowerCase()} is ${rv.value}`).join(' and ')}`,
|
|
1037
|
+
impact,
|
|
1038
|
+
requiredValues,
|
|
1039
|
+
sourceLocation: compound.sourceLocation,
|
|
1040
|
+
};
|
|
1041
|
+
if (!seenFlowIds.has(compoundFlow.id)) {
|
|
1042
|
+
seenFlowIds.add(compoundFlow.id);
|
|
1043
|
+
flows.push(compoundFlow);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
else {
|
|
1048
|
+
// No derived variables - use the original generateFlowFromCompound
|
|
1049
|
+
// Create a modified compound with just this condition set
|
|
1050
|
+
const modifiedCompound = {
|
|
1051
|
+
...compound,
|
|
1052
|
+
conditions: conditionSet,
|
|
1053
|
+
};
|
|
1054
|
+
const compoundFlow = generateFlowFromCompound(modifiedCompound, resolvedPaths);
|
|
1055
|
+
if (compoundFlow && !seenFlowIds.has(compoundFlow.id)) {
|
|
1056
|
+
seenFlowIds.add(compoundFlow.id);
|
|
1057
|
+
flows.push(compoundFlow);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
521
1060
|
}
|
|
522
1061
|
}
|
|
523
1062
|
}
|
|
@@ -541,7 +1080,17 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
541
1080
|
const [, varName, operator, comparedValue] = comparisonMatch;
|
|
542
1081
|
// Try to resolve the variable name
|
|
543
1082
|
const varResolution = resolvePathToControllable(varName, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
1083
|
+
// Only use controllable paths for gating conditions (whitelist approach).
|
|
1084
|
+
// Do NOT fall back to equivalentSignatureVariables because those may contain
|
|
1085
|
+
// uncontrollable paths like useState that cannot be mocked.
|
|
1086
|
+
let resolvedVarPath = null;
|
|
544
1087
|
if (varResolution.isControllable && varResolution.resolvedPath) {
|
|
1088
|
+
resolvedVarPath = varResolution.resolvedPath;
|
|
1089
|
+
}
|
|
1090
|
+
// Note: We intentionally do NOT fall back to equivalentSignatureVariables here
|
|
1091
|
+
// because that would allow uncontrollable paths (like useState) to be added
|
|
1092
|
+
// as gating conditions.
|
|
1093
|
+
if (resolvedVarPath) {
|
|
545
1094
|
const isNegated = gatingCondition.isNegated === true;
|
|
546
1095
|
const isNotEquals = operator === '!=' || operator === '!==';
|
|
547
1096
|
// Determine the effective value for this gating condition
|
|
@@ -551,7 +1100,7 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
551
1100
|
// XOR logic: isNegated XOR isNotEquals
|
|
552
1101
|
const needsExactValue = isNegated !== isNotEquals;
|
|
553
1102
|
gatingRequiredValues.push({
|
|
554
|
-
attributePath:
|
|
1103
|
+
attributePath: resolvedVarPath,
|
|
555
1104
|
value: needsExactValue ? 'falsy' : comparedValue,
|
|
556
1105
|
comparison: needsExactValue ? 'falsy' : 'equals',
|
|
557
1106
|
});
|
|
@@ -604,7 +1153,7 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
604
1153
|
// For non-negated &&: all parts must be truthy
|
|
605
1154
|
// For negated ||: all parts must be falsy (DeMorgan: !(A || B) = !A && !B)
|
|
606
1155
|
gatingRequiredValues.push({
|
|
607
|
-
attributePath: partResolution.resolvedPath,
|
|
1156
|
+
attributePath: stripLengthSuffix(partResolution.resolvedPath),
|
|
608
1157
|
value: isNegated ? 'falsy' : 'truthy',
|
|
609
1158
|
comparison: isNegated ? 'falsy' : 'truthy',
|
|
610
1159
|
});
|
|
@@ -616,14 +1165,24 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
616
1165
|
// Simple gating condition (single path)
|
|
617
1166
|
// Resolve the gating path in parent context
|
|
618
1167
|
const gatingResolution = resolvePathToControllable(gatingPath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
1168
|
+
// Only use controllable paths for gating conditions (whitelist approach).
|
|
1169
|
+
// Do NOT fall back to equivalentSignatureVariables because those may contain
|
|
1170
|
+
// uncontrollable paths like useState that cannot be mocked.
|
|
1171
|
+
let resolvedGatingPath = null;
|
|
619
1172
|
if (gatingResolution.isControllable &&
|
|
620
1173
|
gatingResolution.resolvedPath) {
|
|
1174
|
+
resolvedGatingPath = gatingResolution.resolvedPath;
|
|
1175
|
+
}
|
|
1176
|
+
// Note: We intentionally do NOT fall back to equivalentSignatureVariables here
|
|
1177
|
+
// because that would allow uncontrollable paths (like useState) to be added
|
|
1178
|
+
// as gating conditions.
|
|
1179
|
+
if (resolvedGatingPath) {
|
|
621
1180
|
// For truthiness conditions on gating, check if the condition is negated
|
|
622
1181
|
// e.g., ternary else branch: isError ? <ErrorView /> : <SuccessView />
|
|
623
1182
|
// SuccessView has isNegated: true, meaning it renders when isError is falsy
|
|
624
1183
|
const isNegated = gatingCondition.isNegated === true;
|
|
625
1184
|
gatingRequiredValues.push({
|
|
626
|
-
attributePath:
|
|
1185
|
+
attributePath: resolvedGatingPath,
|
|
627
1186
|
value: isNegated ? 'falsy' : 'truthy',
|
|
628
1187
|
comparison: isNegated ? 'falsy' : 'truthy',
|
|
629
1188
|
});
|
|
@@ -636,6 +1195,8 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
636
1195
|
const childCompoundChainIds = new Set(childData.compoundConditionals.map((c) => c.chainId).filter(Boolean));
|
|
637
1196
|
for (const [_path, usages] of Object.entries(childData.conditionalUsages)) {
|
|
638
1197
|
for (const usage of usages) {
|
|
1198
|
+
// Debug logging (disabled - set to true for troubleshooting child flow resolution)
|
|
1199
|
+
const shouldDebugChild = false;
|
|
639
1200
|
// Skip usages that are part of compound conditionals (handled separately)
|
|
640
1201
|
// Fix 33: Only skip if the chainId is in the child's compound conditionals
|
|
641
1202
|
if (usage.chainId && childCompoundChainIds.has(usage.chainId)) {
|
|
@@ -647,30 +1208,112 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
647
1208
|
if (usage.derivedFrom?.sourcePath) {
|
|
648
1209
|
childPath = usage.derivedFrom.sourcePath;
|
|
649
1210
|
}
|
|
1211
|
+
if (shouldDebugChild) {
|
|
1212
|
+
console.log(`[DEBUG CHILD ${childName}] Processing usage path: ${usage.path}`);
|
|
1213
|
+
console.log(`[DEBUG CHILD ${childName}] childPath (after derivedFrom): ${childPath}`);
|
|
1214
|
+
console.log(`[DEBUG CHILD ${childName}] sourceDataPath: ${usage.sourceDataPath}`);
|
|
1215
|
+
}
|
|
650
1216
|
// Translate the child path to a parent path
|
|
651
1217
|
let translatedPath = translateChildPathToParent(childPath, childData.equivalentSignatureVariables, equivalentSignatureVariables, childName);
|
|
1218
|
+
if (shouldDebugChild) {
|
|
1219
|
+
console.log(`[DEBUG CHILD ${childName}] translatedPath (from translateChildPathToParent): ${translatedPath}`);
|
|
1220
|
+
}
|
|
652
1221
|
// If translation failed but we have sourceDataPath, try to extract the prop path from it
|
|
653
1222
|
// sourceDataPath format: "ChildName.signature[n].propPath.rest" → extract "propPath.rest"
|
|
654
1223
|
if (!translatedPath && usage.sourceDataPath) {
|
|
655
1224
|
const signatureMatch = usage.sourceDataPath.match(/\.signature\[\d+\]\.(.+)$/);
|
|
656
1225
|
if (signatureMatch) {
|
|
657
1226
|
translatedPath = signatureMatch[1];
|
|
1227
|
+
if (shouldDebugChild) {
|
|
1228
|
+
console.log(`[DEBUG CHILD ${childName}] translatedPath (from sourceDataPath regex): ${translatedPath}`);
|
|
1229
|
+
}
|
|
658
1230
|
}
|
|
659
1231
|
}
|
|
660
1232
|
if (!translatedPath) {
|
|
661
1233
|
// Could not translate - skip this usage
|
|
1234
|
+
if (shouldDebugChild) {
|
|
1235
|
+
console.log(`[DEBUG CHILD ${childName}] SKIPPED - no translation found`);
|
|
1236
|
+
}
|
|
662
1237
|
continue;
|
|
663
1238
|
}
|
|
664
1239
|
// Now resolve the translated path in the parent context
|
|
1240
|
+
// First, try standard resolution
|
|
665
1241
|
const resolution = resolvePathToControllable(translatedPath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
666
|
-
if (
|
|
667
|
-
|
|
668
|
-
|
|
1242
|
+
if (shouldDebugChild) {
|
|
1243
|
+
console.log(`[DEBUG CHILD ${childName}] resolvePathToControllable result:`);
|
|
1244
|
+
console.log(`[DEBUG CHILD ${childName}] isControllable: ${resolution.isControllable}`);
|
|
1245
|
+
console.log(`[DEBUG CHILD ${childName}] resolvedPath: ${resolution.resolvedPath}`);
|
|
1246
|
+
console.log(`[DEBUG CHILD ${childName}] chain: ${resolution.resolutionChain.join(' -> ')}`);
|
|
1247
|
+
}
|
|
1248
|
+
// Only create flows for controllable paths (whitelist approach).
|
|
1249
|
+
// If the path doesn't resolve to something in attributesMap, skip it.
|
|
1250
|
+
// This prevents creating flows for useState values which are not
|
|
1251
|
+
// controllable via mock data injection.
|
|
1252
|
+
let resolvedPath = resolution.resolvedPath;
|
|
1253
|
+
if (!resolution.isControllable || !resolvedPath) {
|
|
1254
|
+
// Path is not controllable via standard resolution.
|
|
1255
|
+
// Try fallback: For useState values (cyScope*().functionCallReturnValue),
|
|
1256
|
+
// look for a related URL parameter like "varNameFromUrl" that might
|
|
1257
|
+
// control the initial state.
|
|
1258
|
+
//
|
|
1259
|
+
// Example: viewMode → cyScope20().functionCallReturnValue (useState value)
|
|
1260
|
+
// Fallback: viewModeFromUrl → segments[2] (URL param that initializes the useState)
|
|
1261
|
+
const useStateMatch = translatedPath.match(/^cyScope\d+\(\)\.functionCallReturnValue$/);
|
|
1262
|
+
if (useStateMatch) {
|
|
1263
|
+
// Find what variable this useState value corresponds to by looking
|
|
1264
|
+
// for entries like "varName": "cyScope20()" in equivalentSignatureVariables
|
|
1265
|
+
const useStatePattern = translatedPath.replace(/\.functionCallReturnValue$/, ''); // e.g., "cyScope20()"
|
|
1266
|
+
// Find the variable name that maps to this useState
|
|
1267
|
+
let useStateVarName = null;
|
|
1268
|
+
for (const [varName, varPath] of Object.entries(equivalentSignatureVariables)) {
|
|
1269
|
+
if (varPath === useStatePattern) {
|
|
1270
|
+
useStateVarName = varName;
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
if (shouldDebugChild) {
|
|
1275
|
+
console.log(`[DEBUG CHILD ${childName}] useState fallback: looking for URL param`);
|
|
1276
|
+
console.log(`[DEBUG CHILD ${childName}] useStatePattern: ${useStatePattern}`);
|
|
1277
|
+
console.log(`[DEBUG CHILD ${childName}] useStateVarName: ${useStateVarName}`);
|
|
1278
|
+
}
|
|
1279
|
+
if (useStateVarName) {
|
|
1280
|
+
// Look for a related URL param like "varNameFromUrl"
|
|
1281
|
+
const urlParamName = `${useStateVarName}FromUrl`;
|
|
1282
|
+
const urlParamPath = equivalentSignatureVariables[urlParamName];
|
|
1283
|
+
if (shouldDebugChild) {
|
|
1284
|
+
console.log(`[DEBUG CHILD ${childName}] urlParamName: ${urlParamName}`);
|
|
1285
|
+
console.log(`[DEBUG CHILD ${childName}] urlParamPath: ${urlParamPath}`);
|
|
1286
|
+
}
|
|
1287
|
+
if (urlParamPath) {
|
|
1288
|
+
// For useState values initialized from URL params, use the
|
|
1289
|
+
// URL param variable name directly (e.g., "viewModeFromUrl")
|
|
1290
|
+
// rather than fully resolving it. This keeps the path meaningful
|
|
1291
|
+
// for scenario generation and avoids overly generic paths like
|
|
1292
|
+
// "useParams().functionCallReturnValue.*".
|
|
1293
|
+
//
|
|
1294
|
+
// The flow will use the URL param name as the attributePath,
|
|
1295
|
+
// which gets properly resolved when generating mock data.
|
|
1296
|
+
resolvedPath = urlParamName;
|
|
1297
|
+
if (shouldDebugChild) {
|
|
1298
|
+
console.log(`[DEBUG CHILD ${childName}] useState fallback SUCCESS: using URL param name ${resolvedPath}`);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
// If still not resolved after fallback, skip
|
|
1304
|
+
if (!resolvedPath) {
|
|
1305
|
+
if (shouldDebugChild) {
|
|
1306
|
+
console.log(`[DEBUG CHILD ${childName}] SKIPPED - path not controllable`);
|
|
1307
|
+
}
|
|
1308
|
+
continue;
|
|
1309
|
+
}
|
|
669
1310
|
}
|
|
670
|
-
const resolvedPath = resolution.resolvedPath;
|
|
671
1311
|
// Check for duplicates
|
|
672
1312
|
const normalizedPath = normalizePathForDeduplication(resolvedPath, fullToShortPathMap);
|
|
673
1313
|
if (seenNormalizedPaths.has(normalizedPath)) {
|
|
1314
|
+
if (shouldDebugChild) {
|
|
1315
|
+
console.log(`[DEBUG CHILD ${childName}] SKIPPED - duplicate normalized path: ${normalizedPath}`);
|
|
1316
|
+
}
|
|
674
1317
|
continue;
|
|
675
1318
|
}
|
|
676
1319
|
seenNormalizedPaths.add(normalizedPath);
|
|
@@ -681,6 +1324,12 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
681
1324
|
path: resolvedPath,
|
|
682
1325
|
};
|
|
683
1326
|
const usageFlows = generateFlowsFromUsage(translatedUsage, resolvedPath);
|
|
1327
|
+
if (shouldDebugChild) {
|
|
1328
|
+
console.log(`[DEBUG CHILD ${childName}] GENERATING ${usageFlows.length} flows with resolvedPath: ${resolvedPath}`);
|
|
1329
|
+
for (const f of usageFlows) {
|
|
1330
|
+
console.log(`[DEBUG CHILD ${childName}] - Flow ID: ${f.id}, path: ${f.requiredValues[0]?.attributePath}`);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
684
1333
|
// Add gating conditions to each flow
|
|
685
1334
|
for (const flow of usageFlows) {
|
|
686
1335
|
// Add gating required values to the flow
|
|
@@ -710,28 +1359,77 @@ export default function generateExecutionFlowsFromConditionals(args) {
|
|
|
710
1359
|
// Process child's compound conditionals
|
|
711
1360
|
for (const compound of childData.compoundConditionals) {
|
|
712
1361
|
const resolvedPaths = new Map();
|
|
713
|
-
let
|
|
1362
|
+
let allResolvable = true;
|
|
714
1363
|
for (const condition of compound.conditions) {
|
|
715
1364
|
// Determine the child path to translate
|
|
716
1365
|
const childPath = condition.path;
|
|
717
1366
|
// Translate the child path to a parent path
|
|
718
1367
|
const translatedPath = translateChildPathToParent(childPath, childData.equivalentSignatureVariables, equivalentSignatureVariables, childName);
|
|
719
1368
|
if (!translatedPath) {
|
|
720
|
-
|
|
1369
|
+
allResolvable = false;
|
|
721
1370
|
break;
|
|
722
1371
|
}
|
|
723
1372
|
const resolution = resolvePathToControllable(translatedPath, attributesMap, equivalentSignatureVariables, fullToShortPathMap);
|
|
724
|
-
|
|
725
|
-
|
|
1373
|
+
// Only create flows for controllable paths (whitelist approach).
|
|
1374
|
+
// If the path doesn't resolve to something in attributesMap, skip it.
|
|
1375
|
+
// This prevents creating flows for useState values which are not
|
|
1376
|
+
// controllable via mock data injection.
|
|
1377
|
+
let resolvedPath = resolution.resolvedPath;
|
|
1378
|
+
if (!resolution.isControllable || !resolvedPath) {
|
|
1379
|
+
// Path is not controllable via standard resolution.
|
|
1380
|
+
// Try fallback: For useState values (cyScope*().functionCallReturnValue),
|
|
1381
|
+
// look for a related URL parameter like "varNameFromUrl" that might
|
|
1382
|
+
// control the initial state.
|
|
1383
|
+
const useStateMatch = translatedPath.match(/^cyScope\d+\(\)\.functionCallReturnValue$/);
|
|
1384
|
+
if (useStateMatch) {
|
|
1385
|
+
const useStatePattern = translatedPath.replace(/\.functionCallReturnValue$/, '');
|
|
1386
|
+
// Find the variable name that maps to this useState
|
|
1387
|
+
let useStateVarName = null;
|
|
1388
|
+
for (const [varName, varPath] of Object.entries(equivalentSignatureVariables)) {
|
|
1389
|
+
if (varPath === useStatePattern) {
|
|
1390
|
+
useStateVarName = varName;
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
if (useStateVarName) {
|
|
1395
|
+
const urlParamName = `${useStateVarName}FromUrl`;
|
|
1396
|
+
const urlParamPath = equivalentSignatureVariables[urlParamName];
|
|
1397
|
+
if (urlParamPath) {
|
|
1398
|
+
resolvedPath = urlParamName;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
if (!resolvedPath) {
|
|
1404
|
+
allResolvable = false;
|
|
726
1405
|
break;
|
|
727
1406
|
}
|
|
728
|
-
resolvedPaths.set(condition.path,
|
|
1407
|
+
resolvedPaths.set(condition.path, resolvedPath);
|
|
729
1408
|
}
|
|
730
|
-
if (
|
|
1409
|
+
if (allResolvable && resolvedPaths.size > 0) {
|
|
731
1410
|
const compoundFlow = generateFlowFromCompound(compound, resolvedPaths);
|
|
732
|
-
if (compoundFlow
|
|
733
|
-
|
|
734
|
-
|
|
1411
|
+
if (compoundFlow) {
|
|
1412
|
+
// Add gating conditions to compound flow (same as regular usage flows)
|
|
1413
|
+
if (gatingRequiredValues.length > 0) {
|
|
1414
|
+
// Filter out any gating values that are already in the flow
|
|
1415
|
+
const existingPaths = new Set(compoundFlow.requiredValues.map((rv) => rv.attributePath));
|
|
1416
|
+
const newGatingValues = gatingRequiredValues.filter((gv) => !existingPaths.has(gv.attributePath));
|
|
1417
|
+
compoundFlow.requiredValues = [
|
|
1418
|
+
...compoundFlow.requiredValues,
|
|
1419
|
+
...newGatingValues,
|
|
1420
|
+
];
|
|
1421
|
+
// Update the flow ID to include gating conditions
|
|
1422
|
+
if (newGatingValues.length > 0) {
|
|
1423
|
+
const gatingIdPart = newGatingValues
|
|
1424
|
+
.map((gv) => `${gv.attributePath}-${gv.value}`)
|
|
1425
|
+
.join('-');
|
|
1426
|
+
compoundFlow.id = `${compoundFlow.id}-gated-${gatingIdPart}`;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
if (!seenFlowIds.has(compoundFlow.id)) {
|
|
1430
|
+
seenFlowIds.add(compoundFlow.id);
|
|
1431
|
+
flows.push(compoundFlow);
|
|
1432
|
+
}
|
|
735
1433
|
}
|
|
736
1434
|
}
|
|
737
1435
|
}
|