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
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # 🕸️ entkapp Ultimate v5.4.0
1
+ # 🕸️ entkapp Ultimate v5.6.0
2
2
 
3
3
  > **The Ultimate Enterprise Codebase Janitor.** High-speed OXC integration, type-aware analysis, and automated structural healing. Fully standalone architectural orchestrator.
4
4
 
@@ -35,6 +35,12 @@ Starts the interactive analysis:
35
35
  npx entkapp -r
36
36
  ```
37
37
 
38
+ ### Headless Analysis Mode
39
+ Ideal for CI/CD pipelines. Performs analysis without prompts and outputs JSON:
40
+ ```bash
41
+ npx entkapp --analyze
42
+ ```
43
+
38
44
  ### Auto-Fix Mode
39
45
  Automatically resolves dependency conflicts and structural issues:
40
46
  ```bash
package/bin/cli.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  /**
4
4
  * ============================================================================
5
- * 🚀 entkapp: The High-Performance Codebase Orchestrator
5
+ * 🏁 loui CLI Entry Point
6
6
  * ============================================================================
7
- * Command-line interface for executing architectural audits, structural
8
- * refactoring cycles, and autonomous codebase healing.
7
+ * Handles option compilation, environment orchestration, option validation,
8
+ * and initiates the primary operational pipeline loop.
9
9
  */
10
10
 
11
11
  import { Command } from 'commander';
@@ -13,104 +13,163 @@ import ansis from 'ansis';
13
13
  import path from 'path';
14
14
  import fs from 'fs/promises';
15
15
  import { fileURLToPath } from 'url';
16
- import { ConfigLoader } from '../src/resolution/ConfigLoader.js';
16
+ import readline from 'readline/promises';
17
17
 
18
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
- const pkg = JSON.parse(await fs.readFile(path.join(__dirname, '../package.json'), 'utf8'));
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = path.dirname(__filename);
20
20
 
21
21
  const program = new Command();
22
22
 
23
- async function main() {
23
+ async function bootstrap() {
24
24
  try {
25
+ const packageJsonPath = path.resolve(__dirname, '../package.json');
26
+ const packageJsonContent = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
27
+
25
28
  program
26
29
  .name('entkapp')
27
- .description('Autonomous architectural refactoring and codebase optimization engine')
28
- .version(pkg.version)
29
- .argument('[path]', 'Target directory for codebase analysis and refactoring', '.')
30
- .option('-f, --fix', 'Automatically apply identified structural optimizations and healing', false)
30
+ .description(ansis.cyan('The Ultimate Enterprise Codebase Janitor with OXC integration, type-aware analysis, and automated structural healing.'))
31
+ .version(packageJsonContent.version || '5.6.0');
32
+
33
+ program
34
+ .option('-c, --cwd <path>', 'Specify the execution context root directory', process.cwd())
35
+ .option('-d, --debug', 'Developer`s comprehensive telemetry debug diagnostics', false)
36
+ .option('--fix', 'Enable atomic code updates, structural file pruning, and active type sanitization', false)
31
37
  .option('--tsconfig <filename>', 'Specify path to custom layout configurations', 'tsconfig.json')
32
38
  .option('--test-command <command>', 'Integrated continuous safety test validation script execution path', 'npm test')
33
39
  .option('--workspace', 'Enable high-density workspace workspace/monorepo cluster mesh evaluation parsing', false)
34
40
  .option('--verbose', 'Toggle expanded trace telemetry for debug operational diagnostics', false)
35
41
  .option('--visualize', 'Generate an interactive execution graph visualization', false)
36
- .option('-ef, --entry-file <path>', 'Manually specify a primary entry file for analysis')
37
42
  .option('-r, --run', 'Execute the primary operational pipeline loop', false)
38
43
  .option('-y, --yes', 'Skip confirmation prompts and execute planned structural modifications automatically', false)
39
44
  .option('--timeout <ms>', 'Set execution timeout in milliseconds', '30000');
40
45
 
41
46
  program.parse(process.argv);
42
-
43
47
  const options = program.opts();
44
- const targetCwd = path.resolve(process.cwd(), program.args[0] || '.');
45
-
46
- // Load configuration
47
- const configLoader = new ConfigLoader(targetCwd);
48
- const localConfig = await configLoader.loadConfig(options);
49
-
50
- if (options.verbose) {
51
- const summary = {
52
- packages: localConfig.workspacePackages?.length || 0,
53
- tsconfigs: localConfig.workspaceTsConfigs?.length || 0,
54
- configs: localConfig.workspaceConfigFiles?.length || 0
55
- };
56
- console.log(ansis.dim(`[ConfigLoader] Monorepo detected – ${summary.packages} package(s), ${summary.tsconfigs} tsconfig(s), ${summary.configs} *.config file(s) loaded`));
48
+
49
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
50
+
51
+ // --- Onboarding Check (Skipped in Non-Interactive Mode) ---
52
+ // FIX: Ensure options.cwd is always a string, never undefined
53
+ const targetCwd = path.resolve(options.cwd || process.cwd());
54
+ const pkgJsonPath = path.join(targetCwd, 'package.json');
55
+ const configDirPath = path.join(targetCwd, 'entkapp');
56
+
57
+ let pkgJson;
58
+ try {
59
+ pkgJson = JSON.parse(await fs.readFile(pkgJsonPath, 'utf8'));
60
+ } catch (e) {}
61
+
62
+ let configInstalled = false;
63
+ if (!options.yes && !options.run) {
64
+ // 1. Ask to install script
65
+ if (pkgJson && !pkgJson.scripts?.['entkapp:run']) {
66
+ const answer = await rl.question(ansis.bold.yellow('❓ No "entkapp:run" script found in package.json. Install it? (y/n): '));
67
+ if (answer.toLowerCase() === 'y') {
68
+ pkgJson.scripts = pkgJson.scripts || {};
69
+ pkgJson.scripts['entkapp:run'] = 'npx entkapp --fix';
70
+ await fs.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
71
+ console.log(ansis.green('✅ "entkapp:run" script added to package.json.'));
72
+ }
73
+ }
74
+
75
+ // 2. Ask to install config folder
76
+ try {
77
+ await fs.access(configDirPath);
78
+ configInstalled = true;
79
+ } catch (e) {
80
+ const answer = await rl.question(ansis.bold.yellow('❓ No "/entkapp" configuration folder found. Create it with defaults? (y/n): '));
81
+ if (answer.toLowerCase() === 'y') {
82
+ await fs.mkdir(configDirPath, { recursive: true });
83
+ await fs.mkdir(path.join(configDirPath, 'plugins'), { recursive: true });
84
+ const defaultConfig = {
85
+ interface: "CLI",
86
+ useBuiltinPlugins: true,
87
+ useCustomPlugins: true,
88
+
89
+ options: { verbose: false, fastMode: true, selfHealing: true },
90
+ enabledPlugins: ["nextjs", "nuxt", "remix", "sveltekit", "astro"]
91
+ };
92
+ await fs.writeFile(path.join(configDirPath, 'config.json'), JSON.stringify(defaultConfig, null, 2));
93
+ console.log(ansis.green('✅ "/entkapp" folder? and default config created.'));
94
+ configInstalled = true;
95
+ }
96
+ }
97
+
98
+ if (pkgJson?.scripts?.['entkapp:run'] || configInstalled) {
99
+ console.log(ansis.bold.cyan('\n🚀 Setup complete! To start the engine, run:'));
100
+ console.log(ansis.white(` - npx entkapp -r`));
101
+ console.log(ansis.white(` - npm run entkapp:run\n`));
102
+ }
57
103
  }
58
104
 
105
+ rl.close();
106
+
107
+ // Load local config if available
108
+ let localConfig = {};
109
+ try {
110
+ const { ConfigLoader } = await import('../src/resolution/ConfigLoader.js');
111
+ const loader = new ConfigLoader(targetCwd);
112
+ localConfig = await loader.loadConfig();
113
+ } catch (e) {}
114
+
115
+ // Merge options with local config
116
+ const finalInterface = localConfig.interface || 'CLI';
117
+ if (finalInterface === 'GUI') {
118
+ console.log(ansis.bold.magenta('🎨 GUI Mode Detected. Starting Web Interface...'));
119
+ return;
120
+ }
121
+
122
+ // Only proceed to execution if -r/--run is provided
123
+ if (!options.run) {
124
+ return;
125
+ }
126
+
127
+ // --- Timeout Handling ---
128
+ const timeoutMs = parseInt(options.timeout);
59
129
  const timeoutTimer = setTimeout(() => {
60
- console.error(ansis.red(`\n❌ Execution Timeout: Operation exceeded ${options.timeout}ms limit.`));
130
+ console.error(ansis.bold.red(`\n🚨 Execution Timeout: The process exceeded the limit of ${timeoutMs}ms.`));
61
131
  process.exit(1);
62
- }, parseInt(options.timeout));
132
+ }, timeoutMs);
133
+ timeoutTimer.unref(); // Allow process to exit if work finishes
63
134
 
64
- console.log('\n' + ansis.bold.cyan(`📦 entkapp v${pkg.version} Engine Activation`));
135
+ console.log(ansis.bold.green(`\n📦 entkapp v${packageJsonContent.version || '5.6.0'} Engine Activation`));
65
136
  console.log(ansis.dim('------------------------------------------------------------'));
66
- console.log(`${ansis.bold('Target Workspace Root')} : ${targetCwd}`);
67
- console.log(`${ansis.bold('Refactoring Mode')} : ${options.fix ? ansis.yellow('Automated Healing Active') : 'Dry-Run Reporting Only'}`);
68
- console.log(`${ansis.bold('Validation Sandbox')} : ${options.testCommand}`);
137
+ console.log(`${ansis.bold('Target Workspace Root :')} ${ansis.blue(targetCwd)}`);
138
+ console.log(`${ansis.bold('Refactoring Mode :')} ${options.fix ? ansis.yellow('Active Fixing & Self-Healing Enabled') : ansis.gray('Dry-Run Reporting Only')}`);
139
+ console.log(`${ansis.bold('Validation Sandbox :')} ${ansis.magenta(options.testCommand)}`);
69
140
  console.log(ansis.dim('------------------------------------------------------------\n'));
70
141
 
71
142
  const { RefactoringEngine } = await import('../src/index.js');
72
143
 
73
- // Prepare entry points - EXTREMELY ROBUST ARRAY HANDLING
74
- let entryPoints = [];
75
- if (localConfig.entryPoints && typeof localConfig.entryPoints[Symbol.iterator] === 'function') {
76
- entryPoints = [...localConfig.entryPoints];
77
- } else if (localConfig.entryPoints) {
78
- entryPoints = [localConfig.entryPoints];
79
- }
80
-
81
- if (options.entryFile) {
82
- const absEntry = path.resolve(targetCwd, options.entryFile).replace(/\\/g, '/');
83
- if (!entryPoints.includes(absEntry)) {
84
- entryPoints.push(absEntry);
85
- }
86
- }
87
-
88
144
  const engine = new RefactoringEngine({
89
145
  cwd: targetCwd,
90
146
  autoFix: options.fix,
91
147
  tsconfig: options.tsconfig,
92
148
  testCommand: options.testCommand,
93
- workspace: options.workspace || localConfig.workspace || false,
149
+ workspace: options.workspace,
94
150
  verbose: options.verbose,
95
151
  skipConfirm: options.yes,
96
- entryPoints: entryPoints,
97
- exclude: localConfig.exclude || [],
98
- rules: localConfig.rules || {},
152
+ // Pass through local config settings
153
+ entryPoints: localConfig.entryPoints,
154
+ exclude: localConfig.exclude,
155
+ rules: localConfig.rules,
99
156
  debug: options.debug,
100
157
  visualize: options.visualize,
101
- workspacePackages: localConfig.workspacePackages || [],
102
- workspaceTsConfigs: localConfig.workspaceTsConfigs || [],
103
- workspaceConfigFiles: localConfig.workspaceConfigFiles || [],
104
158
  });
105
159
 
106
160
  await engine.run();
107
161
 
108
162
  clearTimeout(timeoutTimer);
109
- } catch (err) {
110
- console.error(ansis.red(`\n❌ Engine Failure: ${err.message}`));
111
- if (program.opts().verbose) console.error(err);
163
+ console.log(ansis.bold.green('\n✨ Core cycle execution completed successfully. Structural layout is clean.'));
164
+ process.exit(0);
165
+
166
+ } catch (criticalBootError) {
167
+ console.error(ansis.bold.red(`\n🚨 Critical Lifecycle Boot Instability: ${criticalBootError.message}`));
168
+ if (criticalBootError.stack) {
169
+ console.error(ansis.dim(criticalBootError.stack));
170
+ }
112
171
  process.exit(1);
113
172
  }
114
173
  }
115
174
 
116
- main();
175
+ bootstrap();
package/bin/cli.mjs ADDED
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * ============================================================================
5
+ * 🏁 loui CLI Entry Point
6
+ * ============================================================================
7
+ * Handles option compilation, environment orchestration, option validation,
8
+ * and initiates the primary operational pipeline loop.
9
+ */
10
+
11
+ import { Command } from 'commander';
12
+ import ansis from 'ansis';
13
+ import path from 'path';
14
+ import fs from 'fs/promises';
15
+ import { fileURLToPath } from 'url';
16
+ import readline from 'readline/promises';
17
+
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = path.dirname(__filename);
20
+
21
+ const program = new Command();
22
+
23
+ async function bootstrap() {
24
+ try {
25
+ const packageJsonPath = path.resolve(__dirname, '../package.json');
26
+ const packageJsonContent = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
27
+
28
+ program
29
+ .name('entkapp')
30
+ .description(ansis.cyan('The Ultimate Enterprise Codebase Janitor with OXC integration, type-aware analysis, and automated structural healing.'))
31
+ .version(packageJsonContent.version || '5.6.0');
32
+
33
+ program
34
+ .option('-c, --cwd <path>', 'Specify the execution context root directory', process.cwd())
35
+ .option('-d, --debug', 'Developer`s comprehensive telemetry debug diagnostics', false)
36
+ .option('--fix', 'Enable atomic code updates, structural file pruning, and active type sanitization', false)
37
+ .option('--tsconfig <filename>', 'Specify path to custom layout configurations', 'tsconfig.json')
38
+ .option('--test-command <command>', 'Integrated continuous safety test validation script execution path', 'npm test')
39
+ .option('--workspace', 'Enable high-density workspace workspace/monorepo cluster mesh evaluation parsing', false)
40
+ .option('--verbose', 'Toggle expanded trace telemetry for debug operational diagnostics', false)
41
+ .option('--visualize', 'Generate an interactive execution graph visualization', false)
42
+ .option('-r, --run', 'Execute the primary operational pipeline loop', false)
43
+ .option('-y, --yes', 'Skip confirmation prompts and execute planned structural modifications automatically', false)
44
+ .option('--timeout <ms>', 'Set execution timeout in milliseconds', '30000');
45
+
46
+ program.parse(process.argv);
47
+ const options = program.opts();
48
+
49
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
50
+
51
+ // --- Onboarding Check (Skipped in Non-Interactive Mode) ---
52
+ // FIX: Ensure options.cwd is always a string, never undefined
53
+ const targetCwd = path.resolve(options.cwd || process.cwd());
54
+ const pkgJsonPath = path.join(targetCwd, 'package.json');
55
+ const configDirPath = path.join(targetCwd, 'entkapp');
56
+
57
+ let pkgJson;
58
+ try {
59
+ pkgJson = JSON.parse(await fs.readFile(pkgJsonPath, 'utf8'));
60
+ } catch (e) {}
61
+
62
+ let configInstalled = false;
63
+ if (!options.yes && !options.run) {
64
+ // 1. Ask to install script
65
+ if (pkgJson && !pkgJson.scripts?.['entkapp:run']) {
66
+ const answer = await rl.question(ansis.bold.yellow('❓ No "entkapp:run" script found in package.json. Install it? (y/n): '));
67
+ if (answer.toLowerCase() === 'y') {
68
+ pkgJson.scripts = pkgJson.scripts || {};
69
+ pkgJson.scripts['entkapp:run'] = 'npx entkapp --fix';
70
+ await fs.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
71
+ console.log(ansis.green('✅ "entkapp:run" script added to package.json.'));
72
+ }
73
+ }
74
+
75
+ // 2. Ask to install config folder
76
+ try {
77
+ await fs.access(configDirPath);
78
+ configInstalled = true;
79
+ } catch (e) {
80
+ const answer = await rl.question(ansis.bold.yellow('❓ No "/entkapp" configuration folder found. Create it with defaults? (y/n): '));
81
+ if (answer.toLowerCase() === 'y') {
82
+ await fs.mkdir(configDirPath, { recursive: true });
83
+ await fs.mkdir(path.join(configDirPath, 'plugins'), { recursive: true });
84
+ const defaultConfig = {
85
+ interface: "CLI",
86
+ useBuiltinPlugins: true,
87
+ useCustomPlugins: true,
88
+
89
+ options: { verbose: false, fastMode: true, selfHealing: true },
90
+ enabledPlugins: ["nextjs", "nuxt", "remix", "sveltekit", "astro"]
91
+ };
92
+ await fs.writeFile(path.join(configDirPath, 'config.json'), JSON.stringify(defaultConfig, null, 2));
93
+ console.log(ansis.green('✅ "/entkapp" folder? and default config created.'));
94
+ configInstalled = true;
95
+ }
96
+ }
97
+
98
+ if (pkgJson?.scripts?.['entkapp:run'] || configInstalled) {
99
+ console.log(ansis.bold.cyan('\n🚀 Setup complete! To start the engine, run:'));
100
+ console.log(ansis.white(` - npx entkapp -r`));
101
+ console.log(ansis.white(` - npm run entkapp:run\n`));
102
+ }
103
+ }
104
+
105
+ rl.close();
106
+
107
+ // Load local config if available
108
+ let localConfig = {};
109
+ try {
110
+ const { ConfigLoader } = await import('../src/resolution/ConfigLoader.mjs');
111
+ const loader = new ConfigLoader(targetCwd);
112
+ localConfig = await loader.loadConfig();
113
+ } catch (e) {}
114
+
115
+ // Merge options with local config
116
+ const finalInterface = localConfig.interface || 'CLI';
117
+ if (finalInterface === 'GUI') {
118
+ console.log(ansis.bold.magenta('🎨 GUI Mode Detected. Starting Web Interface...'));
119
+ return;
120
+ }
121
+
122
+ // Only proceed to execution if -r/--run is provided
123
+ if (!options.run) {
124
+ return;
125
+ }
126
+
127
+ // --- Timeout Handling ---
128
+ const timeoutMs = parseInt(options.timeout);
129
+ const timeoutTimer = setTimeout(() => {
130
+ console.error(ansis.bold.red(`\n🚨 Execution Timeout: The process exceeded the limit of ${timeoutMs}ms.`));
131
+ process.exit(1);
132
+ }, timeoutMs);
133
+ timeoutTimer.unref(); // Allow process to exit if work finishes
134
+
135
+ console.log(ansis.bold.green(`\n📦 entkapp v${packageJsonContent.version || '5.6.0'} Engine Activation`));
136
+ console.log(ansis.dim('------------------------------------------------------------'));
137
+ console.log(`${ansis.bold('Target Workspace Root :')} ${ansis.blue(targetCwd)}`);
138
+ console.log(`${ansis.bold('Refactoring Mode :')} ${options.fix ? ansis.yellow('Active Fixing & Self-Healing Enabled') : ansis.gray('Dry-Run Reporting Only')}`);
139
+ console.log(`${ansis.bold('Validation Sandbox :')} ${ansis.magenta(options.testCommand)}`);
140
+ console.log(ansis.dim('------------------------------------------------------------\n'));
141
+
142
+ const { RefactoringEngine } = await import('../src/index.mjs');
143
+
144
+ const engine = new RefactoringEngine({
145
+ cwd: targetCwd,
146
+ autoFix: options.fix,
147
+ tsconfig: options.tsconfig,
148
+ testCommand: options.testCommand,
149
+ workspace: options.workspace,
150
+ verbose: options.verbose,
151
+ skipConfirm: options.yes,
152
+ // Pass through local config settings
153
+ entryPoints: localConfig.entryPoints,
154
+ exclude: localConfig.exclude,
155
+ rules: localConfig.rules,
156
+ debug: options.debug,
157
+ visualize: options.visualize,
158
+ });
159
+
160
+ await engine.run();
161
+
162
+ clearTimeout(timeoutTimer);
163
+ console.log(ansis.bold.green('\n✨ Core cycle execution completed successfully. Structural layout is clean.'));
164
+ process.exit(0);
165
+
166
+ } catch (criticalBootError) {
167
+ console.error(ansis.bold.red(`\n🚨 Critical Lifecycle Boot Instability: ${criticalBootError.message}`));
168
+ if (criticalBootError.stack) {
169
+ console.error(ansis.dim(criticalBootError.stack));
170
+ }
171
+ process.exit(1);
172
+ }
173
+ }
174
+
175
+ bootstrap();
package/index.cjs ADDED
@@ -0,0 +1,18 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+
4
+ /**
5
+ * entkapp Legacy CJS Wrapper
6
+ * Allows the tool to be used in older Node.js environments.
7
+ */
8
+ module.exports = async function runLegacy() {
9
+ console.log("⚠️ Running in Legacy CommonJS mode...");
10
+ const { EntkappEngine } = await import('./src/index.js');
11
+ const { EngineContext } = await import('./src/EngineContext.js');
12
+
13
+ const targetCwd = process.cwd();
14
+ const context = new EngineContext(targetCwd);
15
+ const engine = new EntkappEngine(context);
16
+
17
+ return engine.run();
18
+ };
package/index.mjs ADDED
@@ -0,0 +1,51 @@
1
+ import path from 'path';
2
+ import fs from 'fs/promises';
3
+ import { existsSync } from 'fs';
4
+ import ansis from 'ansis';
5
+ import { Initializer } from './src/Initializer.mjs';
6
+ import { EngineContext } from './src/EngineContext.mjs';
7
+ import { EntkappEngine } from './src/index.mjs';
8
+
9
+ /**
10
+ * entkapp Ultimate v5.2.0
11
+ * The main interactive entry point that orchestrates the entire workflow.
12
+ */
13
+ async function main() {
14
+ const args = process.argv.slice(2);
15
+ const isVerbose = args.includes('--verbose');
16
+ const cwdIdx = args.indexOf('--cwd');
17
+ const targetCwd = (cwdIdx !== -1 && args[cwdIdx + 1]) ? path.resolve(args[cwdIdx + 1]) : process.cwd();
18
+
19
+ try {
20
+ const context = new EngineContext(targetCwd);
21
+ context.verbose = isVerbose;
22
+ context.options = {
23
+ autoFix: args.includes('--fix'),
24
+ skipConfirm: args.includes('-y') || args.includes('--yes'),
25
+ debug: args.includes('--debug')
26
+ };
27
+
28
+ // 1. Initialize Project (Scaffold / package.json)
29
+ const initializer = new Initializer(context);
30
+ await initializer.run();
31
+
32
+ // 2. Run Engine
33
+ const engine = new EntkappEngine(context);
34
+ await engine.run();
35
+
36
+ } catch (err) {
37
+ console.error(ansis.bold.red(`\n🚨 Critical Lifecycle Failure: ${err.message}`));
38
+ if (isVerbose) console.error(err.stack);
39
+ process.exit(1);
40
+ }
41
+ }
42
+
43
+ // Only run if executed directly
44
+ const currentFilePath = path.resolve(process.argv[1]);
45
+ const indexFilePath = path.resolve(import.meta.url.replace('file://', ''));
46
+
47
+ if (currentFilePath === indexFilePath) {
48
+ main();
49
+ }
50
+
51
+ export { EntkappEngine, EngineContext, Initializer };
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "name": "entkapp",
4
- "version": "5.4.0",
4
+ "version": "5.6.0",
5
5
  "description": "The Ultimate Enterprise Codebase Janitor. High-speed OXC integration, type-aware analysis, and automated structural healing. Fully standalone architectural orchestrator.",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "bin": {
9
- "entkapp": "./bin/cli.js"
9
+ "entkapp": "./bin/cli.mjs"
10
10
  },
11
11
  "scripts": {
12
- "start": "node bin/cli.js",
12
+ "start": "node bin/cli.mjs",
13
13
  "entkapp:run": "npx entkapp --fix",
14
- "test": "echo \"Error: no test specified\" && exit 0",
14
+ "test": "node test.js",
15
15
  "test:stability": "npm run test",
16
16
  "docs:dev": "vitepress dev docs",
17
- "docs:build": "vitepress build docs && cp docs/sitemap.xml docs/.vitepress/dist/ && cp docs/robots.txt docs/.vitepress/dist && cp logo.png docs/.vitepress/dist",
17
+ "docs:build": "vitepress build docs && (cp docs/sitemap.xml docs/.vitepress/dist/ || true) && (cp docs/robots.txt docs/.vitepress/dist || true) && (cp logo.png docs/.vitepress/dist || true)",
18
18
  "docs:preview": "vitepress preview docs"
19
19
  },
20
20
  "keywords": [
@@ -82,7 +82,8 @@
82
82
  "enhanced-resolve": "^5.24.0",
83
83
  "execa": "^8.0.1",
84
84
  "oxc-parser": "^0.135.0",
85
- "typescript": "^5.9.3"
85
+ "typescript": "^5.9.3",
86
+ "glob": "^10.3.10"
86
87
  },
87
88
  "devDependencies": {
88
89
  "@types/node": "^25.9.3",
@@ -419,12 +419,6 @@ export class EngineContext {
419
419
  report.importedUnusedPackages = Array.from(this.importedUnusedPackages);
420
420
  report.unusedBinaries = Array.from(this.unusedBinaries);
421
421
 
422
- // UPGRADE 5.4.3: Integrate enhanced results from GraphAnalyzer
423
- const analyzer = new (await import('./resolution/GraphAnalyzer.js')).GraphAnalyzer(this);
424
- const { unusedImports, boundaryViolations } = await analyzer.findDeadCode();
425
- report.unusedImports = unusedImports;
426
- report.boundaryViolations = boundaryViolations;
427
-
428
422
  return report;
429
423
  }
430
424
  }