@codeyam/codeyam-cli 0.1.21 → 0.1.23
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/packages/ai/src/lib/astScopes/methodSemantics.ts +135 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/nodeToSource.ts +19 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/paths.ts +11 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +31 -8
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.ts +10 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +16 -6
- package/analyzer-template/packages/analyze/index.ts +4 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +28 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +5 -36
- package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts +21 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +82 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeNextRoute.ts +8 -3
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +239 -58
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1684 -1462
- package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js +47 -0
- package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js +71 -0
- package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js.map +1 -0
- package/codeyam-cli/src/commands/editor.js +545 -94
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js +23 -0
- package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +456 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +11 -3
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +140 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +50 -1
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +33 -1
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js +302 -0
- package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/testRunner.test.js +217 -0
- package/codeyam-cli/src/utils/__tests__/testRunner.test.js.map +1 -0
- package/codeyam-cli/src/utils/analysisRunner.js +28 -1
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +4 -2
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/editorAudit.js +136 -5
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
- package/codeyam-cli/src/utils/editorPreview.js +5 -3
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
- package/codeyam-cli/src/utils/editorScenarios.js +60 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
- package/codeyam-cli/src/utils/editorSeedAdapter.js +42 -2
- package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -1
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +16 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
- package/codeyam-cli/src/utils/manualEntityAnalysis.js +196 -0
- package/codeyam-cli/src/utils/manualEntityAnalysis.js.map +1 -0
- package/codeyam-cli/src/utils/queue/job.js +20 -2
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/testRunner.js +199 -1
- package/codeyam-cli/src/utils/testRunner.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +30 -11
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +35 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/MiniClaudeChat-CQENLSrF.js +36 -0
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-Coe5NhbS.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-CJzc4vOH.svg → cy-logo-cli-DoA97ML3.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DMv5ESGo.js +96 -0
- package/codeyam-cli/src/webserver/build/client/assets/{editorPreview-NTuLi4Xg.js → editorPreview-CluPkvXJ.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-Blfy9UlN.js → entity._sha._-ByHz6rAQ.js} +13 -12
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-BA5L8bU-.js → entity._sha.scenarios._scenarioId.dev-CmLO432x.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-D4dmRgvO.js → entity._sha.scenarios._scenarioId.fullscreen-Bz9sCUF_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-oyPmV37k.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{manifest-5025e428.js → manifest-1a45e154.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{root-BCx1S8Z3.js → root-D2_tktnk.js} +6 -6
- package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-By5slFjw.js +16 -0
- package/codeyam-cli/src/webserver/build/server/assets/{index-C91yWWCI.js → index-DXaOwBnm.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{init-Dkas-RUS.js → init-CLG1LjQM.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-NZmUqQv6.js +688 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/editorProxy.js +55 -3
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
- package/codeyam-cli/src/webserver/idleDetector.js +15 -0
- package/codeyam-cli/src/webserver/idleDetector.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +8 -2
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
- package/codeyam-cli/templates/codeyam-editor-reference.md +8 -6
- package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +42 -34
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +2 -2
- package/package.json +1 -1
- package/packages/ai/src/lib/astScopes/methodSemantics.js +99 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/nodeToSource.js +16 -0
- package/packages/ai/src/lib/astScopes/nodeToSource.js.map +1 -1
- package/packages/ai/src/lib/astScopes/paths.js +12 -3
- package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +23 -9
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js +9 -2
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +14 -4
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/analyze/index.js +1 -1
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +16 -2
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +6 -26
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +14 -0
- package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +44 -11
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeNextRoute.js +5 -1
- package/packages/analyze/src/lib/files/analyzeNextRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +120 -28
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +1368 -1193
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DODLxLcw.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-Dx-h1rJK.js +0 -130
- package/codeyam-cli/src/webserver/build/client/assets/globals-BrPXT1iR.css +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-C1kjC9UJ.js +0 -13
- package/codeyam-cli/src/webserver/build/server/assets/server-build-pulXLTrG.js +0 -640
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"buildTimestamp": "2026-03-
|
|
3
|
-
"buildTime":
|
|
4
|
-
"gitCommit": "
|
|
2
|
+
"buildTimestamp": "2026-03-25T14:20:38.638Z",
|
|
3
|
+
"buildTime": 1774448438638,
|
|
4
|
+
"gitCommit": "c7c95ab59975fd59b8a33c1299058ba1fca32a62",
|
|
5
5
|
"nodeVersion": "v20.20.1",
|
|
6
|
-
"contentHash": "
|
|
7
|
-
"buildNumber":
|
|
8
|
-
"semanticVersion": "0.1.
|
|
9
|
-
"version": "0.1.
|
|
6
|
+
"contentHash": "1ef6e4857c54ba0e5ddecacacdd26bdc64e7a25cd41e9f154b5ea6e3cd5525dc",
|
|
7
|
+
"buildNumber": 1223,
|
|
8
|
+
"semanticVersion": "0.1.1223",
|
|
9
|
+
"version": "0.1.1223 (2026-03-25T14:20+1ef6e48)"
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
[3/
|
|
3
|
-
[3/
|
|
2
|
+
[3/25/2026, 2:20:38 PM] > codeyam-combo@1.0.0 mergeDependencies
|
|
3
|
+
[3/25/2026, 2:20:38 PM] > node ./scripts/mergePackageJsonFiles.cjs
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
[3/
|
|
6
|
+
[3/25/2026, 2:20:38 PM] Merged dependencies into root package.json
|
|
7
7
|
|
|
@@ -895,6 +895,132 @@ export class UseStateSemantics implements MethodSemantics {
|
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
897
|
|
|
898
|
+
// ─── Set/Map method semantics ──────────────────────────────────────────
|
|
899
|
+
//
|
|
900
|
+
// Set/Map membership operations (.has, .delete, .add, .get, .set, .clear)
|
|
901
|
+
// don't create data flow equivalencies — they're membership checks or
|
|
902
|
+
// mutations, not transformations that propagate schema structure.
|
|
903
|
+
// Without these semantics, code like `filterRatings.has(articleId)` creates
|
|
904
|
+
// spurious equivalencies (332 entries in the Margo LibraryPage case).
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Set.has() / Map.has() — membership check, returns boolean
|
|
908
|
+
*/
|
|
909
|
+
export class CollectionHasSemantics implements MethodSemantics {
|
|
910
|
+
getReturnType(): string {
|
|
911
|
+
return 'boolean';
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
addEquivalences(
|
|
915
|
+
methodCallPath: StructuredPath,
|
|
916
|
+
_sourcePath: StructuredPath,
|
|
917
|
+
context: AnalysisContext,
|
|
918
|
+
): void {
|
|
919
|
+
context.addType(methodCallPath, 'boolean');
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
isComplete(): boolean {
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Set.delete() / Map.delete() — removal, returns boolean
|
|
929
|
+
*/
|
|
930
|
+
export class CollectionDeleteSemantics implements MethodSemantics {
|
|
931
|
+
getReturnType(): string {
|
|
932
|
+
return 'boolean';
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
addEquivalences(
|
|
936
|
+
methodCallPath: StructuredPath,
|
|
937
|
+
_sourcePath: StructuredPath,
|
|
938
|
+
context: AnalysisContext,
|
|
939
|
+
): void {
|
|
940
|
+
context.addType(methodCallPath, 'boolean');
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
isComplete(): boolean {
|
|
944
|
+
return true;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Set.add() — adds an element, returns the Set (for chaining)
|
|
950
|
+
*/
|
|
951
|
+
export class SetAddSemantics implements MethodSemantics {
|
|
952
|
+
getReturnType(): string {
|
|
953
|
+
return 'object'; // Returns the Set itself
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
addEquivalences(
|
|
957
|
+
_methodCallPath: StructuredPath,
|
|
958
|
+
_sourcePath: StructuredPath,
|
|
959
|
+
_context: AnalysisContext,
|
|
960
|
+
): void {
|
|
961
|
+
// No equivalencies — add() doesn't create data flow
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
isComplete(): boolean {
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Set.clear() / Map.clear() — removes all elements, returns void
|
|
971
|
+
*/
|
|
972
|
+
export class CollectionClearSemantics implements MethodSemantics {
|
|
973
|
+
getReturnType(): string {
|
|
974
|
+
return 'void';
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
addEquivalences(): void {
|
|
978
|
+
// No equivalencies
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
isComplete(): boolean {
|
|
982
|
+
return true;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Map.get() — retrieves a value by key, returns unknown (value type)
|
|
988
|
+
*/
|
|
989
|
+
export class MapGetSemantics implements MethodSemantics {
|
|
990
|
+
getReturnType(): string {
|
|
991
|
+
return 'unknown';
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
addEquivalences(
|
|
995
|
+
_methodCallPath: StructuredPath,
|
|
996
|
+
_sourcePath: StructuredPath,
|
|
997
|
+
_context: AnalysisContext,
|
|
998
|
+
): void {
|
|
999
|
+
// No equivalencies — the return value type depends on the map contents
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
isComplete(): boolean {
|
|
1003
|
+
return true;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Map.set() — sets a key-value pair, returns the Map (for chaining)
|
|
1009
|
+
*/
|
|
1010
|
+
export class MapSetSemantics implements MethodSemantics {
|
|
1011
|
+
getReturnType(): string {
|
|
1012
|
+
return 'object'; // Returns the Map itself
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
addEquivalences(): void {
|
|
1016
|
+
// No equivalencies
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
isComplete(): boolean {
|
|
1020
|
+
return true;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
898
1024
|
/**
|
|
899
1025
|
* Create and populate the registry with method semantics
|
|
900
1026
|
*/
|
|
@@ -930,6 +1056,15 @@ export function createMethodRegistry(): MethodSemanticsRegistry {
|
|
|
930
1056
|
registry.register('useState', new UseStateSemantics(), 'React');
|
|
931
1057
|
registry.register('useMemo', new UseMemoSemantics(), 'React');
|
|
932
1058
|
|
|
1059
|
+
// Register Set/Map collection methods.
|
|
1060
|
+
// Only .has() and .delete() are safe to register by method name — they always
|
|
1061
|
+
// return boolean regardless of the collection type (Set, Map, WeakSet, WeakMap,
|
|
1062
|
+
// FormData, URLSearchParams, etc.).
|
|
1063
|
+
// .add(), .clear(), .get(), .set() are too ambiguous across different types
|
|
1064
|
+
// and can't be registered until the lookup code supports class-aware resolution.
|
|
1065
|
+
registry.register('has', new CollectionHasSemantics());
|
|
1066
|
+
registry.register('delete', new CollectionDeleteSemantics());
|
|
1067
|
+
|
|
933
1068
|
return registry;
|
|
934
1069
|
}
|
|
935
1070
|
|
|
@@ -54,6 +54,25 @@ export function nodeToSource(
|
|
|
54
54
|
// return serializeBindingElement(node, sourceFile, options);
|
|
55
55
|
// }
|
|
56
56
|
|
|
57
|
+
// Object/array/function literals should be marked as literal paths.
|
|
58
|
+
// This prevents them from creating sourceEquivalencies when used as
|
|
59
|
+
// function call arguments (e.g., setUndoEntry({ label: '...', undo: ... })).
|
|
60
|
+
// Without this, the full source text of the literal (300-500 chars for complex
|
|
61
|
+
// objects) gets embedded in path strings, creating expensive-to-parse
|
|
62
|
+
// equivalency entries that don't contribute useful schema information.
|
|
63
|
+
if (ts.isObjectLiteralExpression(node)) {
|
|
64
|
+
return StructuredPath.createLiteralPath(node.getText(sourceFile), 'object');
|
|
65
|
+
}
|
|
66
|
+
if (ts.isArrayLiteralExpression(node)) {
|
|
67
|
+
return StructuredPath.createLiteralPath(node.getText(sourceFile), 'array');
|
|
68
|
+
}
|
|
69
|
+
if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
|
|
70
|
+
return StructuredPath.createLiteralPath(
|
|
71
|
+
node.getText(sourceFile),
|
|
72
|
+
'function',
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
57
76
|
// Fallback for unsupported node types
|
|
58
77
|
return StructuredPath.fromBase(node.getText(sourceFile));
|
|
59
78
|
}
|
|
@@ -406,11 +406,18 @@ export class StructuredPath {
|
|
|
406
406
|
} else {
|
|
407
407
|
// Convert each argument to its string representation
|
|
408
408
|
const argsStr = funcSegment.args
|
|
409
|
-
.map((arg) =>
|
|
410
|
-
|
|
409
|
+
.map((arg) => {
|
|
410
|
+
// For literal arguments (object/array/function literals),
|
|
411
|
+
// use a compact placeholder instead of the full source text.
|
|
412
|
+
// This prevents 300-500 char inline objects from being embedded
|
|
413
|
+
// in call signature paths, which creates expensive equivalencies.
|
|
414
|
+
if (arg.isLiteral()) {
|
|
415
|
+
return `{...}`;
|
|
416
|
+
}
|
|
417
|
+
return arg.toStringWithSegments(arg.base, arg.segments, {
|
|
411
418
|
withReturnValues: doRenderNestedFunctionCallReturnValue,
|
|
412
|
-
})
|
|
413
|
-
)
|
|
419
|
+
});
|
|
420
|
+
})
|
|
414
421
|
.join(', ');
|
|
415
422
|
result += `(${argsStr})`;
|
|
416
423
|
}
|
|
@@ -398,6 +398,7 @@ const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
|
398
398
|
'transformed non-object function equivalency - Array.from() equivalency',
|
|
399
399
|
'Spread operator equivalency key update: Explicit array deconstruction equivalency value',
|
|
400
400
|
// 'transformed non-object function equivalency - Explicit array deconstruction equivalency value',
|
|
401
|
+
'useState setter call equivalency (direct)',
|
|
401
402
|
]);
|
|
402
403
|
|
|
403
404
|
export class ScopeDataStructure {
|
|
@@ -1048,6 +1049,31 @@ export class ScopeDataStructure {
|
|
|
1048
1049
|
equivalencyValueChain?: EquivalencyValueChainItem[],
|
|
1049
1050
|
traceId?: number,
|
|
1050
1051
|
) {
|
|
1052
|
+
// Fast early exits that don't count toward the limit.
|
|
1053
|
+
// These are "no-op" calls that would be caught further below anyway,
|
|
1054
|
+
// but checking them first prevents counter inflation from redundant calls
|
|
1055
|
+
// generated by managers and followEquivalencies during scope processing.
|
|
1056
|
+
|
|
1057
|
+
// Skip silently-ignored reasons before counting
|
|
1058
|
+
if (SILENTLY_IGNORED_EQUIVALENCY_REASONS.has(equivalencyReason)) {
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
// Skip exact duplicates before counting (Phase 1 only — Phase 2 needs
|
|
1063
|
+
// to process duplicates for database chain tracking)
|
|
1064
|
+
if (this.onlyEquivalencies) {
|
|
1065
|
+
const existing = scopeNode.equivalencies[path];
|
|
1066
|
+
if (
|
|
1067
|
+
existing?.some(
|
|
1068
|
+
(v) =>
|
|
1069
|
+
v.schemaPath === equivalentPath &&
|
|
1070
|
+
v.scopeNodeName === equivalentScopeName,
|
|
1071
|
+
)
|
|
1072
|
+
) {
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1051
1077
|
addEquivalencyCallCount++;
|
|
1052
1078
|
|
|
1053
1079
|
const limit =
|
|
@@ -1069,14 +1095,11 @@ export class ScopeDataStructure {
|
|
|
1069
1095
|
}
|
|
1070
1096
|
// Filter equivalency reasons - use pre-computed Sets for O(1) lookup
|
|
1071
1097
|
if (!ALLOWED_EQUIVALENCY_REASONS.has(equivalencyReason)) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
console.info('Not tracked equivalency reason', { equivalencyReason });
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1098
|
+
// Silently-ignored reasons already handled above
|
|
1099
|
+
// Log and skip - if an equivalency reason isn't in ALLOWED or SILENTLY_IGNORED,
|
|
1100
|
+
// it shouldn't be stored (was previously missing the return)
|
|
1101
|
+
console.info('Not tracked equivalency reason', { equivalencyReason });
|
|
1102
|
+
return;
|
|
1080
1103
|
}
|
|
1081
1104
|
|
|
1082
1105
|
// Skip self-referential equivalencies that would create infinite loops.
|
|
@@ -97,6 +97,16 @@ export default class ParentScopeManager implements EquivalencyManager {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
if (instantiatedInParent || returnValueFromChildScope) {
|
|
100
|
+
// Skip if we've already propagated this variable to the parent scope.
|
|
101
|
+
// Without this guard, nested scopes trigger redundant addEquivalency calls
|
|
102
|
+
// for the same variable on every addToSchema pass (e.g., 'a' and 'b' in sort
|
|
103
|
+
// callbacks get propagated 30+ times per scope instead of once).
|
|
104
|
+
this.addedToParent[scopeNode.name] ||= new Set<string>();
|
|
105
|
+
if (this.addedToParent[scopeNode.name].has(rootPath)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
this.addedToParent[scopeNode.name].add(rootPath);
|
|
109
|
+
|
|
100
110
|
if (traceId && debugLevel > 0) {
|
|
101
111
|
console.info(
|
|
102
112
|
'Debug Propagation: parentScope executed',
|
|
@@ -114,9 +124,6 @@ export default class ParentScopeManager implements EquivalencyManager {
|
|
|
114
124
|
);
|
|
115
125
|
}
|
|
116
126
|
|
|
117
|
-
this.addedToParent[scopeNode.name] ||= new Set<string>();
|
|
118
|
-
this.addedToParent[scopeNode.name].add(rootPath);
|
|
119
|
-
|
|
120
127
|
scopeDataStructure.addEquivalency(
|
|
121
128
|
rootPath,
|
|
122
129
|
rootPath,
|
package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ScopeNode, ScopeDataStructure } from '../ScopeDataStructure';
|
|
|
6
6
|
|
|
7
7
|
type PrimitiveKind = 'array' | 'string' | 'number' | 'boolean' | 'date';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const IGNORE_CLASSES_AND_OBJECTS_SET = new Set([
|
|
10
10
|
'Math',
|
|
11
11
|
'JSON',
|
|
12
12
|
'Reflect',
|
|
@@ -22,7 +22,7 @@ const IGNORE_CLASSES_AND_OBJECTS = [
|
|
|
22
22
|
'useContext',
|
|
23
23
|
'useReducer',
|
|
24
24
|
'useLayoutEffect',
|
|
25
|
-
];
|
|
25
|
+
]);
|
|
26
26
|
|
|
27
27
|
/** cache the tokenised representation of every path we touch */
|
|
28
28
|
const partsCache = new Map<string, string[]>();
|
|
@@ -147,16 +147,26 @@ function scrub(
|
|
|
147
147
|
rootTable: Map<string, PrimitiveKind>,
|
|
148
148
|
onRemove: (key: string) => void,
|
|
149
149
|
): void {
|
|
150
|
-
|
|
150
|
+
// Early exit: if no primitive types exist in the schema, there are no
|
|
151
|
+
// built-in methods to clean. Saves sorting + walking 10K+ keys.
|
|
152
|
+
if (rootTable.size === 0) return;
|
|
153
|
+
|
|
154
|
+
// Use direct comparison instead of localeCompare (3-5x faster for large arrays)
|
|
155
|
+
const sortedKeys = Object.keys(mapping).sort((a, b) =>
|
|
156
|
+
a < b ? -1 : a > b ? 1 : 0,
|
|
157
|
+
);
|
|
151
158
|
|
|
152
159
|
for (const keyPath of sortedKeys) {
|
|
153
160
|
const keyParts = getParts(keyPath);
|
|
154
161
|
const prefixParts = buildPrefixParts(keyParts);
|
|
155
162
|
|
|
163
|
+
const firstPart = keyParts[0];
|
|
164
|
+
const firstPartBase = firstPart.includes('(')
|
|
165
|
+
? firstPart.split('(')[0]
|
|
166
|
+
: firstPart;
|
|
156
167
|
if (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
168
|
+
IGNORE_CLASSES_AND_OBJECTS_SET.has(firstPart) ||
|
|
169
|
+
IGNORE_CLASSES_AND_OBJECTS_SET.has(firstPartBase)
|
|
160
170
|
) {
|
|
161
171
|
delete mapping[keyPath];
|
|
162
172
|
continue;
|
|
@@ -36,7 +36,10 @@ export { getAllEntityNodes } from './src/lib/asts/sourceFiles/getAllEntityNodes'
|
|
|
36
36
|
export { default as fileAnalyzerFromCode } from './src/lib/files/fileAnalyzerFromCode';
|
|
37
37
|
|
|
38
38
|
export { default as isolateDataStructure } from './src/lib/files/scenarios/isolateDataStructure';
|
|
39
|
-
export {
|
|
39
|
+
export {
|
|
40
|
+
default as mergeInDependentDataStructure,
|
|
41
|
+
DataStructureTimeoutError,
|
|
42
|
+
} from './src/lib/files/scenarios/mergeInDependentDataStructure';
|
|
40
43
|
export { default as mergeValidatedDataStructures } from './src/lib/files/scenarios/mergeValidatedDataStructures';
|
|
41
44
|
|
|
42
45
|
export { discoverDirectDependencies } from './src/lib/files/analyze/dependencyResolver';
|
|
@@ -289,18 +289,44 @@ export default async function prepareEntityDataStructures(
|
|
|
289
289
|
skipWorkerPool();
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
+
awsLogDebugLevel(
|
|
293
|
+
1,
|
|
294
|
+
`Preparing data structures for ${entities.length} entities (${entitiesNeedingGeneration} need generation)...`,
|
|
295
|
+
);
|
|
296
|
+
const startTime = Date.now();
|
|
297
|
+
let completedCount = 0;
|
|
298
|
+
|
|
299
|
+
// Wrap processEntity to track progress
|
|
300
|
+
const processEntityWithProgress = async (entity: Entity) => {
|
|
301
|
+
await processEntity(entity);
|
|
302
|
+
completedCount++;
|
|
303
|
+
// Emit progress every 10 entities
|
|
304
|
+
if (completedCount % 10 === 0) {
|
|
305
|
+
awsLogDebugLevel(
|
|
306
|
+
1,
|
|
307
|
+
`Preparing data structures... (${completedCount}/${entities.length})`,
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
|
|
292
312
|
const sequential =
|
|
293
313
|
DEBUG_SEQUENTIAL_EXECUTION || options.sequentialDataStructurePrep;
|
|
294
314
|
|
|
295
315
|
if (sequential) {
|
|
296
316
|
// Sequential execution for debugging - process one entity at a time
|
|
297
317
|
for (const entity of entities) {
|
|
298
|
-
await
|
|
318
|
+
await processEntityWithProgress(entity);
|
|
299
319
|
}
|
|
300
320
|
} else {
|
|
301
321
|
// Parallel execution for speed
|
|
302
|
-
await Promise.all(entities.map(
|
|
322
|
+
await Promise.all(entities.map(processEntityWithProgress));
|
|
303
323
|
}
|
|
324
|
+
|
|
325
|
+
const elapsed = Date.now() - startTime;
|
|
326
|
+
awsLogDebugLevel(
|
|
327
|
+
1,
|
|
328
|
+
`Data structure preparation complete: ${entities.length} entities in ${elapsed}ms`,
|
|
329
|
+
);
|
|
304
330
|
}
|
|
305
331
|
|
|
306
332
|
/**
|
|
@@ -8,13 +8,11 @@ import {
|
|
|
8
8
|
import { transformationTracer } from '../scenarios/TransformationTracer';
|
|
9
9
|
import { getFileByPathSafe } from '../../utils/getFileByPath';
|
|
10
10
|
import trackEntityCircularDependencies from './trackEntityCircularDependencies';
|
|
11
|
-
import validateDependencyAnalyses from './validateDependencyAnalyses';
|
|
12
11
|
import extractClassMethods from './analyzeEntities/extractClassMethods';
|
|
13
12
|
import prepareDataStructures from './analyzeEntities/prepareDataStructures';
|
|
14
13
|
import { strategies, asyncComplex } from './analyzeEntities/strategies';
|
|
15
14
|
import {
|
|
16
15
|
updateCommitMetadata,
|
|
17
|
-
updateFreshAnalysisMetadata,
|
|
18
16
|
updateFreshAnalysisStatus,
|
|
19
17
|
upsertAnalyses,
|
|
20
18
|
upsertEntities,
|
|
@@ -263,40 +261,11 @@ export default async function analyzeEntities({
|
|
|
263
261
|
}
|
|
264
262
|
}
|
|
265
263
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Validate dependencies, which modifies analysis.metadata.dependentAnalyses
|
|
275
|
-
validateDependencyAnalyses({ analysis, entity: analysis.entity, context });
|
|
276
|
-
|
|
277
|
-
// Carefully update only the metadata field
|
|
278
|
-
if (analysis.id) {
|
|
279
|
-
const updatedMetadata = await updateFreshAnalysisMetadata(
|
|
280
|
-
analysis.id,
|
|
281
|
-
(metadata) => {
|
|
282
|
-
metadata.dependentAnalyses =
|
|
283
|
-
analysis.metadata?.dependentAnalyses || [];
|
|
284
|
-
},
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
if (updatedMetadata) {
|
|
288
|
-
analysis.metadata = updatedMetadata;
|
|
289
|
-
} else {
|
|
290
|
-
console.warn(
|
|
291
|
-
`CodeYam: analyzeEntities: Failed to update metadata for analysis ${analysis.id}`,
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
} else {
|
|
295
|
-
console.warn(
|
|
296
|
-
`CodeYam: analyzeEntities: Analysis ${analysis.filePath}:${analysis.entityName} has no ID, skipping metadata update`,
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
264
|
+
// NOTE: patch-up dependency validation loop was removed here.
|
|
265
|
+
// analysis.metadata.dependentAnalyses is already populated by validateDependencyAnalyses
|
|
266
|
+
// inside analyzeEntity() (Call #1) and persisted via upsertAnalysesWithScenarios at the
|
|
267
|
+
// end of analyzeEntity, then again by upsertAnalyses in analyzeOneEntityKey. Re-validating
|
|
268
|
+
// every analysis from scratch was redundant work — especially costly for large projects.
|
|
300
269
|
|
|
301
270
|
const newlyReady = await updateReadyAnalyses();
|
|
302
271
|
if (newlyReady.length > 0) {
|
package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Entity } from '~codeyam/types';
|
|
2
2
|
import { AnalysisContext } from '../../analysisContext';
|
|
3
|
+
import { awsLogDebugLevel } from '~codeyam/utils';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Optimized version that processes multiple root entities in a single traversal.
|
|
@@ -16,6 +17,8 @@ export default function trackEntityCircularDependencies(
|
|
|
16
17
|
try {
|
|
17
18
|
const allEntities = new Set<Entity>();
|
|
18
19
|
const globalVisited = new Set<string>(); // Track by SHA to avoid duplicate traversals
|
|
20
|
+
let circularCount = 0;
|
|
21
|
+
const startTime = Date.now();
|
|
19
22
|
|
|
20
23
|
// Process each root entity, but skip if already processed
|
|
21
24
|
for (const rootEntity of rootEntities) {
|
|
@@ -32,8 +35,26 @@ export default function trackEntityCircularDependencies(
|
|
|
32
35
|
globalVisited,
|
|
33
36
|
allEntities,
|
|
34
37
|
);
|
|
38
|
+
|
|
39
|
+
// Emit periodic progress for large projects
|
|
40
|
+
if (allEntities.size % 100 === 0 && allEntities.size > 0) {
|
|
41
|
+
awsLogDebugLevel(
|
|
42
|
+
1,
|
|
43
|
+
`Mapping dependencies... (${allEntities.size} entities discovered)`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
35
46
|
}
|
|
36
47
|
|
|
48
|
+
const elapsed = Date.now() - startTime;
|
|
49
|
+
// Count circular deps
|
|
50
|
+
for (const entity of allEntities) {
|
|
51
|
+
if (entity.metadata?.hasCircularDependency) circularCount++;
|
|
52
|
+
}
|
|
53
|
+
awsLogDebugLevel(
|
|
54
|
+
1,
|
|
55
|
+
`Dependency mapping complete: ${allEntities.size} entities, ${circularCount} circular, ${elapsed}ms`,
|
|
56
|
+
);
|
|
57
|
+
|
|
37
58
|
return allEntities;
|
|
38
59
|
} catch (e) {
|
|
39
60
|
console.log(
|