@codeyam/codeyam-cli 0.1.0-staging.323686 → 0.1.0-staging.4813bf3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +7 -7
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +5 -5
- package/analyzer-template/packages/ai/index.ts +7 -1
- package/analyzer-template/packages/ai/package.json +2 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +62 -18
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +67 -9
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +409 -50
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +21 -6
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +992 -249
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +31 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +37 -15
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +126 -11
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +367 -96
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +33 -15
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +315 -6
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +9 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +49 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +649 -142
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +24 -4
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +25 -13
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +4 -3
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +65 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +89 -9
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +19 -4
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +0 -3
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +61 -13
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +37 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +229 -19
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +117 -9
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +459 -39
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/package.json +1 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +5 -5
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +6 -5
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +5 -5
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/project/constructMockCode.ts +90 -10
- package/analyzer-template/project/writeMockDataTsx.ts +181 -8
- package/analyzer-template/project/writeScenarioComponents.ts +60 -12
- package/analyzer-template/project/writeSimpleRoot.ts +21 -11
- package/background/src/lib/local/createLocalAnalyzer.js +1 -1
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +75 -4
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +162 -4
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +60 -15
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +2 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +4 -2
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +2 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -1
- package/codeyam-cli/src/commands/debug.js +9 -5
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +31 -20
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +49 -257
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +17 -26
- package/codeyam-cli/src/commands/memory.js.map +1 -1
- package/codeyam-cli/src/commands/recapture.js +2 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- package/codeyam-cli/src/commands/test-startup.js +2 -0
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +14 -2
- package/codeyam-cli/src/commands/verify.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -86
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +5 -0
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +2 -2
- package/codeyam-cli/src/utils/install-skills.js +70 -45
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +4 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +378 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +115 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +1 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -1
- package/codeyam-cli/src/utils/rules/parser.js +2 -25
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -1
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +16 -11
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -1
- package/codeyam-cli/src/utils/serverState.js +37 -10
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -44
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +15 -3
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +24 -0
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-DsN1wKrm.js → EntityItem-B86KKU7e.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DLqD3qNt.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-Ba2JVPzP.js → EntityTypeIcon-BqY8gDAW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-C8lyxW9k.js → InlineSpinner-ClaLpuOo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-aht4aafF.js → InteractivePreview-BDhPilK7.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CVtiBnY5.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-B0GLXMsr.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-xgeCVgSM.js → LogViewer-Bm3PmcCz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-OApQuNyq.js → ReportIssueModal-CgMEzchJ.js} +3 -8
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DuDvi0jm.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DzccYyI8.js → ScenarioViewer-CBui0id_.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-DyFZkK0l.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{_index-BwqWJOgH.js → _index-B3TDXxnk.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BwavGCpm.js → activity.(_tab)-BtBFH820.js} +6 -11
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-CN61MOMa.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-Cx24_aWc.js → chevron-down-TJp6ofnp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-CXRTFQ3F.js → chunk-JZWAC4HX-JE9ZIoBl.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BOARzkeR.js → circle-check-CXhHQYrI.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-BdhJEx6B.js → createLucideIcon-Ca9fAY46.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BBnGWYga.js → dev.empty-C0epRiVn.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BJUiQqZF.js → entity._sha._-BVnB8a9L.js} +10 -10
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js → entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D1T4TGjf.js → entity._sha_.create-scenario-DGgZjdFg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CTBG2mmz.js → entity._sha_.edit._scenarioId-38yPijoD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CS2cb_eZ.js → entry.client-BSHEfydn.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DMJ7zii9.js → fileTableUtils-DCPhhSMo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{files-CJ6lTdTA.js → files-0N0YJQv7.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{git-CPTZZ-JZ.js → git-DXnyr8uP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-CKT08Djd.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-lzqtyFU8.js → index-CcsFv748.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-B1h680n5.js → index-ChN9-fAY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-BLJ7HxOC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-B7B9V-bu.js → loader-circle-CTqLEAGU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-b171b9d3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CCQd4aZA.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-CHhiHoo_.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-CxXUmBSd.js → search-B8VUL8nl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BejnUJ6R.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-DwFIBT09.js → simulations-CPoAg7Zo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-B6LgvRJg.js → triangle-alert-BZz2NjYa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-C1v1PQzo.js → useCustomSizes-DNwUduNu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-aSv48UbS.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DYxHZQuP.js → useReportContext-CpZgwliL.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-mBRpZPiu.js → useToast-Bv9JFvUO.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-DVzYx8PN.js → index-8Fv-lH1-.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Akn3iYFP.js +257 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/{codeyam:debug.md → codeyam-debug.md} +1 -1
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +19 -20
- package/codeyam-cli/templates/codeyam-memory.md +392 -0
- package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
- package/codeyam-cli/templates/{codeyam:setup.md → codeyam-setup.md} +13 -1
- package/codeyam-cli/templates/{codeyam:sim.md → codeyam-sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam:test.md → codeyam-test.md} +1 -1
- package/codeyam-cli/templates/{codeyam:verify.md → codeyam-verify.md} +1 -1
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
- package/codeyam-cli/templates/rules-instructions.md +132 -0
- package/package.json +2 -2
- package/packages/ai/index.js +3 -2
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +50 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +54 -8
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +317 -44
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +763 -171
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +33 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +36 -11
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +113 -11
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +309 -84
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructureChunking.js +26 -11
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +46 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +227 -4
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +7 -1
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +26 -4
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +447 -80
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +39 -3
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +70 -51
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +17 -2
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/resolvePathToControllable.js +24 -14
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +60 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +65 -7
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +17 -4
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +0 -3
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +56 -10
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +33 -8
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +150 -17
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +56 -8
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +399 -31
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/database/src/lib/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +3 -0
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/packages/database/src/lib/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -76
- package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-7522edd4.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-yxFcrxBX.js +0 -92
- package/codeyam-cli/src/webserver/build/client/assets/root-eVAaavTS.js +0 -62
- package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-4Cr0uToj.js +0 -257
- package/codeyam-cli/templates/codeyam:diagnose.md +0 -803
- package/codeyam-cli/templates/codeyam:memory.md +0 -462
- package/codeyam-cli/templates/codeyam:new-rule.md +0 -13
|
@@ -3,9 +3,11 @@ import type { ExecutionFlow, ScenariosDataStructure } from '~codeyam/types';
|
|
|
3
3
|
// Type for a single required value from ExecutionFlow
|
|
4
4
|
type RequiredValue = NonNullable<ExecutionFlow['requiredValues']>[number];
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const DEFAULT_MAX_CHUNK_SIZE = 10_000; // ~10K chars per chunk
|
|
7
7
|
|
|
8
8
|
export interface ChunkOptions {
|
|
9
|
+
maxChunkSize?: number;
|
|
10
|
+
/** @deprecated Use maxChunkSize instead. Kept for backward compatibility in tests. */
|
|
9
11
|
maxKeysPerChunk?: number;
|
|
10
12
|
}
|
|
11
13
|
|
|
@@ -15,8 +17,12 @@ export interface ChunkOptions {
|
|
|
15
17
|
* Large schemas overwhelm LLMs, causing them to make mistakes on some keys.
|
|
16
18
|
* By processing smaller chunks, each key gets more focused attention.
|
|
17
19
|
*
|
|
20
|
+
* Uses cumulative JSON size to decide chunk boundaries rather than a fixed
|
|
21
|
+
* key count, so a single oversized key gets its own chunk while many small
|
|
22
|
+
* keys are grouped together efficiently.
|
|
23
|
+
*
|
|
18
24
|
* @param dataForMocks - The full data structure schema
|
|
19
|
-
* @param options - Chunking options (
|
|
25
|
+
* @param options - Chunking options (maxChunkSize defaults to 10_000)
|
|
20
26
|
* @returns Array of smaller data structure chunks
|
|
21
27
|
*/
|
|
22
28
|
export function chunkDataStructure(
|
|
@@ -27,27 +33,39 @@ export function chunkDataStructure(
|
|
|
27
33
|
return [dataForMocks];
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
const {
|
|
36
|
+
const { maxChunkSize = DEFAULT_MAX_CHUNK_SIZE } = options;
|
|
31
37
|
const keys = Object.keys(dataForMocks);
|
|
32
38
|
|
|
33
|
-
//
|
|
34
|
-
|
|
39
|
+
// Calculate total size to see if chunking is needed
|
|
40
|
+
const totalSize = JSON.stringify(dataForMocks).length;
|
|
41
|
+
if (totalSize <= maxChunkSize) {
|
|
35
42
|
return [dataForMocks];
|
|
36
43
|
}
|
|
37
44
|
|
|
45
|
+
// Greedily pack keys into chunks by cumulative size
|
|
38
46
|
const chunks: Array<ScenariosDataStructure['dataForMocks']> = [];
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
let currentChunk: Record<string, unknown> = {};
|
|
48
|
+
let currentSize = 0;
|
|
49
|
+
|
|
50
|
+
for (const key of keys) {
|
|
51
|
+
const keySize = JSON.stringify(
|
|
52
|
+
(dataForMocks as Record<string, unknown>)[key],
|
|
53
|
+
).length;
|
|
54
|
+
|
|
55
|
+
// If adding this key would exceed the limit AND chunk isn't empty, start a new chunk
|
|
56
|
+
if (currentSize > 0 && currentSize + keySize > maxChunkSize) {
|
|
57
|
+
chunks.push(currentChunk as ScenariosDataStructure['dataForMocks']);
|
|
58
|
+
currentChunk = {};
|
|
59
|
+
currentSize = 0;
|
|
48
60
|
}
|
|
49
61
|
|
|
50
|
-
|
|
62
|
+
currentChunk[key] = (dataForMocks as Record<string, unknown>)[key];
|
|
63
|
+
currentSize += keySize;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Push the last chunk
|
|
67
|
+
if (Object.keys(currentChunk).length > 0) {
|
|
68
|
+
chunks.push(currentChunk as ScenariosDataStructure['dataForMocks']);
|
|
51
69
|
}
|
|
52
70
|
|
|
53
71
|
return chunks;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Entity } from '~codeyam/types';
|
|
2
2
|
import isolateScopes from './isolateScopes';
|
|
3
3
|
import analyzeScope from './analyzeScope';
|
|
4
|
-
import { FileAnalyzer } from '~codeyam/analyze';
|
|
4
|
+
import { FileAnalyzer, transformationTracer } from '~codeyam/analyze';
|
|
5
5
|
import { AI, SerializableDataStructure } from '~codeyam/ai';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
resetScopeDataStructureMetrics,
|
|
8
|
+
ScopeDataStructure,
|
|
9
|
+
} from './dataStructure/ScopeDataStructure';
|
|
7
10
|
|
|
8
11
|
// import { awsLog } from '~codeyam/utils';
|
|
9
12
|
|
|
@@ -91,8 +94,60 @@ export default async function generateEntityDataStructure({
|
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
// Inspect the runtime type of dataStructure to see if it must be serialized
|
|
97
|
+
// Note: When worker threads are used, dataStructure is already serialized (no toSerializable).
|
|
98
|
+
// Workers are disabled when CODEYAM_TRACE_TRANSFORMS=1 to enable full tracing.
|
|
94
99
|
if ('toSerializable' in entityScope.dataStructure) {
|
|
95
|
-
|
|
100
|
+
const scopeDataStructure =
|
|
101
|
+
entityScope.dataStructure as unknown as ScopeDataStructure;
|
|
102
|
+
|
|
103
|
+
// Trace the internal state BEFORE serialization - captures what methods return
|
|
104
|
+
if (transformationTracer.isEnabled()) {
|
|
105
|
+
transformationTracer.startEntity({
|
|
106
|
+
name: entity.name,
|
|
107
|
+
entityType: entity.entityType ?? 'unknown',
|
|
108
|
+
filePath: entity.filePath,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Capture internal state - this is what getReturnValue/getFunctionSignature return
|
|
112
|
+
transformationTracer.snapshot(entity.name, 'scopeDataStructure', {
|
|
113
|
+
signatureSchema: scopeDataStructure.getFunctionSignature({
|
|
114
|
+
fillInUnknowns: true,
|
|
115
|
+
}),
|
|
116
|
+
returnValueSchema: scopeDataStructure.getReturnValue({
|
|
117
|
+
fillInUnknowns: true,
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const serialized = scopeDataStructure.toSerializable();
|
|
123
|
+
|
|
124
|
+
// Trace AFTER serialization - shows what gets output
|
|
125
|
+
if (transformationTracer.isEnabled()) {
|
|
126
|
+
// Build schema from external function calls for comparison
|
|
127
|
+
const externalSchemas: Record<string, string> = {};
|
|
128
|
+
for (const efc of serialized.externalFunctionCalls ?? []) {
|
|
129
|
+
for (const [path, type] of Object.entries(efc.schema ?? {})) {
|
|
130
|
+
externalSchemas[path] = type;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
transformationTracer.snapshot(entity.name, 'serialized', {
|
|
135
|
+
signatureSchema:
|
|
136
|
+
serialized.functionResults?.[entity.name]?.signatureWithUnknowns,
|
|
137
|
+
returnValueSchema:
|
|
138
|
+
serialized.functionResults?.[entity.name]?.returnValueWithUnknowns,
|
|
139
|
+
// Include external function schemas to detect serialization gaps
|
|
140
|
+
dependencySchemas: {
|
|
141
|
+
externalFunctions: {
|
|
142
|
+
combined: {
|
|
143
|
+
returnValueSchema: externalSchemas,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return serialized;
|
|
96
151
|
}
|
|
97
152
|
return entityScope.dataStructure;
|
|
98
153
|
}
|
|
@@ -16,7 +16,9 @@ import validateJson from './validateJson';
|
|
|
16
16
|
import { awsLog, awsLogDebugLevel } from '~codeyam/utils';
|
|
17
17
|
import { AI, parseJsonSafe } from '~codeyam/ai';
|
|
18
18
|
import convertNullToUndefinedBySchema from './dataStructure/helpers/convertNullToUndefinedBySchema';
|
|
19
|
+
import convertTypeAnnotationsToValues from './dataStructure/helpers/convertTypeAnnotationsToValues';
|
|
19
20
|
import fixNullIdsBySchema from './dataStructure/helpers/fixNullIdsBySchema';
|
|
21
|
+
import coerceObjectsToPrimitivesBySchema from './dataStructure/helpers/coerceObjectsToPrimitivesBySchema';
|
|
20
22
|
import { JsonTypeDefinition } from '~codeyam/types';
|
|
21
23
|
import { deepMerge } from '~codeyam/generate';
|
|
22
24
|
import {
|
|
@@ -292,11 +294,13 @@ function generateDefaultForSchemaType(schemaType: unknown): unknown {
|
|
|
292
294
|
if (schemaType.includes('| null')) return null;
|
|
293
295
|
return schemaType; // Return the type as a string placeholder
|
|
294
296
|
}
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
if (Array.isArray(schemaType)) {
|
|
298
|
+
if (schemaType.length === 0) return [];
|
|
299
|
+
// Generate a single default element based on the first element's schema
|
|
300
|
+
const elementDefault = generateDefaultForSchemaType(schemaType[0]);
|
|
301
|
+
return elementDefault !== undefined ? [elementDefault] : [];
|
|
302
|
+
}
|
|
303
|
+
if (typeof schemaType === 'object' && schemaType !== null) {
|
|
300
304
|
// Recursively generate defaults for nested objects
|
|
301
305
|
const result: Record<string, unknown> = {};
|
|
302
306
|
for (const [key, value] of Object.entries(schemaType)) {
|
|
@@ -424,6 +428,8 @@ function fillMissingMockDataKeysWithDefaults(
|
|
|
424
428
|
const missingKeys: string[] = [];
|
|
425
429
|
|
|
426
430
|
for (const key of Object.keys(dataForMocks)) {
|
|
431
|
+
if (key === '_nullable') continue; // Internal marker, not a data key
|
|
432
|
+
|
|
427
433
|
const fullPath = pathPrefix ? `${pathPrefix}.${key}` : key;
|
|
428
434
|
|
|
429
435
|
if (mockData[key] === undefined) {
|
|
@@ -459,6 +465,193 @@ function fillMissingMockDataKeysWithDefaults(
|
|
|
459
465
|
}
|
|
460
466
|
}
|
|
461
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Enforce execution flow requiredValues by setting falsy paths to null.
|
|
470
|
+
*
|
|
471
|
+
* The LLM doesn't reliably generate null for `comparison: 'falsy'` requirements.
|
|
472
|
+
* For example, a flow like "diffView: falsy" should hide a modal, but the LLM
|
|
473
|
+
* might generate a truthy object, causing the modal to show in all screenshots.
|
|
474
|
+
*
|
|
475
|
+
* This function:
|
|
476
|
+
* 1. Gets requiredValues from covered flows
|
|
477
|
+
* 2. For 'falsy' comparisons: sets the value to null
|
|
478
|
+
* 3. For 'truthy' comparisons with falsy values: generates a default truthy value
|
|
479
|
+
*/
|
|
480
|
+
function enforceRequiredValues(
|
|
481
|
+
mockData: Record<string, unknown>,
|
|
482
|
+
coveredFlowIds: string[],
|
|
483
|
+
executionFlows: ExecutionFlow[],
|
|
484
|
+
): void {
|
|
485
|
+
if (!coveredFlowIds.length || !executionFlows.length) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// Get all requiredValues from covered flows
|
|
490
|
+
const coveredFlows = executionFlows.filter((flow) =>
|
|
491
|
+
coveredFlowIds.includes(flow.id),
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
for (const flow of coveredFlows) {
|
|
495
|
+
if (!flow.requiredValues) continue;
|
|
496
|
+
|
|
497
|
+
for (const rv of flow.requiredValues) {
|
|
498
|
+
if (!rv.attributePath) continue;
|
|
499
|
+
|
|
500
|
+
// Find the value in mockData - the path could be nested
|
|
501
|
+
// e.g., attributePath: "diffView" could be at mockData['useDiffModal()'].diffView
|
|
502
|
+
const result = findAndSetValueInMockData(
|
|
503
|
+
mockData,
|
|
504
|
+
rv.attributePath,
|
|
505
|
+
rv.comparison,
|
|
506
|
+
rv.valueType,
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
if (result.found) {
|
|
510
|
+
awsLog(
|
|
511
|
+
`CodeYam: Enforced ${rv.comparison} for ${rv.attributePath} (set to ${result.newValue === null ? 'null' : typeof result.newValue})`,
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Find a value in mockData by attributePath and enforce the comparison.
|
|
520
|
+
* The attributePath could be a simple key or a nested path.
|
|
521
|
+
*
|
|
522
|
+
* Returns { found: boolean, newValue: unknown }
|
|
523
|
+
*/
|
|
524
|
+
function findAndSetValueInMockData(
|
|
525
|
+
mockData: Record<string, unknown>,
|
|
526
|
+
attributePath: string,
|
|
527
|
+
comparison: string,
|
|
528
|
+
valueType?: string,
|
|
529
|
+
): { found: boolean; newValue?: unknown } {
|
|
530
|
+
// Try to find the path at various nesting levels
|
|
531
|
+
// The attributePath might be "diffView" but the actual location is
|
|
532
|
+
// mockData['useDiffModal()'].diffView
|
|
533
|
+
|
|
534
|
+
// Strategy 1: Direct path (e.g., mockData[attributePath])
|
|
535
|
+
if (attributePath in mockData) {
|
|
536
|
+
const currentValue = mockData[attributePath];
|
|
537
|
+
const { shouldChange, newValue } = getEnforcedValue(
|
|
538
|
+
currentValue,
|
|
539
|
+
comparison,
|
|
540
|
+
valueType,
|
|
541
|
+
);
|
|
542
|
+
if (shouldChange) {
|
|
543
|
+
mockData[attributePath] = newValue;
|
|
544
|
+
return { found: true, newValue };
|
|
545
|
+
}
|
|
546
|
+
return { found: true, newValue: currentValue };
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// Strategy 2: Search in nested objects
|
|
550
|
+
for (const [key, value] of Object.entries(mockData)) {
|
|
551
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
552
|
+
const nestedObj = value as Record<string, unknown>;
|
|
553
|
+
|
|
554
|
+
// Check if attributePath exists in this nested object
|
|
555
|
+
if (attributePath in nestedObj) {
|
|
556
|
+
const currentValue = nestedObj[attributePath];
|
|
557
|
+
const { shouldChange, newValue } = getEnforcedValue(
|
|
558
|
+
currentValue,
|
|
559
|
+
comparison,
|
|
560
|
+
valueType,
|
|
561
|
+
);
|
|
562
|
+
if (shouldChange) {
|
|
563
|
+
nestedObj[attributePath] = newValue;
|
|
564
|
+
return { found: true, newValue };
|
|
565
|
+
}
|
|
566
|
+
return { found: true, newValue: currentValue };
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// Also check dot-notation paths (e.g., "diffView.type")
|
|
570
|
+
if (attributePath.includes('.')) {
|
|
571
|
+
const parts = attributePath.split('.');
|
|
572
|
+
const firstPart = parts[0];
|
|
573
|
+
if (firstPart in nestedObj) {
|
|
574
|
+
// Recurse with the rest of the path
|
|
575
|
+
const result = findAndSetValueInMockData(
|
|
576
|
+
nestedObj,
|
|
577
|
+
attributePath,
|
|
578
|
+
comparison,
|
|
579
|
+
valueType,
|
|
580
|
+
);
|
|
581
|
+
if (result.found) return result;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Recursively search deeper
|
|
586
|
+
const result = findAndSetValueInMockData(
|
|
587
|
+
nestedObj,
|
|
588
|
+
attributePath,
|
|
589
|
+
comparison,
|
|
590
|
+
valueType,
|
|
591
|
+
);
|
|
592
|
+
if (result.found) return result;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
return { found: false };
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Determine if a value should be changed to match a comparison requirement.
|
|
601
|
+
*
|
|
602
|
+
* For 'falsy' comparison: truthy values should become null
|
|
603
|
+
* For 'truthy' comparison: falsy values should become a default truthy value
|
|
604
|
+
*/
|
|
605
|
+
function getEnforcedValue(
|
|
606
|
+
currentValue: unknown,
|
|
607
|
+
comparison: string,
|
|
608
|
+
valueType?: string,
|
|
609
|
+
): { shouldChange: boolean; newValue: unknown } {
|
|
610
|
+
const isTruthy = Boolean(currentValue);
|
|
611
|
+
|
|
612
|
+
if (comparison === 'falsy') {
|
|
613
|
+
// Value should be falsy
|
|
614
|
+
if (isTruthy) {
|
|
615
|
+
return { shouldChange: true, newValue: null };
|
|
616
|
+
}
|
|
617
|
+
return { shouldChange: false, newValue: currentValue };
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if (comparison === 'truthy') {
|
|
621
|
+
// Value should be truthy
|
|
622
|
+
if (!isTruthy) {
|
|
623
|
+
// Generate a default truthy value based on valueType
|
|
624
|
+
const defaultValue = generateDefaultTruthyValue(valueType);
|
|
625
|
+
return { shouldChange: true, newValue: defaultValue };
|
|
626
|
+
}
|
|
627
|
+
return { shouldChange: false, newValue: currentValue };
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// For other comparisons (equals, exists, etc.), don't auto-enforce
|
|
631
|
+
return { shouldChange: false, newValue: currentValue };
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Generate a default truthy value for a given type.
|
|
636
|
+
*/
|
|
637
|
+
function generateDefaultTruthyValue(valueType?: string): unknown {
|
|
638
|
+
if (!valueType) return { _placeholder: true };
|
|
639
|
+
|
|
640
|
+
switch (valueType.toLowerCase()) {
|
|
641
|
+
case 'string':
|
|
642
|
+
return 'default-value';
|
|
643
|
+
case 'number':
|
|
644
|
+
return 1;
|
|
645
|
+
case 'boolean':
|
|
646
|
+
return true;
|
|
647
|
+
case 'array':
|
|
648
|
+
return [{ _placeholder: true }];
|
|
649
|
+
case 'object':
|
|
650
|
+
default:
|
|
651
|
+
return { _placeholder: true };
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
462
655
|
type ScenarioDataWithoutDescription = Omit<ScenarioData, 'scenarioDescription'>;
|
|
463
656
|
|
|
464
657
|
interface GenerateEntityScenarioDataArgs {
|
|
@@ -652,6 +845,29 @@ export async function generateDataForScenario({
|
|
|
652
845
|
}
|
|
653
846
|
}
|
|
654
847
|
|
|
848
|
+
// Detect keys that were lost from failed or partial chunk responses
|
|
849
|
+
// and fill them with schema-based defaults so they aren't permanently lost.
|
|
850
|
+
const allChunkedKeys = chunks.flatMap((c) => Object.keys(c || {}));
|
|
851
|
+
const returnedKeys = new Set(Object.keys(chunkedMockData));
|
|
852
|
+
const missingChunkKeys = allChunkedKeys.filter(
|
|
853
|
+
(k) => !returnedKeys.has(k),
|
|
854
|
+
);
|
|
855
|
+
|
|
856
|
+
if (missingChunkKeys.length > 0) {
|
|
857
|
+
awsLog(
|
|
858
|
+
`Chunked processing: ${missingChunkKeys.length} key(s) missing from chunk results, filling with defaults: ${missingChunkKeys.join(', ')}`,
|
|
859
|
+
);
|
|
860
|
+
const dataForMocksRecord = structure.dataForMocks as Record<
|
|
861
|
+
string,
|
|
862
|
+
unknown
|
|
863
|
+
>;
|
|
864
|
+
for (const key of missingChunkKeys) {
|
|
865
|
+
chunkedMockData[key] = generateDefaultForSchemaType(
|
|
866
|
+
dataForMocksRecord[key],
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
655
871
|
awsLog(
|
|
656
872
|
`Chunked processing complete. Generated ${Object.keys(chunkedMockData).length} keys total`,
|
|
657
873
|
);
|
|
@@ -869,6 +1085,19 @@ export async function generateDataForScenario({
|
|
|
869
1085
|
);
|
|
870
1086
|
}
|
|
871
1087
|
|
|
1088
|
+
// Coerce objects/arrays to primitives when the schema expects a primitive type.
|
|
1089
|
+
// The LLM sometimes generates an object where the schema expects "string",
|
|
1090
|
+
// e.g., { body: { "env": "production" } } instead of { body: "some string" }.
|
|
1091
|
+
// This causes runtime errors like "TypeError: body.match is not a function".
|
|
1092
|
+
// Must run BEFORE convertCommaSeparatedStringsToArrays, which intentionally
|
|
1093
|
+
// overrides schema types for array-like field names.
|
|
1094
|
+
if (structure.dataForMocks && fullScenarioData.data.mockData) {
|
|
1095
|
+
coerceObjectsToPrimitivesBySchema(
|
|
1096
|
+
fullScenarioData.data.mockData,
|
|
1097
|
+
structure.dataForMocks,
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
872
1101
|
// Convert comma-separated strings to arrays when appropriate.
|
|
873
1102
|
// The LLM sometimes generates strings like "color,size" instead of arrays
|
|
874
1103
|
// like ["color", "size"] when the schema type is incorrectly inferred as
|
|
@@ -878,6 +1107,16 @@ export async function generateDataForScenario({
|
|
|
878
1107
|
convertCommaSeparatedStringsToArrays(fullScenarioData.data.mockData);
|
|
879
1108
|
}
|
|
880
1109
|
|
|
1110
|
+
// Convert type annotation strings that appear as values to actual values.
|
|
1111
|
+
// The LLM sometimes echoes the schema type annotation as the value.
|
|
1112
|
+
// For example, if the schema says { filePath: "string | undefined" },
|
|
1113
|
+
// the LLM might return { filePath: "string | undefined" } instead of
|
|
1114
|
+
// generating an actual value. This converts those type strings to
|
|
1115
|
+
// appropriate default values (e.g., "string | undefined" → undefined).
|
|
1116
|
+
if (fullScenarioData.data.mockData) {
|
|
1117
|
+
convertTypeAnnotationsToValues(fullScenarioData.data.mockData);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
881
1120
|
// Fix null values for ID fields when the schema indicates they should be non-null.
|
|
882
1121
|
// The LLM sometimes generates `null` for ID fields (e.g., `"id": null`) when
|
|
883
1122
|
// the schema type is `"number"`. This causes runtime issues when code checks
|
|
@@ -886,6 +1125,18 @@ export async function generateDataForScenario({
|
|
|
886
1125
|
fixNullIdsBySchema(fullScenarioData.data.mockData, structure.dataForMocks);
|
|
887
1126
|
}
|
|
888
1127
|
|
|
1128
|
+
// Enforce execution flow requiredValues by setting falsy paths to null.
|
|
1129
|
+
// The LLM doesn't reliably generate null for falsy requirements (e.g., diffView: falsy
|
|
1130
|
+
// to hide a modal). This post-processing ensures that scenarios match their
|
|
1131
|
+
// covered flows' requiredValues.
|
|
1132
|
+
if (fullScenarioData.data.mockData && executionFlows) {
|
|
1133
|
+
enforceRequiredValues(
|
|
1134
|
+
fullScenarioData.data.mockData,
|
|
1135
|
+
scenario.metadata?.coveredFlows || [],
|
|
1136
|
+
executionFlows,
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
889
1140
|
if (structure.arguments && fullScenarioData.data.argumentsData) {
|
|
890
1141
|
for (let i = 0; i < fullScenarioData.data.argumentsData.length; i++) {
|
|
891
1142
|
if (structure.arguments[i]) {
|
|
@@ -1075,6 +1326,60 @@ export default async function generateEntityScenarioData({
|
|
|
1075
1326
|
defaultScenarioData.data.argumentsData.map((arg) => ({ ...arg }));
|
|
1076
1327
|
}
|
|
1077
1328
|
|
|
1329
|
+
// Enforce requiredValues AFTER merge for non-default scenarios
|
|
1330
|
+
// This ensures that if a non-default scenario doesn't cover a certain flow,
|
|
1331
|
+
// it inherits the enforcement from the default scenario
|
|
1332
|
+
if (scenarioData.data?.mockData && executionFlows) {
|
|
1333
|
+
// Get the flows covered by this scenario
|
|
1334
|
+
const scenarioCoveredFlows =
|
|
1335
|
+
nonDefaultScenarios.find(
|
|
1336
|
+
(s) => s.name === result.scenarioData.scenarioDescription,
|
|
1337
|
+
)?.metadata?.coveredFlows || [];
|
|
1338
|
+
|
|
1339
|
+
// Get the paths that the scenario's flows affect
|
|
1340
|
+
const scenarioAffectedPaths = new Set<string>();
|
|
1341
|
+
for (const flowId of scenarioCoveredFlows) {
|
|
1342
|
+
const flow = executionFlows.find((f) => f.id === flowId);
|
|
1343
|
+
if (flow?.requiredValues) {
|
|
1344
|
+
for (const rv of flow.requiredValues) {
|
|
1345
|
+
if (rv.attributePath) {
|
|
1346
|
+
// Extract base path (e.g., "diffView" from "diffView.type")
|
|
1347
|
+
const basePath = rv.attributePath.split('.')[0];
|
|
1348
|
+
scenarioAffectedPaths.add(basePath);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
// Get the default scenario's flows
|
|
1355
|
+
const defaultCoveredFlows =
|
|
1356
|
+
defaultScenario.metadata?.coveredFlows || [];
|
|
1357
|
+
|
|
1358
|
+
// For paths NOT affected by the scenario, apply default's enforcement
|
|
1359
|
+
const defaultFlowsForUnaffectedPaths = defaultCoveredFlows.filter(
|
|
1360
|
+
(flowId) => {
|
|
1361
|
+
const flow = executionFlows.find((f) => f.id === flowId);
|
|
1362
|
+
if (!flow?.requiredValues) return false;
|
|
1363
|
+
|
|
1364
|
+
// Check if this flow affects a path that the scenario doesn't cover
|
|
1365
|
+
return flow.requiredValues.some((rv) => {
|
|
1366
|
+
if (!rv.attributePath) return false;
|
|
1367
|
+
const basePath = rv.attributePath.split('.')[0];
|
|
1368
|
+
return !scenarioAffectedPaths.has(basePath);
|
|
1369
|
+
});
|
|
1370
|
+
},
|
|
1371
|
+
);
|
|
1372
|
+
|
|
1373
|
+
// Apply enforcement from default scenario for unaffected paths
|
|
1374
|
+
if (defaultFlowsForUnaffectedPaths.length > 0) {
|
|
1375
|
+
enforceRequiredValues(
|
|
1376
|
+
scenarioData.data.mockData,
|
|
1377
|
+
defaultFlowsForUnaffectedPaths,
|
|
1378
|
+
executionFlows,
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1078
1383
|
return scenarioData;
|
|
1079
1384
|
});
|
|
1080
1385
|
|
|
@@ -1104,7 +1409,8 @@ Generate COMPLETE, robust data for the entire data structure.
|
|
|
1104
1409
|
: `## Non-Default Scenario
|
|
1105
1410
|
Generate ONLY the differences from the default scenario.
|
|
1106
1411
|
- Include only fields that need to change
|
|
1107
|
-
-
|
|
1412
|
+
- For object/scalar fields: set to \`null\` to remove/unset the data
|
|
1413
|
+
- For array fields: use \`[]\` for empty arrays (not \`null\`) unless the schema type explicitly includes \`| null\`
|
|
1108
1414
|
- Omit unchanged fields—they merge from default`;
|
|
1109
1415
|
|
|
1110
1416
|
// Only include the "NO ERROR DATA" instruction when the scenario doesn't require error data
|
|
@@ -1188,6 +1494,7 @@ Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
|
|
|
1188
1494
|
- Arrays should have many items (at least 4) unless specified otherwise
|
|
1189
1495
|
- Each item must follow the exact structure provided
|
|
1190
1496
|
- In general we want robust data, not minimal data unless specified otherwise
|
|
1497
|
+
- For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
|
|
1191
1498
|
|
|
1192
1499
|
## CRITICAL: Preserve Exact Structure
|
|
1193
1500
|
Your response MUST mirror the EXACT nested structure provided in mockData Structure.
|
|
@@ -1267,6 +1574,7 @@ Use simple elements only (\`<div>\`, \`<span>\`). No custom components.
|
|
|
1267
1574
|
### Arrays
|
|
1268
1575
|
- Arrays should have many items (at least 4) unless specified otherwise
|
|
1269
1576
|
- Each item must follow the exact structure provided
|
|
1577
|
+
- For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
|
|
1270
1578
|
|
|
1271
1579
|
## CRITICAL: Preserve Exact Structure
|
|
1272
1580
|
Your response MUST mirror the EXACT nested structure provided for the missing keys.
|
|
@@ -1395,4 +1703,5 @@ NEVER include "error" fields in responses. Skip them entirely.
|
|
|
1395
1703
|
- No \`undefined\`—use \`null\` or omit
|
|
1396
1704
|
- Generate data for ALL keys in the chunk (don't skip any)
|
|
1397
1705
|
- Arrays should have many items (at least 4) unless specified otherwise
|
|
1706
|
+
- For empty arrays, use \`[]\` (not \`null\`) unless the schema type explicitly includes \`| null\` and the scenario requires the attribute be removed
|
|
1398
1707
|
`;
|
|
@@ -176,11 +176,15 @@ export default async function generateEntityScenarios({
|
|
|
176
176
|
return { scenarios: [], llmCall };
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
const dataScenarios = result[`${error ? 'errorD' : 'd'}ataScenarios`];
|
|
180
|
+
|
|
181
|
+
// Gracefully handle missing dataScenarios (e.g., when LLM returns unexpected format
|
|
182
|
+
// or when test fixtures don't include the expected key)
|
|
183
|
+
if (!Array.isArray(dataScenarios)) {
|
|
184
|
+
return { scenarios: [], llmCall };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const scenarios = (dataScenarios as unknown as ScenarioResult[]).map(
|
|
184
188
|
(scenarioInfo) =>
|
|
185
189
|
({
|
|
186
190
|
projectId: entity.projectId,
|