@codeyam/codeyam-cli 0.1.0-staging.76566f9 → 0.1.0-staging.79ef713
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/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +15 -12
- package/analyzer-template/packages/ai/index.ts +20 -5
- package/analyzer-template/packages/ai/package.json +3 -3
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +212 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +183 -10
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +15 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1128 -30
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +259 -6
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1577 -313
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +296 -35
- 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 +54 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +129 -20
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +80 -5
- 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 +393 -90
- 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/deepEqual.ts +30 -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/generateChangesEntityScenarioData.ts +33 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +86 -142
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +59 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1358 -67
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +200 -196
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +578 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2267 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +5 -5
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -142
- 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 +90 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -89
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +11 -11
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +122 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -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/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- 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 +449 -283
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +34 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -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/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- 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 +201 -46
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +254 -41
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +306 -20
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -3
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +723 -46
- 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/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +3 -3
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +8 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +17 -1
- 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/loadReadyToBeCapturedAnalyses.ts +7 -3
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -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 +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 +1 -18
- 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/kysely/tables/debugReportsTable.d.ts +17 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.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/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.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/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +3 -4
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js +0 -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 +71 -27
- 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/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +3 -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/Scenario.d.ts +9 -54
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +153 -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/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.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/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +3 -6
- package/analyzer-template/packages/types/src/types/Analysis.ts +87 -27
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +1 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +9 -77
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +181 -5
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/index.d.ts +3 -4
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js +0 -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 +71 -27
- 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/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +3 -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/Scenario.d.ts +9 -54
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.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 +57 -26
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1004 -105
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +18 -7
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +81 -9
- package/analyzer-template/project/reconcileMockDataKeys.ts +240 -0
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +51 -15
- package/analyzer-template/project/startScenarioCapture.ts +6 -0
- package/analyzer-template/project/writeMockDataTsx.ts +298 -11
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +312 -42
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +23 -13
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +1 -29
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/local/execAsync.js +1 -1
- package/background/src/lib/local/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/common/execAsync.js +1 -1
- package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
- 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 +879 -69
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.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/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.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/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.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/KyselyAnalysisLoader.js +3 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.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 +65 -10
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +199 -0
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +47 -15
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +7 -0
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +255 -8
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +245 -41
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +23 -13
- 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 +7 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +1 -1
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +174 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +35 -23
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +0 -15
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +264 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +29 -18
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/report.js +46 -1
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +1 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +31 -27
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +29 -15
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +16 -2
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +4 -3
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +76 -17
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +109 -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/queue/persistence.js.map +1 -1
- 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 +285 -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 +6 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +78 -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/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +7 -5
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/versionInfo.js +25 -19
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +74 -20
- 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/CopyButton-CA3JxPb7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-B86KKU7e.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-CzGX-miz.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BqY8gDAW.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-ClaLpuOo.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-BDhPilK7.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CBQPrpT0.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-D1CdlbrV.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-wDPcZNKx.js → LogViewer-Bm3PmcCz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-C6PKeMYR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-BfmDgXxG.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BNLaXBHR.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-6J7zDUD5.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-B3TDXxnk.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BtBFH820.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DfKzxuoe.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-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-BYimnrHg.js → chevron-down-TJp6ofnp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-JE9ZIoBl.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CaVsIRxt.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-CgUsG7ib.js → createLucideIcon-Ca9fAY46.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-C5lqplTC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-Dt-SjPsw.js → entity._sha._-n38keI1k.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DGgZjdFg.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CfLCUi9S.js → entity._sha_.edit._scenarioId-38yPijoD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DKJyZfAY.js → entry.client-BSHEfydn.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DAtOlaWE.js → fileTableUtils-DCPhhSMo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-0N0YJQv7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{git-D62Lxxmv.js → git-DXnyr8uP.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/globals-Bh6jH0cL.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-BosqDOlH.js → index-CcsFv748.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-CzNNiTkw.js → index-ChN9-fAY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-CdVUfvji.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CNp9QFCX.js → loader-circle-CTqLEAGU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-87319d0f.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CPIDnDEj.js +76 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-D6oziHts.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-DDGjYAMJ.js → search-B8VUL8nl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-eBI36Yv5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CPoAg7Zo.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CBc5dE1s.js → triangle-alert-BZz2NjYa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DNwUduNu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BqPPNjAl.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CpZgwliL.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-DWHcCcl1.js → useToast-Bv9JFvUO.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-9ox9LcrG.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Cq5Vqcob.js +260 -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/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +48 -4
- package/codeyam-cli/templates/{debug-codeyam.md → codeyam:diagnose.md} +204 -26
- package/codeyam-cli/templates/codeyam:memory.md +404 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +13 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +1 -1
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +590 -0
- package/codeyam-cli/templates/rules-instructions.md +123 -0
- package/package.json +12 -9
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +165 -13
- 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 +138 -9
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.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/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +7 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +866 -29
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +178 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1240 -181
- 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/equivalencyManagers/frameworks/MuiManager.js +230 -23
- 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 +52 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +111 -14
- 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 +73 -5
- 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 +333 -81
- 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/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.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/generateChangesEntityScenarioData.js +21 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +78 -120
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +47 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1082 -62
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +177 -163
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +400 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1646 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -2
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +88 -46
- 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/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -100
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.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 +68 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -70
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +9 -9
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.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 +677 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -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/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -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/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- 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 +196 -57
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +24 -1
- 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/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.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/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.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/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.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 +170 -40
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +211 -29
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +218 -20
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -3
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +599 -38
- 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/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/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +8 -1
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/debugReportsTable.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/loadReadyToBeCapturedAnalyses.js +7 -4
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.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/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js +0 -1
- package/packages/types/index.js.map +1 -1
- package/packages/types/src/types/Scenario.js +1 -21
- package/packages/types/src/types/Scenario.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/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -409
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -288
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -495
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -120
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CVP_WGQ3.js +0 -32
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-C9s7Lhdl.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-0d27da29.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-B_wIKCIf.js +0 -56
- package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CU58-Ttc.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-D35o2uae.js +0 -175
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -298
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -226
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -408
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -77
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.link-scenario-value-l0sNRNKZ.js → api.agent-transcripts-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-key-attributes-l0sNRNKZ.js → api.health-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-valid-values-l0sNRNKZ.js → api.memory-profile-l0sNRNKZ.js} +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -215,12 +215,28 @@ function funcArgs(functionSignature) {
|
|
|
215
215
|
}
|
|
216
216
|
// isValidKey ensures that the key does not contain any characters that would make it invalid in a JavaScript object.
|
|
217
217
|
// For example, it should not contain spaces, special characters, or start with a number.
|
|
218
|
+
// Also rejects keys that are pure function calls like "()" or "(args)" - these aren't property names.
|
|
218
219
|
function isValidKey(key) {
|
|
219
220
|
if (!key || key.length === 0)
|
|
220
221
|
return false;
|
|
221
222
|
const keyWithOutArguments = key.split('(')[0];
|
|
223
|
+
// Reject empty keys (happens when key is "()" or "(args)") - these are function calls, not property names
|
|
224
|
+
if (!keyWithOutArguments || keyWithOutArguments.length === 0)
|
|
225
|
+
return false;
|
|
222
226
|
return !/\s/.test(keyWithOutArguments);
|
|
223
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Known hooks that return tuples [value, setter] instead of arrays.
|
|
230
|
+
* These should NOT use the .map() pattern even when the schema has generic array access ([]).
|
|
231
|
+
* Instead, they should return [data, () => {}] where data is from scenarios().
|
|
232
|
+
*/
|
|
233
|
+
const TUPLE_RETURNING_HOOKS = new Set([
|
|
234
|
+
'useAtom', // Jotai
|
|
235
|
+
'useState', // React
|
|
236
|
+
'useReducer', // React
|
|
237
|
+
'useRecoilState', // Recoil
|
|
238
|
+
'useImmerAtom', // Jotai with Immer
|
|
239
|
+
]);
|
|
224
240
|
export default function constructMockCode(mockName, dependencySchemas, entityType, _canonicalKey, // DEPRECATED: No longer used, kept for API compatibility
|
|
225
241
|
options) {
|
|
226
242
|
// Check if mockName is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
@@ -300,14 +316,16 @@ options) {
|
|
|
300
316
|
// Entity is an object/namespace - use bare name as key
|
|
301
317
|
dataKey = mockName;
|
|
302
318
|
}
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
319
|
+
// Helper to wrap key in appropriate quotes for computed property access
|
|
320
|
+
// Use single quotes when key contains double quotes to avoid syntax errors
|
|
321
|
+
const quotePropertyKey = (key) => {
|
|
322
|
+
const escaped = key.replace(/\n/g, '\\n');
|
|
323
|
+
if (escaped.includes('"')) {
|
|
324
|
+
// Use single quotes, escaping any single quotes in the key
|
|
325
|
+
return `['${escaped.replace(/'/g, "\\'")}']`;
|
|
326
|
+
}
|
|
327
|
+
return `["${escaped}"]`;
|
|
328
|
+
};
|
|
311
329
|
// Check if the return value schema only contains function type markers
|
|
312
330
|
// (e.g., "validateInputs()": "function") without actual return data
|
|
313
331
|
// (no functionCallReturnValue entries)
|
|
@@ -330,6 +348,8 @@ options) {
|
|
|
330
348
|
// Count the number of arguments from signature schema
|
|
331
349
|
const argCount = Object.keys(signatureSchema).filter((key) => key.startsWith('signature[')).length;
|
|
332
350
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
351
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
352
|
+
args.push('...rest');
|
|
333
353
|
const argsString = args.join(', ');
|
|
334
354
|
// Generate empty mock function
|
|
335
355
|
return `function ${mockName}(${argsString}) {
|
|
@@ -348,7 +368,33 @@ options) {
|
|
|
348
368
|
!hasMeaningfulReturnData(relevantReturnValueSchema)) {
|
|
349
369
|
const argCount = Object.keys(signatureSchema).filter((key) => key.startsWith('signature[')).length;
|
|
350
370
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
371
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
372
|
+
args.push('...rest');
|
|
351
373
|
const argsString = args.join(', ');
|
|
374
|
+
// Check for Higher-Order Component (HOC) pattern:
|
|
375
|
+
// - First argument is a function (component) or unknown (couldn't trace type)
|
|
376
|
+
// - Returns a function
|
|
377
|
+
// HOCs like memo, forwardRef, createContext should return their first argument
|
|
378
|
+
//
|
|
379
|
+
// The return value key can be either:
|
|
380
|
+
// - 'memo()' (clean format)
|
|
381
|
+
// - 'memo(({ value, width }: Props) => { ... })' (full component code format)
|
|
382
|
+
const firstArgIsFunctionOrUnknown = signatureSchema['signature[0]'] === 'function' ||
|
|
383
|
+
signatureSchema['signature[0]'] === 'unknown';
|
|
384
|
+
const returnsFunction = relevantReturnValueSchema
|
|
385
|
+
? Object.entries(relevantReturnValueSchema).some(([key, value]) => {
|
|
386
|
+
// Check if key represents a function call that returns a function
|
|
387
|
+
// Key should start with the mock name, contain '(', end with ')', and have value 'function'
|
|
388
|
+
const isFunctionCall = key.startsWith(mockName + '(') && key.endsWith(')');
|
|
389
|
+
return isFunctionCall && value === 'function';
|
|
390
|
+
})
|
|
391
|
+
: false;
|
|
392
|
+
if (firstArgIsFunctionOrUnknown && returnsFunction) {
|
|
393
|
+
// HOC pattern detected - return the first argument
|
|
394
|
+
return `function ${mockName}(${argsString}) {
|
|
395
|
+
return arg1;
|
|
396
|
+
}`;
|
|
397
|
+
}
|
|
352
398
|
// Generate empty mock function
|
|
353
399
|
return `function ${mockName}(${argsString}) {
|
|
354
400
|
// Empty mock - original function mocked out
|
|
@@ -365,6 +411,87 @@ options) {
|
|
|
365
411
|
const pathDepth = splitOutsideParenthesesAndArrays(dataStructurePath).length;
|
|
366
412
|
const isRootArray = dataStructureValue === 'array' &&
|
|
367
413
|
(dataStructurePath === 'returnValue' || pathDepth <= mockNameParts.length);
|
|
414
|
+
// OPTIMIZATION: Early return for tuple-returning hooks (useAtom, useState, etc.)
|
|
415
|
+
// These hooks have simple [value, setter] return patterns that don't need the full
|
|
416
|
+
// 9216-key schema processing. Check if this is a tuple-returning hook and generate
|
|
417
|
+
// the mock code directly without iterating over all schema keys.
|
|
418
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && isFunction) {
|
|
419
|
+
// Check if schema has generic array pattern (indicates tuple return like [value, setter])
|
|
420
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
421
|
+
const hasGenericArrayInSchema = schemaKeys.some((k) => k.includes('.functionCallReturnValue[]') ||
|
|
422
|
+
k === `${dataKey}.functionCallReturnValue[]` ||
|
|
423
|
+
k === 'returnValue[]');
|
|
424
|
+
// Check for differentiated tuple indices (e.g., functionCallReturnValue[2], [3]) which would NOT be a standard tuple
|
|
425
|
+
// We only check indices immediately after functionCallReturnValue, not nested indices like signature[2]
|
|
426
|
+
const tupleHasDifferentiatedIndices = schemaKeys.some((k) => {
|
|
427
|
+
// Look for .functionCallReturnValue[N] where N >= 2
|
|
428
|
+
const match = k.match(/\.functionCallReturnValue\[(\d+)\]/);
|
|
429
|
+
if (!match)
|
|
430
|
+
return false;
|
|
431
|
+
const idx = parseInt(match[1], 10);
|
|
432
|
+
return idx >= 2;
|
|
433
|
+
});
|
|
434
|
+
const isTupleReturningHook = hasGenericArrayInSchema && !tupleHasDifferentiatedIndices;
|
|
435
|
+
if (isTupleReturningHook) {
|
|
436
|
+
// Find all call patterns for this hook (e.g., useAtom(quoteFilterAtom), useAtom(supplierAtom))
|
|
437
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
438
|
+
.filter((k) => {
|
|
439
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
440
|
+
return regex.test(k);
|
|
441
|
+
})
|
|
442
|
+
.map((k) => {
|
|
443
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
444
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
445
|
+
});
|
|
446
|
+
let tupleReturnCode;
|
|
447
|
+
if (hookCallPatterns.length > 1) {
|
|
448
|
+
// Multiple patterns - generate conditional dispatch
|
|
449
|
+
const conditions = hookCallPatterns
|
|
450
|
+
.map(({ key, arg }) => `if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`)
|
|
451
|
+
.join('\n ');
|
|
452
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
453
|
+
tupleReturnCode = `(() => {
|
|
454
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
455
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
456
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
457
|
+
${conditions}
|
|
458
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
459
|
+
})()`;
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
// Single or no patterns - use dynamic dispatch
|
|
463
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
464
|
+
tupleReturnCode = `(() => {
|
|
465
|
+
// Dynamic dispatch for tuple-returning hook
|
|
466
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
467
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
468
|
+
const allData = scenarios().data() ?? {};
|
|
469
|
+
if (argLabel) {
|
|
470
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
471
|
+
if (allData[labelKey]) {
|
|
472
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
476
|
+
for (const key of keys) {
|
|
477
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
478
|
+
if (argStr.includes(keyArg)) {
|
|
479
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return [allData[keys[0] ?? '${fallbackKey}']?.[0] ?? [], () => {}];
|
|
483
|
+
})()`;
|
|
484
|
+
}
|
|
485
|
+
const safeFunctionName = options?.uniqueFunctionSuffix
|
|
486
|
+
? `${baseMockName}_${options.uniqueFunctionSuffix}`
|
|
487
|
+
: options?.keepOriginalFunctionName
|
|
488
|
+
? baseMockName
|
|
489
|
+
: mockNameIsCallSignature && derivedFunctionName
|
|
490
|
+
? derivedFunctionName
|
|
491
|
+
: baseMockName;
|
|
492
|
+
return `function ${safeFunctionName}(...args) {\n return ${tupleReturnCode};\n}`;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
368
495
|
const returnValueParts = {
|
|
369
496
|
name: dataStructureName,
|
|
370
497
|
isArray: isRootArray,
|
|
@@ -391,13 +518,13 @@ options) {
|
|
|
391
518
|
// For call signature format, use the original mockName as the data key
|
|
392
519
|
// e.g., scenarios().data()?.["useFetcher<User>()"]
|
|
393
520
|
// e.g., scenarios().data()?.["db.select(usersQuery)"]
|
|
394
|
-
return
|
|
521
|
+
return `?.${quotePropertyKey(dataKey)}`;
|
|
395
522
|
}
|
|
396
523
|
// Only use unquoted array access syntax for pure array indices like [0], [1]
|
|
397
524
|
if (name.match(/^\[\d+\]$/)) {
|
|
398
525
|
return `?.${name}`;
|
|
399
526
|
}
|
|
400
|
-
return
|
|
527
|
+
return `?.${quotePropertyKey(name)}`;
|
|
401
528
|
};
|
|
402
529
|
const constructDataPaths = () => {
|
|
403
530
|
// For structural elements, return modified base paths for children
|
|
@@ -445,7 +572,17 @@ options) {
|
|
|
445
572
|
};
|
|
446
573
|
const constructContent = (dataPaths) => {
|
|
447
574
|
const { name, args, nested, isArray, isGenericArray, returnsFunctionArgs, returnsFunctionArray, isAsyncFunction, hasNoReturnData, } = returnValue;
|
|
448
|
-
|
|
575
|
+
// When an array has differentiated indices ([0], [1], etc.), filter out any
|
|
576
|
+
// non-index items from nested. These non-index items come from generic [] paths
|
|
577
|
+
// like [].filter or [].sort, which describe element properties, not array elements.
|
|
578
|
+
// Including them would generate invalid syntax like "sort: ..." inside an array literal.
|
|
579
|
+
const hasDifferentiatedIndices = isArray &&
|
|
580
|
+
nested &&
|
|
581
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
582
|
+
const filteredNested = hasDifferentiatedIndices && nested
|
|
583
|
+
? nested.filter((n) => n.name.match(/^\[\d+\]$/))
|
|
584
|
+
: nested;
|
|
585
|
+
const nestedContent = (filteredNested ?? []).map((nestedItem) => {
|
|
449
586
|
const nestedContent = constructReturnValueString(nestedItem, dataPaths);
|
|
450
587
|
return nestedContent;
|
|
451
588
|
});
|
|
@@ -519,52 +656,110 @@ options) {
|
|
|
519
656
|
(!returnValue.isStructural || isStructuralArrayElementWithNested)) {
|
|
520
657
|
levelContentItems.push(...dataPaths.map((path) => `...${path}`));
|
|
521
658
|
}
|
|
522
|
-
|
|
659
|
+
// Filter out nested content that would be invalid as object properties
|
|
660
|
+
// (e.g., bare arrow functions like "() => {...}" without a property name)
|
|
661
|
+
// Only apply this filter when building object content, not array content.
|
|
662
|
+
// Bare arrow functions ARE valid as array elements (like [0] = {...}, [1] = () => {...})
|
|
663
|
+
// Check both isArray (item IS an array) and returnsFunctionArray (item returns an array)
|
|
664
|
+
const inArrayContext = isArray || returnsFunctionArray;
|
|
665
|
+
const validNestedContent = nestedContent.filter((content) => {
|
|
666
|
+
if (!content)
|
|
667
|
+
return false;
|
|
668
|
+
// Only filter bare arrow functions when NOT in array context
|
|
669
|
+
// In arrays, bare arrow functions are valid elements
|
|
670
|
+
if (!inArrayContext && content.match(/^\s*\([^)]*\)\s*=>/)) {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
return true;
|
|
674
|
+
});
|
|
675
|
+
levelContentItems.push(...validNestedContent);
|
|
523
676
|
let levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
524
677
|
if (returnsFunctionArgs) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
678
|
+
// When returnsFunctionArgs is empty [] OR has a single literal string argument,
|
|
679
|
+
// the function returns a callable function (e.g., getTranslate() returns t,
|
|
680
|
+
// where t('key') looks up translations)
|
|
681
|
+
// Generate a dispatch function that looks up keys based on the argument
|
|
682
|
+
//
|
|
683
|
+
// Detect translation-like pattern:
|
|
684
|
+
// - Data path ends with ["('some.literal')"] - a literal string key
|
|
685
|
+
// - This means the mock data has keys like "('common.surveys')": "Surveys"
|
|
686
|
+
// - Exclude ["()"] which is an empty function call (not a translation pattern)
|
|
687
|
+
const dataPath = dataPaths[0];
|
|
688
|
+
// Pattern matches ?.["('...')"] at end of path, but NOT ?.["()"] (empty args)
|
|
689
|
+
const literalKeyPattern = dataPath?.match(/\?\.\["\('.+'\)"\]$/);
|
|
690
|
+
if (!returnsFunctionArray &&
|
|
691
|
+
dataPaths.length === 1 &&
|
|
692
|
+
literalKeyPattern // Only dispatch when there's a literal key pattern
|
|
693
|
+
) {
|
|
694
|
+
// Function returns a function - generate dispatch function
|
|
695
|
+
// Strip the literal key from the path and use dynamic lookup
|
|
696
|
+
const dataPathBase = literalKeyPattern
|
|
697
|
+
? dataPath.replace(/\?\.\["\('.+'\)"\]$/, '')
|
|
698
|
+
: dataPath;
|
|
699
|
+
const funcContents = `return ${dataPathBase}?.[\`('\${arg1}')\`]`;
|
|
700
|
+
levelContents = `(arg1) => {\n${indent(funcContents)}\n}`;
|
|
701
|
+
if (!isArray) {
|
|
702
|
+
return levelContents;
|
|
544
703
|
}
|
|
545
704
|
}
|
|
546
705
|
else {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
706
|
+
const argsString = returnsFunctionArgs
|
|
707
|
+
.map((_, index) => `arg${index + 1}`)
|
|
708
|
+
.join(', ');
|
|
709
|
+
let funcContents = '';
|
|
710
|
+
if (returnsFunctionArray) {
|
|
711
|
+
if (hasNoReturnData) {
|
|
553
712
|
// Function has no return data (only signatures) - return empty array
|
|
554
713
|
funcContents = 'return []';
|
|
555
714
|
}
|
|
556
|
-
else {
|
|
557
|
-
//
|
|
715
|
+
else if (levelContents.length === 0 && dataPaths.length === 1) {
|
|
716
|
+
// When returning an array with no nested content, return the data path directly
|
|
717
|
+
// (the data path points to the array in scenario data)
|
|
558
718
|
funcContents = `return ${dataPaths[0]}`;
|
|
559
719
|
}
|
|
720
|
+
else if (levelContents.length === 0) {
|
|
721
|
+
funcContents = 'return []';
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
funcContents = `return [\n${indent(levelContents)}\n]`;
|
|
725
|
+
}
|
|
560
726
|
}
|
|
561
727
|
else {
|
|
562
|
-
|
|
728
|
+
// Check if function has no actual return data (only signatures)
|
|
729
|
+
const hasNestedItems = nested && nested.length > 0;
|
|
730
|
+
const hasActualNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
731
|
+
if (levelContentItems.length === 1 && dataPaths.length === 1) {
|
|
732
|
+
if (hasNoReturnData ||
|
|
733
|
+
(hasNestedItems && !hasActualNestedContent)) {
|
|
734
|
+
// Function has no return data (only signatures) - return empty array
|
|
735
|
+
funcContents = 'return []';
|
|
736
|
+
}
|
|
737
|
+
else {
|
|
738
|
+
// Has return data - return data path
|
|
739
|
+
funcContents = `return ${dataPaths[0]}`;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
funcContents = `return {\n${indent(levelContents)}\n}`;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
levelContents = `(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
747
|
+
if (!isArray) {
|
|
748
|
+
return levelContents;
|
|
563
749
|
}
|
|
564
750
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
751
|
+
// For generic arrays of functions WITH nested properties (e.g., functionCallReturnValue[] = "function"
|
|
752
|
+
// with nested .filter, .sort, etc.), the levelContents would be a bare arrow function "() => {...}"
|
|
753
|
+
// that wraps object content. Using this in a .map(({...})) creates invalid syntax like "({ () => {...} })".
|
|
754
|
+
// When isGenericArray is true AND there are nested properties, we're accessing data from the elements,
|
|
755
|
+
// not calling them - so skip the function wrapping.
|
|
756
|
+
// But if there are NO nested properties, keep the wrapper because callers may want to call the elements.
|
|
757
|
+
const hasNonStructuralNestedItems = nested &&
|
|
758
|
+
nested.length > 0 &&
|
|
759
|
+
nested.some((n) => !n.name.match(/^\[\d*\]$/));
|
|
760
|
+
if (isGenericArray && hasNonStructuralNestedItems) {
|
|
761
|
+
// Skip the arrow function wrapper - just use the nested content directly
|
|
762
|
+
levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
568
763
|
}
|
|
569
764
|
}
|
|
570
765
|
// Check if all nested items are array prototype methods
|
|
@@ -577,7 +772,102 @@ options) {
|
|
|
577
772
|
return ARRAY_PROTOTYPE_METHODS.has(methodName);
|
|
578
773
|
});
|
|
579
774
|
let returnValueContents = '';
|
|
580
|
-
if (
|
|
775
|
+
// Check if this is a known tuple-returning hook (useAtom, useState, etc.)
|
|
776
|
+
// These should return [value, setter] tuples, not arrays or data paths
|
|
777
|
+
// Check isGenericArray from current context OR from schema for root level calls
|
|
778
|
+
// (at root level, isGenericArray might not be set yet but the schema contains [] pattern)
|
|
779
|
+
const hasGenericArrayInSchema = root &&
|
|
780
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
781
|
+
Object.keys(relevantReturnValueSchema ?? {}).some((k) => k.includes('.functionCallReturnValue[]'));
|
|
782
|
+
// Check if there are array indices beyond what a standard 2-element tuple would have
|
|
783
|
+
// For tuple-returning hooks, [0] and [1] are expected (value and setter)
|
|
784
|
+
// Only consider it "differentiated" if there are indices >= 2 (e.g., [2], [3])
|
|
785
|
+
const tupleHasDifferentiatedIndices = nested?.some((n) => {
|
|
786
|
+
const indexMatch = n.name.match(/^\[(\d+)\]$/);
|
|
787
|
+
if (!indexMatch)
|
|
788
|
+
return false;
|
|
789
|
+
const index = parseInt(indexMatch[1], 10);
|
|
790
|
+
return index >= 2;
|
|
791
|
+
});
|
|
792
|
+
const isTupleReturningHook = TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
793
|
+
(isGenericArray || hasGenericArrayInSchema) &&
|
|
794
|
+
!tupleHasDifferentiatedIndices;
|
|
795
|
+
// Debug logging for tuple-returning hooks
|
|
796
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && root) {
|
|
797
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
798
|
+
const hasArrayPattern = schemaKeys.some((k) => k.includes('.functionCallReturnValue[]'));
|
|
799
|
+
console.log(`CodeYam: Tuple hook check for ${baseMockName} (root):`, `hasGenericArrayInSchema=${hasGenericArrayInSchema}`, `hasArrayPattern=${hasArrayPattern}`, `tupleHasDifferentiatedIndices=${tupleHasDifferentiatedIndices}`, `isTupleReturningHook=${isTupleReturningHook}`, `schemaKeysSample=${schemaKeys.slice(0, 5).join(', ')}`);
|
|
800
|
+
}
|
|
801
|
+
if (isTupleReturningHook) {
|
|
802
|
+
// Tuple-returning hooks should return [value, setter] tuple
|
|
803
|
+
// The value is the first element from scenarios data, setter is a no-op
|
|
804
|
+
// Default to [] when data is undefined to prevent errors like ".includes is not a function"
|
|
805
|
+
// Check if there are multiple call patterns for this hook in the schema
|
|
806
|
+
// (e.g., useAtom(quoteFilterAtom) and useAtom(supplierAtom))
|
|
807
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
808
|
+
.filter((k) => {
|
|
809
|
+
// Match patterns like "useAtom(someArg)" but not nested paths like "useAtom(x).foo"
|
|
810
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
811
|
+
return regex.test(k);
|
|
812
|
+
})
|
|
813
|
+
.map((k) => {
|
|
814
|
+
// Extract the argument from the key like "useAtom(quoteFilterAtom)" -> "quoteFilterAtom"
|
|
815
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
816
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
817
|
+
});
|
|
818
|
+
if (hookCallPatterns.length > 1) {
|
|
819
|
+
// Multiple patterns - generate conditional dispatch based on first argument
|
|
820
|
+
// For Jotai atoms, we use debugLabel; for others, we try to match the argument string
|
|
821
|
+
const conditions = hookCallPatterns
|
|
822
|
+
.map(({ key, arg }) => `if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`)
|
|
823
|
+
.join('\n ');
|
|
824
|
+
// Use the first pattern as fallback
|
|
825
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
826
|
+
returnValueContents = `(() => {
|
|
827
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
828
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
829
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
830
|
+
${conditions}
|
|
831
|
+
// Fallback to first pattern
|
|
832
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
833
|
+
})()`;
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
// Single pattern or no patterns - use dynamic dispatch to handle case where
|
|
837
|
+
// the mock is used with different atoms than what was captured in the schema.
|
|
838
|
+
// Use the first argument to construct the data key dynamically.
|
|
839
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
840
|
+
returnValueContents = `(() => {
|
|
841
|
+
// Dynamic dispatch for tuple-returning hook
|
|
842
|
+
// Try to construct key from argument's debugLabel (Jotai atoms) or toString
|
|
843
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
844
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
845
|
+
const allData = scenarios().data() ?? {};
|
|
846
|
+
|
|
847
|
+
// Try to find a matching key using debugLabel first
|
|
848
|
+
if (argLabel) {
|
|
849
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
850
|
+
if (allData[labelKey]) {
|
|
851
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// Try to find any matching key that contains part of the argument string
|
|
856
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
857
|
+
for (const key of keys) {
|
|
858
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
859
|
+
if (argStr.includes(keyArg)) {
|
|
860
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// Fallback to first matching key or default
|
|
865
|
+
const fallback = keys[0] ?? '${fallbackKey}';
|
|
866
|
+
return [allData[fallback]?.[0] ?? [], () => {}];
|
|
867
|
+
})()`;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
else if (!returnsFunctionArgs &&
|
|
581
871
|
nestedContent.length === 0 &&
|
|
582
872
|
dataPaths.length === 1) {
|
|
583
873
|
returnValueContents = dataPaths[0];
|
|
@@ -610,14 +900,354 @@ options) {
|
|
|
610
900
|
// Get the array base path (without the [0])
|
|
611
901
|
const arrayBasePath = dataPaths[0].replace(/\?\.\[0\]$/, '');
|
|
612
902
|
// Replace [0] references with [__idx__] in level contents
|
|
613
|
-
|
|
903
|
+
let mappedContents = levelContents.replace(/\?\.\[0\]/g, '?.[__idx__]');
|
|
614
904
|
// levelContents may already be wrapped in {...} from structural [0] element,
|
|
615
905
|
// so check if we need to add the wrapper or not
|
|
616
906
|
const needsWrapper = !mappedContents.trim().startsWith('{');
|
|
907
|
+
// Helper to check if a position is inside a string literal
|
|
908
|
+
// Returns the end position of the string if inside one, -1 otherwise
|
|
909
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
910
|
+
const skipStringLiteral = (content, pos) => {
|
|
911
|
+
const char = content[pos];
|
|
912
|
+
if (char !== '"' && char !== "'" && char !== '`')
|
|
913
|
+
return -1;
|
|
914
|
+
// Find the matching closing quote
|
|
915
|
+
let j = pos + 1;
|
|
916
|
+
while (j < content.length) {
|
|
917
|
+
if (content[j] === '\\') {
|
|
918
|
+
j += 2; // Skip escaped character
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
if (content[j] === char) {
|
|
922
|
+
return j + 1; // Return position after closing quote
|
|
923
|
+
}
|
|
924
|
+
j++;
|
|
925
|
+
}
|
|
926
|
+
return content.length; // Unclosed string, skip to end
|
|
927
|
+
};
|
|
928
|
+
// Filter out bare arrow functions which are invalid as object properties.
|
|
929
|
+
// Arrow functions can be multi-line, so we need to match the entire function body, not just the first line.
|
|
930
|
+
// Pattern: starts with "(args) =>", followed by either:
|
|
931
|
+
// - A single-line body: "() => expression"
|
|
932
|
+
// - A multi-line body: "() => { ... }" (with matching braces)
|
|
933
|
+
// IMPORTANT: Only filter BARE arrow functions (without property names).
|
|
934
|
+
// "() => {...}" is invalid, but "get: (arg1) => {...}" is valid.
|
|
935
|
+
// We use a function to properly handle nested braces.
|
|
936
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
937
|
+
const filterOutArrowFunctions = (content) => {
|
|
938
|
+
const result = [];
|
|
939
|
+
let i = 0;
|
|
940
|
+
while (i < content.length) {
|
|
941
|
+
// Skip over string literals entirely
|
|
942
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
943
|
+
if (stringEnd !== -1) {
|
|
944
|
+
result.push(content.slice(i, stringEnd));
|
|
945
|
+
i = stringEnd;
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
// Check if we're at the start of an arrow function (with optional leading whitespace)
|
|
949
|
+
const arrowMatch = content
|
|
950
|
+
.slice(i)
|
|
951
|
+
.match(/^(\s*)\([^)]*\)\s*=>\s*/);
|
|
952
|
+
if (arrowMatch) {
|
|
953
|
+
// Check if this is a bare arrow function or a named property with arrow function value
|
|
954
|
+
// Look back to see if there's a "key:" pattern before this position
|
|
955
|
+
const before = content.slice(0, i);
|
|
956
|
+
const beforeTrimmed = before.trim();
|
|
957
|
+
// Valid patterns where arrow function is NOT bare:
|
|
958
|
+
// 1. Property value: "key: (arg) => ..." - ends with ':'
|
|
959
|
+
// 2. Function argument: ".map((arg) => ..." - ends with '('
|
|
960
|
+
// 3. Method call: "?.map" followed directly by the arrow function
|
|
961
|
+
// In this case, the '(' is consumed by the arrow function regex match,
|
|
962
|
+
// so beforeTrimmed ends with the method name (e.g., 'map'), not '('.
|
|
963
|
+
// We detect this by checking if beforeTrimmed ends with an identifier
|
|
964
|
+
// that could be a method name (preceded by '.' or '?.').
|
|
965
|
+
// NOTE: We don't include ',' because "{ prop, () => {} }" is invalid
|
|
966
|
+
// (can't distinguish function argument from object property context)
|
|
967
|
+
const isPropertyValue = beforeTrimmed.endsWith(':');
|
|
968
|
+
const isFunctionArg = beforeTrimmed.endsWith('(');
|
|
969
|
+
// Check if before ends with a method call pattern like ".map" or "?.map"
|
|
970
|
+
// The '(' after the method name is consumed by the arrow function regex
|
|
971
|
+
const isMethodCallArg = /\??\.\w+$/.test(beforeTrimmed);
|
|
972
|
+
const hasPropertyName = isPropertyValue || isFunctionArg || isMethodCallArg;
|
|
973
|
+
if (!hasPropertyName) {
|
|
974
|
+
// This is a bare arrow function - filter it out
|
|
975
|
+
// Found arrow function start, need to find its end
|
|
976
|
+
const afterArrow = i + arrowMatch[0].length;
|
|
977
|
+
if (content[afterArrow] === '{') {
|
|
978
|
+
// Multi-line arrow function - find matching closing brace
|
|
979
|
+
// Must respect string literals when counting braces
|
|
980
|
+
let braceCount = 1;
|
|
981
|
+
let j = afterArrow + 1;
|
|
982
|
+
while (j < content.length && braceCount > 0) {
|
|
983
|
+
const strEnd = skipStringLiteral(content, j);
|
|
984
|
+
if (strEnd !== -1) {
|
|
985
|
+
j = strEnd;
|
|
986
|
+
continue;
|
|
987
|
+
}
|
|
988
|
+
if (content[j] === '{')
|
|
989
|
+
braceCount++;
|
|
990
|
+
if (content[j] === '}')
|
|
991
|
+
braceCount--;
|
|
992
|
+
j++;
|
|
993
|
+
}
|
|
994
|
+
// Skip past the arrow function
|
|
995
|
+
i = j;
|
|
996
|
+
// Only skip trailing comma, keep newlines
|
|
997
|
+
while (i < content.length && content[i] === ' ') {
|
|
998
|
+
i++;
|
|
999
|
+
}
|
|
1000
|
+
if (content[i] === ',') {
|
|
1001
|
+
i++; // Skip the comma after the arrow function
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
// Single expression arrow function - skip to next comma or newline
|
|
1006
|
+
let j = afterArrow;
|
|
1007
|
+
while (j < content.length &&
|
|
1008
|
+
content[j] !== ',' &&
|
|
1009
|
+
content[j] !== '\n') {
|
|
1010
|
+
j++;
|
|
1011
|
+
}
|
|
1012
|
+
i = j;
|
|
1013
|
+
if (content[i] === ',')
|
|
1014
|
+
i++; // Skip the comma
|
|
1015
|
+
}
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
// Not a bare arrow function, keep this character
|
|
1020
|
+
result.push(content[i]);
|
|
1021
|
+
i++;
|
|
1022
|
+
}
|
|
1023
|
+
return result.join('');
|
|
1024
|
+
};
|
|
1025
|
+
// Filter out bare object blocks (e.g., "{ ...spread, props }," without a property name)
|
|
1026
|
+
// These are invalid in object literal context - you need "key: { ... }" not just "{ ... }"
|
|
1027
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1028
|
+
// The skipFirstBrace parameter allows the else branch to preserve the outer object
|
|
1029
|
+
const filterOutBareObjects = (content, skipFirstBrace = false) => {
|
|
1030
|
+
const result = [];
|
|
1031
|
+
let i = 0;
|
|
1032
|
+
let firstBraceSkipped = false;
|
|
1033
|
+
while (i < content.length) {
|
|
1034
|
+
// Skip over string literals entirely - braces inside strings should not be processed
|
|
1035
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1036
|
+
if (stringEnd !== -1) {
|
|
1037
|
+
result.push(content.slice(i, stringEnd));
|
|
1038
|
+
i = stringEnd;
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
// Check if we're at a bare object start (newline/comma followed by { without : before it)
|
|
1042
|
+
// Look back to see if there's a colon (property assignment) before this brace
|
|
1043
|
+
const isStartOfLine = i === 0 ||
|
|
1044
|
+
content[i - 1] === '\n' ||
|
|
1045
|
+
content.slice(0, i).trim().endsWith(',');
|
|
1046
|
+
if (content[i] === '{' && isStartOfLine) {
|
|
1047
|
+
// Check if this is actually a bare object (not "key: {")
|
|
1048
|
+
const beforeTrimmed = content.slice(0, i).trim();
|
|
1049
|
+
const isBareObject = beforeTrimmed.endsWith(',') ||
|
|
1050
|
+
beforeTrimmed === '' ||
|
|
1051
|
+
beforeTrimmed.endsWith('(');
|
|
1052
|
+
if (isBareObject) {
|
|
1053
|
+
// If skipFirstBrace is true and this is the first bare brace at position 0,
|
|
1054
|
+
// don't filter it - it's the intentional outer object wrapper
|
|
1055
|
+
if (skipFirstBrace && !firstBraceSkipped && i === 0) {
|
|
1056
|
+
firstBraceSkipped = true;
|
|
1057
|
+
result.push(content[i]);
|
|
1058
|
+
i++;
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
// Find matching closing brace, respecting string literals
|
|
1062
|
+
let braceCount = 1;
|
|
1063
|
+
let j = i + 1;
|
|
1064
|
+
while (j < content.length && braceCount > 0) {
|
|
1065
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1066
|
+
if (strEnd !== -1) {
|
|
1067
|
+
j = strEnd;
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
if (content[j] === '{')
|
|
1071
|
+
braceCount++;
|
|
1072
|
+
if (content[j] === '}')
|
|
1073
|
+
braceCount--;
|
|
1074
|
+
j++;
|
|
1075
|
+
}
|
|
1076
|
+
// Skip past the object
|
|
1077
|
+
i = j;
|
|
1078
|
+
// Skip trailing comma
|
|
1079
|
+
while (i < content.length && content[i] === ' ') {
|
|
1080
|
+
i++;
|
|
1081
|
+
}
|
|
1082
|
+
if (content[i] === ',') {
|
|
1083
|
+
i++;
|
|
1084
|
+
}
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
result.push(content[i]);
|
|
1089
|
+
i++;
|
|
1090
|
+
}
|
|
1091
|
+
return result.join('');
|
|
1092
|
+
};
|
|
1093
|
+
// Helper to clean up formatting issues after filtering
|
|
1094
|
+
const cleanupContent = (content) => {
|
|
1095
|
+
return (content
|
|
1096
|
+
.replace(/,\s*,/g, ',') // Double commas
|
|
1097
|
+
.replace(/,(\s*\n\s*\})/g, '$1') // Trailing comma before closing brace
|
|
1098
|
+
.replace(/\{\s*\n\s*,/g, '{\n') // Leading comma after opening brace
|
|
1099
|
+
// Remove incomplete .map calls where callback was filtered out
|
|
1100
|
+
// Pattern: ".map" followed by newline/whitespace without "(" for args
|
|
1101
|
+
.replace(/\?\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1102
|
+
.replace(/\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1103
|
+
// Clean up orphan })) sequences (from nested filtered map callbacks)
|
|
1104
|
+
.replace(/\s*\}\)\)\s*\n\s*\}/g, '\n}')
|
|
1105
|
+
.replace(/^\s*\n/gm, '') // Empty lines
|
|
1106
|
+
.trim());
|
|
1107
|
+
};
|
|
617
1108
|
if (needsWrapper) {
|
|
618
|
-
|
|
1109
|
+
// Apply filters to remove invalid content
|
|
1110
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1111
|
+
mappedContents = filterOutBareObjects(mappedContents);
|
|
1112
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1113
|
+
// If mappedContents is empty after filtering, don't generate .map() at all
|
|
1114
|
+
// Just use the array path directly with spread or as-is
|
|
1115
|
+
// This prevents orphan )) from empty .map() callbacks
|
|
1116
|
+
const cleanedForEmptyCheck = mappedContents
|
|
1117
|
+
.replace(/\s+/g, '')
|
|
1118
|
+
.replace(/,+/g, '');
|
|
1119
|
+
if (cleanedForEmptyCheck.length === 0) {
|
|
1120
|
+
// Content is empty - just return the array directly
|
|
1121
|
+
returnValueContents = arrayBasePath;
|
|
1122
|
+
}
|
|
1123
|
+
else {
|
|
1124
|
+
// Check if mappedContents is just a bare expression (no property names)
|
|
1125
|
+
// A bare expression like "scenarios().data()?.["key"]?.[__idx__]," cannot be
|
|
1126
|
+
// wrapped in ({ }) because it's not a valid object property.
|
|
1127
|
+
// Pattern: content has no ":" that's not inside brackets/parens/strings
|
|
1128
|
+
const hasBareExpression = (() => {
|
|
1129
|
+
const trimmed = mappedContents.trim().replace(/,\s*$/, ''); // Remove trailing comma
|
|
1130
|
+
let depth = 0;
|
|
1131
|
+
let inString = false;
|
|
1132
|
+
let stringChar = '';
|
|
1133
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
1134
|
+
const char = trimmed[i];
|
|
1135
|
+
if (inString) {
|
|
1136
|
+
if (char === '\\') {
|
|
1137
|
+
i++; // Skip escaped char
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
if (char === stringChar) {
|
|
1141
|
+
inString = false;
|
|
1142
|
+
}
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
1146
|
+
inString = true;
|
|
1147
|
+
stringChar = char;
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
if (char === '(' || char === '[' || char === '{') {
|
|
1151
|
+
depth++;
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
if (char === ')' || char === ']' || char === '}') {
|
|
1155
|
+
depth--;
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
// Found a colon at depth 0 = has property name
|
|
1159
|
+
if (char === ':' && depth === 0) {
|
|
1160
|
+
return false;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
return true;
|
|
1164
|
+
})();
|
|
1165
|
+
if (hasBareExpression) {
|
|
1166
|
+
// Content is just an expression - return it directly without object wrapper
|
|
1167
|
+
const trimmedContent = mappedContents
|
|
1168
|
+
.trim()
|
|
1169
|
+
.replace(/,\s*$/, '');
|
|
1170
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(trimmedContent)}\n))`;
|
|
1171
|
+
}
|
|
1172
|
+
else {
|
|
1173
|
+
// When generating object-wrapped .map(), ensure original item data is preserved.
|
|
1174
|
+
// If no data spread was included (e.g., because this is a plain array property,
|
|
1175
|
+
// not a function return), add ...__item__ to spread the original item properties.
|
|
1176
|
+
// Without this, the .map() would create new objects with only nested function
|
|
1177
|
+
// properties, losing data like filePath, frontmatter, body, etc.
|
|
1178
|
+
const hasDataSpread = mappedContents.includes('...scenarios()') ||
|
|
1179
|
+
mappedContents.includes('...__item__');
|
|
1180
|
+
if (!hasDataSpread) {
|
|
1181
|
+
mappedContents = `...__item__,\n${mappedContents}`;
|
|
1182
|
+
}
|
|
1183
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => ({\n${indent(mappedContents)}\n}))`;
|
|
1184
|
+
}
|
|
1185
|
+
} // Close the empty content check else block
|
|
619
1186
|
}
|
|
620
1187
|
else {
|
|
1188
|
+
// Content already starts with '{'. Check if there are additional properties after the inner object.
|
|
1189
|
+
// If so, we need to merge them INTO the object, not leave them outside.
|
|
1190
|
+
// Pattern: "{ ...spread, props },\nfilter: ...,\nsort: ..."
|
|
1191
|
+
// Should become: "{ ...spread, props, filter: ..., sort: ... }"
|
|
1192
|
+
const trimmed = mappedContents.trim();
|
|
1193
|
+
// Find first }, at depth 0 that is NOT inside a string literal
|
|
1194
|
+
// This prevents splitting keys like ?.["useQuery({ id }, { enabled })"]
|
|
1195
|
+
// and also prevents finding }, inside nested arrow functions
|
|
1196
|
+
const findBraceCommaOutsideStrings = (content) => {
|
|
1197
|
+
let i = 0;
|
|
1198
|
+
let depth = 0; // Track brace depth to find the outer object's },
|
|
1199
|
+
while (i < content.length - 1) {
|
|
1200
|
+
// Skip over string literals
|
|
1201
|
+
const strEnd = skipStringLiteral(content, i);
|
|
1202
|
+
if (strEnd !== -1) {
|
|
1203
|
+
i = strEnd;
|
|
1204
|
+
continue;
|
|
1205
|
+
}
|
|
1206
|
+
// Track brace depth
|
|
1207
|
+
if (content[i] === '{') {
|
|
1208
|
+
depth++;
|
|
1209
|
+
i++;
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
// Check for }, pattern at depth 1 (the outer object level)
|
|
1213
|
+
// We're looking for the outer object's closing brace, which is at depth 1
|
|
1214
|
+
// (we started at depth 0, opened { at depth 0 -> 1)
|
|
1215
|
+
if (content[i] === '}') {
|
|
1216
|
+
depth--;
|
|
1217
|
+
if (depth === 0 &&
|
|
1218
|
+
i + 1 < content.length &&
|
|
1219
|
+
content[i + 1] === ',') {
|
|
1220
|
+
return i;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
i++;
|
|
1224
|
+
}
|
|
1225
|
+
return -1;
|
|
1226
|
+
};
|
|
1227
|
+
const firstBraceEnd = findBraceCommaOutsideStrings(trimmed);
|
|
1228
|
+
if (firstBraceEnd !== -1) {
|
|
1229
|
+
// Found pattern "{ ... }," followed by more content
|
|
1230
|
+
// Extract the inner object and the trailing properties
|
|
1231
|
+
const innerObject = trimmed.slice(0, firstBraceEnd);
|
|
1232
|
+
const trailingContent = trimmed.slice(firstBraceEnd + 2).trim();
|
|
1233
|
+
if (trailingContent) {
|
|
1234
|
+
// Merge trailing properties into the inner object
|
|
1235
|
+
mappedContents = `${innerObject},\n${trailingContent}\n}`;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
// Even when content starts with {, we need to filter out invalid properties inside
|
|
1239
|
+
// (arrow functions and bare objects that were generated from the schema)
|
|
1240
|
+
// Pass skipFirstBrace=true because the content's outer { is the intentional wrapper
|
|
1241
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1242
|
+
mappedContents = filterOutBareObjects(mappedContents, true);
|
|
1243
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1244
|
+
// Same as needsWrapper branch: ensure item data is preserved in .map()
|
|
1245
|
+
const hasDataSpreadInner = mappedContents.includes('...scenarios()') ||
|
|
1246
|
+
mappedContents.includes('...__item__');
|
|
1247
|
+
if (!hasDataSpreadInner && mappedContents.trim().length > 0) {
|
|
1248
|
+
// Insert ...__item__ after the opening brace
|
|
1249
|
+
mappedContents = mappedContents.replace(/^\s*\{/, '{\n...__item__,');
|
|
1250
|
+
}
|
|
621
1251
|
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(mappedContents)}\n))`;
|
|
622
1252
|
}
|
|
623
1253
|
}
|
|
@@ -626,7 +1256,36 @@ options) {
|
|
|
626
1256
|
}
|
|
627
1257
|
}
|
|
628
1258
|
else {
|
|
629
|
-
|
|
1259
|
+
// When we have a single data path and nested content that creates an object structure,
|
|
1260
|
+
// and we're NOT at the root level, we need to handle the case where the parent data
|
|
1261
|
+
// value is null or undefined. Without this check, `{ ...null, prop: null?.["prop"] }`
|
|
1262
|
+
// creates `{ prop: undefined }` instead of `null`, causing errors like
|
|
1263
|
+
// "Cannot read properties of undefined (reading 'some')" when code does
|
|
1264
|
+
// data?.prop.some(...) because data is an object with prop: undefined, not null.
|
|
1265
|
+
// We only apply this to non-root cases because root-level mocks are expected to exist.
|
|
1266
|
+
// We also skip structural elements (like [0] inside arrays) because the null check
|
|
1267
|
+
// syntax doesn't work inside .map() callbacks where structural elements are used.
|
|
1268
|
+
// We also skip array index elements ([0], [1], etc.) because they represent tuple/array
|
|
1269
|
+
// elements, not properties that could be null.
|
|
1270
|
+
// We also only apply this when we're inside a function return value context - i.e.,
|
|
1271
|
+
// when the data path contains a function call pattern like ?.["someFunction(...)"].
|
|
1272
|
+
// This prevents adding null checks to intermediate objects in chains like supabase.auth.
|
|
1273
|
+
const hasNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
1274
|
+
const isArrayIndexElement = name.match(/^\[\d*\]$/);
|
|
1275
|
+
// Check if data path contains a function call pattern, indicating we're inside a function return value
|
|
1276
|
+
const isInsideFunctionReturnValue = dataPaths.length === 1 &&
|
|
1277
|
+
dataPaths[0].match(/\?\.\["\w+\([^"]*\)"\]/);
|
|
1278
|
+
if (!root &&
|
|
1279
|
+
!returnValue.isStructural &&
|
|
1280
|
+
!isArrayIndexElement &&
|
|
1281
|
+
isInsideFunctionReturnValue &&
|
|
1282
|
+
hasNestedContent) {
|
|
1283
|
+
// Wrap with null check: if parent is null/undefined, return it directly; otherwise create object
|
|
1284
|
+
returnValueContents = `${dataPaths[0]} == null ? ${dataPaths[0]} : {\n${indent(levelContents)}\n}`;
|
|
1285
|
+
}
|
|
1286
|
+
else {
|
|
1287
|
+
returnValueContents = `{\n${indent(levelContents)}\n}`;
|
|
1288
|
+
}
|
|
630
1289
|
}
|
|
631
1290
|
}
|
|
632
1291
|
if (root) {
|
|
@@ -702,7 +1361,18 @@ options) {
|
|
|
702
1361
|
}
|
|
703
1362
|
else {
|
|
704
1363
|
// No argument variants - use existing behavior
|
|
705
|
-
|
|
1364
|
+
// But if there's nested content, we need to include it in the return object
|
|
1365
|
+
// (similar to how argument variant branches handle this at line 1070-1072)
|
|
1366
|
+
const hasNestedContent = validNestedContent.length > 0;
|
|
1367
|
+
let funcReturnContents;
|
|
1368
|
+
if (hasNestedContent && levelContentItems.length > 1) {
|
|
1369
|
+
// Include both spread and nested content in the return
|
|
1370
|
+
funcReturnContents = `{\n${indent(levelContents)}\n}`;
|
|
1371
|
+
}
|
|
1372
|
+
else {
|
|
1373
|
+
funcReturnContents = returnValueContents;
|
|
1374
|
+
}
|
|
1375
|
+
const funcContents = `return ${funcReturnContents}`;
|
|
706
1376
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
707
1377
|
}
|
|
708
1378
|
}
|
|
@@ -711,8 +1381,14 @@ options) {
|
|
|
711
1381
|
return;
|
|
712
1382
|
}
|
|
713
1383
|
else if (name.match(/\[\d*\]/)) {
|
|
1384
|
+
// Numeric array index like [0], [1] - can be used as computed property
|
|
714
1385
|
content = returnValueContents;
|
|
715
1386
|
}
|
|
1387
|
+
else if (name.match(/^\[[a-zA-Z_]\w*\]$/)) {
|
|
1388
|
+
// Variable-based index like [currentItemIndex] - must be quoted string key
|
|
1389
|
+
// Otherwise JavaScript would try to evaluate the variable name
|
|
1390
|
+
content = `"${safeString(name)}": ${returnValueContents}`;
|
|
1391
|
+
}
|
|
716
1392
|
else {
|
|
717
1393
|
content = `${safeString(name)}: ${returnValueContents}`;
|
|
718
1394
|
}
|
|
@@ -724,7 +1400,31 @@ options) {
|
|
|
724
1400
|
return content;
|
|
725
1401
|
};
|
|
726
1402
|
// Create the return value structure
|
|
727
|
-
|
|
1403
|
+
// OPTIMIZATION: Filter keys to only those starting with baseMockName before sorting.
|
|
1404
|
+
// This dramatically reduces processing time for large schemas (e.g., 9216 keys -> ~100 relevant keys).
|
|
1405
|
+
// Without this filter, the loop would call splitOutsideParenthesesAndArrays on every key
|
|
1406
|
+
// even though most are filtered out later by the baseMockName check.
|
|
1407
|
+
const allSchemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1408
|
+
const relevantKeys = allSchemaKeys.filter((key) => {
|
|
1409
|
+
// Fast prefix check - key must start with baseMockName followed by ( or < or .
|
|
1410
|
+
// This matches: "useAtom()", "useAtom<T>()", "useAtom.something", but not "useAtomValue()"
|
|
1411
|
+
if (key === baseMockName)
|
|
1412
|
+
return true;
|
|
1413
|
+
if (key.startsWith(baseMockName + '('))
|
|
1414
|
+
return true;
|
|
1415
|
+
if (key.startsWith(baseMockName + '<'))
|
|
1416
|
+
return true;
|
|
1417
|
+
if (key.startsWith(baseMockName + '.'))
|
|
1418
|
+
return true;
|
|
1419
|
+
// Also include 'returnValue' paths which are normalized later
|
|
1420
|
+
if (key === 'returnValue' ||
|
|
1421
|
+
key.startsWith('returnValue.') ||
|
|
1422
|
+
key.startsWith('returnValue['))
|
|
1423
|
+
return true;
|
|
1424
|
+
return false;
|
|
1425
|
+
});
|
|
1426
|
+
const schemaKeyCount = relevantKeys.length;
|
|
1427
|
+
const sortedKeys = relevantKeys.sort((a, b) => {
|
|
728
1428
|
const aParts = splitOutsideParenthesesAndArrays(a);
|
|
729
1429
|
const bParts = splitOutsideParenthesesAndArrays(b);
|
|
730
1430
|
const maxLength = Math.max(aParts.length, bParts.length);
|
|
@@ -748,6 +1448,36 @@ options) {
|
|
|
748
1448
|
}
|
|
749
1449
|
return 0;
|
|
750
1450
|
});
|
|
1451
|
+
// OPTIMIZATION: Pre-compute prefix indexes for O(1) lookups instead of O(n) scans.
|
|
1452
|
+
// This reduces complexity from O(n²) to O(n) for large schemas (9k+ keys).
|
|
1453
|
+
//
|
|
1454
|
+
// 1. extendedReturnValuePrefixes: Set of all path prefixes that have a .functionCallReturnValue extension
|
|
1455
|
+
// Used by hasExtendedFunctionCallReturnValue check at line ~1754
|
|
1456
|
+
// 2. functionCallsWithReturnValue: Set of function call paths where .functionCallReturnValue IMMEDIATELY follows
|
|
1457
|
+
// Used by hasProperFunctionCallPath check at line ~1787
|
|
1458
|
+
// IMPORTANT: Only includes paths where the function call is directly followed by .functionCallReturnValue
|
|
1459
|
+
// e.g., "a.b().functionCallReturnValue" -> adds "a.b()" but NOT "a" even if "a" ends with ")"
|
|
1460
|
+
const extendedReturnValuePrefixes = new Set();
|
|
1461
|
+
const functionCallsWithReturnValue = new Set();
|
|
1462
|
+
for (const k of relevantKeys) {
|
|
1463
|
+
const parts = splitOutsideParenthesesAndArrays(k);
|
|
1464
|
+
const returnValueIndex = parts.findIndex((part) => part.startsWith(RETURN_VALUE));
|
|
1465
|
+
if (returnValueIndex !== -1) {
|
|
1466
|
+
// Add all prefixes of k up to (but not including) functionCallReturnValue
|
|
1467
|
+
const prefix = joinParenthesesAndArrays(parts.slice(0, returnValueIndex));
|
|
1468
|
+
extendedReturnValuePrefixes.add(prefix);
|
|
1469
|
+
// ONLY add to functionCallsWithReturnValue if functionCallReturnValue IMMEDIATELY follows
|
|
1470
|
+
if (prefix.endsWith(')')) {
|
|
1471
|
+
functionCallsWithReturnValue.add(prefix);
|
|
1472
|
+
}
|
|
1473
|
+
// Also add intermediate prefixes for nested paths to extendedReturnValuePrefixes
|
|
1474
|
+
// This helps hasExtendedFunctionCallReturnValue which checks key + '.'
|
|
1475
|
+
for (let i = 1; i < returnValueIndex; i++) {
|
|
1476
|
+
const partialPrefix = joinParenthesesAndArrays(parts.slice(0, i));
|
|
1477
|
+
extendedReturnValuePrefixes.add(partialPrefix);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
751
1481
|
for (const key of sortedKeys) {
|
|
752
1482
|
const value = relevantReturnValueSchema[key];
|
|
753
1483
|
const parts = splitOutsideParenthesesAndArrays(key);
|
|
@@ -793,7 +1523,9 @@ options) {
|
|
|
793
1523
|
// nested inside (e.g., methods on array elements passed as arguments).
|
|
794
1524
|
if (hasSignaturePath)
|
|
795
1525
|
continue;
|
|
796
|
-
|
|
1526
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1527
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(key + '.') && k.includes('.functionCallReturnValue'))
|
|
1528
|
+
const hasExtendedFunctionCallReturnValue = extendedReturnValuePrefixes.has(key);
|
|
797
1529
|
// Skip JSX components - they look like function calls (e.g., Context.Provider())
|
|
798
1530
|
// but they're React components used in JSX, not functions that need mocking
|
|
799
1531
|
// Check both the value type and whether the functionCallReturnValue is jsx-component
|
|
@@ -818,7 +1550,9 @@ options) {
|
|
|
818
1550
|
// This part is a function call, and the next part is NOT .functionCallReturnValue
|
|
819
1551
|
// Check if there's any path with .functionCallReturnValue for this function call
|
|
820
1552
|
const functionCallPath = joinParenthesesAndArrays(parts.slice(0, i + 1));
|
|
821
|
-
|
|
1553
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1554
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(functionCallPath + '.functionCallReturnValue'))
|
|
1555
|
+
const hasProperFunctionCallPath = functionCallsWithReturnValue.has(functionCallPath);
|
|
822
1556
|
if (hasProperFunctionCallPath) {
|
|
823
1557
|
// Skip this path - the .functionCallReturnValue path will handle it correctly
|
|
824
1558
|
shouldSkipKey = true;
|
|
@@ -872,6 +1606,16 @@ options) {
|
|
|
872
1606
|
const nextIsArray = !!nextPart?.match(/^\[\d*\]/);
|
|
873
1607
|
const isDifferentiatedArray = !!part?.match(/^\[\d+\]/);
|
|
874
1608
|
const nextIsDifferentiatedArray = !!nextPart?.match(/^\[\d+\]/);
|
|
1609
|
+
// Variable index patterns like [currentItemIndex] or [targetIndex] indicate array access
|
|
1610
|
+
// but don't represent actual data structure - they're markers from variable-based index tracking.
|
|
1611
|
+
// Skip them AND all remaining parts to avoid creating spurious nested structure that breaks array iteration.
|
|
1612
|
+
// The remaining parts (e.g., .missing_attributes) describe properties of array elements, which are
|
|
1613
|
+
// already handled by the generic [] accessor path.
|
|
1614
|
+
const isVariableIndex = !!part?.match(/^\[[a-zA-Z_]\w*\]$/);
|
|
1615
|
+
if (isVariableIndex) {
|
|
1616
|
+
// Break out of the loop entirely - don't process any remaining parts
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
875
1619
|
// Find the correct value for the current part being processed
|
|
876
1620
|
let partValue = value; // default to the final value
|
|
877
1621
|
if (isFunctionCallReturnValue(part) && nextIsArray) {
|
|
@@ -963,7 +1707,35 @@ options) {
|
|
|
963
1707
|
}
|
|
964
1708
|
}
|
|
965
1709
|
else {
|
|
966
|
-
|
|
1710
|
+
// Before setting returnsFunctionArgs on the parent (for generic [] = function),
|
|
1711
|
+
// check if there are specific array indices (like [0], [1]) that are NOT functions.
|
|
1712
|
+
// If so, don't set returnsFunctionArgs because those specific indices take precedence.
|
|
1713
|
+
// This prevents adding ["()"] to paths like [0] when [0] is 'unknown' but [] is 'function'.
|
|
1714
|
+
//
|
|
1715
|
+
// Use parts.slice(0, i + 1) to get the current path INCLUDING functionCallReturnValue.
|
|
1716
|
+
// For example, if parts = ['useAtom()','functionCallReturnValue','[]']
|
|
1717
|
+
// and i = 1, we want to check 'useAtom().functionCallReturnValue[0]' etc.
|
|
1718
|
+
const arrayContainerPath = joinParenthesesAndArrays(parts.slice(0, i + 1));
|
|
1719
|
+
const hasNonFunctionSpecificIndices = Object.entries(relevantReturnValueSchema).some(([k, v]) => {
|
|
1720
|
+
// Look for paths like "arrayContainerPath[0]", "arrayContainerPath[1]" etc.
|
|
1721
|
+
const indexMatch = k.match(new RegExp(`^${arrayContainerPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\[(\\d+)\\]$`));
|
|
1722
|
+
// If found and it's NOT a function type, we have a conflict
|
|
1723
|
+
return (indexMatch &&
|
|
1724
|
+
!['function', 'async-function'].includes(v));
|
|
1725
|
+
});
|
|
1726
|
+
// Also check if [] has nested object properties (like [].filter, [].name)
|
|
1727
|
+
// If so, [] items are objects with properties, not pure functions to be called
|
|
1728
|
+
// This handles cases where the schema shows [].filter = object but doesn't
|
|
1729
|
+
// have explicit [0] entries
|
|
1730
|
+
const genericArrayPath = `${arrayContainerPath}[]`;
|
|
1731
|
+
const hasNestedProperties = Object.keys(relevantReturnValueSchema).some((k) => {
|
|
1732
|
+
// Check for paths like "arrayContainerPath[].propertyName" (not [].())
|
|
1733
|
+
return (k.startsWith(genericArrayPath + '.') &&
|
|
1734
|
+
!k.startsWith(genericArrayPath + '.('));
|
|
1735
|
+
});
|
|
1736
|
+
if (!hasNonFunctionSpecificIndices && !hasNestedProperties) {
|
|
1737
|
+
returnValueSection.returnsFunctionArgs = [];
|
|
1738
|
+
}
|
|
967
1739
|
}
|
|
968
1740
|
}
|
|
969
1741
|
}
|
|
@@ -984,7 +1756,8 @@ options) {
|
|
|
984
1756
|
}
|
|
985
1757
|
// If the next part is an object with nested content, continue processing
|
|
986
1758
|
// This handles paths like functionCallReturnValue.selectedOptions.elementOptions[]
|
|
987
|
-
|
|
1759
|
+
// Also handles union types like 'array | undefined' or 'object | undefined'
|
|
1760
|
+
if (nextValue?.includes('object') || nextValue?.includes('array')) {
|
|
988
1761
|
continue;
|
|
989
1762
|
}
|
|
990
1763
|
}
|
|
@@ -1114,7 +1887,12 @@ options) {
|
|
|
1114
1887
|
relevantPart.isArray = true;
|
|
1115
1888
|
relevantPart.isGenericArray = true;
|
|
1116
1889
|
}
|
|
1117
|
-
if
|
|
1890
|
+
// Check if there are remaining parts after functionCallReturnValue that need processing
|
|
1891
|
+
// (e.g., data properties like useQuery().functionCallReturnValue.data)
|
|
1892
|
+
const hasRemainingPartsAfterReturnValue = nextPart &&
|
|
1893
|
+
(isFunctionCallReturnValue(nextPart) ||
|
|
1894
|
+
(isFunctionCallReturnValue(parts[i]) && i < parts.length - 1));
|
|
1895
|
+
if (!hasNestedFunction && !hasRemainingPartsAfterReturnValue) {
|
|
1118
1896
|
// Before breaking, check if this function returns an array
|
|
1119
1897
|
// by looking for a functionCallReturnValue: 'array' entry in the schema
|
|
1120
1898
|
if (relevantPart && part.endsWith(')')) {
|
|
@@ -1142,6 +1920,7 @@ options) {
|
|
|
1142
1920
|
const contents = constructReturnValueString(returnValueParts);
|
|
1143
1921
|
if (mockNameParts.length > 1) {
|
|
1144
1922
|
const originalLib = `${mockNameParts[0]}__cyOriginal`;
|
|
1923
|
+
const skipOriginalSpread = options?.skipOriginalSpread;
|
|
1145
1924
|
const subPart = (parts, originalLib) => {
|
|
1146
1925
|
const part = parts.shift();
|
|
1147
1926
|
if (!isValidKey(part))
|
|
@@ -1149,7 +1928,9 @@ options) {
|
|
|
1149
1928
|
const isLast = parts.length === 0;
|
|
1150
1929
|
const partContents = isLast
|
|
1151
1930
|
? contents
|
|
1152
|
-
:
|
|
1931
|
+
: skipOriginalSpread
|
|
1932
|
+
? subPart(parts, originalLib)
|
|
1933
|
+
: `...${originalLib}.${part},\n${subPart(parts, originalLib)}`;
|
|
1153
1934
|
let code = `${part}: {\n${indent(partContents)}\n}`;
|
|
1154
1935
|
if (part.includes('(') || (isFunction && isLast)) {
|
|
1155
1936
|
const args = funcArgs(part)
|
|
@@ -1159,11 +1940,13 @@ options) {
|
|
|
1159
1940
|
}
|
|
1160
1941
|
return code;
|
|
1161
1942
|
};
|
|
1162
|
-
const returnParts =
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1943
|
+
const returnParts = skipOriginalSpread
|
|
1944
|
+
? [subPart(mockNameParts.slice(1), originalLib)]
|
|
1945
|
+
: [
|
|
1946
|
+
`...${mockNameParts[0]}__cyOriginal`,
|
|
1947
|
+
subPart(mockNameParts.slice(1), originalLib),
|
|
1948
|
+
];
|
|
1949
|
+
return `const ${mockNameParts[0]} = {\n${indent(returnParts.filter(Boolean).join(',\n'))}\n};`;
|
|
1167
1950
|
}
|
|
1168
1951
|
else if (isFunction) {
|
|
1169
1952
|
// For headers() and cookies() from next/headers, add common iterator methods
|
|
@@ -1174,12 +1957,13 @@ options) {
|
|
|
1174
1957
|
if (needsIteratorMethods && contents.trim().startsWith('{')) {
|
|
1175
1958
|
// Add iterator methods that operate on the scenario data
|
|
1176
1959
|
// Use the dataKey (original call signature or canonical key)
|
|
1960
|
+
const quotedDataKey = quotePropertyKey(dataKey);
|
|
1177
1961
|
const iteratorMethods = `,
|
|
1178
|
-
entries: () => Object.entries(scenarios().data()
|
|
1179
|
-
keys: () => Object.keys(scenarios().data()
|
|
1180
|
-
values: () => Object.values(scenarios().data()
|
|
1181
|
-
forEach: (fn) => Object.entries(scenarios().data()
|
|
1182
|
-
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()
|
|
1962
|
+
entries: () => Object.entries(scenarios().data()?.${quotedDataKey} || {}),
|
|
1963
|
+
keys: () => Object.keys(scenarios().data()?.${quotedDataKey} || {}),
|
|
1964
|
+
values: () => Object.values(scenarios().data()?.${quotedDataKey} || {}),
|
|
1965
|
+
forEach: (fn) => Object.entries(scenarios().data()?.${quotedDataKey} || {}).forEach(([k, v]) => fn(v, k)),
|
|
1966
|
+
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()?.${quotedDataKey} || {}, key)`;
|
|
1183
1967
|
// Insert before the closing brace (handle trailing whitespace)
|
|
1184
1968
|
enhancedContents = contents.replace(/\}\s*$/, iteratorMethods + '\n}');
|
|
1185
1969
|
}
|
|
@@ -1202,7 +1986,7 @@ options) {
|
|
|
1202
1986
|
constructor(message) {
|
|
1203
1987
|
${superCall}
|
|
1204
1988
|
${nameAssignment}
|
|
1205
|
-
Object.assign(this, scenarios().data()
|
|
1989
|
+
Object.assign(this, scenarios().data()?.${quotePropertyKey(dataKey)} || {});
|
|
1206
1990
|
}
|
|
1207
1991
|
}`;
|
|
1208
1992
|
}
|
|
@@ -1261,12 +2045,38 @@ options) {
|
|
|
1261
2045
|
return true;
|
|
1262
2046
|
return false;
|
|
1263
2047
|
});
|
|
2048
|
+
// Use ...args to accept any number of arguments - prevents TypeScript errors
|
|
2049
|
+
// like "Expected 0 arguments, but got X" when caller passes arguments
|
|
1264
2050
|
// For higher-order functions, wrap the return in an arrow function
|
|
1265
2051
|
// so that mockFunc(arg)() works correctly (outer call returns a function, inner call gets the data)
|
|
1266
2052
|
const returnValue = isHigherOrderFunction
|
|
1267
|
-
? `() => ${
|
|
1268
|
-
:
|
|
1269
|
-
|
|
2053
|
+
? `() => (${enhancedContents})`
|
|
2054
|
+
: enhancedContents;
|
|
2055
|
+
// Inline the return value directly in the function to avoid module-level const
|
|
2056
|
+
// that would be evaluated before scenario context is ready
|
|
2057
|
+
// Add fallback for simple data path returns to prevent undefined errors (e.g., createTheme)
|
|
2058
|
+
// Only add fallback if returnValue is a simple data accessor (starts with scenarios().data())
|
|
2059
|
+
// and doesn't already have nested structure (object literal, array, or method chains like .map())
|
|
2060
|
+
const isSimpleDataPath = returnValue.startsWith('scenarios().data()') &&
|
|
2061
|
+
!returnValue.trim().startsWith('{') &&
|
|
2062
|
+
!returnValue.trim().startsWith('[') &&
|
|
2063
|
+
!returnValue.includes('.map('); // Exclude method chains
|
|
2064
|
+
const safeReturnValue = isSimpleDataPath
|
|
2065
|
+
? `${returnValue} ?? {}`
|
|
2066
|
+
: returnValue;
|
|
2067
|
+
const refName = `_${safeFunctionName}Ref`;
|
|
2068
|
+
const assignment = `${refName}.current = ${safeReturnValue};`;
|
|
2069
|
+
const ifBlock = `if (!${refName}.current) {\n${indent(assignment)}\n}`;
|
|
2070
|
+
const body = `${ifBlock}\nreturn ${refName}.current;`;
|
|
2071
|
+
return [
|
|
2072
|
+
`// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)`,
|
|
2073
|
+
`const ${refName} = {`,
|
|
2074
|
+
` current: null,`,
|
|
2075
|
+
`};`,
|
|
2076
|
+
`${isRootAsyncFunction ? 'async ' : ''}function ${safeFunctionName}(...args) {`,
|
|
2077
|
+
indent(body),
|
|
2078
|
+
`}`,
|
|
2079
|
+
].join('\n');
|
|
1270
2080
|
}
|
|
1271
2081
|
else {
|
|
1272
2082
|
// Generate safe const name:
|