@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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import completionCall from './completionCall';
|
|
2
2
|
import generateEntityScenarioDataGenerator from './promptGenerators/generateEntityScenarioDataGenerator';
|
|
3
3
|
import generateMissingKeysPrompt from './promptGenerators/generateMissingKeysPrompt';
|
|
4
|
+
import generateChunkPrompt from './promptGenerators/generateChunkPrompt';
|
|
4
5
|
import { saveLlmCall } from '~codeyam/aws/dynamodb';
|
|
6
|
+
import { trackDataSnapshot } from './e2eDataTracking';
|
|
5
7
|
import type {
|
|
6
8
|
Analysis,
|
|
7
9
|
Entity,
|
|
@@ -14,6 +16,14 @@ import validateJson from './validateJson';
|
|
|
14
16
|
import { awsLog, awsLogDebugLevel } from '~codeyam/utils';
|
|
15
17
|
import { AI, parseJsonSafe } from '~codeyam/ai';
|
|
16
18
|
import convertNullToUndefinedBySchema from './dataStructure/helpers/convertNullToUndefinedBySchema';
|
|
19
|
+
import convertTypeAnnotationsToValues from './dataStructure/helpers/convertTypeAnnotationsToValues';
|
|
20
|
+
import fixNullIdsBySchema from './dataStructure/helpers/fixNullIdsBySchema';
|
|
21
|
+
import { JsonTypeDefinition } from '~codeyam/types';
|
|
22
|
+
import { deepMerge } from '~codeyam/generate';
|
|
23
|
+
import {
|
|
24
|
+
chunkDataStructure,
|
|
25
|
+
getRequiredValuesForChunk,
|
|
26
|
+
} from './dataStructureChunking';
|
|
17
27
|
|
|
18
28
|
/**
|
|
19
29
|
* Check if any of the scenario's covered flows require error data.
|
|
@@ -119,6 +129,337 @@ function deepMergeScenarioData(
|
|
|
119
129
|
|
|
120
130
|
const DEFAULT_SCENARIO_NAME = 'Default Scenario';
|
|
121
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Find the path to a key within a nested dataForMocks structure.
|
|
134
|
+
* Returns the path as an array of keys, or null if not found.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // dataForMocks = { trpc: { fastener: { "useMutation()": { isLoading: "boolean" } } } }
|
|
138
|
+
* // findKeyPath("fastener", dataForMocks) returns ["trpc"]
|
|
139
|
+
*/
|
|
140
|
+
function findKeyPath(
|
|
141
|
+
targetKey: string,
|
|
142
|
+
obj: JsonTypeDefinition,
|
|
143
|
+
currentPath: string[] = [],
|
|
144
|
+
): string[] | null {
|
|
145
|
+
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
for (const key of Object.keys(obj)) {
|
|
150
|
+
if (key === targetKey) {
|
|
151
|
+
return currentPath;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Recursively search in nested objects
|
|
155
|
+
const nested = obj[key];
|
|
156
|
+
if (
|
|
157
|
+
typeof nested === 'object' &&
|
|
158
|
+
nested !== null &&
|
|
159
|
+
!Array.isArray(nested)
|
|
160
|
+
) {
|
|
161
|
+
const result = findKeyPath(targetKey, nested as JsonTypeDefinition, [
|
|
162
|
+
...currentPath,
|
|
163
|
+
key,
|
|
164
|
+
]);
|
|
165
|
+
if (result !== null) {
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Relocate misplaced nested keys in mockData to their correct position
|
|
176
|
+
* based on the dataForMocks structure.
|
|
177
|
+
*
|
|
178
|
+
* When the LLM returns mockData with keys at the wrong nesting level
|
|
179
|
+
* (e.g., { trpc: { quote: {...} }, fastener: {...} } when fastener should
|
|
180
|
+
* be inside trpc), this function moves them to the correct position.
|
|
181
|
+
*
|
|
182
|
+
* This function works recursively to handle nested misplacements, not just
|
|
183
|
+
* root-level ones. For example, if getQuote is at trpc.getQuote instead of
|
|
184
|
+
* trpc.quote.getQuote, it will be relocated.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* // dataForMocks: { trpc: { quote: {...}, fastener: {...} } }
|
|
188
|
+
* // mockData: { trpc: { quote: {...} }, fastener: {...} }
|
|
189
|
+
* // After: mockData: { trpc: { quote: {...}, fastener: {...} } }
|
|
190
|
+
*
|
|
191
|
+
* @example (nested case)
|
|
192
|
+
* // dataForMocks: { trpc: { quote: { getQuote: {...} } } }
|
|
193
|
+
* // mockData: { trpc: { quote: {...}, getQuote: {...} } }
|
|
194
|
+
* // After: mockData: { trpc: { quote: { getQuote: {...} } } }
|
|
195
|
+
*/
|
|
196
|
+
function relocateMisplacedNestedKeys(
|
|
197
|
+
mockData: Record<string, unknown>,
|
|
198
|
+
dataForMocks: JsonTypeDefinition,
|
|
199
|
+
currentPathForLogging: string[] = [],
|
|
200
|
+
): void {
|
|
201
|
+
if (typeof dataForMocks !== 'object' || dataForMocks === null) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const keysInSchema = Object.keys(dataForMocks);
|
|
206
|
+
const keysToRelocate: { key: string; path: string[] }[] = [];
|
|
207
|
+
|
|
208
|
+
// Find keys in mockData that are NOT at this level in dataForMocks
|
|
209
|
+
// but DO exist somewhere nested in dataForMocks
|
|
210
|
+
for (const key of Object.keys(mockData)) {
|
|
211
|
+
if (!keysInSchema.includes(key)) {
|
|
212
|
+
// This key is at this level in mockData but not at this level in dataForMocks
|
|
213
|
+
// Check if it exists somewhere nested in dataForMocks
|
|
214
|
+
const path = findKeyPath(key, dataForMocks);
|
|
215
|
+
if (path !== null && path.length > 0) {
|
|
216
|
+
keysToRelocate.push({ key, path });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Relocate each misplaced key to its correct nested position
|
|
222
|
+
for (const { key, path } of keysToRelocate) {
|
|
223
|
+
const value = mockData[key];
|
|
224
|
+
|
|
225
|
+
// Navigate to the correct parent in mockData, creating nested objects if needed
|
|
226
|
+
let current: Record<string, unknown> = mockData;
|
|
227
|
+
for (const pathKey of path) {
|
|
228
|
+
if (current[pathKey] === undefined) {
|
|
229
|
+
current[pathKey] = {};
|
|
230
|
+
}
|
|
231
|
+
current = current[pathKey] as Record<string, unknown>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Deep merge the value into the correct location
|
|
235
|
+
// Use deep merge to preserve existing data at that location
|
|
236
|
+
if (current[key] !== undefined && typeof current[key] === 'object') {
|
|
237
|
+
current[key] = deepMerge(
|
|
238
|
+
current[key] as Record<string, unknown>,
|
|
239
|
+
value as Record<string, unknown>,
|
|
240
|
+
);
|
|
241
|
+
} else {
|
|
242
|
+
current[key] = value;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Remove the key from its current (wrong) level
|
|
246
|
+
delete mockData[key];
|
|
247
|
+
|
|
248
|
+
const fullPath = [...currentPathForLogging, ...path].join('.');
|
|
249
|
+
awsLog(
|
|
250
|
+
`CodeYam: Relocated misplaced key "${key}" from [${currentPathForLogging.join('.')}] to [${fullPath}]`,
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Recursively process nested objects to handle deeply nested misplacements
|
|
255
|
+
for (const key of Object.keys(mockData)) {
|
|
256
|
+
const mockValue = mockData[key];
|
|
257
|
+
const schemaValue = dataForMocks[key];
|
|
258
|
+
|
|
259
|
+
// Only recurse if both mockData and schema have nested objects at this key
|
|
260
|
+
if (
|
|
261
|
+
typeof mockValue === 'object' &&
|
|
262
|
+
mockValue !== null &&
|
|
263
|
+
!Array.isArray(mockValue) &&
|
|
264
|
+
typeof schemaValue === 'object' &&
|
|
265
|
+
schemaValue !== null &&
|
|
266
|
+
!Array.isArray(schemaValue)
|
|
267
|
+
) {
|
|
268
|
+
relocateMisplacedNestedKeys(
|
|
269
|
+
mockValue as Record<string, unknown>,
|
|
270
|
+
schemaValue as JsonTypeDefinition,
|
|
271
|
+
[...currentPathForLogging, key],
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Generate default mock data for a schema type.
|
|
279
|
+
* Returns reasonable default values based on the schema type string.
|
|
280
|
+
*/
|
|
281
|
+
function generateDefaultForSchemaType(schemaType: unknown): unknown {
|
|
282
|
+
if (typeof schemaType === 'string') {
|
|
283
|
+
// Handle common type strings
|
|
284
|
+
if (schemaType === 'function') return () => {};
|
|
285
|
+
if (schemaType === 'promise') return Promise.resolve();
|
|
286
|
+
if (schemaType === 'boolean') return false;
|
|
287
|
+
if (schemaType === 'string') return '';
|
|
288
|
+
if (schemaType === 'number') return 0;
|
|
289
|
+
if (schemaType.includes('number | undefined')) return undefined;
|
|
290
|
+
if (schemaType.includes('string | undefined')) return undefined;
|
|
291
|
+
if (schemaType.includes('boolean | undefined')) return undefined;
|
|
292
|
+
if (schemaType.includes('| undefined')) return undefined;
|
|
293
|
+
if (schemaType.includes('| null')) return null;
|
|
294
|
+
return schemaType; // Return the type as a string placeholder
|
|
295
|
+
}
|
|
296
|
+
if (
|
|
297
|
+
typeof schemaType === 'object' &&
|
|
298
|
+
schemaType !== null &&
|
|
299
|
+
!Array.isArray(schemaType)
|
|
300
|
+
) {
|
|
301
|
+
// Recursively generate defaults for nested objects
|
|
302
|
+
const result: Record<string, unknown> = {};
|
|
303
|
+
for (const [key, value] of Object.entries(schemaType)) {
|
|
304
|
+
result[key] = generateDefaultForSchemaType(value);
|
|
305
|
+
}
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Detect if a string should be converted to an array.
|
|
313
|
+
* Returns the array if the field appears to be an array field, or null if it should remain a string.
|
|
314
|
+
*
|
|
315
|
+
* This handles two cases:
|
|
316
|
+
* 1. Comma-separated values: "color,size" -> ["color", "size"]
|
|
317
|
+
* 2. Single values for array-named fields: "Finish" -> ["Finish"]
|
|
318
|
+
*/
|
|
319
|
+
function parseCommaSeparatedStringAsArray(
|
|
320
|
+
value: string,
|
|
321
|
+
key: string,
|
|
322
|
+
): string[] | null {
|
|
323
|
+
// Heuristic: if the key name suggests it's an array field, convert it
|
|
324
|
+
// Common patterns: *_attributes, *_ids, *_items, *_tags, *_values, plural names
|
|
325
|
+
// Check this FIRST because array-named fields should be converted regardless
|
|
326
|
+
// of whether they contain commas (single values become single-element arrays).
|
|
327
|
+
const arrayFieldPatterns = [
|
|
328
|
+
/_attributes$/i,
|
|
329
|
+
/_ids$/i,
|
|
330
|
+
/_items$/i,
|
|
331
|
+
/_tags$/i,
|
|
332
|
+
/_values$/i,
|
|
333
|
+
/_types$/i,
|
|
334
|
+
/_names$/i,
|
|
335
|
+
/_keys$/i,
|
|
336
|
+
/^attributes$/i,
|
|
337
|
+
/^items$/i,
|
|
338
|
+
/^tags$/i,
|
|
339
|
+
/^values$/i,
|
|
340
|
+
];
|
|
341
|
+
|
|
342
|
+
const looksLikeArrayField = arrayFieldPatterns.some((pattern) =>
|
|
343
|
+
pattern.test(key),
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
if (looksLikeArrayField) {
|
|
347
|
+
// Skip newlines check - multiline values shouldn't be split
|
|
348
|
+
if (value.includes('\n')) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
// Split by comma and trim whitespace
|
|
352
|
+
const parts = value.split(',').map((s) => s.trim());
|
|
353
|
+
// Filter out empty strings - this handles both "Finish" -> ["Finish"]
|
|
354
|
+
// and "" -> []
|
|
355
|
+
return parts.filter((s) => s.length > 0);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// For non-array-named fields, only convert if there are commas
|
|
359
|
+
if (!value.includes(',')) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// For non-array-named fields, apply stricter sentence detection
|
|
364
|
+
// Skip if it looks like a sentence (comma followed by space and lowercase)
|
|
365
|
+
if (/,\s+[a-z]/.test(value)) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
// Skip if it contains newlines (likely formatted text)
|
|
369
|
+
if (value.includes('\n')) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Convert comma-separated string values to arrays when they look like array data.
|
|
378
|
+
* This handles cases where the LLM generates strings like "color,size" instead
|
|
379
|
+
* of arrays like ["color", "size"] due to schema type misdetection.
|
|
380
|
+
*/
|
|
381
|
+
function convertCommaSeparatedStringsToArrays(
|
|
382
|
+
mockData: Record<string, unknown>,
|
|
383
|
+
): void {
|
|
384
|
+
for (const [key, value] of Object.entries(mockData)) {
|
|
385
|
+
if (typeof value === 'string') {
|
|
386
|
+
const asArray = parseCommaSeparatedStringAsArray(value, key);
|
|
387
|
+
if (asArray !== null) {
|
|
388
|
+
mockData[key] = asArray;
|
|
389
|
+
awsLog(
|
|
390
|
+
`CodeYam: Converted comma-separated string to array for key "${key}": "${value}" -> [${asArray.map((s) => `"${s}"`).join(', ')}]`,
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
} else if (
|
|
394
|
+
value !== null &&
|
|
395
|
+
typeof value === 'object' &&
|
|
396
|
+
!Array.isArray(value)
|
|
397
|
+
) {
|
|
398
|
+
// Recursively process nested objects
|
|
399
|
+
convertCommaSeparatedStringsToArrays(value as Record<string, unknown>);
|
|
400
|
+
} else if (Array.isArray(value)) {
|
|
401
|
+
// Recursively process arrays (each element could be an object)
|
|
402
|
+
for (const item of value) {
|
|
403
|
+
if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
|
|
404
|
+
convertCommaSeparatedStringsToArrays(item as Record<string, unknown>);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Ensure all keys from dataForMocks have corresponding data in mockData.
|
|
413
|
+
* For missing keys, generate default values based on the schema.
|
|
414
|
+
* Recursively checks nested objects to fill in any missing nested fields.
|
|
415
|
+
*/
|
|
416
|
+
function fillMissingMockDataKeysWithDefaults(
|
|
417
|
+
mockData: Record<string, unknown>,
|
|
418
|
+
dataForMocks: JsonTypeDefinition,
|
|
419
|
+
pathPrefix: string = '',
|
|
420
|
+
): void {
|
|
421
|
+
if (typeof dataForMocks !== 'object' || dataForMocks === null) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const missingKeys: string[] = [];
|
|
426
|
+
|
|
427
|
+
for (const key of Object.keys(dataForMocks)) {
|
|
428
|
+
const fullPath = pathPrefix ? `${pathPrefix}.${key}` : key;
|
|
429
|
+
|
|
430
|
+
if (mockData[key] === undefined) {
|
|
431
|
+
missingKeys.push(fullPath);
|
|
432
|
+
// Generate default data based on schema
|
|
433
|
+
const schemaForKey = dataForMocks[key];
|
|
434
|
+
mockData[key] = generateDefaultForSchemaType(schemaForKey);
|
|
435
|
+
} else {
|
|
436
|
+
// Key exists, but if both are objects, recursively check for missing nested keys
|
|
437
|
+
const schemaValue = dataForMocks[key];
|
|
438
|
+
const mockValue = mockData[key];
|
|
439
|
+
if (
|
|
440
|
+
typeof schemaValue === 'object' &&
|
|
441
|
+
schemaValue !== null &&
|
|
442
|
+
!Array.isArray(schemaValue) &&
|
|
443
|
+
typeof mockValue === 'object' &&
|
|
444
|
+
mockValue !== null &&
|
|
445
|
+
!Array.isArray(mockValue)
|
|
446
|
+
) {
|
|
447
|
+
fillMissingMockDataKeysWithDefaults(
|
|
448
|
+
mockValue as Record<string, unknown>,
|
|
449
|
+
schemaValue as JsonTypeDefinition,
|
|
450
|
+
fullPath,
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (missingKeys.length > 0) {
|
|
457
|
+
awsLog(
|
|
458
|
+
`CodeYam: Generated default mock data for ${missingKeys.length} missing key(s): ${missingKeys.slice(0, 10).join(', ')}${missingKeys.length > 10 ? '...' : ''}`,
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
122
463
|
type ScenarioDataWithoutDescription = Omit<ScenarioData, 'scenarioDescription'>;
|
|
123
464
|
|
|
124
465
|
interface GenerateEntityScenarioDataArgs {
|
|
@@ -236,12 +577,99 @@ export async function generateDataForScenario({
|
|
|
236
577
|
}: GenerateDataForScenarioArgs) {
|
|
237
578
|
awsLogDebugLevel(1, `Generating data for ${entity.name}: ${scenario.name}`);
|
|
238
579
|
|
|
580
|
+
// Check if we should chunk the data structure for focused processing
|
|
581
|
+
let chunkedMockData: Record<string, unknown> | undefined;
|
|
582
|
+
const coveredFlowIds = scenario.metadata?.coveredFlows || [];
|
|
583
|
+
|
|
584
|
+
if (
|
|
585
|
+
structure.dataForMocks &&
|
|
586
|
+
!incompleteResponse // Don't do chunked calls on continuation
|
|
587
|
+
) {
|
|
588
|
+
const chunks = chunkDataStructure(structure.dataForMocks);
|
|
589
|
+
|
|
590
|
+
// If we have multiple chunks, process each one with a focused call
|
|
591
|
+
if (chunks.length > 1) {
|
|
592
|
+
awsLog(
|
|
593
|
+
`Data structure has ${Object.keys(structure.dataForMocks).length} keys, splitting into ${chunks.length} chunks for focused processing`,
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
chunkedMockData = {};
|
|
597
|
+
|
|
598
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
599
|
+
const chunk = chunks[i];
|
|
600
|
+
const chunkKeys = Object.keys(chunk || {});
|
|
601
|
+
|
|
602
|
+
// Get relevant requiredValues for this chunk
|
|
603
|
+
const relevantRequiredValues = getRequiredValuesForChunk(
|
|
604
|
+
chunk,
|
|
605
|
+
executionFlows || [],
|
|
606
|
+
coveredFlowIds,
|
|
607
|
+
);
|
|
608
|
+
|
|
609
|
+
awsLog(
|
|
610
|
+
`Processing chunk ${i + 1}/${chunks.length}: ${chunkKeys.join(', ')}`,
|
|
611
|
+
);
|
|
612
|
+
|
|
613
|
+
const chunkPrompt = generateChunkPrompt({
|
|
614
|
+
scenario,
|
|
615
|
+
chunk,
|
|
616
|
+
chunkIndex: i,
|
|
617
|
+
totalChunks: chunks.length,
|
|
618
|
+
relevantRequiredValues,
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
const chunkResponse = await completionCall({
|
|
622
|
+
type: 'generateChunkMockData',
|
|
623
|
+
systemMessage: generateChunkSystemMessage(scenario.name),
|
|
624
|
+
prompt: chunkPrompt,
|
|
625
|
+
model,
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
// Save chunk call to LLM log for replay support
|
|
629
|
+
await saveLlmCall({
|
|
630
|
+
object_type: 'analysis',
|
|
631
|
+
object_id: analysis.id,
|
|
632
|
+
propsJson: {
|
|
633
|
+
entity: { name: entity.name, filePath: entity.filePath },
|
|
634
|
+
scenario: { name: scenario.name },
|
|
635
|
+
chunkIndex: i,
|
|
636
|
+
totalChunks: chunks.length,
|
|
637
|
+
},
|
|
638
|
+
...chunkResponse.stats,
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
if (chunkResponse.completion) {
|
|
642
|
+
const validJson = validateJson(chunkResponse.completion);
|
|
643
|
+
const parsed = parseJsonSafe(validJson);
|
|
644
|
+
if (parsed && typeof parsed === 'object' && 'mockData' in parsed) {
|
|
645
|
+
const chunkMockData = (parsed as any).mockData;
|
|
646
|
+
if (chunkMockData && typeof chunkMockData === 'object') {
|
|
647
|
+
Object.assign(chunkedMockData, chunkMockData);
|
|
648
|
+
awsLog(
|
|
649
|
+
`Chunk ${i + 1} generated data for: ${Object.keys(chunkMockData).join(', ')}`,
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
awsLog(
|
|
657
|
+
`Chunked processing complete. Generated ${Object.keys(chunkedMockData).length} keys total`,
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// When we have chunked mock data with actual content, tell the main prompt to skip mockData generation
|
|
663
|
+
// Important: Check for actual keys, not just truthy object, because {} would skip generation incorrectly
|
|
664
|
+
const hasChunkedData =
|
|
665
|
+
chunkedMockData && Object.keys(chunkedMockData).length > 0;
|
|
239
666
|
const prompt = generateEntityScenarioDataGenerator(
|
|
240
667
|
structure,
|
|
241
668
|
scenario,
|
|
242
669
|
executionFlows,
|
|
243
670
|
defaultScenarioData,
|
|
244
671
|
incompleteResponse,
|
|
672
|
+
{ mockDataAlreadyGenerated: hasChunkedData },
|
|
245
673
|
);
|
|
246
674
|
|
|
247
675
|
const isDefault = scenario.name === DEFAULT_SCENARIO_NAME;
|
|
@@ -390,12 +818,45 @@ export async function generateDataForScenario({
|
|
|
390
818
|
}
|
|
391
819
|
}
|
|
392
820
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
821
|
+
// Merge flat-level mock data into mockData.
|
|
822
|
+
// Sometimes the LLM returns some data inside data.mockData but other data at the flat
|
|
823
|
+
// data level (e.g., data.useRouter() instead of data.mockData.useRouter()).
|
|
824
|
+
// This code ensures all dataForMocks keys end up in mockData.
|
|
825
|
+
if (structure.dataForMocks) {
|
|
826
|
+
fullScenarioData.data.mockData ||= {};
|
|
827
|
+
const dataAsAny = fullScenarioData.data as any;
|
|
828
|
+
for (const propKey of Object.keys(structure.dataForMocks)) {
|
|
829
|
+
// Only copy if it exists at flat level and not already in mockData
|
|
830
|
+
if (
|
|
831
|
+
dataAsAny[propKey] !== undefined &&
|
|
832
|
+
!fullScenarioData.data.mockData[propKey]
|
|
833
|
+
) {
|
|
834
|
+
fullScenarioData.data.mockData[propKey] = dataAsAny[propKey];
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// Merge chunked mock data from focused calls (takes priority over main call's data)
|
|
840
|
+
// This ensures keys processed with focused attention are correctly generated.
|
|
841
|
+
if (chunkedMockData && fullScenarioData.data.mockData) {
|
|
842
|
+
for (const [key, value] of Object.entries(chunkedMockData)) {
|
|
843
|
+
// Chunked data takes priority - overwrite main call's potentially wrong data
|
|
844
|
+
fullScenarioData.data.mockData[key] = value;
|
|
398
845
|
}
|
|
846
|
+
awsLog(
|
|
847
|
+
`Merged chunked mock data for keys: ${Object.keys(chunkedMockData).join(', ')}`,
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// Relocate misplaced nested keys to their correct position.
|
|
852
|
+
// The LLM sometimes places nested keys at root level instead of inside their
|
|
853
|
+
// parent object (e.g., 'fastener' at root instead of inside 'trpc').
|
|
854
|
+
// This ensures the mockData structure matches the dataForMocks schema.
|
|
855
|
+
if (structure.dataForMocks && fullScenarioData.data.mockData) {
|
|
856
|
+
relocateMisplacedNestedKeys(
|
|
857
|
+
fullScenarioData.data.mockData,
|
|
858
|
+
structure.dataForMocks,
|
|
859
|
+
);
|
|
399
860
|
}
|
|
400
861
|
|
|
401
862
|
// Convert null values to undefined based on schema type constraints.
|
|
@@ -408,6 +869,34 @@ export async function generateDataForScenario({
|
|
|
408
869
|
structure.dataForMocks,
|
|
409
870
|
);
|
|
410
871
|
}
|
|
872
|
+
|
|
873
|
+
// Convert comma-separated strings to arrays when appropriate.
|
|
874
|
+
// The LLM sometimes generates strings like "color,size" instead of arrays
|
|
875
|
+
// like ["color", "size"] when the schema type is incorrectly inferred as
|
|
876
|
+
// 'string' instead of 'string[]'. This causes runtime errors when code
|
|
877
|
+
// calls array methods like .map() on the value.
|
|
878
|
+
if (fullScenarioData.data.mockData) {
|
|
879
|
+
convertCommaSeparatedStringsToArrays(fullScenarioData.data.mockData);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// Convert type annotation strings that appear as values to actual values.
|
|
883
|
+
// The LLM sometimes echoes the schema type annotation as the value.
|
|
884
|
+
// For example, if the schema says { filePath: "string | undefined" },
|
|
885
|
+
// the LLM might return { filePath: "string | undefined" } instead of
|
|
886
|
+
// generating an actual value. This converts those type strings to
|
|
887
|
+
// appropriate default values (e.g., "string | undefined" → undefined).
|
|
888
|
+
if (fullScenarioData.data.mockData) {
|
|
889
|
+
convertTypeAnnotationsToValues(fullScenarioData.data.mockData);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// Fix null values for ID fields when the schema indicates they should be non-null.
|
|
893
|
+
// The LLM sometimes generates `null` for ID fields (e.g., `"id": null`) when
|
|
894
|
+
// the schema type is `"number"`. This causes runtime issues when code checks
|
|
895
|
+
// `if (!data?.id)` expecting a truthy value.
|
|
896
|
+
if (structure.dataForMocks && fullScenarioData.data.mockData) {
|
|
897
|
+
fixNullIdsBySchema(fullScenarioData.data.mockData, structure.dataForMocks);
|
|
898
|
+
}
|
|
899
|
+
|
|
411
900
|
if (structure.arguments && fullScenarioData.data.argumentsData) {
|
|
412
901
|
for (let i = 0; i < fullScenarioData.data.argumentsData.length; i++) {
|
|
413
902
|
if (structure.arguments[i]) {
|
|
@@ -419,7 +908,8 @@ export async function generateDataForScenario({
|
|
|
419
908
|
}
|
|
420
909
|
}
|
|
421
910
|
|
|
422
|
-
// For Default Scenario only: check for missing keys and make follow-up call if needed
|
|
911
|
+
// For Default Scenario only: check for missing keys and make follow-up call if needed.
|
|
912
|
+
// This tries to get better-quality data via LLM before falling back to defaults.
|
|
423
913
|
if (isDefault) {
|
|
424
914
|
await fillMissingMockDataKeys({
|
|
425
915
|
structure,
|
|
@@ -430,6 +920,31 @@ export async function generateDataForScenario({
|
|
|
430
920
|
});
|
|
431
921
|
}
|
|
432
922
|
|
|
923
|
+
// Fill in missing mock data keys with default values (after trying LLM follow-up).
|
|
924
|
+
// The LLM sometimes doesn't generate data for all keys in large schemas.
|
|
925
|
+
// This ensures all dataForMocks keys have corresponding data to prevent
|
|
926
|
+
// runtime errors like "Cannot read properties of undefined".
|
|
927
|
+
// Only run for Default Scenario - non-default scenarios will get missing
|
|
928
|
+
// data filled in from the merge with default scenario data.
|
|
929
|
+
if (isDefault && structure.dataForMocks && fullScenarioData.data.mockData) {
|
|
930
|
+
fillMissingMockDataKeysWithDefaults(
|
|
931
|
+
fullScenarioData.data.mockData,
|
|
932
|
+
structure.dataForMocks,
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// Track the final scenario data for E2E debugging
|
|
937
|
+
trackDataSnapshot(
|
|
938
|
+
'generateDataForScenario_result',
|
|
939
|
+
{
|
|
940
|
+
scenarioName: scenario.name,
|
|
941
|
+
mockData: fullScenarioData.data.mockData,
|
|
942
|
+
argumentsData: fullScenarioData.data.argumentsData,
|
|
943
|
+
},
|
|
944
|
+
entity.name,
|
|
945
|
+
scenario.name,
|
|
946
|
+
);
|
|
947
|
+
|
|
433
948
|
return {
|
|
434
949
|
scenarioData: fullScenarioData,
|
|
435
950
|
llmCall: { name: scenario.name, id: llmCall.id },
|
|
@@ -600,7 +1115,8 @@ Generate COMPLETE, robust data for the entire data structure.
|
|
|
600
1115
|
: `## Non-Default Scenario
|
|
601
1116
|
Generate ONLY the differences from the default scenario.
|
|
602
1117
|
- Include only fields that need to change
|
|
603
|
-
-
|
|
1118
|
+
- For object/scalar fields: set to \`null\` to remove/unset the data
|
|
1119
|
+
- For array fields: use \`[]\` for empty arrays (not \`null\`) unless the schema type explicitly includes \`| null\`
|
|
604
1120
|
- Omit unchanged fields—they merge from default`;
|
|
605
1121
|
|
|
606
1122
|
// Only include the "NO ERROR DATA" instruction when the scenario doesn't require error data
|
|
@@ -633,6 +1149,17 @@ For example, if a flow requires:
|
|
|
633
1149
|
\`\`\`
|
|
634
1150
|
Then set \`isLoading: false\` in the mockData.
|
|
635
1151
|
|
|
1152
|
+
### Array Length Requirements (length< and length>)
|
|
1153
|
+
For array size variation flows:
|
|
1154
|
+
- \`comparison: "length<"\` with \`value: "0"\` → generate EMPTY array \`[]\`
|
|
1155
|
+
- \`comparison: "length<"\` with \`value: "3"\` → generate 1-2 items (few items)
|
|
1156
|
+
- \`comparison: "length>"\` with \`value: "10"\` → generate 12+ items (many items)
|
|
1157
|
+
|
|
1158
|
+
### String Length Requirements (normal vs long)
|
|
1159
|
+
For text length variation flows:
|
|
1160
|
+
- \`value: "normal"\` with \`valueType: "string"\` → generate normal length text (10-50 chars)
|
|
1161
|
+
- \`value: "long"\` with \`valueType: "string"\` → generate LONG text (200+ chars) to test overflow/truncation
|
|
1162
|
+
|
|
636
1163
|
## CRITICAL: Blocking Flows to Avoid
|
|
637
1164
|
If the scenario includes \`blockingFlowsToAvoid\`, these are flows (like modals, overlays) that would BLOCK the expected UI.
|
|
638
1165
|
You MUST generate mock data that PREVENTS these flows from triggering:
|
|
@@ -673,6 +1200,7 @@ Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
|
|
|
673
1200
|
- Arrays should have many items (at least 4) unless specified otherwise
|
|
674
1201
|
- Each item must follow the exact structure provided
|
|
675
1202
|
- In general we want robust data, not minimal data unless specified otherwise
|
|
1203
|
+
- For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
|
|
676
1204
|
|
|
677
1205
|
## CRITICAL: Preserve Exact Structure
|
|
678
1206
|
Your response MUST mirror the EXACT nested structure provided in mockData Structure.
|
|
@@ -733,6 +1261,8 @@ export const generateMissingKeysSystemMessage =
|
|
|
733
1261
|
|
|
734
1262
|
Generate data ONLY for the missing keys provided in the prompt. Do not skip any of them.
|
|
735
1263
|
|
|
1264
|
+
- Scenario name must match exactly: "Default Scenario"
|
|
1265
|
+
|
|
736
1266
|
## Special Markers
|
|
737
1267
|
|
|
738
1268
|
### Dynamic Dates (\`~~codeyam-code~~\`)
|
|
@@ -750,6 +1280,7 @@ Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
|
|
|
750
1280
|
### Arrays
|
|
751
1281
|
- Arrays should have many items (at least 4) unless specified otherwise
|
|
752
1282
|
- Each item must follow the exact structure provided
|
|
1283
|
+
- For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
|
|
753
1284
|
|
|
754
1285
|
## CRITICAL: Preserve Exact Structure
|
|
755
1286
|
Your response MUST mirror the EXACT nested structure provided for the missing keys.
|
|
@@ -776,3 +1307,107 @@ NEVER include "error" fields in responses. Skip them entirely.
|
|
|
776
1307
|
- No \`undefined\`—use \`null\` or omit
|
|
777
1308
|
- No data references (can't use \`posts[0]\` elsewhere — duplicate the value)
|
|
778
1309
|
`;
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* System message for focused calls to generate critical mockData keys.
|
|
1313
|
+
* These are keys referenced by the scenario's execution flow requiredValues.
|
|
1314
|
+
*/
|
|
1315
|
+
export const generateCriticalKeysSystemMessage = (
|
|
1316
|
+
scenarioName: string,
|
|
1317
|
+
) => `You are generating mock data for CRITICAL keys that control scenario behavior.
|
|
1318
|
+
|
|
1319
|
+
These keys are referenced by the execution flow's requiredValues - they directly determine
|
|
1320
|
+
what the component renders. Pay EXTRA attention to matching the exact structure and values.
|
|
1321
|
+
|
|
1322
|
+
- Scenario name must match exactly: "${scenarioName}"
|
|
1323
|
+
|
|
1324
|
+
## CRITICAL: Special Characters in Keys
|
|
1325
|
+
Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
|
|
1326
|
+
- If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
|
|
1327
|
+
- Do NOT interpret \`*\` as "any key" - use it as an actual key name
|
|
1328
|
+
|
|
1329
|
+
## CRITICAL: Preserve Exact Structure
|
|
1330
|
+
Your response MUST mirror the EXACT nested structure provided.
|
|
1331
|
+
- Copy key strings EXACTLY as shown (including special characters)
|
|
1332
|
+
- Only change leaf VALUES (replacing type descriptions with actual data)
|
|
1333
|
+
- Do NOT modify keys, type parameters, or add extra keys
|
|
1334
|
+
|
|
1335
|
+
## Matching requiredValues
|
|
1336
|
+
When the prompt shows requiredValues like:
|
|
1337
|
+
- \`attributePath: "useParams().functionCallReturnValue.*"\`
|
|
1338
|
+
- \`value: "scenarios"\`
|
|
1339
|
+
|
|
1340
|
+
This means set the \`*\` key to include "scenarios". For URL paths split by \`/\`,
|
|
1341
|
+
generate a path like \`"scenarios/id/mode"\` where segments match requirements.
|
|
1342
|
+
|
|
1343
|
+
## Response Format
|
|
1344
|
+
\`\`\`json
|
|
1345
|
+
{
|
|
1346
|
+
"scenarioData": {
|
|
1347
|
+
"scenarioName": "${scenarioName}",
|
|
1348
|
+
"data": {
|
|
1349
|
+
"mockData": {
|
|
1350
|
+
// generate data for ONLY the critical keys
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
\`\`\`
|
|
1356
|
+
|
|
1357
|
+
## Rules
|
|
1358
|
+
- Valid JSON only
|
|
1359
|
+
- No \`undefined\`—use \`null\` or omit
|
|
1360
|
+
- Match the exact schema structure provided
|
|
1361
|
+
`;
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* System message for focused calls to generate mock data for a chunk of keys.
|
|
1365
|
+
* Used when data structures are large and need to be processed in smaller pieces.
|
|
1366
|
+
*/
|
|
1367
|
+
export const generateChunkSystemMessage = (
|
|
1368
|
+
scenarioName: string,
|
|
1369
|
+
) => `You are generating mock data for a SUBSET of keys from a larger data structure.
|
|
1370
|
+
|
|
1371
|
+
This chunk contains fewer keys so you can focus on generating HIGH QUALITY data for each one.
|
|
1372
|
+
Pay EXTRA attention to matching the exact structure and values for each key.
|
|
1373
|
+
|
|
1374
|
+
- Scenario name must match exactly: "${scenarioName}"
|
|
1375
|
+
|
|
1376
|
+
## CRITICAL: Special Characters in Keys
|
|
1377
|
+
Keys like \`*\` are LITERAL string keys, NOT wildcards or patterns.
|
|
1378
|
+
- If the schema shows \`{ "*": "string" }\`, generate \`{ "*": "some value" }\`
|
|
1379
|
+
- Do NOT interpret \`*\` as "any key" - use it as an actual key name
|
|
1380
|
+
|
|
1381
|
+
## CRITICAL: Preserve Exact Structure
|
|
1382
|
+
Your response MUST mirror the EXACT nested structure provided.
|
|
1383
|
+
- Copy key strings EXACTLY as shown (including special characters)
|
|
1384
|
+
- Only change leaf VALUES (replacing type descriptions with actual data)
|
|
1385
|
+
- Do NOT modify keys, type parameters, or add extra keys
|
|
1386
|
+
|
|
1387
|
+
## Matching requiredValues
|
|
1388
|
+
If the prompt includes requiredValues, these are specific values that MUST be set:
|
|
1389
|
+
- For \`attributePath: "useParams().functionCallReturnValue.*"\` with \`value: "scenarios"\`
|
|
1390
|
+
→ Set the \`*\` key to include "scenarios" (e.g., "scenarios/id/mode")
|
|
1391
|
+
- For URL paths, generate realistic paths that satisfy the requirements
|
|
1392
|
+
|
|
1393
|
+
## CRITICAL: NO ERROR DATA
|
|
1394
|
+
NEVER include "error" fields in responses. Skip them entirely.
|
|
1395
|
+
- If structure has \`{ data: {...}, error: {...} }\`, only fill \`data\`
|
|
1396
|
+
- Leave out any attribute named "error"—do not set to null, omit entirely
|
|
1397
|
+
|
|
1398
|
+
## Response Format
|
|
1399
|
+
\`\`\`json
|
|
1400
|
+
{
|
|
1401
|
+
"mockData": {
|
|
1402
|
+
// generate data for ONLY the keys in this chunk
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
\`\`\`
|
|
1406
|
+
|
|
1407
|
+
## Rules
|
|
1408
|
+
- Valid JSON only
|
|
1409
|
+
- No \`undefined\`—use \`null\` or omit
|
|
1410
|
+
- Generate data for ALL keys in the chunk (don't skip any)
|
|
1411
|
+
- Arrays should have many items (at least 4) unless specified otherwise
|
|
1412
|
+
- For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
|
|
1413
|
+
`;
|