@codeyam/codeyam-cli 0.1.0-staging.1669d45 → 0.1.0-staging.2a88920
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +5 -5
- package/analyzer-template/packages/ai/index.ts +15 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +87 -51
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +98 -9
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +139 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +6 -126
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +555 -28
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +88 -7
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +198 -34
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +772 -243
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +205 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +10 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +43 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +122 -15
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +160 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +319 -88
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +156 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +642 -7
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +35 -6
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +383 -6
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1299 -51
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +23 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +179 -45
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +26 -4
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +65 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +30 -19
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +14 -4
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +189 -76
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +29 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +77 -9
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +118 -10
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +276 -17
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/package.json +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +8 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +8 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +25 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +56 -6
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/types/index.ts +1 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +25 -0
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +70 -6
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/index.d.ts +1 -1
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +25 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +56 -6
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +20 -8
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/project/analyzeBaselineCommit.ts +5 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +5 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +367 -37
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +18 -7
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +71 -6
- package/analyzer-template/project/reconcileMockDataKeys.ts +152 -9
- package/analyzer-template/project/runAnalysis.ts +4 -0
- package/analyzer-template/project/start.ts +35 -11
- package/analyzer-template/project/writeMockDataTsx.ts +127 -4
- package/analyzer-template/project/writeScenarioComponents.ts +101 -8
- package/analyzer-template/scripts/comboWorkerLoop.cjs +98 -50
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +5 -0
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +5 -0
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +300 -7
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +7 -5
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +58 -6
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +126 -9
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +3 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +32 -11
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +101 -4
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +57 -8
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/codeyam-cli/src/cli.js +2 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/debug.js +7 -5
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +273 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +4 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +21 -2
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +42 -6
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +1 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +6 -0
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/rules/index.js +5 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +106 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +132 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +2 -0
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +7 -3
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +40 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-DsN1wKrm.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-COi5OvsN.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-BwdQv49w.js → EntityTypeIcon-Ba2JVPzP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-CEleMv_j.js → InlineSpinner-C8lyxW9k.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-D68KarMg.js → InteractivePreview-aht4aafF.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-L75Wvqgw.js → LibraryFunctionPreview-CVtiBnY5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-C53WM8qn.js → LoadingDots-B0GLXMsr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-CrNkmy4i.js → LogViewer-xgeCVgSM.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-OApQuNyq.js +16 -0
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-CQifa1n-.js → SafeScreenshot-DuDvi0jm.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-CyaBFX7l.js → ScenarioViewer-DzccYyI8.js} +3 -13
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-D36O1rzU.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-BwqWJOgH.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BwavGCpm.js +32 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-DgTPh8H-.js → chevron-down-Cx24_aWc.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-DdQKK6on.js → chunk-EPOLDU6W-CXRTFQ3F.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-Dmr2bb1R.js → circle-check-BOARzkeR.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-Do4ZLUYa.js → createLucideIcon-BdhJEx6B.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BBnGWYga.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CbdFyxZh.js → entity._sha._-BJUiQqZF.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-B4iCfs5M.js → entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-wDWZZO1W.js → entity._sha_.create-scenario-D1T4TGjf.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMbl7MeQ.js → entity._sha_.edit._scenarioId-CTBG2mmz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-5wRKRIH9.js → entry.client-CS2cb_eZ.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DD3SDH7t.js → fileTableUtils-DMJ7zii9.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-CJ6lTdTA.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{git-zXjT7J0G.js → git-CPTZZ-JZ.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-DLbXwndH.js → index-B1h680n5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-gPZ-lad1.js → index-lzqtyFU8.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-BsPXJ81F.js → loader-circle-B7B9V-bu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-a78b90a2.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory--GCbFsBE.js +92 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-eVAaavTS.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-P2FKIUql.js → search-CxXUmBSd.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{settings-B2eDuBj8.js → settings-CS5f3WzT.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-L18M6-kN.js → simulations-DwFIBT09.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-BDz7kbVA.js → triangle-alert-B6LgvRJg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-29dDmbH8.js → useCustomSizes-C1v1PQzo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BUm0UVJm.js → useLastLogLine-aSv48UbS.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-CkIOKTrZ.js → useReportContext-DYxHZQuP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-KKw5kTn-.js → useToast-mBRpZPiu.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-BM6TDT1Y.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-dYC34MHw.js +257 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/codeyam-memory-hook.sh +200 -0
- package/codeyam-cli/templates/codeyam:debug.md +47 -3
- package/codeyam-cli/templates/codeyam:diagnose.md +203 -25
- package/codeyam-cli/templates/codeyam:memory.md +341 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +160 -0
- package/codeyam-cli/templates/rules-instructions.md +93 -0
- package/package.json +8 -5
- package/packages/ai/index.js +7 -3
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +70 -29
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +78 -8
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/methodSemantics.js +109 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +1 -102
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +440 -27
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +161 -30
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +589 -166
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +179 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +7 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +41 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +104 -11
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +159 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +265 -79
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +111 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateEntityScenarioData.js +525 -8
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +26 -2
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +281 -4
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +946 -42
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/mergeStatements.js +70 -51
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +15 -7
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +155 -41
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +7 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +94 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +60 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +21 -9
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +14 -4
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +160 -68
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +25 -8
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +71 -9
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +57 -9
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +233 -9
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/database/src/lib/kysely/db.js +8 -1
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/loadAnalyses.js +45 -2
- package/packages/database/src/lib/loadAnalyses.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-vauWK972.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DzJRkCkr.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/_index-Be83mo_j.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BN6wu6Y-.js +0 -37
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Bn6aCAy_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-DKyMFI90.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-DTTQ3gY7.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-22590fcf.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-BsAarjAM.js +0 -57
- package/codeyam-cli/src/webserver/build/server/assets/index-BND5I5fv.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CFXnd7MG.js +0 -228
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates execution flows from JSX rendering usages.
|
|
3
|
+
*
|
|
4
|
+
* This module creates variation flows for arrays and strings that are rendered
|
|
5
|
+
* directly in JSX, even without explicit conditionals:
|
|
6
|
+
* - Arrays rendered via .map() → empty, few, many flows
|
|
7
|
+
* - Strings rendered via interpolation → normal, long flows
|
|
8
|
+
*
|
|
9
|
+
* Only controllable paths (from props, hooks, or external data) produce flows.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ExecutionFlow } from '~codeyam/types';
|
|
13
|
+
import type { JsxRenderingUsage } from './astScopes/types';
|
|
14
|
+
import resolvePathToControllable from './resolvePathToControllable';
|
|
15
|
+
|
|
16
|
+
export interface GenerateFlowsFromJsxUsagesArgs {
|
|
17
|
+
/** JSX rendering usages extracted from AST analysis */
|
|
18
|
+
jsxRenderingUsages: JsxRenderingUsage[];
|
|
19
|
+
/** Map of controllable paths to their types */
|
|
20
|
+
attributesMap: Record<string, string>;
|
|
21
|
+
/** Map from local variable names to data sources */
|
|
22
|
+
equivalentSignatureVariables: Record<string, string | string[]>;
|
|
23
|
+
/** Map from full paths to short paths */
|
|
24
|
+
fullToShortPathMap: Record<string, string>;
|
|
25
|
+
/** Structure map for type lookup */
|
|
26
|
+
structure: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generate a slug from a path for use in exclusive groups
|
|
31
|
+
*/
|
|
32
|
+
function pathToSlug(path: string): string {
|
|
33
|
+
return path
|
|
34
|
+
.replace(/\[\d+\]/g, '')
|
|
35
|
+
.replace(/\[\]/g, '')
|
|
36
|
+
.replace(/\(\)/g, '')
|
|
37
|
+
.replace(/\.functionCallReturnValue/g, '')
|
|
38
|
+
.replace(/[<>]/g, '')
|
|
39
|
+
.replace(/\./g, '-')
|
|
40
|
+
.toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generate a human-readable name from a path.
|
|
45
|
+
*/
|
|
46
|
+
function generateNameFromPath(path: string): string {
|
|
47
|
+
const cleanPath = path
|
|
48
|
+
.replace(/\(\)/g, '')
|
|
49
|
+
.replace(/\.functionCallReturnValue/g, '');
|
|
50
|
+
const parts = cleanPath.split('.');
|
|
51
|
+
const lastPart = parts[parts.length - 1];
|
|
52
|
+
|
|
53
|
+
// Convert camelCase to Title Case
|
|
54
|
+
return lastPart
|
|
55
|
+
.replace(/([A-Z])/g, ' $1')
|
|
56
|
+
.replace(/^./, (str) => str.toUpperCase())
|
|
57
|
+
.trim();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Generate execution flows from JSX rendering usages.
|
|
62
|
+
*
|
|
63
|
+
* For arrays: generates empty (0), few (1-3), many (10+) flows
|
|
64
|
+
* For strings: generates normal and long text flows
|
|
65
|
+
*/
|
|
66
|
+
export default function generateExecutionFlowsFromJsxUsages(
|
|
67
|
+
args: GenerateFlowsFromJsxUsagesArgs,
|
|
68
|
+
): ExecutionFlow[] {
|
|
69
|
+
const {
|
|
70
|
+
jsxRenderingUsages,
|
|
71
|
+
attributesMap,
|
|
72
|
+
equivalentSignatureVariables,
|
|
73
|
+
fullToShortPathMap,
|
|
74
|
+
} = args;
|
|
75
|
+
|
|
76
|
+
const flows: ExecutionFlow[] = [];
|
|
77
|
+
const seenPaths = new Set<string>();
|
|
78
|
+
|
|
79
|
+
for (const usage of jsxRenderingUsages) {
|
|
80
|
+
// Resolve the path to a controllable data source
|
|
81
|
+
const resolution = resolvePathToControllable(
|
|
82
|
+
usage.path,
|
|
83
|
+
attributesMap,
|
|
84
|
+
equivalentSignatureVariables,
|
|
85
|
+
fullToShortPathMap,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (!resolution.isControllable || !resolution.resolvedPath) {
|
|
89
|
+
// Path is not controllable - skip
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const resolvedPath = resolution.resolvedPath;
|
|
94
|
+
|
|
95
|
+
// Deduplicate by resolved path + rendering type
|
|
96
|
+
const dedupeKey = `${resolvedPath}:${usage.renderingType}`;
|
|
97
|
+
if (seenPaths.has(dedupeKey)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
seenPaths.add(dedupeKey);
|
|
101
|
+
|
|
102
|
+
const baseName = generateNameFromPath(resolvedPath);
|
|
103
|
+
const pathSlug = pathToSlug(resolvedPath);
|
|
104
|
+
|
|
105
|
+
if (usage.renderingType === 'array-map') {
|
|
106
|
+
// Generate 3 mutually exclusive flows for array sizes
|
|
107
|
+
const exclusiveGroup = `array-length-${pathSlug}`;
|
|
108
|
+
|
|
109
|
+
// Empty array flow
|
|
110
|
+
flows.push({
|
|
111
|
+
id: `${pathSlug}-empty-array`,
|
|
112
|
+
name: `${baseName} Empty`,
|
|
113
|
+
description: `When ${baseName.toLowerCase()} array is empty`,
|
|
114
|
+
requiredValues: [
|
|
115
|
+
{
|
|
116
|
+
attributePath: resolvedPath,
|
|
117
|
+
value: '0',
|
|
118
|
+
comparison: 'length<',
|
|
119
|
+
valueType: 'array',
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
impact: 'medium',
|
|
123
|
+
exclusiveGroup,
|
|
124
|
+
sourceLocation: usage.sourceLocation
|
|
125
|
+
? {
|
|
126
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
127
|
+
column: usage.sourceLocation.column,
|
|
128
|
+
}
|
|
129
|
+
: undefined,
|
|
130
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Few items flow (1-3)
|
|
134
|
+
flows.push({
|
|
135
|
+
id: `${pathSlug}-few-items`,
|
|
136
|
+
name: `${baseName} Few Items`,
|
|
137
|
+
description: `When ${baseName.toLowerCase()} array has 1-3 items`,
|
|
138
|
+
requiredValues: [
|
|
139
|
+
{
|
|
140
|
+
attributePath: resolvedPath,
|
|
141
|
+
value: '3',
|
|
142
|
+
comparison: 'length<',
|
|
143
|
+
valueType: 'array',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
impact: 'low', // Baseline case
|
|
147
|
+
exclusiveGroup,
|
|
148
|
+
sourceLocation: usage.sourceLocation
|
|
149
|
+
? {
|
|
150
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
151
|
+
column: usage.sourceLocation.column,
|
|
152
|
+
}
|
|
153
|
+
: undefined,
|
|
154
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Many items flow (10+)
|
|
158
|
+
flows.push({
|
|
159
|
+
id: `${pathSlug}-many-items`,
|
|
160
|
+
name: `${baseName} Many Items`,
|
|
161
|
+
description: `When ${baseName.toLowerCase()} array has 10+ items`,
|
|
162
|
+
requiredValues: [
|
|
163
|
+
{
|
|
164
|
+
attributePath: resolvedPath,
|
|
165
|
+
value: '10',
|
|
166
|
+
comparison: 'length>',
|
|
167
|
+
valueType: 'array',
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
impact: 'medium',
|
|
171
|
+
exclusiveGroup,
|
|
172
|
+
sourceLocation: usage.sourceLocation
|
|
173
|
+
? {
|
|
174
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
175
|
+
column: usage.sourceLocation.column,
|
|
176
|
+
}
|
|
177
|
+
: undefined,
|
|
178
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
179
|
+
});
|
|
180
|
+
} else if (
|
|
181
|
+
usage.renderingType === 'text-interpolation' &&
|
|
182
|
+
usage.valueType === 'string'
|
|
183
|
+
) {
|
|
184
|
+
// Only generate text flows for strings (not numbers or other types)
|
|
185
|
+
// Generate 2 mutually exclusive flows for text lengths
|
|
186
|
+
const exclusiveGroup = `text-length-${pathSlug}`;
|
|
187
|
+
|
|
188
|
+
// Normal text flow
|
|
189
|
+
flows.push({
|
|
190
|
+
id: `${pathSlug}-normal-text`,
|
|
191
|
+
name: `${baseName} Normal`,
|
|
192
|
+
description: `When ${baseName.toLowerCase()} has normal length text`,
|
|
193
|
+
requiredValues: [
|
|
194
|
+
{
|
|
195
|
+
attributePath: resolvedPath,
|
|
196
|
+
value: 'normal',
|
|
197
|
+
comparison: 'equals',
|
|
198
|
+
valueType: 'string',
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
impact: 'low',
|
|
202
|
+
exclusiveGroup,
|
|
203
|
+
sourceLocation: usage.sourceLocation
|
|
204
|
+
? {
|
|
205
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
206
|
+
column: usage.sourceLocation.column,
|
|
207
|
+
}
|
|
208
|
+
: undefined,
|
|
209
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// Long text flow
|
|
213
|
+
flows.push({
|
|
214
|
+
id: `${pathSlug}-long-text`,
|
|
215
|
+
name: `${baseName} Long Text`,
|
|
216
|
+
description: `When ${baseName.toLowerCase()} has long text that might overflow`,
|
|
217
|
+
requiredValues: [
|
|
218
|
+
{
|
|
219
|
+
attributePath: resolvedPath,
|
|
220
|
+
value: 'long',
|
|
221
|
+
comparison: 'equals',
|
|
222
|
+
valueType: 'string',
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
impact: 'low',
|
|
226
|
+
exclusiveGroup,
|
|
227
|
+
sourceLocation: usage.sourceLocation
|
|
228
|
+
? {
|
|
229
|
+
lineNumber: usage.sourceLocation.lineNumber,
|
|
230
|
+
column: usage.sourceLocation.column,
|
|
231
|
+
}
|
|
232
|
+
: undefined,
|
|
233
|
+
codeSnippet: usage.sourceLocation?.codeSnippet,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return flows;
|
|
239
|
+
}
|
|
@@ -7,58 +7,12 @@ import {
|
|
|
7
7
|
|
|
8
8
|
export interface Statement {
|
|
9
9
|
structure: { [key: string]: string };
|
|
10
|
-
|
|
10
|
+
// Supports multiple equivalencies per key for OR expressions (e.g., x = a || b)
|
|
11
|
+
equivalentVariables: { [key: string]: string | string[] };
|
|
11
12
|
llmCall?: LlmCall;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export default function mergeStatements(statements: Statement[]) {
|
|
15
|
-
// Debug: Log input statements to understand what we're merging
|
|
16
|
-
const hasStateStructure = statements.some((s) =>
|
|
17
|
-
Object.keys(s.structure || {}).some(
|
|
18
|
-
(k) => k === 'state' || k.includes('state'),
|
|
19
|
-
),
|
|
20
|
-
);
|
|
21
|
-
const hasStateEquiv = statements.some((s) =>
|
|
22
|
-
Object.keys(s.equivalentVariables || {}).some(
|
|
23
|
-
(k) => k === 'state' || k.includes('state'),
|
|
24
|
-
),
|
|
25
|
-
);
|
|
26
|
-
if (hasStateStructure || hasStateEquiv) {
|
|
27
|
-
console.log(
|
|
28
|
-
`[UNION-TYPE] mergeStatements INPUT: ${statements.length} statements`,
|
|
29
|
-
);
|
|
30
|
-
statements.forEach((s, i) => {
|
|
31
|
-
const stateInStructure = Object.entries(s.structure || {}).filter(
|
|
32
|
-
([k]) => k === 'state' || k.includes('state'),
|
|
33
|
-
);
|
|
34
|
-
const stateInEquiv = Object.entries(s.equivalentVariables || {}).filter(
|
|
35
|
-
([k]) => k === 'state' || k.includes('state'),
|
|
36
|
-
);
|
|
37
|
-
const sigInEquiv = Object.entries(s.equivalentVariables || {}).filter(
|
|
38
|
-
([k, v]) => k === 'state' || v === 'signature[0]',
|
|
39
|
-
);
|
|
40
|
-
if (
|
|
41
|
-
stateInStructure.length > 0 ||
|
|
42
|
-
stateInEquiv.length > 0 ||
|
|
43
|
-
sigInEquiv.length > 0
|
|
44
|
-
) {
|
|
45
|
-
console.log(`[UNION-TYPE] Statement ${i}:`);
|
|
46
|
-
if (stateInStructure.length > 0)
|
|
47
|
-
console.log(
|
|
48
|
-
`[UNION-TYPE] structure: ${JSON.stringify(Object.fromEntries(stateInStructure))}`,
|
|
49
|
-
);
|
|
50
|
-
if (stateInEquiv.length > 0)
|
|
51
|
-
console.log(
|
|
52
|
-
`[UNION-TYPE] equivalentVariables (state): ${JSON.stringify(Object.fromEntries(stateInEquiv))}`,
|
|
53
|
-
);
|
|
54
|
-
if (sigInEquiv.length > 0)
|
|
55
|
-
console.log(
|
|
56
|
-
`[UNION-TYPE] equivalentVariables (sig): ${JSON.stringify(Object.fromEntries(sigInEquiv))}`,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
16
|
// This should be handled by the AST Analyzer but it currently has a bug
|
|
63
17
|
const ensureFunctionCallReturnValue = (path: string, value: string) => {
|
|
64
18
|
if (path.endsWith(')') && value !== 'function') {
|
|
@@ -172,12 +126,54 @@ export default function mergeStatements(statements: Statement[]) {
|
|
|
172
126
|
// settingsData → fetcher.data.data uses fetcher::cyDuplicateKey1::.data.data
|
|
173
127
|
const activeRemappings: Record<string, string> = {};
|
|
174
128
|
|
|
129
|
+
// Helper to normalize value to array and process
|
|
130
|
+
const normalizeValue = (value: string | string[]): string[] =>
|
|
131
|
+
Array.isArray(value) ? value : [value];
|
|
132
|
+
|
|
175
133
|
const equivalentVariables = statements.reduce((acc: any, result) => {
|
|
176
|
-
for (const [key,
|
|
134
|
+
for (const [key, rawValue] of Object.entries(
|
|
177
135
|
result.equivalentVariables ?? {},
|
|
178
136
|
)) {
|
|
137
|
+
// Handle arrays from AST analyzer (OR expressions like x = a || b)
|
|
138
|
+
// These should be preserved as arrays to track all sources
|
|
139
|
+
if (Array.isArray(rawValue)) {
|
|
140
|
+
const keyOptions = deBinaryPath(key);
|
|
141
|
+
const validValues = rawValue.filter(
|
|
142
|
+
(v): v is string => typeof v === 'string' && v.length > 0,
|
|
143
|
+
);
|
|
144
|
+
if (validValues.length === 0) continue;
|
|
145
|
+
|
|
146
|
+
// Process each array value through deBinaryPath
|
|
147
|
+
const allValueOptions: string[] = [];
|
|
148
|
+
for (const value of validValues) {
|
|
149
|
+
const valueOptions = deBinaryPath(value);
|
|
150
|
+
allValueOptions.push(...valueOptions);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Remove duplicates while preserving order
|
|
154
|
+
const uniqueValueOptions = [...new Set(allValueOptions)];
|
|
155
|
+
const finalValue =
|
|
156
|
+
uniqueValueOptions.length === 1
|
|
157
|
+
? uniqueValueOptions[0]
|
|
158
|
+
: uniqueValueOptions;
|
|
159
|
+
|
|
160
|
+
delete result.equivalentVariables[key];
|
|
161
|
+
if (keyOptions.length >= 2) {
|
|
162
|
+
for (const keyOption of keyOptions) {
|
|
163
|
+
result.equivalentVariables[keyOption] = finalValue;
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
result.equivalentVariables[keyOptions[0]] = finalValue;
|
|
167
|
+
}
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Original logic for string values with potential binary expressions in the string
|
|
172
|
+
const firstValue = rawValue;
|
|
173
|
+
if (!firstValue) continue;
|
|
174
|
+
|
|
179
175
|
const keyOptions = deBinaryPath(key);
|
|
180
|
-
const valueOptions = deBinaryPath(
|
|
176
|
+
const valueOptions = deBinaryPath(firstValue);
|
|
181
177
|
delete result.equivalentVariables[key];
|
|
182
178
|
if (keyOptions.length === 2) {
|
|
183
179
|
if (valueOptions.length === 2) {
|
|
@@ -199,27 +195,38 @@ export default function mergeStatements(statements: Statement[]) {
|
|
|
199
195
|
}
|
|
200
196
|
}
|
|
201
197
|
|
|
202
|
-
for (const [key,
|
|
198
|
+
for (const [key, rawValue] of Object.entries(
|
|
203
199
|
result.equivalentVariables ?? {},
|
|
204
200
|
)) {
|
|
201
|
+
// Normalize to array for consistent handling
|
|
202
|
+
const values = normalizeValue(rawValue);
|
|
203
|
+
|
|
205
204
|
// Apply any active remappings to the VALUE, but ONLY for property paths
|
|
206
205
|
// e.g., if fetcher was remapped to fetcher::cyDuplicateKey1::,
|
|
207
206
|
// then "fetcher.data.data" should become "fetcher::cyDuplicateKey1::.data.data"
|
|
208
207
|
// However, we should NOT remap standalone variable references like "description"
|
|
209
208
|
// because that would lose type information from the original variable.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
209
|
+
const remappedValues = values.map((value) => {
|
|
210
|
+
let remappedValue = value;
|
|
211
|
+
for (const [originalKey, remappedKey] of Object.entries(
|
|
212
|
+
activeRemappings,
|
|
213
|
+
)) {
|
|
214
|
+
// Only remap if the value is a property path (contains a dot after the key)
|
|
215
|
+
// This preserves type information for simple variable references
|
|
216
|
+
const keyRegex = new RegExp(
|
|
217
|
+
`^${originalKey.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?=\\.)`,
|
|
218
|
+
);
|
|
219
|
+
if (keyRegex.test(remappedValue)) {
|
|
220
|
+
remappedValue = remappedValue.replace(keyRegex, remappedKey);
|
|
221
|
+
}
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
+
return remappedValue;
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// Use array if multiple values, string if single
|
|
227
|
+
const remappedValue =
|
|
228
|
+
remappedValues.length === 1 ? remappedValues[0] : remappedValues;
|
|
229
|
+
const firstRemappedValue = remappedValues[0];
|
|
223
230
|
|
|
224
231
|
if (acc[key]) {
|
|
225
232
|
if (acc[key] === remappedValue) continue;
|
|
@@ -247,45 +254,32 @@ export default function mergeStatements(statements: Statement[]) {
|
|
|
247
254
|
// If we have equivalentVariables[A] = B, and structure[A] is more specific than structure[B],
|
|
248
255
|
// then update structure[B] to match structure[A]
|
|
249
256
|
// This handles cases like: "state" -> "signature[0]" where "state" has a union type
|
|
250
|
-
|
|
251
|
-
// Debug: Log union types in merged structure
|
|
252
|
-
const unionTypesInStructure = Object.entries(structure).filter(
|
|
253
|
-
([_, v]) => typeof v === 'string' && v.includes("'") && v.includes(' | '),
|
|
254
|
-
);
|
|
255
|
-
if (unionTypesInStructure.length > 0) {
|
|
256
|
-
console.log(
|
|
257
|
-
`[UNION-TYPE] mergeStatements: Found ${unionTypesInStructure.length} union types in merged structure`,
|
|
258
|
-
);
|
|
259
|
-
unionTypesInStructure.forEach(([k, v]) =>
|
|
260
|
-
console.log(`[UNION-TYPE] structure["${k}"] = ${v}`),
|
|
261
|
-
);
|
|
262
|
-
console.log(
|
|
263
|
-
`[UNION-TYPE] mergeStatements: equivalentVariables = ${JSON.stringify(equivalentVariables)}`,
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
for (const [source, target] of Object.entries(equivalentVariables) as [
|
|
268
|
-
string,
|
|
257
|
+
for (const [source, rawTarget] of Object.entries(equivalentVariables) as [
|
|
269
258
|
string,
|
|
259
|
+
string | string[],
|
|
270
260
|
][]) {
|
|
261
|
+
// Normalize to array for consistent handling
|
|
262
|
+
const targets = Array.isArray(rawTarget) ? rawTarget : [rawTarget];
|
|
271
263
|
const sourceType = structure[source];
|
|
272
|
-
const targetType = structure[target];
|
|
273
264
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const sourceIsUnion =
|
|
277
|
-
sourceType.includes("'") && sourceType.includes(' | ');
|
|
265
|
+
for (const target of targets) {
|
|
266
|
+
if (typeof target !== 'string') continue;
|
|
278
267
|
|
|
279
|
-
|
|
280
|
-
// Target doesn't exist or is generic - propagate the union type
|
|
281
|
-
const targetIsGeneric =
|
|
282
|
-
!targetType || targetType === 'string' || targetType === 'unknown';
|
|
268
|
+
const targetType = structure[target];
|
|
283
269
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
);
|
|
288
|
-
|
|
270
|
+
// Check if source has a more specific type (union type vs generic type)
|
|
271
|
+
if (sourceType) {
|
|
272
|
+
const sourceIsUnion =
|
|
273
|
+
sourceType.includes("'") && sourceType.includes(' | ');
|
|
274
|
+
|
|
275
|
+
if (sourceIsUnion) {
|
|
276
|
+
// Target doesn't exist or is generic - propagate the union type
|
|
277
|
+
const targetIsGeneric =
|
|
278
|
+
!targetType || targetType === 'string' || targetType === 'unknown';
|
|
279
|
+
|
|
280
|
+
if (targetIsGeneric) {
|
|
281
|
+
structure[target] = sourceType;
|
|
282
|
+
}
|
|
289
283
|
}
|
|
290
284
|
}
|
|
291
285
|
}
|
|
@@ -139,16 +139,19 @@ export function gatherAttributesMap(
|
|
|
139
139
|
// Use merged type if available, otherwise fall back to isolated type
|
|
140
140
|
const typeValue =
|
|
141
141
|
mergedSignatureSchema[key] ?? isolatedSignatureSchema[key];
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
// Handle array case (OR expressions) - use first element if array
|
|
143
|
+
const rawEquivalent = equivalentSignatureVariables[keyParts[0]];
|
|
144
|
+
const equivalentSignatureVariable = Array.isArray(rawEquivalent)
|
|
145
|
+
? rawEquivalent[0]
|
|
146
|
+
: rawEquivalent;
|
|
147
|
+
const equivalentSignatureVariableParts = equivalentSignatureVariable
|
|
148
|
+
? splitOutsideParenthesesAndArrays(equivalentSignatureVariable)
|
|
149
|
+
: [];
|
|
147
150
|
if (
|
|
148
151
|
equivalentSignatureVariable &&
|
|
149
|
-
!equivalentSignatureVariableParts[0]
|
|
152
|
+
!equivalentSignatureVariableParts[0]?.includes('(')
|
|
150
153
|
) {
|
|
151
|
-
const equivalentKey =
|
|
154
|
+
const equivalentKey = equivalentSignatureVariable;
|
|
152
155
|
const equivalentPath = joinParenthesesAndArrays([
|
|
153
156
|
equivalentKey,
|
|
154
157
|
...keyParts.slice(1),
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExecutionFlow,
|
|
3
|
+
Scenario,
|
|
4
|
+
ScenariosDataStructure,
|
|
5
|
+
} from '~codeyam/types';
|
|
6
|
+
import simplifyKeysForLLM from './simplifyKeysForLLM';
|
|
7
|
+
import noErrorAttributes from './noErrorAttributes';
|
|
8
|
+
import { JsonTypeDefinition } from '~codeyam/types';
|
|
9
|
+
|
|
10
|
+
type RequiredValue = NonNullable<ExecutionFlow['requiredValues']>[number];
|
|
11
|
+
|
|
12
|
+
interface GenerateChunkPromptArgs {
|
|
13
|
+
scenario: Scenario;
|
|
14
|
+
chunk: ScenariosDataStructure['dataForMocks'];
|
|
15
|
+
chunkIndex: number;
|
|
16
|
+
totalChunks: number;
|
|
17
|
+
relevantRequiredValues: RequiredValue[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generate a prompt for a focused LLM call to generate mock data for a single chunk.
|
|
22
|
+
*
|
|
23
|
+
* Large data structures overwhelm LLMs, causing them to make mistakes on some keys.
|
|
24
|
+
* By processing smaller chunks, each key gets more focused attention.
|
|
25
|
+
*/
|
|
26
|
+
export default function generateChunkPrompt({
|
|
27
|
+
scenario,
|
|
28
|
+
chunk,
|
|
29
|
+
chunkIndex,
|
|
30
|
+
totalChunks,
|
|
31
|
+
relevantRequiredValues,
|
|
32
|
+
}: GenerateChunkPromptArgs): string {
|
|
33
|
+
// Clean up the schema for LLM consumption
|
|
34
|
+
const cleanedSchema = simplifyKeysForLLM(
|
|
35
|
+
noErrorAttributes(chunk) as JsonTypeDefinition,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const keysInChunk = Object.keys(chunk || {});
|
|
39
|
+
|
|
40
|
+
// Build requirements section if there are relevant requiredValues
|
|
41
|
+
const requirementsSection =
|
|
42
|
+
relevantRequiredValues.length > 0
|
|
43
|
+
? `## Execution Flow Requirements for These Keys
|
|
44
|
+
These specific values MUST be set to produce the correct scenario behavior:
|
|
45
|
+
\`\`\`json
|
|
46
|
+
${JSON.stringify(relevantRequiredValues, null, 2)}
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
`
|
|
50
|
+
: '';
|
|
51
|
+
|
|
52
|
+
return `Generate mock data for chunk ${chunkIndex + 1} of ${totalChunks}.
|
|
53
|
+
|
|
54
|
+
## Scenario
|
|
55
|
+
\`\`\`json
|
|
56
|
+
${JSON.stringify({ name: scenario.name, description: scenario.description }, null, 2)}
|
|
57
|
+
\`\`\`
|
|
58
|
+
|
|
59
|
+
${requirementsSection}## Keys in This Chunk (${keysInChunk.length} keys)
|
|
60
|
+
Generate data for ONLY these keys:
|
|
61
|
+
${keysInChunk.map((k) => `- \`${k}\``).join('\n')}
|
|
62
|
+
|
|
63
|
+
## Schema for This Chunk
|
|
64
|
+
\`\`\`json
|
|
65
|
+
${JSON.stringify(cleanedSchema, null, 2)}
|
|
66
|
+
\`\`\`
|
|
67
|
+
|
|
68
|
+
## Instructions
|
|
69
|
+
1. Match the EXACT structure shown in the schema
|
|
70
|
+
2. Keys with special characters like \`*\` are LITERAL keys, not patterns
|
|
71
|
+
3. If requiredValues are shown above, set values that satisfy them
|
|
72
|
+
4. For paths like \`functionCall().functionCallReturnValue.property\`, the mock data key is just \`functionCall()\`
|
|
73
|
+
|
|
74
|
+
Return ONLY a JSON object with this structure:
|
|
75
|
+
\`\`\`json
|
|
76
|
+
{
|
|
77
|
+
"mockData": {
|
|
78
|
+
// fill in ONLY the keys from this chunk
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
\`\`\``;
|
|
82
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExecutionFlow,
|
|
3
|
+
Scenario,
|
|
4
|
+
ScenariosDataStructure,
|
|
5
|
+
} from '~codeyam/types';
|
|
6
|
+
import simplifyKeysForLLM from './simplifyKeysForLLM';
|
|
7
|
+
import noErrorAttributes from './noErrorAttributes';
|
|
8
|
+
import { JsonTypeDefinition } from '~codeyam/types';
|
|
9
|
+
|
|
10
|
+
interface GenerateCriticalKeysPromptArgs {
|
|
11
|
+
scenario: Scenario;
|
|
12
|
+
executionFlows: ExecutionFlow[] | undefined;
|
|
13
|
+
criticalKeys: string[];
|
|
14
|
+
fullDataForMocks: ScenariosDataStructure['dataForMocks'];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generate a prompt for a focused LLM call to generate only the critical mock data keys.
|
|
19
|
+
*
|
|
20
|
+
* When a scenario has covered flows with requiredValues, only a subset of the full
|
|
21
|
+
* dataForMocks schema is actually needed to satisfy those requirements. This prompt
|
|
22
|
+
* focuses the LLM on JUST those critical keys, avoiding confusion from large schemas.
|
|
23
|
+
*
|
|
24
|
+
* This is called BEFORE the main data generation to ensure critical keys are correctly
|
|
25
|
+
* generated with full attention from the LLM.
|
|
26
|
+
*/
|
|
27
|
+
export default function generateCriticalKeysPrompt({
|
|
28
|
+
scenario,
|
|
29
|
+
executionFlows,
|
|
30
|
+
criticalKeys,
|
|
31
|
+
fullDataForMocks,
|
|
32
|
+
}: GenerateCriticalKeysPromptArgs): string {
|
|
33
|
+
// Build the subset schema with only critical keys
|
|
34
|
+
const criticalSchema: Record<string, any> = {};
|
|
35
|
+
if (fullDataForMocks && typeof fullDataForMocks === 'object') {
|
|
36
|
+
for (const key of criticalKeys) {
|
|
37
|
+
if (key in fullDataForMocks) {
|
|
38
|
+
criticalSchema[key] = (fullDataForMocks as Record<string, any>)[key];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Clean up the schema for LLM consumption
|
|
44
|
+
const cleanedSchema = simplifyKeysForLLM(
|
|
45
|
+
noErrorAttributes(criticalSchema) as JsonTypeDefinition,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// Get the covered flows and their requirements
|
|
49
|
+
const coveredFlowIds = scenario.metadata?.coveredFlows || [];
|
|
50
|
+
const coveredFlowRequirements = coveredFlowIds
|
|
51
|
+
.map((flowId) => {
|
|
52
|
+
const flow = executionFlows?.find((f) => f.id === flowId);
|
|
53
|
+
if (!flow) return null;
|
|
54
|
+
return {
|
|
55
|
+
flowId: flow.id,
|
|
56
|
+
flowName: flow.name,
|
|
57
|
+
flowDescription: flow.description,
|
|
58
|
+
requiredValues: flow.requiredValues,
|
|
59
|
+
};
|
|
60
|
+
})
|
|
61
|
+
.filter(Boolean);
|
|
62
|
+
|
|
63
|
+
return `Generate mock data for these CRITICAL keys. Pay close attention to the requiredValues.
|
|
64
|
+
|
|
65
|
+
## IMPORTANT: These keys are critical for satisfying the execution flow requirements
|
|
66
|
+
The keys below directly control the scenario's behavior. Generate values that EXACTLY satisfy the requiredValues.
|
|
67
|
+
|
|
68
|
+
## Scenario
|
|
69
|
+
\`\`\`json
|
|
70
|
+
${JSON.stringify({ name: scenario.name, description: scenario.description }, null, 2)}
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
## Execution Flow Requirements
|
|
74
|
+
These are the specific values that MUST be set:
|
|
75
|
+
\`\`\`json
|
|
76
|
+
${JSON.stringify(coveredFlowRequirements, null, 2)}
|
|
77
|
+
\`\`\`
|
|
78
|
+
|
|
79
|
+
## Critical Keys Schema (generate data for ONLY these keys)
|
|
80
|
+
\`\`\`json
|
|
81
|
+
${JSON.stringify(cleanedSchema, null, 2)}
|
|
82
|
+
\`\`\`
|
|
83
|
+
|
|
84
|
+
## Instructions
|
|
85
|
+
1. Match the EXACT structure shown in the schema
|
|
86
|
+
2. Keys with special characters like \`*\` are LITERAL keys, not patterns
|
|
87
|
+
3. Set values that satisfy ALL the requiredValues above
|
|
88
|
+
4. For paths like \`functionCall().functionCallReturnValue.property\`, the mock data key is just \`functionCall()\`
|
|
89
|
+
|
|
90
|
+
Return ONLY a JSON object with this structure:
|
|
91
|
+
\`\`\`json
|
|
92
|
+
{
|
|
93
|
+
"scenarioData": {
|
|
94
|
+
"scenarioName": "${scenario.name}",
|
|
95
|
+
"data": {
|
|
96
|
+
"mockData": {
|
|
97
|
+
// fill in ONLY the critical keys above
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
\`\`\``;
|
|
103
|
+
}
|