entkapp 5.4.0 → 5.6.0

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.
Files changed (76) hide show
  1. package/README.md +7 -1
  2. package/bin/cli.js +117 -58
  3. package/bin/cli.mjs +175 -0
  4. package/index.cjs +18 -0
  5. package/index.mjs +51 -0
  6. package/package.json +7 -6
  7. package/src/EngineContext.js +0 -6
  8. package/src/EngineContext.mjs +428 -0
  9. package/src/Initializer.mjs +82 -0
  10. package/src/analyzers/CodeSmellAnalyzer.mjs +106 -0
  11. package/src/analyzers/OxcAnalyzer.mjs +11 -0
  12. package/src/api/HeadlessAPI.js +31 -16
  13. package/src/api/HeadlessAPI.mjs +369 -0
  14. package/src/api/PluginSDK.mjs +135 -0
  15. package/src/ast/ASTAnalyzer.js +23 -97
  16. package/src/ast/ASTAnalyzer.mjs +742 -0
  17. package/src/ast/AdvancedAnalysis.mjs +586 -0
  18. package/src/ast/BarrelParser.mjs +230 -0
  19. package/src/ast/DeadCodeDetector.js +7 -5
  20. package/src/ast/DeadCodeDetector.mjs +92 -0
  21. package/src/ast/MagicDetector.js +43 -23
  22. package/src/ast/MagicDetector.mjs +203 -0
  23. package/src/ast/OxcAnalyzer.js +27 -190
  24. package/src/ast/OxcAnalyzer.mjs +188 -0
  25. package/src/ast/SecretScanner.mjs +374 -0
  26. package/src/healing/GitSandbox.mjs +82 -0
  27. package/src/healing/SelfHealer.mjs +48 -0
  28. package/src/index.js +41 -88
  29. package/src/index.mjs +1176 -0
  30. package/src/performance/GraphCache.js +0 -27
  31. package/src/performance/GraphCache.mjs +108 -0
  32. package/src/performance/SupplyChainGuard.mjs +92 -0
  33. package/src/performance/WorkerPool.js +4 -22
  34. package/src/performance/WorkerPool.mjs +132 -0
  35. package/src/performance/WorkerTaskRunner.js +0 -26
  36. package/src/performance/WorkerTaskRunner.mjs +144 -0
  37. package/src/plugins/BasePlugin.js +27 -16
  38. package/src/plugins/BasePlugin.mjs +240 -0
  39. package/src/plugins/PluginRegistry.js +0 -44
  40. package/src/plugins/PluginRegistry.mjs +203 -0
  41. package/src/plugins/ecosystems/BackendServices.mjs +197 -0
  42. package/src/plugins/ecosystems/GenericPlugins.mjs +142 -0
  43. package/src/plugins/ecosystems/ModernFrameworks.mjs +162 -0
  44. package/src/plugins/ecosystems/MorePlugins.mjs +562 -0
  45. package/src/plugins/ecosystems/NewPlugins.mjs +526 -0
  46. package/src/plugins/ecosystems/NextJsPlugin.mjs +45 -0
  47. package/src/plugins/ecosystems/PluginLoader.mjs +193 -0
  48. package/src/plugins/ecosystems/TypeScriptPlugin.mjs +56 -0
  49. package/src/plugins/ecosystems/UltimateBundle.js +0 -259
  50. package/src/plugins/ecosystems/UltimateBundle.mjs +1182 -0
  51. package/src/refractor/ImpactAnalyzer.mjs +92 -0
  52. package/src/refractor/SourceRewriter.mjs +86 -0
  53. package/src/refractor/TransactionManager.mjs +5 -0
  54. package/src/refractor/TypeIntegrity.mjs +4 -0
  55. package/src/resolution/BuildOrchestrator.mjs +46 -0
  56. package/src/resolution/CircularDetector.mjs +91 -0
  57. package/src/resolution/ConfigGenerator.mjs +83 -0
  58. package/src/resolution/ConfigLoader.js +26 -190
  59. package/src/resolution/ConfigLoader.mjs +94 -0
  60. package/src/resolution/DepencyResolver.mjs +66 -0
  61. package/src/resolution/DependencyFixer.mjs +88 -0
  62. package/src/resolution/DependencyProfiler.mjs +286 -0
  63. package/src/resolution/EntryPointDetector.mjs +134 -0
  64. package/src/resolution/FrameworkConfigParser.mjs +119 -0
  65. package/src/resolution/GraphAnalyzer.js +1 -65
  66. package/src/resolution/GraphAnalyzer.mjs +80 -0
  67. package/src/resolution/MigrationAnalyzer.mjs +60 -0
  68. package/src/resolution/PathMapper.js +0 -81
  69. package/src/resolution/PathMapper.mjs +82 -0
  70. package/src/resolution/TSConfigLoader.js +1 -3
  71. package/src/resolution/TSConfigLoader.mjs +162 -0
  72. package/src/resolution/WorkSpaceGraph.js +89 -260
  73. package/src/resolution/WorkSpaceGraph.mjs +183 -0
  74. package/src/resolution/WorkspaceDiagnostic.mjs +139 -0
  75. package/test.js +76 -0
  76. package/wrangler.toml +6 -0
@@ -66,6 +66,17 @@ export class ASTAnalyzer {
66
66
  fileNode.isPureBarrel = true;
67
67
  }
68
68
 
69
+ // ADVANCED: Deep reachability analysis for dynamic imports
70
+ if (fileNode.dynamicImports.size > 0) {
71
+ fileNode.dynamicImports.forEach(specifier => {
72
+ const resolved = this.resolveAbsoluteTargetFile(specifier, filePath);
73
+ if (resolved) {
74
+ fileNode.outgoingEdges.add(resolved);
75
+ this.context.getOrCreateNode(resolved).isDynamicEntry = true;
76
+ }
77
+ });
78
+ }
79
+
69
80
  this.scopeStack = [];
70
81
  this.currentScope = null;
71
82
  }
@@ -222,6 +233,9 @@ export class ASTAnalyzer {
222
233
  case ts.SyntaxKind.ExpressionStatement:
223
234
  this.handleAssignmentExpressionPass1(node, fileNode, sourceFile);
224
235
  break;
236
+ case ts.SyntaxKind.ExportDeclaration:
237
+ this.handleExportDeclaration(node, fileNode, sourceFile);
238
+ break;
225
239
  }
226
240
  } else {
227
241
  // --- PASS 2: REFERENCE TRACKING ---
@@ -265,16 +279,7 @@ export class ASTAnalyzer {
265
279
  fileNode.explicitImports.add(specifier);
266
280
  fileNode.importedSymbols.add(`${specifier}:*`);
267
281
  if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
268
- // UPGRADE: Apply alias/workspace filtering before adding to externalPackageUsage
269
- const pkgNameReq = this._extractPackageName(specifier);
270
- let isInternalReq = false;
271
- if (this.context.pathMapper && typeof this.context.pathMapper.isTsconfigAlias === 'function') {
272
- if (this.context.pathMapper.isTsconfigAlias(specifier) || this.context.pathMapper.isTsconfigAlias(pkgNameReq)) isInternalReq = true;
273
- }
274
- if (!isInternalReq && this.context.workspaceGraph && typeof this.context.workspaceGraph.isLocalWorkspaceSpecifier === 'function') {
275
- if (this.context.workspaceGraph.isLocalWorkspaceSpecifier(specifier) || this.context.workspaceGraph.isLocalWorkspaceSpecifier(pkgNameReq)) isInternalReq = true;
276
- }
277
- if (!isInternalReq) fileNode.externalPackageUsage.add(pkgNameReq);
282
+ fileNode.externalPackageUsage.add(this._extractPackageName(specifier));
278
283
  }
279
284
  } else if (arg && ts.isTemplateExpression(arg)) {
280
285
  // Dynamic require with template literal
@@ -360,40 +365,8 @@ export class ASTAnalyzer {
360
365
  const specifier = node.moduleSpecifier.text;
361
366
  fileNode.explicitImports.add(specifier);
362
367
 
363
- // UPGRADE 5.4.2: Distinguish between local aliases and workspace packages
364
368
  if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
365
- let isInternalAlias = false;
366
- const pkgName = this._extractPackageName(specifier);
367
-
368
- // UPGRADE: First check via isTsconfigAlias() — works even when the target file doesn't exist yet
369
- if (this.context.pathMapper && typeof this.context.pathMapper.isTsconfigAlias === 'function') {
370
- if (this.context.pathMapper.isTsconfigAlias(specifier) || this.context.pathMapper.isTsconfigAlias(pkgName)) {
371
- isInternalAlias = true;
372
- }
373
- }
374
-
375
- // UPGRADE: Check workspace packages (pnpm-workspace.yaml / package.json workspaces)
376
- if (!isInternalAlias && this.context.workspaceGraph && typeof this.context.workspaceGraph.isLocalWorkspaceSpecifier === 'function') {
377
- if (this.context.workspaceGraph.isLocalWorkspaceSpecifier(specifier) || this.context.workspaceGraph.isLocalWorkspaceSpecifier(pkgName)) {
378
- isInternalAlias = true;
379
- }
380
- }
381
-
382
- // Fallback: try resolvePath() — works when the target file exists on disk
383
- if (!isInternalAlias && this.context.pathMapper && typeof this.context.pathMapper.resolvePath === 'function') {
384
- const resolved = this.context.pathMapper.resolvePath(specifier);
385
- if (resolved !== specifier && (resolved.startsWith('/') || resolved.includes(':'))) {
386
- // Only mark as internal alias if it's NOT a registered workspace package
387
- const isWorkspacePkg = this.context.workspaceGraph && this.context.workspaceGraph.isLocalWorkspaceSpecifier(pkgName);
388
- if (!isWorkspacePkg) {
389
- isInternalAlias = true;
390
- }
391
- }
392
- }
393
-
394
- if (!isInternalAlias) {
395
- fileNode.externalPackageUsage.add(pkgName);
396
- }
369
+ fileNode.externalPackageUsage.add(this._extractPackageName(specifier));
397
370
  }
398
371
 
399
372
  if (this.context.workspaceGraph && typeof this.context.workspaceGraph.auditImportSpecifier === 'function') {
@@ -414,29 +387,14 @@ export class ASTAnalyzer {
414
387
  if (ts.isNamespaceImport(node.importClause.namedBindings)) {
415
388
  fileNode.importedSymbols.add(`${specifier}:*`);
416
389
  if (targetFile) this.context.importUsageRegistry.add(`${targetFile}:*`);
417
-
418
- // Track local name for unused import detection
419
- if (!fileNode.localImportBindings) fileNode.localImportBindings = new Map();
420
- fileNode.localImportBindings.set(node.importClause.namedBindings.name.text, { specifier, originalName: '*' });
421
390
  } else if (ts.isNamedImports(node.importClause.namedBindings)) {
422
391
  node.importClause.namedBindings.elements.forEach(element => {
423
392
  const importedName = element.propertyName ? element.propertyName.text : element.name.text;
424
- const localName = element.name.text;
425
393
  fileNode.importedSymbols.add(`${specifier}:${importedName}`);
426
394
  if (targetFile) this.context.importUsageRegistry.add(`${targetFile}:${importedName}`);
427
-
428
- // Track local name for unused import detection
429
- if (!fileNode.localImportBindings) fileNode.localImportBindings = new Map();
430
- fileNode.localImportBindings.set(localName, { specifier, originalName: importedName });
431
395
  });
432
396
  }
433
397
  }
434
-
435
- // Handle default import binding
436
- if (node.importClause.name) {
437
- if (!fileNode.localImportBindings) fileNode.localImportBindings = new Map();
438
- fileNode.localImportBindings.set(node.importClause.name.text, { specifier, originalName: 'default' });
439
- }
440
398
  } else {
441
399
  // Side-Effect Import (import '...')
442
400
  // FIX: Mark the target file as used even if no symbols are imported
@@ -479,22 +437,7 @@ export class ASTAnalyzer {
479
437
  if (specifier) {
480
438
  fileNode.explicitImports.add(specifier);
481
439
  if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
482
- // UPGRADE: Apply the same alias/workspace filtering as handleImportDeclaration
483
- const pkgNameExport = this._extractPackageName(specifier);
484
- let isInternalAliasExport = false;
485
- if (this.context.pathMapper && typeof this.context.pathMapper.isTsconfigAlias === 'function') {
486
- if (this.context.pathMapper.isTsconfigAlias(specifier) || this.context.pathMapper.isTsconfigAlias(pkgNameExport)) {
487
- isInternalAliasExport = true;
488
- }
489
- }
490
- if (!isInternalAliasExport && this.context.workspaceGraph && typeof this.context.workspaceGraph.isLocalWorkspaceSpecifier === 'function') {
491
- if (this.context.workspaceGraph.isLocalWorkspaceSpecifier(specifier) || this.context.workspaceGraph.isLocalWorkspaceSpecifier(pkgNameExport)) {
492
- isInternalAliasExport = true;
493
- }
494
- }
495
- if (!isInternalAliasExport) {
496
- fileNode.externalPackageUsage.add(pkgNameExport);
497
- }
440
+ fileNode.externalPackageUsage.add(this._extractPackageName(specifier));
498
441
  }
499
442
 
500
443
  if (!node.exportClause) {
@@ -658,23 +601,14 @@ export class ASTAnalyzer {
658
601
  fileNode.dynamicImports.add(specifier);
659
602
  fileNode.importedSymbols.add(`${specifier}:*`);
660
603
  if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
661
- // UPGRADE: Apply alias/workspace filtering before adding to externalPackageUsage
662
- const pkgNameDyn = this._extractPackageName(specifier);
663
- let isInternalDyn = false;
664
- if (this.context.pathMapper && typeof this.context.pathMapper.isTsconfigAlias === 'function') {
665
- if (this.context.pathMapper.isTsconfigAlias(specifier) || this.context.pathMapper.isTsconfigAlias(pkgNameDyn)) isInternalDyn = true;
666
- }
667
- if (!isInternalDyn && this.context.workspaceGraph && typeof this.context.workspaceGraph.isLocalWorkspaceSpecifier === 'function') {
668
- if (this.context.workspaceGraph.isLocalWorkspaceSpecifier(specifier) || this.context.workspaceGraph.isLocalWorkspaceSpecifier(pkgNameDyn)) isInternalDyn = true;
669
- }
670
- if (!isInternalDyn) fileNode.externalPackageUsage.add(pkgNameDyn);
604
+ fileNode.externalPackageUsage.add(this._extractPackageName(specifier));
671
605
  }
672
606
  } else {
673
607
  // Non-literal dynamic import
674
- if (!Array.isArray(fileNode.calculatedDynamicImports)) {
675
- fileNode.calculatedDynamicImports = [];
608
+ if (!fileNode.calculatedDynamicImports || Array.isArray(fileNode.calculatedDynamicImports)) {
609
+ fileNode.calculatedDynamicImports = new Set();
676
610
  }
677
- fileNode.calculatedDynamicImports.push({ kind: ts.SyntaxKind[arg.kind], start: arg.getStart(sourceFile) });
611
+ fileNode.calculatedDynamicImports.add({ kind: ts.SyntaxKind[arg.kind], start: arg.getStart(sourceFile) });
678
612
 
679
613
  // UPGRADE 2: Try to perform Glob-Analysis on Template Strings
680
614
  this.handlePartialEvaluation(arg, fileNode, sourceFile);
@@ -688,17 +622,9 @@ export class ASTAnalyzer {
688
622
  if (this.context.verbose) console.log(`[AST-DEBUG] Added import: ${specifier}`);
689
623
  fileNode.explicitImports.add(specifier);
690
624
 
691
- // UPGRADE: Apply alias/workspace filtering before adding to externalPackageUsage
625
+ // UPGRADE: Also track package usage for unlisted dependency detection
692
626
  if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
693
- const pkgNameCE = this._extractPackageName(specifier);
694
- let isInternalCE = false;
695
- if (this.context.pathMapper && typeof this.context.pathMapper.isTsconfigAlias === 'function') {
696
- if (this.context.pathMapper.isTsconfigAlias(specifier) || this.context.pathMapper.isTsconfigAlias(pkgNameCE)) isInternalCE = true;
697
- }
698
- if (!isInternalCE && this.context.workspaceGraph && typeof this.context.workspaceGraph.isLocalWorkspaceSpecifier === 'function') {
699
- if (this.context.workspaceGraph.isLocalWorkspaceSpecifier(specifier) || this.context.workspaceGraph.isLocalWorkspaceSpecifier(pkgNameCE)) isInternalCE = true;
700
- }
701
- if (!isInternalCE) fileNode.externalPackageUsage.add(pkgNameCE);
627
+ fileNode.externalPackageUsage.add(this._extractPackageName(specifier));
702
628
  }
703
629
  }
704
630
  }