@codeyam/codeyam-cli 0.1.0-staging.2a88920 → 0.1.0-staging.4813bf3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +7 -7
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +3 -3
- package/analyzer-template/packages/ai/index.ts +1 -0
- package/analyzer-template/packages/ai/package.json +2 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +23 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +101 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +6 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +330 -9
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +11 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +2 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +126 -11
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +20 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +84 -19
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +33 -15
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +299 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +38 -2
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +359 -142
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +24 -4
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +69 -3
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +5 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +4 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +9 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +194 -15
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +260 -22
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/project/constructMockCode.ts +36 -1
- package/analyzer-template/project/writeMockDataTsx.ts +174 -12
- package/analyzer-template/project/writeScenarioComponents.ts +60 -12
- package/analyzer-template/project/writeSimpleRoot.ts +21 -11
- package/background/src/lib/local/createLocalAnalyzer.js +1 -1
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +30 -1
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +156 -8
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +60 -15
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +2 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +4 -2
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +2 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -1
- package/codeyam-cli/src/commands/debug.js +2 -0
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +31 -20
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +49 -257
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +17 -26
- package/codeyam-cli/src/commands/memory.js.map +1 -1
- package/codeyam-cli/src/commands/recapture.js +2 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- package/codeyam-cli/src/commands/test-startup.js +2 -0
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +14 -2
- package/codeyam-cli/src/commands/verify.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -86
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +5 -0
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +2 -2
- package/codeyam-cli/src/utils/install-skills.js +57 -54
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +4 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +378 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +115 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +1 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -1
- package/codeyam-cli/src/utils/rules/parser.js +2 -25
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -1
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +16 -11
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -1
- package/codeyam-cli/src/utils/serverState.js +37 -10
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -44
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +15 -3
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +24 -0
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-DsN1wKrm.js → EntityItem-B86KKU7e.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DLqD3qNt.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-Ba2JVPzP.js → EntityTypeIcon-BqY8gDAW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-C8lyxW9k.js → InlineSpinner-ClaLpuOo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-aht4aafF.js → InteractivePreview-BDhPilK7.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CVtiBnY5.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-B0GLXMsr.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-xgeCVgSM.js → LogViewer-Bm3PmcCz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-OApQuNyq.js → ReportIssueModal-CgMEzchJ.js} +3 -8
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DuDvi0jm.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DzccYyI8.js → ScenarioViewer-CBui0id_.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-DyFZkK0l.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{_index-BwqWJOgH.js → _index-B3TDXxnk.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BwavGCpm.js → activity.(_tab)-BtBFH820.js} +6 -11
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-CN61MOMa.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-PttOB2SF.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-Cx24_aWc.js → chevron-down-TJp6ofnp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-CXRTFQ3F.js → chunk-JZWAC4HX-JE9ZIoBl.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BOARzkeR.js → circle-check-CXhHQYrI.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-BdhJEx6B.js → createLucideIcon-Ca9fAY46.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BBnGWYga.js → dev.empty-C0epRiVn.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BJUiQqZF.js → entity._sha._-BVnB8a9L.js} +10 -10
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js → entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D1T4TGjf.js → entity._sha_.create-scenario-DGgZjdFg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CTBG2mmz.js → entity._sha_.edit._scenarioId-38yPijoD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CS2cb_eZ.js → entry.client-BSHEfydn.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DMJ7zii9.js → fileTableUtils-DCPhhSMo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{files-CJ6lTdTA.js → files-0N0YJQv7.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{git-CPTZZ-JZ.js → git-DXnyr8uP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-CKT08Djd.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-lzqtyFU8.js → index-CcsFv748.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-B1h680n5.js → index-ChN9-fAY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-BLJ7HxOC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-B7B9V-bu.js → loader-circle-CTqLEAGU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-b171b9d3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CCQd4aZA.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-CHhiHoo_.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-CxXUmBSd.js → search-B8VUL8nl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BejnUJ6R.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-DwFIBT09.js → simulations-CPoAg7Zo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-B6LgvRJg.js → triangle-alert-BZz2NjYa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-C1v1PQzo.js → useCustomSizes-DNwUduNu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-aSv48UbS.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DYxHZQuP.js → useReportContext-CpZgwliL.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-mBRpZPiu.js → useToast-Bv9JFvUO.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-BM6TDT1Y.js → index-8Fv-lH1-.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Akn3iYFP.js +257 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/{codeyam:debug.md → codeyam-debug.md} +1 -1
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +19 -20
- package/codeyam-cli/templates/codeyam-memory.md +392 -0
- package/codeyam-cli/templates/{codeyam:new-rule.md → codeyam-new-rule.md} +2 -2
- package/codeyam-cli/templates/{codeyam:setup.md → codeyam-setup.md} +13 -1
- package/codeyam-cli/templates/{codeyam:sim.md → codeyam-sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam:test.md → codeyam-test.md} +1 -1
- package/codeyam-cli/templates/{codeyam:verify.md → codeyam-verify.md} +1 -1
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +554 -87
- package/codeyam-cli/templates/rules-instructions.md +63 -24
- package/package.json +2 -2
- package/packages/ai/index.js +1 -1
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +21 -1
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +78 -1
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +262 -8
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +11 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +2 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +113 -11
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +15 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +78 -17
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructureChunking.js +26 -11
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +46 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +212 -3
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +16 -2
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +242 -81
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +39 -3
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +17 -2
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +52 -2
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +3 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.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 +5 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +9 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +116 -13
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +231 -22
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.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/database/src/lib/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +3 -0
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/packages/database/src/lib/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -76
- package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-a78b90a2.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory--GCbFsBE.js +0 -92
- package/codeyam-cli/src/webserver/build/client/assets/root-eVAaavTS.js +0 -62
- package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-dYC34MHw.js +0 -257
- package/codeyam-cli/templates/codeyam:diagnose.md +0 -803
- package/codeyam-cli/templates/codeyam:memory.md +0 -341
|
@@ -397,6 +397,7 @@ const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
|
397
397
|
'transformed non-object function equivalency - implicit parent equivalency - rerouted via useCallback',
|
|
398
398
|
'transformed non-object function equivalency - Array.from() equivalency',
|
|
399
399
|
'Spread operator equivalency key update: Explicit array deconstruction equivalency value',
|
|
400
|
+
// 'transformed non-object function equivalency - Explicit array deconstruction equivalency value',
|
|
400
401
|
]);
|
|
401
402
|
|
|
402
403
|
export class ScopeDataStructure {
|
|
@@ -799,6 +800,11 @@ export class ScopeDataStructure {
|
|
|
799
800
|
return;
|
|
800
801
|
}
|
|
801
802
|
|
|
803
|
+
// PERF: Early exit for paths with repeated function-call signature patterns
|
|
804
|
+
if (this.hasExcessivePatternRepetition(path)) {
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
|
|
802
808
|
// Update chain metadata for database tracking
|
|
803
809
|
if (equivalencyValueChain.length > 0) {
|
|
804
810
|
equivalencyValueChain[equivalencyValueChain.length - 1].addToSchemaId =
|
|
@@ -1486,6 +1492,15 @@ export class ScopeDataStructure {
|
|
|
1486
1492
|
|
|
1487
1493
|
const bestValue = selectBestValue(value1, value2);
|
|
1488
1494
|
|
|
1495
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
1496
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
1497
|
+
if (
|
|
1498
|
+
this.hasExcessivePatternRepetition(schemaPath) ||
|
|
1499
|
+
this.hasExcessivePatternRepetition(equivalentSchemaPath)
|
|
1500
|
+
) {
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1489
1504
|
scopeNode.schema[schemaPath] = bestValue;
|
|
1490
1505
|
equivalentScopeNode.schema[equivalentSchemaPath] = bestValue;
|
|
1491
1506
|
} else if (
|
|
@@ -1499,6 +1514,11 @@ export class ScopeDataStructure {
|
|
|
1499
1514
|
...remainingSchemaPathParts,
|
|
1500
1515
|
]);
|
|
1501
1516
|
|
|
1517
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
1518
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
1519
|
+
continue;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1502
1522
|
equivalentScopeNode.schema[newEquivalentPath] =
|
|
1503
1523
|
scopeNode.schema[schemaPath];
|
|
1504
1524
|
}
|
|
@@ -1618,6 +1638,23 @@ export class ScopeDataStructure {
|
|
|
1618
1638
|
}
|
|
1619
1639
|
}
|
|
1620
1640
|
|
|
1641
|
+
// Check for repeated function calls that indicate recursive type expansion.
|
|
1642
|
+
// E.g., localeCompare(b[])...localeCompare(b[]) means string.localeCompare
|
|
1643
|
+
// returns a type that again has localeCompare, causing infinite expansion.
|
|
1644
|
+
// We extract all function call patterns like "funcName(args)" and check if
|
|
1645
|
+
// the same normalized call appears more than once.
|
|
1646
|
+
const funcCallPattern = /(?:^|\.)[^.([]+\([^)]*\)/g;
|
|
1647
|
+
const funcCallMatches = path.match(funcCallPattern);
|
|
1648
|
+
if (funcCallMatches && funcCallMatches.length > 1) {
|
|
1649
|
+
const seen = new Set<string>();
|
|
1650
|
+
for (const match of funcCallMatches) {
|
|
1651
|
+
// Strip leading dot and normalize array indices
|
|
1652
|
+
const normalized = match.replace(/^\./, '').replace(/\[\d+\]/g, '[]');
|
|
1653
|
+
if (seen.has(normalized)) return true;
|
|
1654
|
+
seen.add(normalized);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1621
1658
|
// For longer paths, detect any repeated multi-part segments we haven't explicitly listed
|
|
1622
1659
|
const pathParts = this.splitPath(path);
|
|
1623
1660
|
if (pathParts.length <= 6) {
|
|
@@ -2574,6 +2611,7 @@ export class ScopeDataStructure {
|
|
|
2574
2611
|
relevantSubPathParts.every((part, i) => part === schemaPathParts[i]) &&
|
|
2575
2612
|
equivalentValue.scopeNodeName === scopeNode.name
|
|
2576
2613
|
) {
|
|
2614
|
+
// DEBUG
|
|
2577
2615
|
continue;
|
|
2578
2616
|
}
|
|
2579
2617
|
|
|
@@ -2760,6 +2798,8 @@ export class ScopeDataStructure {
|
|
|
2760
2798
|
usageEquivalency.scopeNodeName,
|
|
2761
2799
|
) as ScopeNode;
|
|
2762
2800
|
|
|
2801
|
+
if (!usageScopeNode) continue;
|
|
2802
|
+
|
|
2763
2803
|
// Guard against infinite recursion by tracking which paths we've already
|
|
2764
2804
|
// added from addComplexSourcePathVariables
|
|
2765
2805
|
if (
|
|
@@ -2839,6 +2879,8 @@ export class ScopeDataStructure {
|
|
|
2839
2879
|
usageEquivalency.scopeNodeName,
|
|
2840
2880
|
) as ScopeNode;
|
|
2841
2881
|
|
|
2882
|
+
if (!usageScopeNode) continue;
|
|
2883
|
+
|
|
2842
2884
|
// This is put in place to avoid propagating array functions like 'filter' through complex equivalencies
|
|
2843
2885
|
// but may cause problems if the funtion call is not on a known object (e.g. string or array)
|
|
2844
2886
|
if (
|
|
@@ -3291,6 +3333,14 @@ export class ScopeDataStructure {
|
|
|
3291
3333
|
}
|
|
3292
3334
|
}
|
|
3293
3335
|
|
|
3336
|
+
// Ensure parameter-to-signature equivalencies are fully propagated.
|
|
3337
|
+
// When a parameter variable (e.g., `node`) is equivalenced to `signature[N]`,
|
|
3338
|
+
// all sub-paths of that variable should also appear under `signature[N]`.
|
|
3339
|
+
// This handles cases where the sub-path was added to the schema via a propagation
|
|
3340
|
+
// chain that already included the variable↔signature equivalency, causing the
|
|
3341
|
+
// cycle detection to prevent the reverse mapping.
|
|
3342
|
+
this.propagateParameterToSignaturePaths(scopeNode);
|
|
3343
|
+
|
|
3294
3344
|
fillInSchemaGapsAndUnknowns(scopeNode, fillInUnknowns);
|
|
3295
3345
|
|
|
3296
3346
|
if (final) {
|
|
@@ -3305,6 +3355,50 @@ export class ScopeDataStructure {
|
|
|
3305
3355
|
}
|
|
3306
3356
|
}
|
|
3307
3357
|
|
|
3358
|
+
/**
|
|
3359
|
+
* For each equivalency where a simple variable maps to signature[N],
|
|
3360
|
+
* ensure all sub-paths of that variable are reflected under signature[N].
|
|
3361
|
+
*/
|
|
3362
|
+
private propagateParameterToSignaturePaths(scopeNode: ScopeNode) {
|
|
3363
|
+
// Find variable → signature[N] equivalencies
|
|
3364
|
+
for (const [varName, equivalencies] of Object.entries(
|
|
3365
|
+
scopeNode.equivalencies,
|
|
3366
|
+
)) {
|
|
3367
|
+
// Only process simple variable names (no dots, brackets, or parens)
|
|
3368
|
+
if (
|
|
3369
|
+
varName.includes('.') ||
|
|
3370
|
+
varName.includes('[') ||
|
|
3371
|
+
varName.includes('(')
|
|
3372
|
+
) {
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
for (const equiv of equivalencies) {
|
|
3377
|
+
if (
|
|
3378
|
+
equiv.scopeNodeName === scopeNode.name &&
|
|
3379
|
+
equiv.schemaPath.startsWith('signature[')
|
|
3380
|
+
) {
|
|
3381
|
+
const signaturePath = equiv.schemaPath;
|
|
3382
|
+
const varPrefix = varName + '.';
|
|
3383
|
+
const varBracketPrefix = varName + '[';
|
|
3384
|
+
|
|
3385
|
+
// Find all schema keys starting with the variable
|
|
3386
|
+
for (const key in scopeNode.schema) {
|
|
3387
|
+
if (key.startsWith(varPrefix) || key.startsWith(varBracketPrefix)) {
|
|
3388
|
+
const suffix = key.slice(varName.length);
|
|
3389
|
+
const sigKey = signaturePath + suffix;
|
|
3390
|
+
|
|
3391
|
+
// Only add if the signature path doesn't already exist
|
|
3392
|
+
if (!scopeNode.schema[sigKey]) {
|
|
3393
|
+
scopeNode.schema[sigKey] = scopeNode.schema[key];
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3308
3402
|
private filterAndConvertSchema({
|
|
3309
3403
|
filterPath,
|
|
3310
3404
|
newPath,
|
|
@@ -3391,6 +3485,9 @@ export class ScopeDataStructure {
|
|
|
3391
3485
|
equivalentValueSchemaPathParts.length,
|
|
3392
3486
|
),
|
|
3393
3487
|
]);
|
|
3488
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
3489
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
3490
|
+
if (this.hasExcessivePatternRepetition(newKey)) continue;
|
|
3394
3491
|
resolvedSchema[newKey] = value;
|
|
3395
3492
|
}
|
|
3396
3493
|
}
|
|
@@ -3413,6 +3510,8 @@ export class ScopeDataStructure {
|
|
|
3413
3510
|
if (!subSchema) continue;
|
|
3414
3511
|
|
|
3415
3512
|
for (const resolvedKey in subSchema) {
|
|
3513
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
3514
|
+
if (this.hasExcessivePatternRepetition(resolvedKey)) continue;
|
|
3416
3515
|
if (
|
|
3417
3516
|
!resolvedSchema[resolvedKey] ||
|
|
3418
3517
|
subSchema[resolvedKey] === 'unknown'
|
|
@@ -3804,25 +3903,116 @@ export class ScopeDataStructure {
|
|
|
3804
3903
|
return [source];
|
|
3805
3904
|
};
|
|
3806
3905
|
|
|
3807
|
-
|
|
3808
|
-
(
|
|
3809
|
-
if (entry.sourceCandidates.length === 0) return
|
|
3906
|
+
const acc = entries.reduce(
|
|
3907
|
+
(result, entry) => {
|
|
3908
|
+
if (entry.sourceCandidates.length === 0) return result;
|
|
3810
3909
|
const usages = entry.usages.filter(usageMatchesScope);
|
|
3811
3910
|
for (const usage of usages) {
|
|
3812
|
-
|
|
3911
|
+
result[usage.schemaPath] ||= [];
|
|
3813
3912
|
// Resolve each source candidate through the equivalency chain
|
|
3814
3913
|
for (const source of entry.sourceCandidates) {
|
|
3815
3914
|
const resolvedSources = resolveToSignature(source, new Set());
|
|
3816
|
-
|
|
3915
|
+
result[usage.schemaPath].push(...resolvedSources);
|
|
3817
3916
|
}
|
|
3818
3917
|
}
|
|
3819
|
-
return
|
|
3918
|
+
return result;
|
|
3820
3919
|
},
|
|
3821
3920
|
{} as Record<
|
|
3822
3921
|
string,
|
|
3823
3922
|
Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[]
|
|
3824
3923
|
>,
|
|
3825
3924
|
);
|
|
3925
|
+
|
|
3926
|
+
// Post-processing: enrich useState-backed sources with co-located external
|
|
3927
|
+
// function calls. When a useState value resolves to a setter variable that
|
|
3928
|
+
// lives in the same scope as a fetch/API call, that fetch is a data source.
|
|
3929
|
+
this.enrichUseStateSourcesWithCoLocatedCalls(acc);
|
|
3930
|
+
|
|
3931
|
+
return acc;
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
/**
|
|
3935
|
+
* For each source that ends at a useState path, check if the setter was called
|
|
3936
|
+
* from a scope that also contains external function calls (like fetch).
|
|
3937
|
+
* If so, add those external calls as additional source candidates.
|
|
3938
|
+
*/
|
|
3939
|
+
private enrichUseStateSourcesWithCoLocatedCalls(
|
|
3940
|
+
acc: Record<string, Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[]>,
|
|
3941
|
+
) {
|
|
3942
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
3943
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
3944
|
+
if (!rootScope) return;
|
|
3945
|
+
|
|
3946
|
+
// Collect all descendants for each scope node
|
|
3947
|
+
const getAllDescendants = (
|
|
3948
|
+
node: import('./helpers/ScopeTreeManager').ScopeTreeNode,
|
|
3949
|
+
): Set<string> => {
|
|
3950
|
+
const names = new Set<string>([node.name]);
|
|
3951
|
+
for (const child of node.children) {
|
|
3952
|
+
for (const name of getAllDescendants(child)) {
|
|
3953
|
+
names.add(name);
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
return names;
|
|
3957
|
+
};
|
|
3958
|
+
|
|
3959
|
+
for (const [usagePath, sources] of Object.entries(acc)) {
|
|
3960
|
+
const additionalSources: Pick<
|
|
3961
|
+
ScopeVariable,
|
|
3962
|
+
'scopeNodeName' | 'schemaPath'
|
|
3963
|
+
>[] = [];
|
|
3964
|
+
|
|
3965
|
+
for (const source of sources) {
|
|
3966
|
+
// Check if this source is a useState-related terminal path
|
|
3967
|
+
// (e.g., useState(X).functionCallReturnValue[1] or useState(X).signature[0])
|
|
3968
|
+
if (!source.schemaPath.match(/^useState\([^)]*\)\./)) continue;
|
|
3969
|
+
|
|
3970
|
+
// Find the useState call from the source path
|
|
3971
|
+
const useStateCallMatch = source.schemaPath.match(
|
|
3972
|
+
/^(useState\([^)]*\))\./,
|
|
3973
|
+
);
|
|
3974
|
+
if (!useStateCallMatch) continue;
|
|
3975
|
+
const useStateCall = useStateCallMatch[1];
|
|
3976
|
+
|
|
3977
|
+
// Look in the root scope for the useState value equivalency
|
|
3978
|
+
// which tells us where the setter was called from
|
|
3979
|
+
const valuePath = `${useStateCall}.functionCallReturnValue[0]`;
|
|
3980
|
+
const valueEquivs = rootScope.equivalencies[valuePath];
|
|
3981
|
+
if (!valueEquivs) continue;
|
|
3982
|
+
|
|
3983
|
+
for (const equiv of valueEquivs) {
|
|
3984
|
+
// Find the scope where the setter was called
|
|
3985
|
+
const setterScopeName = equiv.scopeNodeName;
|
|
3986
|
+
const setterScopeTree =
|
|
3987
|
+
this.scopeTreeManager.findNode(setterScopeName);
|
|
3988
|
+
if (!setterScopeTree) continue;
|
|
3989
|
+
|
|
3990
|
+
// Get all descendant scope names from the setter scope
|
|
3991
|
+
const relatedScopes = getAllDescendants(setterScopeTree);
|
|
3992
|
+
|
|
3993
|
+
// Find external function calls in those scopes whose return values
|
|
3994
|
+
// are actually consumed (assigned to a variable). This excludes
|
|
3995
|
+
// fire-and-forget calls like analytics.track() or console.log().
|
|
3996
|
+
const coLocatedCalls = this.externalFunctionCalls.filter(
|
|
3997
|
+
(efc) =>
|
|
3998
|
+
relatedScopes.has(efc.callScope) &&
|
|
3999
|
+
efc.receivingVariableNames &&
|
|
4000
|
+
efc.receivingVariableNames.length > 0,
|
|
4001
|
+
);
|
|
4002
|
+
|
|
4003
|
+
for (const call of coLocatedCalls) {
|
|
4004
|
+
additionalSources.push({
|
|
4005
|
+
scopeNodeName: call.callScope,
|
|
4006
|
+
schemaPath: `${call.callSignature}.functionCallReturnValue`,
|
|
4007
|
+
});
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
if (additionalSources.length > 0) {
|
|
4013
|
+
acc[usagePath].push(...additionalSources);
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
3826
4016
|
}
|
|
3827
4017
|
|
|
3828
4018
|
getUsageEquivalencies(functionName?: string) {
|
|
@@ -3927,6 +4117,54 @@ export class ScopeDataStructure {
|
|
|
3927
4117
|
}
|
|
3928
4118
|
}
|
|
3929
4119
|
|
|
4120
|
+
// Enrich schema with deeply nested paths from internal function call scopes.
|
|
4121
|
+
// When a function call like traverse(tree) exists, and traverse's scope has
|
|
4122
|
+
// signature[0].children[path][entityName] (from propagateParameterToSignaturePaths),
|
|
4123
|
+
// we need to map those paths back to the argument variable (tree) in this scope.
|
|
4124
|
+
// This handles cases where cycle detection prevented the equivalency chain from
|
|
4125
|
+
// propagating deep paths during Phase 2 batch queue processing.
|
|
4126
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
4127
|
+
// Look for keys matching function call pattern: funcName(...).signature[N]
|
|
4128
|
+
const funcCallMatch = equivalenceKey.match(
|
|
4129
|
+
/^([^(]+)\(.*?\)\.(signature\[\d+\])$/,
|
|
4130
|
+
);
|
|
4131
|
+
if (!funcCallMatch) continue;
|
|
4132
|
+
|
|
4133
|
+
const calledFunctionName = funcCallMatch[1];
|
|
4134
|
+
const signatureParam = funcCallMatch[2]; // e.g., "signature[0]"
|
|
4135
|
+
|
|
4136
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
4137
|
+
if (equivalenceValue.scopeNodeName !== scopeName) continue;
|
|
4138
|
+
|
|
4139
|
+
const targetVariable = equivalenceValue.schemaPath;
|
|
4140
|
+
|
|
4141
|
+
// Get the called function's schema (includes propagated parameter paths)
|
|
4142
|
+
const childSchema = this.getSchema({
|
|
4143
|
+
scopeName: calledFunctionName,
|
|
4144
|
+
});
|
|
4145
|
+
if (!childSchema) continue;
|
|
4146
|
+
|
|
4147
|
+
// Map child function's signature paths to parent variable paths
|
|
4148
|
+
const sigPrefix = signatureParam + '.';
|
|
4149
|
+
const sigBracketPrefix = signatureParam + '[';
|
|
4150
|
+
for (const childKey in childSchema) {
|
|
4151
|
+
let suffix: string | null = null;
|
|
4152
|
+
if (childKey.startsWith(sigPrefix)) {
|
|
4153
|
+
suffix = childKey.slice(signatureParam.length);
|
|
4154
|
+
} else if (childKey.startsWith(sigBracketPrefix)) {
|
|
4155
|
+
suffix = childKey.slice(signatureParam.length);
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
if (suffix !== null) {
|
|
4159
|
+
const parentKey = targetVariable + suffix;
|
|
4160
|
+
if (!schema[parentKey]) {
|
|
4161
|
+
schema[parentKey] = childSchema[childKey];
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
|
|
3930
4168
|
// Propagate nested paths from variables to their signature equivalents
|
|
3931
4169
|
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
3932
4170
|
// signature[0].workouts[].title
|
|
@@ -4281,6 +4519,15 @@ export class ScopeDataStructure {
|
|
|
4281
4519
|
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
4282
4520
|
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
4283
4521
|
) {
|
|
4522
|
+
// Skip bare "returnValue" from child scopes — this is the child's return value,
|
|
4523
|
+
// not a meaningful data source path in the parent scope
|
|
4524
|
+
if (
|
|
4525
|
+
equivalentValue.schemaPath === 'returnValue' &&
|
|
4526
|
+
equivalentValue.scopeNodeName !==
|
|
4527
|
+
this.scopeTreeManager.getRootName()
|
|
4528
|
+
) {
|
|
4529
|
+
continue;
|
|
4530
|
+
}
|
|
4284
4531
|
// Add equivalency (will accumulate if multiple values for OR expressions)
|
|
4285
4532
|
addEquivalency(path, equivalentValue.schemaPath);
|
|
4286
4533
|
}
|
|
@@ -4977,6 +5224,10 @@ export class ScopeDataStructure {
|
|
|
4977
5224
|
getEnrichedConditionalUsages(): Record<string, EnrichedConditionalUsage[]> {
|
|
4978
5225
|
const enriched: Record<string, EnrichedConditionalUsage[]> = {};
|
|
4979
5226
|
|
|
5227
|
+
console.log(
|
|
5228
|
+
`[getEnrichedConditionalUsages] Processing ${Object.keys(this.rawConditionalUsages).length} conditional paths: [${Object.keys(this.rawConditionalUsages).join(', ')}]`,
|
|
5229
|
+
);
|
|
5230
|
+
|
|
4980
5231
|
for (const [path, usages] of Object.entries(this.rawConditionalUsages)) {
|
|
4981
5232
|
// Try to trace this path back to a data source
|
|
4982
5233
|
// First, try the root scope
|
|
@@ -4985,10 +5236,69 @@ export class ScopeDataStructure {
|
|
|
4985
5236
|
|
|
4986
5237
|
let sourceDataPath: string | undefined;
|
|
4987
5238
|
if (explanation.source) {
|
|
4988
|
-
|
|
4989
|
-
|
|
5239
|
+
const { scope, path: sourcePath } = explanation.source;
|
|
5240
|
+
|
|
5241
|
+
// Build initial path — avoid redundant prefix when path already contains the scope call
|
|
5242
|
+
let fullPath: string;
|
|
5243
|
+
if (sourcePath.startsWith(`${scope}(`)) {
|
|
5244
|
+
fullPath = sourcePath;
|
|
5245
|
+
} else {
|
|
5246
|
+
fullPath = `${scope}.${sourcePath}`;
|
|
5247
|
+
}
|
|
5248
|
+
|
|
5249
|
+
sourceDataPath = fullPath;
|
|
5250
|
+
console.log(
|
|
5251
|
+
`[getEnrichedConditionalUsages] "${path}" explainPath → scope="${scope}", sourcePath="${sourcePath}" → sourceDataPath="${sourceDataPath}"`,
|
|
5252
|
+
);
|
|
5253
|
+
} else {
|
|
5254
|
+
console.log(
|
|
5255
|
+
`[getEnrichedConditionalUsages] "${path}" explainPath → no source found`,
|
|
5256
|
+
);
|
|
4990
5257
|
}
|
|
4991
5258
|
|
|
5259
|
+
// If explainPath didn't find a useful external source (e.g., it traced to
|
|
5260
|
+
// useState or just to the component scope itself), check sourceEquivalencies
|
|
5261
|
+
// for an external function call source like a fetch call
|
|
5262
|
+
const hasExternalSource = sourceDataPath?.includes(
|
|
5263
|
+
'.functionCallReturnValue',
|
|
5264
|
+
);
|
|
5265
|
+
if (!hasExternalSource) {
|
|
5266
|
+
console.log(
|
|
5267
|
+
`[getEnrichedConditionalUsages] "${path}" no external source (sourceDataPath="${sourceDataPath}"), checking sourceEquivalencies fallback...`,
|
|
5268
|
+
);
|
|
5269
|
+
const sourceEquiv = this.getSourceEquivalencies();
|
|
5270
|
+
const returnValueKey = `returnValue.${path}`;
|
|
5271
|
+
const sources = sourceEquiv[returnValueKey];
|
|
5272
|
+
if (sources) {
|
|
5273
|
+
console.log(
|
|
5274
|
+
`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] has ${sources.length} sources: [${sources.map((s: { schemaPath: string }) => s.schemaPath).join(', ')}]`,
|
|
5275
|
+
);
|
|
5276
|
+
const externalSource = sources.find(
|
|
5277
|
+
(s: { schemaPath: string }) =>
|
|
5278
|
+
s.schemaPath.includes('.functionCallReturnValue') &&
|
|
5279
|
+
!s.schemaPath.startsWith('useState('),
|
|
5280
|
+
);
|
|
5281
|
+
if (externalSource) {
|
|
5282
|
+
console.log(
|
|
5283
|
+
`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found external source: "${externalSource.schemaPath}"`,
|
|
5284
|
+
);
|
|
5285
|
+
sourceDataPath = externalSource.schemaPath;
|
|
5286
|
+
} else {
|
|
5287
|
+
console.log(
|
|
5288
|
+
`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found no external function call source`,
|
|
5289
|
+
);
|
|
5290
|
+
}
|
|
5291
|
+
} else {
|
|
5292
|
+
console.log(
|
|
5293
|
+
`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] not found`,
|
|
5294
|
+
);
|
|
5295
|
+
}
|
|
5296
|
+
}
|
|
5297
|
+
|
|
5298
|
+
console.log(
|
|
5299
|
+
`[getEnrichedConditionalUsages] "${path}" FINAL sourceDataPath="${sourceDataPath ?? '(none)'}" (${usages.length} usages)`,
|
|
5300
|
+
);
|
|
5301
|
+
|
|
4992
5302
|
enriched[path] = usages.map((usage) => ({
|
|
4993
5303
|
...usage,
|
|
4994
5304
|
sourceDataPath,
|
|
@@ -5336,11 +5646,22 @@ export class ScopeDataStructure {
|
|
|
5336
5646
|
}
|
|
5337
5647
|
}
|
|
5338
5648
|
|
|
5649
|
+
// Enrich the schema with inferred types by applying fillInSchemaGapsAndUnknowns.
|
|
5650
|
+
// This ensures the serialized schema has the same type inference as getReturnValue().
|
|
5651
|
+
// Without this, evidence like "entities[].analyses: array" becomes "unknown".
|
|
5652
|
+
const enrichedSchema = { ...efc.schema };
|
|
5653
|
+
const tempScopeNode = {
|
|
5654
|
+
name: efc.name,
|
|
5655
|
+
schema: enrichedSchema,
|
|
5656
|
+
equivalencies: efc.equivalencies ?? {},
|
|
5657
|
+
};
|
|
5658
|
+
fillInSchemaGapsAndUnknowns(tempScopeNode, true);
|
|
5659
|
+
|
|
5339
5660
|
return {
|
|
5340
5661
|
name: efc.name,
|
|
5341
5662
|
callSignature: efc.callSignature,
|
|
5342
5663
|
callScope: efc.callScope,
|
|
5343
|
-
schema:
|
|
5664
|
+
schema: enrichedSchema,
|
|
5344
5665
|
equivalencies: efc.equivalencies
|
|
5345
5666
|
? Object.entries(efc.equivalencies).reduce(
|
|
5346
5667
|
(acc, [key, vars]) => {
|
|
@@ -72,7 +72,11 @@ export class JavascriptFrameworkManager implements EquivalencyManager {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
finalize(scopeNode: ScopeNode, scopeDataStructure: ScopeDataStructure) {
|
|
75
|
-
cleanNonObjectFunctions
|
|
75
|
+
// Don't call cleanNonObjectFunctions with final=true here.
|
|
76
|
+
// The aggressive cleanup (transformKeyMapping, clearAttributes) removes method call
|
|
77
|
+
// evidence like .includes() before type inference can use it.
|
|
78
|
+
// Instead, defer final cleanup to toSerializable() when we're done with inference.
|
|
79
|
+
cleanNonObjectFunctions(scopeNode, scopeDataStructure, false);
|
|
76
80
|
cleanKnownObjectFunctions(scopeNode, scopeDataStructure);
|
|
77
81
|
this.handleUniformArrays(scopeNode, scopeDataStructure);
|
|
78
82
|
}
|
package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts
CHANGED
|
@@ -172,9 +172,18 @@ function scrub(
|
|
|
172
172
|
const rawMethod = rawToken.split('(')[0];
|
|
173
173
|
|
|
174
174
|
// Check if it's a prototype method (e.g., map, filter, toString)
|
|
175
|
+
// Only match when the token is actually a method reference/call:
|
|
176
|
+
// - Has parentheses (explicit call like map(), filter(x => x))
|
|
177
|
+
// - OR is typed as "function" (method reference like .split)
|
|
178
|
+
// Bare property names that happen to match method names
|
|
179
|
+
// (like .entries = "array", .values = "object") are preserved.
|
|
175
180
|
if (protoMethodSets[rootKind].has(rawMethod)) {
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
const isMethodCall = rawToken.includes('(');
|
|
182
|
+
const isMethodReference = mapping[keyPath] === 'function';
|
|
183
|
+
if (isMethodCall || isMethodReference) {
|
|
184
|
+
onRemove(keyPath);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
178
187
|
}
|
|
179
188
|
|
|
180
189
|
// Check if it's a built-in property (e.g., length on arrays/strings)
|
package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts
CHANGED
|
@@ -510,7 +510,7 @@ function removeNonTransformingArrayMethods(variablePath: string): string {
|
|
|
510
510
|
const part = keyParts[i];
|
|
511
511
|
|
|
512
512
|
const arrayMethod = getMethodName(part);
|
|
513
|
-
if (isValidArrayMethod(arrayMethod)) {
|
|
513
|
+
if (isValidFunctionCall(part) && isValidArrayMethod(arrayMethod)) {
|
|
514
514
|
const nextPart = keyParts[i + 1];
|
|
515
515
|
if (
|
|
516
516
|
!nonTransformingArrayMethodsSet.has(arrayMethod) ||
|
|
@@ -550,7 +550,7 @@ function removeIsolatingArrayMethods(
|
|
|
550
550
|
const part = keyParts[i];
|
|
551
551
|
|
|
552
552
|
const arrayMethod = getMethodName(part);
|
|
553
|
-
if (isValidArrayMethod(arrayMethod)) {
|
|
553
|
+
if (isValidFunctionCall(part) && isValidArrayMethod(arrayMethod)) {
|
|
554
554
|
const nextPart = keyParts[i + 1];
|
|
555
555
|
const prevPart = i > 1 ? keyParts[i - 1] : undefined;
|
|
556
556
|
if (
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coerces object/array values to primitive types when the schema expects a primitive.
|
|
3
|
+
*
|
|
4
|
+
* The LLM sometimes generates an object or array where the schema expects a primitive
|
|
5
|
+
* type like "string", "number", or "boolean". For example:
|
|
6
|
+
* Schema: { body: "string" }
|
|
7
|
+
* LLM output: { body: { "env": "production" } }
|
|
8
|
+
*
|
|
9
|
+
* This causes runtime errors like `TypeError: body.match is not a function` because
|
|
10
|
+
* the code expects a string but gets an object.
|
|
11
|
+
*
|
|
12
|
+
* Coercion rules:
|
|
13
|
+
* - object/array → string: JSON.stringify
|
|
14
|
+
* - object/array → number: 0
|
|
15
|
+
* - object/array → boolean: false
|
|
16
|
+
*
|
|
17
|
+
* @param data The mock data object to coerce (mutated in place)
|
|
18
|
+
* @param schema The schema describing expected types
|
|
19
|
+
*/
|
|
20
|
+
export default function coerceObjectsToPrimitivesBySchema<T>(
|
|
21
|
+
data: T,
|
|
22
|
+
schema: unknown,
|
|
23
|
+
): T {
|
|
24
|
+
if (data === null || data === undefined) {
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof data !== 'object') {
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (Array.isArray(data)) {
|
|
33
|
+
const itemSchema = Array.isArray(schema) ? schema[0] : undefined;
|
|
34
|
+
for (let i = 0; i < data.length; i++) {
|
|
35
|
+
data[i] = coerceObjectsToPrimitivesBySchema(data[i], itemSchema);
|
|
36
|
+
}
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const dataObj = data as Record<string, unknown>;
|
|
41
|
+
const schemaObj = schema as Record<string, unknown> | undefined;
|
|
42
|
+
|
|
43
|
+
for (const key of Object.keys(dataObj)) {
|
|
44
|
+
const value = dataObj[key];
|
|
45
|
+
const fieldSchema = schemaObj?.[key];
|
|
46
|
+
|
|
47
|
+
if (value === null || value === undefined) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (typeof value === 'object' && typeof fieldSchema === 'string') {
|
|
52
|
+
// Schema expects a primitive but the value is an object/array.
|
|
53
|
+
// Coerce to the expected type.
|
|
54
|
+
const schemaType = fieldSchema.toLowerCase();
|
|
55
|
+
|
|
56
|
+
if (schemaType.includes('string')) {
|
|
57
|
+
dataObj[key] = JSON.stringify(value);
|
|
58
|
+
} else if (schemaType.includes('number')) {
|
|
59
|
+
dataObj[key] = 0;
|
|
60
|
+
} else if (schemaType.includes('boolean')) {
|
|
61
|
+
dataObj[key] = false;
|
|
62
|
+
}
|
|
63
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
64
|
+
// Both value and schema are objects — recurse
|
|
65
|
+
coerceObjectsToPrimitivesBySchema(value, fieldSchema);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return data;
|
|
70
|
+
}
|