@codeyam/codeyam-cli 0.1.0-staging.c9dc00c → 0.1.0-staging.d3e886e
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 +1 -1
- package/analyzer-template/packages/ai/index.ts +1 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +14 -0
- 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 +172 -8
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +70 -19
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +40 -13
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +32 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +134 -2
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +359 -142
- 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/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +18 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +50 -25
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +153 -76
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +108 -2
- package/analyzer-template/project/constructMockCode.ts +2 -2
- package/analyzer-template/project/writeScenarioComponents.ts +14 -0
- package/background/src/lib/virtualized/project/constructMockCode.js +2 -2
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +10 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +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 +2 -2
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +18 -17
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +27 -93
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +9 -9
- package/codeyam-cli/src/commands/memory.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +1 -1
- package/codeyam-cli/src/commands/verify.js +12 -2
- package/codeyam-cli/src/commands/verify.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +179 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +11 -11
- package/codeyam-cli/src/utils/backgroundServer.js +90 -23
- 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 +13 -13
- package/codeyam-cli/src/utils/labsAutoCheck.js +0 -29
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -1
- package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +4 -4
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -1
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +2 -2
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -1
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +4 -4
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -1
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +3 -3
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -1
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +23 -23
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -1
- package/codeyam-cli/src/utils/rules/ruleState.js +10 -10
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -1
- package/codeyam-cli/src/utils/rules/staleness.js +6 -6
- 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 +7 -7
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js +66 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +26 -7
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +11 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{CopyButton-CA3JxPb7.js → CopyButton-jNYXRRNI.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-B86KKU7e.js → EntityItem-bwuHPyTa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-B5ctlSYt.js → EntityTypeBadge-CvzqMxcu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-BqY8gDAW.js → EntityTypeIcon-BH0XDim7.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-ClaLpuOo.js → InlineSpinner-EhOseatT.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-BDhPilK7.js → InteractivePreview-yjIHlOGa.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-VeqEBv9v.js → LibraryFunctionPreview-Cq5o8jL4.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-Bs7Nn1Jr.js → LoadingDots-BvMu2i-g.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-Bm3PmcCz.js → LogViewer-kgBTLoJD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-C6PKeMYR.js → ReportIssueModal-BzPgx-xO.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-Gq3Ocjo6.js → SafeScreenshot-CwZrv-Ok.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-BNLaXBHR.js → ScenarioViewer-BX2Ny2Qj.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-CiwXDxLh.js → TruncatedFilePath-CDpEprKa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{_index-B3TDXxnk.js → _index-BRx8ZGZo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BtBFH820.js → activity.(_tab)-4S4yPfFw.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DHKuQSmR.js +17 -0
- package/codeyam-cli/src/webserver/build/client/assets/{book-open-PttOB2SF.js → book-open-D4IPYH_y.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-TJp6ofnp.js → chevron-down-CG65viiV.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-JZWAC4HX-JE9ZIoBl.js → chunk-JZWAC4HX-DB3aFuEO.js} +9 -9
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CXhHQYrI.js → circle-check-igfMr5DY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{copy-6y9ALfGT.js → copy-Coc4o_8c.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-Ca9fAY46.js → createLucideIcon-D1zB-pYc.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-C5lqplTC.js → dev.empty-JTAjQ54M.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-n38keI1k.js → entity._sha._-B0h9AqE6.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js → entity._sha.scenarios._scenarioId.fullscreen-DjLxr2JB.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-DGgZjdFg.js → entity._sha_.create-scenario-CtYowLOt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-38yPijoD.js → entity._sha_.edit._scenarioId-PePWg17F.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-BSHEfydn.js → entry.client-I-Wo99C_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DCPhhSMo.js → fileTableUtils-9sMMAiWJ.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{files-0N0YJQv7.js → files-Co65J0s3.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{git-DXnyr8uP.js → git-BdHOxVfg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-CCgBKWy4.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-ChN9-fAY.js → index-CUM5iXwc.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-CcsFv748.js → index-_417gcQW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-BK0C1H1T.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CTqLEAGU.js → loader-circle-TzRHMVog.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-390cb8fa.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CzZySbBE.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/{pause-D6vreykR.js → pause-hjzB7t2z.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-DnbDhvTU.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-B8VUL8nl.js → search-DcAwD_Ln.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-CclxrcPK.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-CPoAg7Zo.js → simulations-DVNJVQgD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{terminal-BrCP7uQo.js → terminal-DbEAHMbA.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-BZz2NjYa.js → triangle-alert-CAD5b1o_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-DNwUduNu.js → useCustomSizes-BqgrAzs3.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-COky1GVF.js → useLastLogLine-DAFqfEDH.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-CpZgwliL.js → useReportContext-DZlYx2c4.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-Bv9JFvUO.js → useToast-ihdMtlf6.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-Cz2RkDCa.js → index-CxaRxKVt.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-D4DT0nM_.js +259 -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 → codeyam-diagnose.md} +1 -1
- package/codeyam-cli/templates/codeyam-memory-hook.sh +14 -14
- package/codeyam-cli/templates/{codeyam:memory.md → codeyam-memory.md} +16 -23
- package/codeyam-cli/templates/{codeyam:new-rule.md → codeyam-new-rule.md} +1 -1
- package/codeyam-cli/templates/{codeyam:setup.md → codeyam-setup.md} +1 -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-reflection-hook.py +5 -5
- package/codeyam-cli/templates/rules-instructions.md +11 -15
- package/package.json +8 -8
- package/packages/ai/index.js +1 -1
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +14 -0
- package/packages/ai/src/lib/analyzeScope.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 +124 -7
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +59 -17
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructureChunking.js +30 -11
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +22 -3
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +97 -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/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/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +11 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +42 -13
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +123 -67
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-CN61MOMa.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-survey-l0sNRNKZ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-EVn6Z9pz.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-CmBYA0PH.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-aa4ff97b.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-BSlqS1QA.js +0 -81
- package/codeyam-cli/src/webserver/build/client/assets/root-DVAbJY8B.js +0 -62
- package/codeyam-cli/src/webserver/build/client/assets/settings-BK-cnzp-.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CUVsWicu.js +0 -260
|
@@ -181,6 +181,7 @@ const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
|
181
181
|
'transformed non-object function equivalency - implicit parent equivalency - rerouted via useCallback',
|
|
182
182
|
'transformed non-object function equivalency - Array.from() equivalency',
|
|
183
183
|
'Spread operator equivalency key update: Explicit array deconstruction equivalency value',
|
|
184
|
+
// 'transformed non-object function equivalency - Explicit array deconstruction equivalency value',
|
|
184
185
|
]);
|
|
185
186
|
export class ScopeDataStructure {
|
|
186
187
|
// Getter for backward compatibility - returns the tree structure
|
|
@@ -2707,21 +2708,91 @@ export class ScopeDataStructure {
|
|
|
2707
2708
|
}
|
|
2708
2709
|
return [source];
|
|
2709
2710
|
};
|
|
2710
|
-
|
|
2711
|
+
const acc = entries.reduce((result, entry) => {
|
|
2711
2712
|
var _a;
|
|
2712
2713
|
if (entry.sourceCandidates.length === 0)
|
|
2713
|
-
return
|
|
2714
|
+
return result;
|
|
2714
2715
|
const usages = entry.usages.filter(usageMatchesScope);
|
|
2715
2716
|
for (const usage of usages) {
|
|
2716
|
-
|
|
2717
|
+
result[_a = usage.schemaPath] || (result[_a] = []);
|
|
2717
2718
|
// Resolve each source candidate through the equivalency chain
|
|
2718
2719
|
for (const source of entry.sourceCandidates) {
|
|
2719
2720
|
const resolvedSources = resolveToSignature(source, new Set());
|
|
2720
|
-
|
|
2721
|
+
result[usage.schemaPath].push(...resolvedSources);
|
|
2721
2722
|
}
|
|
2722
2723
|
}
|
|
2723
|
-
return
|
|
2724
|
+
return result;
|
|
2724
2725
|
}, {});
|
|
2726
|
+
// Post-processing: enrich useState-backed sources with co-located external
|
|
2727
|
+
// function calls. When a useState value resolves to a setter variable that
|
|
2728
|
+
// lives in the same scope as a fetch/API call, that fetch is a data source.
|
|
2729
|
+
this.enrichUseStateSourcesWithCoLocatedCalls(acc);
|
|
2730
|
+
return acc;
|
|
2731
|
+
}
|
|
2732
|
+
/**
|
|
2733
|
+
* For each source that ends at a useState path, check if the setter was called
|
|
2734
|
+
* from a scope that also contains external function calls (like fetch).
|
|
2735
|
+
* If so, add those external calls as additional source candidates.
|
|
2736
|
+
*/
|
|
2737
|
+
enrichUseStateSourcesWithCoLocatedCalls(acc) {
|
|
2738
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
2739
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
2740
|
+
if (!rootScope)
|
|
2741
|
+
return;
|
|
2742
|
+
// Collect all descendants for each scope node
|
|
2743
|
+
const getAllDescendants = (node) => {
|
|
2744
|
+
const names = new Set([node.name]);
|
|
2745
|
+
for (const child of node.children) {
|
|
2746
|
+
for (const name of getAllDescendants(child)) {
|
|
2747
|
+
names.add(name);
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
return names;
|
|
2751
|
+
};
|
|
2752
|
+
for (const [usagePath, sources] of Object.entries(acc)) {
|
|
2753
|
+
const additionalSources = [];
|
|
2754
|
+
for (const source of sources) {
|
|
2755
|
+
// Check if this source is a useState-related terminal path
|
|
2756
|
+
// (e.g., useState(X).functionCallReturnValue[1] or useState(X).signature[0])
|
|
2757
|
+
if (!source.schemaPath.match(/^useState\([^)]*\)\./))
|
|
2758
|
+
continue;
|
|
2759
|
+
// Find the useState call from the source path
|
|
2760
|
+
const useStateCallMatch = source.schemaPath.match(/^(useState\([^)]*\))\./);
|
|
2761
|
+
if (!useStateCallMatch)
|
|
2762
|
+
continue;
|
|
2763
|
+
const useStateCall = useStateCallMatch[1];
|
|
2764
|
+
// Look in the root scope for the useState value equivalency
|
|
2765
|
+
// which tells us where the setter was called from
|
|
2766
|
+
const valuePath = `${useStateCall}.functionCallReturnValue[0]`;
|
|
2767
|
+
const valueEquivs = rootScope.equivalencies[valuePath];
|
|
2768
|
+
if (!valueEquivs)
|
|
2769
|
+
continue;
|
|
2770
|
+
for (const equiv of valueEquivs) {
|
|
2771
|
+
// Find the scope where the setter was called
|
|
2772
|
+
const setterScopeName = equiv.scopeNodeName;
|
|
2773
|
+
const setterScopeTree = this.scopeTreeManager.findNode(setterScopeName);
|
|
2774
|
+
if (!setterScopeTree)
|
|
2775
|
+
continue;
|
|
2776
|
+
// Get all descendant scope names from the setter scope
|
|
2777
|
+
const relatedScopes = getAllDescendants(setterScopeTree);
|
|
2778
|
+
// Find external function calls in those scopes whose return values
|
|
2779
|
+
// are actually consumed (assigned to a variable). This excludes
|
|
2780
|
+
// fire-and-forget calls like analytics.track() or console.log().
|
|
2781
|
+
const coLocatedCalls = this.externalFunctionCalls.filter((efc) => relatedScopes.has(efc.callScope) &&
|
|
2782
|
+
efc.receivingVariableNames &&
|
|
2783
|
+
efc.receivingVariableNames.length > 0);
|
|
2784
|
+
for (const call of coLocatedCalls) {
|
|
2785
|
+
additionalSources.push({
|
|
2786
|
+
scopeNodeName: call.callScope,
|
|
2787
|
+
schemaPath: `${call.callSignature}.functionCallReturnValue`,
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
if (additionalSources.length > 0) {
|
|
2793
|
+
acc[usagePath].push(...additionalSources);
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2725
2796
|
}
|
|
2726
2797
|
getUsageEquivalencies(functionName) {
|
|
2727
2798
|
const scopeNode = this.getScopeOrFunctionCallInfo(functionName);
|
|
@@ -3118,6 +3189,13 @@ export class ScopeDataStructure {
|
|
|
3118
3189
|
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
3119
3190
|
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
3120
3191
|
) {
|
|
3192
|
+
// Skip bare "returnValue" from child scopes — this is the child's return value,
|
|
3193
|
+
// not a meaningful data source path in the parent scope
|
|
3194
|
+
if (equivalentValue.schemaPath === 'returnValue' &&
|
|
3195
|
+
equivalentValue.scopeNodeName !==
|
|
3196
|
+
this.scopeTreeManager.getRootName()) {
|
|
3197
|
+
continue;
|
|
3198
|
+
}
|
|
3121
3199
|
// Add equivalency (will accumulate if multiple values for OR expressions)
|
|
3122
3200
|
addEquivalency(path, equivalentValue.schemaPath);
|
|
3123
3201
|
}
|
|
@@ -3677,6 +3755,7 @@ export class ScopeDataStructure {
|
|
|
3677
3755
|
*/
|
|
3678
3756
|
getEnrichedConditionalUsages() {
|
|
3679
3757
|
const enriched = {};
|
|
3758
|
+
console.log(`[getEnrichedConditionalUsages] Processing ${Object.keys(this.rawConditionalUsages).length} conditional paths: [${Object.keys(this.rawConditionalUsages).join(', ')}]`);
|
|
3680
3759
|
for (const [path, usages] of Object.entries(this.rawConditionalUsages)) {
|
|
3681
3760
|
// Try to trace this path back to a data source
|
|
3682
3761
|
// First, try the root scope
|
|
@@ -3684,9 +3763,47 @@ export class ScopeDataStructure {
|
|
|
3684
3763
|
const explanation = this.explainPath(rootScopeName, path);
|
|
3685
3764
|
let sourceDataPath;
|
|
3686
3765
|
if (explanation.source) {
|
|
3687
|
-
|
|
3688
|
-
|
|
3766
|
+
const { scope, path: sourcePath } = explanation.source;
|
|
3767
|
+
// Build initial path — avoid redundant prefix when path already contains the scope call
|
|
3768
|
+
let fullPath;
|
|
3769
|
+
if (sourcePath.startsWith(`${scope}(`)) {
|
|
3770
|
+
fullPath = sourcePath;
|
|
3771
|
+
}
|
|
3772
|
+
else {
|
|
3773
|
+
fullPath = `${scope}.${sourcePath}`;
|
|
3774
|
+
}
|
|
3775
|
+
sourceDataPath = fullPath;
|
|
3776
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" explainPath → scope="${scope}", sourcePath="${sourcePath}" → sourceDataPath="${sourceDataPath}"`);
|
|
3777
|
+
}
|
|
3778
|
+
else {
|
|
3779
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" explainPath → no source found`);
|
|
3780
|
+
}
|
|
3781
|
+
// If explainPath didn't find a useful external source (e.g., it traced to
|
|
3782
|
+
// useState or just to the component scope itself), check sourceEquivalencies
|
|
3783
|
+
// for an external function call source like a fetch call
|
|
3784
|
+
const hasExternalSource = sourceDataPath?.includes('.functionCallReturnValue');
|
|
3785
|
+
if (!hasExternalSource) {
|
|
3786
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" no external source (sourceDataPath="${sourceDataPath}"), checking sourceEquivalencies fallback...`);
|
|
3787
|
+
const sourceEquiv = this.getSourceEquivalencies();
|
|
3788
|
+
const returnValueKey = `returnValue.${path}`;
|
|
3789
|
+
const sources = sourceEquiv[returnValueKey];
|
|
3790
|
+
if (sources) {
|
|
3791
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] has ${sources.length} sources: [${sources.map((s) => s.schemaPath).join(', ')}]`);
|
|
3792
|
+
const externalSource = sources.find((s) => s.schemaPath.includes('.functionCallReturnValue') &&
|
|
3793
|
+
!s.schemaPath.startsWith('useState('));
|
|
3794
|
+
if (externalSource) {
|
|
3795
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found external source: "${externalSource.schemaPath}"`);
|
|
3796
|
+
sourceDataPath = externalSource.schemaPath;
|
|
3797
|
+
}
|
|
3798
|
+
else {
|
|
3799
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found no external function call source`);
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
else {
|
|
3803
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] not found`);
|
|
3804
|
+
}
|
|
3689
3805
|
}
|
|
3806
|
+
console.log(`[getEnrichedConditionalUsages] "${path}" FINAL sourceDataPath="${sourceDataPath ?? '(none)'}" (${usages.length} usages)`);
|
|
3690
3807
|
enriched[path] = usages.map((usage) => ({
|
|
3691
3808
|
...usage,
|
|
3692
3809
|
sourceDataPath,
|