@codeyam/codeyam-cli 0.1.0-staging.c90f8c9 → 0.1.0-staging.c9dc00c
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 +7 -7
- package/analyzer-template/packages/ai/index.ts +10 -2
- package/analyzer-template/packages/ai/package.json +2 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +86 -18
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +67 -9
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +41 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +308 -50
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +15 -6
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +837 -243
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +54 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +60 -15
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +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 -97
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +283 -1
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +9 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +11 -3
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +297 -7
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +25 -13
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +4 -3
- package/analyzer-template/packages/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 +65 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +71 -9
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +19 -4
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +0 -3
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +61 -13
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +37 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +229 -19
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +117 -9
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +459 -39
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/package.json +1 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +14 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- 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 +12 -0
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -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/updateCommitMetadata.ts +7 -14
- 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 +11 -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/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/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/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.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.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/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/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/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/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +5 -5
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +6 -5
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/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/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +5 -5
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/playwright/capture.ts +20 -8
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/project/analyzeBaselineCommit.ts +5 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +5 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +90 -10
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +11 -6
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +45 -6
- package/analyzer-template/project/start.ts +35 -11
- package/analyzer-template/project/writeMockDataTsx.ts +181 -8
- package/analyzer-template/project/writeScenarioComponents.ts +60 -12
- package/analyzer-template/project/writeSimpleRoot.ts +21 -11
- package/analyzer-template/scripts/comboWorkerLoop.cjs +98 -50
- 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/analyzeBaselineCommit.js +5 -0
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +5 -0
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +75 -4
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +4 -4
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +38 -6
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +32 -11
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +162 -4
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +60 -15
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +4 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +2 -0
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +2 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -1
- package/codeyam-cli/src/commands/debug.js +9 -5
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +14 -4
- 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 +42 -184
- package/codeyam-cli/src/commands/init.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 +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 +2 -0
- 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/analysisRunner.js +1 -1
- package/codeyam-cli/src/utils/analysisRunner.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 +4 -0
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +71 -46
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +48 -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 +6 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +83 -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/setupClaudeCodeSettings.js +20 -43
- 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 +31 -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-B86KKU7e.js +11 -0
- 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-D4TZhLuw.js → ReportIssueModal-C6PKeMYR.js} +3 -13
- 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-DEx02QDa.js → ScenarioViewer-BNLaXBHR.js} +3 -3
- 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)-DoLIqZX2.js → activity.(_tab)-BtBFH820.js} +6 -16
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-CN61MOMa.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-survey-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.memory-profile-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-C5lqplTC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-C2N4Op8e.js → entity._sha._-n38keI1k.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-0N0YJQv7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{git-B4RJRvYB.js → git-DXnyr8uP.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/globals-EVn6Z9pz.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-CmBYA0PH.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-aa4ff97b.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-BSlqS1QA.js +81 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-DVAbJY8B.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-BK-cnzp-.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-Cz2RkDCa.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CUVsWicu.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/templates/{codeyam-power-rules-hook.sh → codeyam-memory-hook.sh} +12 -13
- package/codeyam-cli/templates/codeyam:diagnose.md +195 -496
- package/codeyam-cli/templates/codeyam:memory.md +403 -0
- package/codeyam-cli/templates/codeyam:new-rule.md +2 -2
- package/codeyam-cli/templates/codeyam:setup.md +12 -0
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
- package/codeyam-cli/templates/rules-instructions.md +136 -0
- package/package.json +8 -6
- package/packages/ai/index.js +3 -2
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +68 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +54 -8
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/methodSemantics.js +41 -17
- 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/processExpression.js +239 -43
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +654 -166
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +52 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +55 -11
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +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 -86
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.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 +205 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +7 -1
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +10 -2
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +209 -3
- 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/mergeStatements.js +70 -51
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/resolvePathToControllable.js +24 -14
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/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 +60 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +54 -6
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +17 -4
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +0 -3
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +56 -10
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +33 -8
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +150 -17
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +56 -8
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +399 -31
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/database/src/lib/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +11 -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/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- 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 +9 -0
- package/packages/database/src/lib/loadCommits.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/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/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -76
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BXhEawa3.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-BRb-0kQl.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-Cs4MdYtv.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-commit-horizontal-CysbcZxi.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-DMUaGAqV.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-f874c610.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-Bz5TunQg.js +0 -57
- package/codeyam-cli/src/webserver/build/client/assets/rules-hEkvVw2-.js +0 -97
- package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-uNNbimct.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-B08qC4Y7.js +0 -257
- package/codeyam-cli/templates/codeyam:power-rules.md +0 -449
- /package/codeyam-cli/src/webserver/build/client/assets/{api.rules-l0sNRNKZ.js → api.agent-transcripts-l0sNRNKZ.js} +0 -0
|
@@ -7,58 +7,12 @@ import {
|
|
|
7
7
|
|
|
8
8
|
export interface Statement {
|
|
9
9
|
structure: { [key: string]: string };
|
|
10
|
-
|
|
10
|
+
// Supports multiple equivalencies per key for OR expressions (e.g., x = a || b)
|
|
11
|
+
equivalentVariables: { [key: string]: string | string[] };
|
|
11
12
|
llmCall?: LlmCall;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export default function mergeStatements(statements: Statement[]) {
|
|
15
|
-
// Debug: Log input statements to understand what we're merging
|
|
16
|
-
const hasStateStructure = statements.some((s) =>
|
|
17
|
-
Object.keys(s.structure || {}).some(
|
|
18
|
-
(k) => k === 'state' || k.includes('state'),
|
|
19
|
-
),
|
|
20
|
-
);
|
|
21
|
-
const hasStateEquiv = statements.some((s) =>
|
|
22
|
-
Object.keys(s.equivalentVariables || {}).some(
|
|
23
|
-
(k) => k === 'state' || k.includes('state'),
|
|
24
|
-
),
|
|
25
|
-
);
|
|
26
|
-
if (hasStateStructure || hasStateEquiv) {
|
|
27
|
-
console.log(
|
|
28
|
-
`[UNION-TYPE] mergeStatements INPUT: ${statements.length} statements`,
|
|
29
|
-
);
|
|
30
|
-
statements.forEach((s, i) => {
|
|
31
|
-
const stateInStructure = Object.entries(s.structure || {}).filter(
|
|
32
|
-
([k]) => k === 'state' || k.includes('state'),
|
|
33
|
-
);
|
|
34
|
-
const stateInEquiv = Object.entries(s.equivalentVariables || {}).filter(
|
|
35
|
-
([k]) => k === 'state' || k.includes('state'),
|
|
36
|
-
);
|
|
37
|
-
const sigInEquiv = Object.entries(s.equivalentVariables || {}).filter(
|
|
38
|
-
([k, v]) => k === 'state' || v === 'signature[0]',
|
|
39
|
-
);
|
|
40
|
-
if (
|
|
41
|
-
stateInStructure.length > 0 ||
|
|
42
|
-
stateInEquiv.length > 0 ||
|
|
43
|
-
sigInEquiv.length > 0
|
|
44
|
-
) {
|
|
45
|
-
console.log(`[UNION-TYPE] Statement ${i}:`);
|
|
46
|
-
if (stateInStructure.length > 0)
|
|
47
|
-
console.log(
|
|
48
|
-
`[UNION-TYPE] structure: ${JSON.stringify(Object.fromEntries(stateInStructure))}`,
|
|
49
|
-
);
|
|
50
|
-
if (stateInEquiv.length > 0)
|
|
51
|
-
console.log(
|
|
52
|
-
`[UNION-TYPE] equivalentVariables (state): ${JSON.stringify(Object.fromEntries(stateInEquiv))}`,
|
|
53
|
-
);
|
|
54
|
-
if (sigInEquiv.length > 0)
|
|
55
|
-
console.log(
|
|
56
|
-
`[UNION-TYPE] equivalentVariables (sig): ${JSON.stringify(Object.fromEntries(sigInEquiv))}`,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
16
|
// This should be handled by the AST Analyzer but it currently has a bug
|
|
63
17
|
const ensureFunctionCallReturnValue = (path: string, value: string) => {
|
|
64
18
|
if (path.endsWith(')') && value !== 'function') {
|
|
@@ -172,12 +126,54 @@ export default function mergeStatements(statements: Statement[]) {
|
|
|
172
126
|
// settingsData → fetcher.data.data uses fetcher::cyDuplicateKey1::.data.data
|
|
173
127
|
const activeRemappings: Record<string, string> = {};
|
|
174
128
|
|
|
129
|
+
// Helper to normalize value to array and process
|
|
130
|
+
const normalizeValue = (value: string | string[]): string[] =>
|
|
131
|
+
Array.isArray(value) ? value : [value];
|
|
132
|
+
|
|
175
133
|
const equivalentVariables = statements.reduce((acc: any, result) => {
|
|
176
|
-
for (const [key,
|
|
134
|
+
for (const [key, rawValue] of Object.entries(
|
|
177
135
|
result.equivalentVariables ?? {},
|
|
178
136
|
)) {
|
|
137
|
+
// Handle arrays from AST analyzer (OR expressions like x = a || b)
|
|
138
|
+
// These should be preserved as arrays to track all sources
|
|
139
|
+
if (Array.isArray(rawValue)) {
|
|
140
|
+
const keyOptions = deBinaryPath(key);
|
|
141
|
+
const validValues = rawValue.filter(
|
|
142
|
+
(v): v is string => typeof v === 'string' && v.length > 0,
|
|
143
|
+
);
|
|
144
|
+
if (validValues.length === 0) continue;
|
|
145
|
+
|
|
146
|
+
// Process each array value through deBinaryPath
|
|
147
|
+
const allValueOptions: string[] = [];
|
|
148
|
+
for (const value of validValues) {
|
|
149
|
+
const valueOptions = deBinaryPath(value);
|
|
150
|
+
allValueOptions.push(...valueOptions);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Remove duplicates while preserving order
|
|
154
|
+
const uniqueValueOptions = [...new Set(allValueOptions)];
|
|
155
|
+
const finalValue =
|
|
156
|
+
uniqueValueOptions.length === 1
|
|
157
|
+
? uniqueValueOptions[0]
|
|
158
|
+
: uniqueValueOptions;
|
|
159
|
+
|
|
160
|
+
delete result.equivalentVariables[key];
|
|
161
|
+
if (keyOptions.length >= 2) {
|
|
162
|
+
for (const keyOption of keyOptions) {
|
|
163
|
+
result.equivalentVariables[keyOption] = finalValue;
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
result.equivalentVariables[keyOptions[0]] = finalValue;
|
|
167
|
+
}
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Original logic for string values with potential binary expressions in the string
|
|
172
|
+
const firstValue = rawValue;
|
|
173
|
+
if (!firstValue) continue;
|
|
174
|
+
|
|
179
175
|
const keyOptions = deBinaryPath(key);
|
|
180
|
-
const valueOptions = deBinaryPath(
|
|
176
|
+
const valueOptions = deBinaryPath(firstValue);
|
|
181
177
|
delete result.equivalentVariables[key];
|
|
182
178
|
if (keyOptions.length === 2) {
|
|
183
179
|
if (valueOptions.length === 2) {
|
|
@@ -199,27 +195,38 @@ export default function mergeStatements(statements: Statement[]) {
|
|
|
199
195
|
}
|
|
200
196
|
}
|
|
201
197
|
|
|
202
|
-
for (const [key,
|
|
198
|
+
for (const [key, rawValue] of Object.entries(
|
|
203
199
|
result.equivalentVariables ?? {},
|
|
204
200
|
)) {
|
|
201
|
+
// Normalize to array for consistent handling
|
|
202
|
+
const values = normalizeValue(rawValue);
|
|
203
|
+
|
|
205
204
|
// Apply any active remappings to the VALUE, but ONLY for property paths
|
|
206
205
|
// e.g., if fetcher was remapped to fetcher::cyDuplicateKey1::,
|
|
207
206
|
// then "fetcher.data.data" should become "fetcher::cyDuplicateKey1::.data.data"
|
|
208
207
|
// However, we should NOT remap standalone variable references like "description"
|
|
209
208
|
// because that would lose type information from the original variable.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
209
|
+
const remappedValues = values.map((value) => {
|
|
210
|
+
let remappedValue = value;
|
|
211
|
+
for (const [originalKey, remappedKey] of Object.entries(
|
|
212
|
+
activeRemappings,
|
|
213
|
+
)) {
|
|
214
|
+
// Only remap if the value is a property path (contains a dot after the key)
|
|
215
|
+
// This preserves type information for simple variable references
|
|
216
|
+
const keyRegex = new RegExp(
|
|
217
|
+
`^${originalKey.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?=\\.)`,
|
|
218
|
+
);
|
|
219
|
+
if (keyRegex.test(remappedValue)) {
|
|
220
|
+
remappedValue = remappedValue.replace(keyRegex, remappedKey);
|
|
221
|
+
}
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
+
return remappedValue;
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// Use array if multiple values, string if single
|
|
227
|
+
const remappedValue =
|
|
228
|
+
remappedValues.length === 1 ? remappedValues[0] : remappedValues;
|
|
229
|
+
const firstRemappedValue = remappedValues[0];
|
|
223
230
|
|
|
224
231
|
if (acc[key]) {
|
|
225
232
|
if (acc[key] === remappedValue) continue;
|
|
@@ -247,45 +254,32 @@ export default function mergeStatements(statements: Statement[]) {
|
|
|
247
254
|
// If we have equivalentVariables[A] = B, and structure[A] is more specific than structure[B],
|
|
248
255
|
// then update structure[B] to match structure[A]
|
|
249
256
|
// This handles cases like: "state" -> "signature[0]" where "state" has a union type
|
|
250
|
-
|
|
251
|
-
// Debug: Log union types in merged structure
|
|
252
|
-
const unionTypesInStructure = Object.entries(structure).filter(
|
|
253
|
-
([_, v]) => typeof v === 'string' && v.includes("'") && v.includes(' | '),
|
|
254
|
-
);
|
|
255
|
-
if (unionTypesInStructure.length > 0) {
|
|
256
|
-
console.log(
|
|
257
|
-
`[UNION-TYPE] mergeStatements: Found ${unionTypesInStructure.length} union types in merged structure`,
|
|
258
|
-
);
|
|
259
|
-
unionTypesInStructure.forEach(([k, v]) =>
|
|
260
|
-
console.log(`[UNION-TYPE] structure["${k}"] = ${v}`),
|
|
261
|
-
);
|
|
262
|
-
console.log(
|
|
263
|
-
`[UNION-TYPE] mergeStatements: equivalentVariables = ${JSON.stringify(equivalentVariables)}`,
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
for (const [source, target] of Object.entries(equivalentVariables) as [
|
|
268
|
-
string,
|
|
257
|
+
for (const [source, rawTarget] of Object.entries(equivalentVariables) as [
|
|
269
258
|
string,
|
|
259
|
+
string | string[],
|
|
270
260
|
][]) {
|
|
261
|
+
// Normalize to array for consistent handling
|
|
262
|
+
const targets = Array.isArray(rawTarget) ? rawTarget : [rawTarget];
|
|
271
263
|
const sourceType = structure[source];
|
|
272
|
-
const targetType = structure[target];
|
|
273
264
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const sourceIsUnion =
|
|
277
|
-
sourceType.includes("'") && sourceType.includes(' | ');
|
|
265
|
+
for (const target of targets) {
|
|
266
|
+
if (typeof target !== 'string') continue;
|
|
278
267
|
|
|
279
|
-
|
|
280
|
-
// Target doesn't exist or is generic - propagate the union type
|
|
281
|
-
const targetIsGeneric =
|
|
282
|
-
!targetType || targetType === 'string' || targetType === 'unknown';
|
|
268
|
+
const targetType = structure[target];
|
|
283
269
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
);
|
|
288
|
-
|
|
270
|
+
// Check if source has a more specific type (union type vs generic type)
|
|
271
|
+
if (sourceType) {
|
|
272
|
+
const sourceIsUnion =
|
|
273
|
+
sourceType.includes("'") && sourceType.includes(' | ');
|
|
274
|
+
|
|
275
|
+
if (sourceIsUnion) {
|
|
276
|
+
// Target doesn't exist or is generic - propagate the union type
|
|
277
|
+
const targetIsGeneric =
|
|
278
|
+
!targetType || targetType === 'string' || targetType === 'unknown';
|
|
279
|
+
|
|
280
|
+
if (targetIsGeneric) {
|
|
281
|
+
structure[target] = sourceType;
|
|
282
|
+
}
|
|
289
283
|
}
|
|
290
284
|
}
|
|
291
285
|
}
|
|
@@ -139,16 +139,19 @@ export function gatherAttributesMap(
|
|
|
139
139
|
// Use merged type if available, otherwise fall back to isolated type
|
|
140
140
|
const typeValue =
|
|
141
141
|
mergedSignatureSchema[key] ?? isolatedSignatureSchema[key];
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
// Handle array case (OR expressions) - use first element if array
|
|
143
|
+
const rawEquivalent = equivalentSignatureVariables[keyParts[0]];
|
|
144
|
+
const equivalentSignatureVariable = Array.isArray(rawEquivalent)
|
|
145
|
+
? rawEquivalent[0]
|
|
146
|
+
: rawEquivalent;
|
|
147
|
+
const equivalentSignatureVariableParts = equivalentSignatureVariable
|
|
148
|
+
? splitOutsideParenthesesAndArrays(equivalentSignatureVariable)
|
|
149
|
+
: [];
|
|
147
150
|
if (
|
|
148
151
|
equivalentSignatureVariable &&
|
|
149
|
-
!equivalentSignatureVariableParts[0]
|
|
152
|
+
!equivalentSignatureVariableParts[0]?.includes('(')
|
|
150
153
|
) {
|
|
151
|
-
const equivalentKey =
|
|
154
|
+
const equivalentKey = equivalentSignatureVariable;
|
|
152
155
|
const equivalentPath = joinParenthesesAndArrays([
|
|
153
156
|
equivalentKey,
|
|
154
157
|
...keyParts.slice(1),
|
|
@@ -525,7 +525,7 @@ function findControllableBaseForDerivedPath(
|
|
|
525
525
|
export default function resolvePathToControllable(
|
|
526
526
|
localPath: string,
|
|
527
527
|
attributesMap: Record<string, string>,
|
|
528
|
-
equivalentSignatureVariables: Record<string, string>,
|
|
528
|
+
equivalentSignatureVariables: Record<string, string | string[]>,
|
|
529
529
|
fullToShortPathMap: Record<string, string>,
|
|
530
530
|
): PathResolutionResult {
|
|
531
531
|
const chain: string[] = [localPath];
|
|
@@ -600,7 +600,11 @@ export default function resolvePathToControllable(
|
|
|
600
600
|
|
|
601
601
|
// 4. Equivalent variable resolution
|
|
602
602
|
const localVarName = extractLocalVariableName(localPath);
|
|
603
|
-
|
|
603
|
+
// Handle array case (OR expressions) - use first element if array
|
|
604
|
+
const rawDataSourceBase = equivalentSignatureVariables[localVarName];
|
|
605
|
+
const dataSourceBase = Array.isArray(rawDataSourceBase)
|
|
606
|
+
? rawDataSourceBase[0]
|
|
607
|
+
: rawDataSourceBase;
|
|
604
608
|
|
|
605
609
|
if (dataSourceBase) {
|
|
606
610
|
chain.push(`equivalent var: ${localVarName} → ${dataSourceBase}`);
|
|
@@ -626,18 +630,26 @@ export default function resolvePathToControllable(
|
|
|
626
630
|
baseVarName in equivalentSignatureVariables &&
|
|
627
631
|
baseVarName !== localVarName
|
|
628
632
|
) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
633
|
+
// Handle array case (OR expressions) - use first element if array
|
|
634
|
+
const rawBaseDataSource = equivalentSignatureVariables[baseVarName];
|
|
635
|
+
const baseDataSource = Array.isArray(rawBaseDataSource)
|
|
636
|
+
? rawBaseDataSource[0]
|
|
637
|
+
: rawBaseDataSource;
|
|
638
|
+
if (baseDataSource) {
|
|
639
|
+
chain.push(
|
|
640
|
+
`transitive resolution: ${baseVarName} → ${baseDataSource}`,
|
|
641
|
+
);
|
|
642
|
+
// Append the array access suffix to the resolved base
|
|
643
|
+
if (baseDataSource.endsWith('()')) {
|
|
644
|
+
fullResolvedPath =
|
|
645
|
+
baseDataSource + '.functionCallReturnValue' + accessSuffix;
|
|
646
|
+
} else if (baseDataSource.endsWith('.functionCallReturnValue')) {
|
|
647
|
+
fullResolvedPath = baseDataSource + accessSuffix;
|
|
648
|
+
} else {
|
|
649
|
+
fullResolvedPath = baseDataSource + accessSuffix;
|
|
650
|
+
}
|
|
651
|
+
chain.push(`transitively resolved: ${fullResolvedPath}`);
|
|
639
652
|
}
|
|
640
|
-
chain.push(`transitively resolved: ${fullResolvedPath}`);
|
|
641
653
|
}
|
|
642
654
|
}
|
|
643
655
|
|
|
@@ -63,7 +63,7 @@ export interface EnrichedConditionalUsage {
|
|
|
63
63
|
/** For comparison conditions, the literal values being compared against */
|
|
64
64
|
comparedValues?: string[];
|
|
65
65
|
/** Where this conditional usage occurs */
|
|
66
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
66
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
67
67
|
/**
|
|
68
68
|
* The traced source data path in the format "scopeName.path"
|
|
69
69
|
* e.g., "useParams().functionCallReturnValue['*']"
|
|
@@ -120,7 +120,8 @@ export interface SerializableDataStructure {
|
|
|
120
120
|
functionResults: Record<string, SerializableFunctionResult>;
|
|
121
121
|
|
|
122
122
|
// Equivalent signature variables for root scope
|
|
123
|
-
|
|
123
|
+
// Values can be arrays for OR expressions where a variable maps to multiple sources
|
|
124
|
+
equivalentSignatureVariables: Record<string, string | string[]>;
|
|
124
125
|
|
|
125
126
|
environmentVariables: string[];
|
|
126
127
|
|
|
@@ -296,7 +297,7 @@ export function getSourceEquivalencies(
|
|
|
296
297
|
|
|
297
298
|
export function getEquivalentSignatureVariables(
|
|
298
299
|
dataStructure: SerializableDataStructure,
|
|
299
|
-
): Record<string, string> {
|
|
300
|
+
): Record<string, string | string[]> {
|
|
300
301
|
return dataStructure.equivalentSignatureVariables;
|
|
301
302
|
}
|
|
302
303
|
|
|
@@ -9,13 +9,14 @@ import { Entity } from '~codeyam/types';
|
|
|
9
9
|
import { FileAnalyzer, ProjectAnalyzer } from '~codeyam/analyze';
|
|
10
10
|
import { analyzeScopeLocal } from '../analyzeScope';
|
|
11
11
|
import {
|
|
12
|
-
ScopeInfo,
|
|
13
12
|
resetScopeDataStructureMetrics,
|
|
13
|
+
ScopeInfo,
|
|
14
14
|
} from '../dataStructure/ScopeDataStructure';
|
|
15
15
|
import { SerializableDataStructure } from './SerializableDataStructure';
|
|
16
16
|
import { AI } from '~codeyam/ai';
|
|
17
17
|
import { setThreadContext } from '~codeyam/utils';
|
|
18
18
|
import { threadId } from 'worker_threads';
|
|
19
|
+
import v8 from 'v8';
|
|
19
20
|
|
|
20
21
|
// Set thread context for logging
|
|
21
22
|
setThreadContext(`<worker-${threadId}>`);
|
|
@@ -45,6 +46,80 @@ let projectAnalyzerKey: string | null = null;
|
|
|
45
46
|
let fileAnalyzer: FileAnalyzer | null = null;
|
|
46
47
|
let fileAnalyzerPath: string | null = null;
|
|
47
48
|
|
|
49
|
+
// Memory tracking
|
|
50
|
+
let entitiesProcessed = 0;
|
|
51
|
+
let lastMemoryLogAt = 0;
|
|
52
|
+
const MEMORY_LOG_INTERVAL = 100; // Log every N entities
|
|
53
|
+
const MEMORY_LOG_TIME_INTERVAL = 60_000; // Or every 60 seconds
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get memory stats for logging
|
|
57
|
+
*/
|
|
58
|
+
function getWorkerMemoryStats() {
|
|
59
|
+
const mem = process.memoryUsage();
|
|
60
|
+
const heapStats = v8.getHeapStatistics();
|
|
61
|
+
return {
|
|
62
|
+
rss: `${Math.round(mem.rss / 1024 / 1024)}MB`,
|
|
63
|
+
heapUsed: `${Math.round(mem.heapUsed / 1024 / 1024)}MB`,
|
|
64
|
+
heapTotal: `${Math.round(mem.heapTotal / 1024 / 1024)}MB`,
|
|
65
|
+
external: `${Math.round(mem.external / 1024 / 1024)}MB`,
|
|
66
|
+
// V8 heap stats give more detail
|
|
67
|
+
v8TotalHeapSize: `${Math.round(heapStats.total_heap_size / 1024 / 1024)}MB`,
|
|
68
|
+
v8UsedHeapSize: `${Math.round(heapStats.used_heap_size / 1024 / 1024)}MB`,
|
|
69
|
+
v8HeapSizeLimit: `${Math.round(heapStats.heap_size_limit / 1024 / 1024)}MB`,
|
|
70
|
+
v8MallocedMemory: `${Math.round(heapStats.malloced_memory / 1024 / 1024)}MB`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get ts.Program stats for understanding TypeScript memory usage
|
|
76
|
+
*/
|
|
77
|
+
function getTsProgramStats(pa: ProjectAnalyzer) {
|
|
78
|
+
const sourceFiles = pa.program.getSourceFiles();
|
|
79
|
+
const projectSourceFiles = sourceFiles.filter(
|
|
80
|
+
(sf) => !sf.fileName.includes('node_modules'),
|
|
81
|
+
);
|
|
82
|
+
const nodeModulesFiles = sourceFiles.filter((sf) =>
|
|
83
|
+
sf.fileName.includes('node_modules'),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// Estimate AST size by sampling text length (rough proxy)
|
|
87
|
+
let totalProjectTextLength = 0;
|
|
88
|
+
for (const sf of projectSourceFiles) {
|
|
89
|
+
totalProjectTextLength += sf.getFullText().length;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
totalSourceFiles: sourceFiles.length,
|
|
94
|
+
projectSourceFiles: projectSourceFiles.length,
|
|
95
|
+
nodeModulesFiles: nodeModulesFiles.length,
|
|
96
|
+
projectTextSizeMB: `${(totalProjectTextLength / 1024 / 1024).toFixed(1)}MB`,
|
|
97
|
+
// Note: Actual AST memory is typically 10-20x the source text size
|
|
98
|
+
estimatedAstSizeMB: `${((totalProjectTextLength * 15) / 1024 / 1024).toFixed(0)}MB`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Write a heap snapshot for detailed profiling.
|
|
104
|
+
* The snapshot can be loaded in Chrome DevTools for analysis.
|
|
105
|
+
*
|
|
106
|
+
* TODO: Once we understand memory usage, change this back to env-var controlled
|
|
107
|
+
*/
|
|
108
|
+
const HEAP_SNAPSHOT_MODE: 'off' | 'once' | 'periodic' = 'off';
|
|
109
|
+
|
|
110
|
+
function maybeWriteHeapSnapshot(label: string) {
|
|
111
|
+
if (HEAP_SNAPSHOT_MODE === 'off') return;
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
const filename = v8.writeHeapSnapshot();
|
|
115
|
+
console.log(
|
|
116
|
+
`CodeYam Worker: Heap snapshot written (${label}): ${filename}`,
|
|
117
|
+
);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('CodeYam Worker: Failed to write heap snapshot:', error);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
48
123
|
/**
|
|
49
124
|
* Main worker function called by Piscina
|
|
50
125
|
*/
|
|
@@ -61,8 +136,25 @@ export default async function runAnalyzeScope(
|
|
|
61
136
|
// Create or reuse ProjectAnalyzer
|
|
62
137
|
const paKey = `${dirPath}`;
|
|
63
138
|
if (!projectAnalyzer || projectAnalyzerKey !== paKey) {
|
|
64
|
-
|
|
139
|
+
const memBefore = process.memoryUsage();
|
|
140
|
+
console.log('CodeYam Worker: Creating ProjectAnalyzer (ts.Program)...', {
|
|
141
|
+
memBefore: getWorkerMemoryStats(),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
projectAnalyzer = ProjectAnalyzer.from({ project, dirPath });
|
|
65
145
|
projectAnalyzerKey = paKey;
|
|
146
|
+
|
|
147
|
+
const memAfter = process.memoryUsage();
|
|
148
|
+
const tsProgramStats = getTsProgramStats(projectAnalyzer);
|
|
149
|
+
console.log('CodeYam Worker: ProjectAnalyzer created', {
|
|
150
|
+
memAfter: getWorkerMemoryStats(),
|
|
151
|
+
rssDelta: `+${Math.round((memAfter.rss - memBefore.rss) / 1024 / 1024)}MB`,
|
|
152
|
+
heapDelta: `+${Math.round((memAfter.heapUsed - memBefore.heapUsed) / 1024 / 1024)}MB`,
|
|
153
|
+
tsProgramStats,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Optionally write heap snapshot after ts.Program creation
|
|
157
|
+
maybeWriteHeapSnapshot('after-ts-program');
|
|
66
158
|
}
|
|
67
159
|
|
|
68
160
|
// Create or reuse FileAnalyzer
|
|
@@ -95,6 +187,26 @@ export default async function runAnalyzeScope(
|
|
|
95
187
|
);
|
|
96
188
|
}
|
|
97
189
|
|
|
190
|
+
// Periodic memory logging
|
|
191
|
+
entitiesProcessed++;
|
|
192
|
+
const now = Date.now();
|
|
193
|
+
const shouldLogMemory =
|
|
194
|
+
entitiesProcessed % MEMORY_LOG_INTERVAL === 0 ||
|
|
195
|
+
now - lastMemoryLogAt > MEMORY_LOG_TIME_INTERVAL;
|
|
196
|
+
|
|
197
|
+
if (shouldLogMemory) {
|
|
198
|
+
lastMemoryLogAt = now;
|
|
199
|
+
console.log('CodeYam Worker: Memory stats', {
|
|
200
|
+
entitiesProcessed,
|
|
201
|
+
...getWorkerMemoryStats(),
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Optionally write periodic heap snapshots
|
|
205
|
+
if (HEAP_SNAPSHOT_MODE === 'periodic' && entitiesProcessed % 500 === 0) {
|
|
206
|
+
maybeWriteHeapSnapshot(`after-${entitiesProcessed}-entities`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
98
210
|
return { dataStructure: dataStructure.toSerializable() };
|
|
99
211
|
} catch (error) {
|
|
100
212
|
console.error(
|
|
@@ -41,6 +41,8 @@ export { default as mergeValidatedDataStructures } from './src/lib/files/scenari
|
|
|
41
41
|
|
|
42
42
|
export { discoverDirectDependencies } from './src/lib/files/analyze/dependencyResolver';
|
|
43
43
|
|
|
44
|
+
export { transformationTracer } from './src/lib/files/scenarios/TransformationTracer';
|
|
45
|
+
|
|
44
46
|
export { default as getAnalysisError } from './src/lib/utils/getAnalysisError';
|
|
45
47
|
export { default as measureAndReportExecutionTime } from './src/lib/utils/measureAndReportExecutionTime';
|
|
46
48
|
|