entkapp 4.1.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.
- package/.scaffold-ignore +22 -0
- package/LICENSE +211 -0
- package/NOTICE +13 -0
- package/README.md +33 -0
- package/bin/cli.js +174 -0
- package/entkapp/config.json +42 -0
- package/entkapp/plugins/README.md +19 -0
- package/index.js +2254 -0
- package/logo.png +0 -0
- package/package.json +96 -0
- package/src/EngineContext.js +185 -0
- package/src/api/HeadlessAPI.js +376 -0
- package/src/api/PluginSDK.js +299 -0
- package/src/ast/ASTAnalyzer.js +492 -0
- package/src/ast/BarrelParser.js +221 -0
- package/src/ast/DeadCodeDetector.js +73 -0
- package/src/ast/MagicDetector.js +203 -0
- package/src/ast/OxcAnalyzer.js +337 -0
- package/src/ast/SecretScanner.js +304 -0
- package/src/healing/GitSandbox.js +82 -0
- package/src/healing/SelfHealer.js +52 -0
- package/src/index.js +723 -0
- package/src/performance/GraphCache.js +87 -0
- package/src/performance/SupplyChainGuard.js +92 -0
- package/src/performance/WorkerPool.js +109 -0
- package/src/plugins/BasePlugin.js +71 -0
- package/src/plugins/KnipAdapter.js +106 -0
- package/src/plugins/PluginRegistry.js +197 -0
- package/src/plugins/ecosystems/BackendServices.js +61 -0
- package/src/plugins/ecosystems/GenericPlugins.js +64 -0
- package/src/plugins/ecosystems/ModernFrameworks.js +159 -0
- package/src/plugins/ecosystems/MorePlugins.js +184 -0
- package/src/plugins/ecosystems/NextJsPlugin.js +33 -0
- package/src/plugins/ecosystems/PluginLoader.js +20 -0
- package/src/plugins/ecosystems/TypeScriptPlugin.js +56 -0
- package/src/refractor/ImpactAnalyzer.js +92 -0
- package/src/refractor/SourceRewriter.js +86 -0
- package/src/refractor/TransactionManager.js +138 -0
- package/src/refractor/TypeIntegrity.js +75 -0
- package/src/resolution/CircularDetector.js +91 -0
- package/src/resolution/ConfigLoader.js +87 -0
- package/src/resolution/DepencyResolver.js +133 -0
- package/src/resolution/DependencyProfiler.js +268 -0
- package/src/resolution/PathMapper.js +125 -0
- package/src/resolution/WorkSpaceGraph.js +474 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Deterministic Version Control Guard for Structural Healing Operations.
|
|
6
|
+
* Manages atomic state rollbacks when automated refactoring breaks the build.
|
|
7
|
+
*/
|
|
8
|
+
export class GitSandbox {
|
|
9
|
+
constructor(context) {
|
|
10
|
+
this.context = context;
|
|
11
|
+
this.initialBranch = '';
|
|
12
|
+
this.healingBranch = `scaffold-healing-${Date.now()}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Captures the current repository state before applying structural modifications.
|
|
17
|
+
*/
|
|
18
|
+
async captureState() {
|
|
19
|
+
try {
|
|
20
|
+
const { stdout } = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: this.context.cwd });
|
|
21
|
+
this.initialBranch = stdout.trim();
|
|
22
|
+
|
|
23
|
+
// Create a temporary recovery branch
|
|
24
|
+
await execa('git', ['checkout', '-b', this.healingBranch], { cwd: this.context.cwd });
|
|
25
|
+
if (this.context.verbose) {
|
|
26
|
+
console.log(`[Git] State captured in temporary branch: ${this.healingBranch}`);
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
throw new Error(`Git state capture failed: Ensure the directory is a git repository. (${e.message})`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Reverts all changes applied during the healing cycle if verification fails.
|
|
35
|
+
*/
|
|
36
|
+
async rollback() {
|
|
37
|
+
try {
|
|
38
|
+
console.log(`[Git] Rolling back structural modifications...`);
|
|
39
|
+
await execa('git', ['reset', '--hard', 'HEAD'], { cwd: this.context.cwd });
|
|
40
|
+
await execa('git', ['checkout', this.initialBranch], { cwd: this.context.cwd });
|
|
41
|
+
await execa('git', ['branch', '-D', this.healingBranch], { cwd: this.context.cwd });
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(`[Git] Critical rollback failure: ${e.message}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Finalizes the healing cycle by merging changes back to the original branch.
|
|
49
|
+
*/
|
|
50
|
+
async commit() {
|
|
51
|
+
try {
|
|
52
|
+
await execa('git', ['add', '.'], { cwd: this.context.cwd });
|
|
53
|
+
await execa('git', ['commit', '-m', 'chore: automated structural healing (entkapp)'], { cwd: this.context.cwd });
|
|
54
|
+
|
|
55
|
+
await execa('git', ['checkout', this.initialBranch], { cwd: this.context.cwd });
|
|
56
|
+
await execa('git', ['merge', this.healingBranch], { cwd: this.context.cwd });
|
|
57
|
+
await execa('git', ['branch', '-D', this.healingBranch], { cwd: this.context.cwd });
|
|
58
|
+
|
|
59
|
+
if (this.context.verbose) {
|
|
60
|
+
console.log(`[Git] Structural modifications successfully merged into ${this.initialBranch}`);
|
|
61
|
+
}
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error(`[Git] Commit failed: ${e.message}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Runs a verification command (e.g., npm test) to ensure structural integrity.
|
|
69
|
+
*/
|
|
70
|
+
async verifyIntegrity() {
|
|
71
|
+
try {
|
|
72
|
+
const [cmd, ...args] = this.context.testCommand.split(' ');
|
|
73
|
+
await execa(cmd, args, { cwd: this.context.cwd });
|
|
74
|
+
return true;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
if (this.context.verbose) {
|
|
77
|
+
console.warn(`[Git] Integrity verification failed: ${e.message}`);
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import ansis from 'ansis';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Automated Structural Healing Orchestrator.
|
|
5
|
+
* Manages the lifecycle of applying structural fixes and verifying codebase health.
|
|
6
|
+
* This is a deterministic engine and does not use AI/LLMs.
|
|
7
|
+
*/
|
|
8
|
+
export class SelfHealer {
|
|
9
|
+
constructor(context, txManager, gitSandbox) {
|
|
10
|
+
this.context = context;
|
|
11
|
+
this.txManager = txManager;
|
|
12
|
+
this.gitSandbox = gitSandbox;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Executes a structural healing cycle with automatic rollback on failure.
|
|
17
|
+
* @param {Function} refactorLogic - Async function that stages structural changes
|
|
18
|
+
*/
|
|
19
|
+
async runSelfHealingLifecycle(refactorLogic) {
|
|
20
|
+
console.log(ansis.bold.blue('\n🩹 Initiating Automated Structural Healing Cycle...'));
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
// 1. Capture current stable state
|
|
24
|
+
await this.gitSandbox.captureState();
|
|
25
|
+
|
|
26
|
+
// 1b. Initialize transaction tracking
|
|
27
|
+
await this.txManager.begin();
|
|
28
|
+
|
|
29
|
+
// 2. Execute the provided refactoring logic (staging deletions/writes)
|
|
30
|
+
await refactorLogic();
|
|
31
|
+
|
|
32
|
+
// 3. Commit staged changes to disk
|
|
33
|
+
await this.txManager.commit();
|
|
34
|
+
|
|
35
|
+
// 4. Verify structural integrity (e.g., run tests)
|
|
36
|
+
console.log(ansis.dim('🧪 Verifying codebase integrity...'));
|
|
37
|
+
const isHealthy = await this.gitSandbox.verifyIntegrity();
|
|
38
|
+
|
|
39
|
+
if (isHealthy) {
|
|
40
|
+
console.log(ansis.bold.green('✅ Structural integrity verified. Finalizing changes.'));
|
|
41
|
+
await this.gitSandbox.commit();
|
|
42
|
+
} else {
|
|
43
|
+
console.log(ansis.bold.red('❌ Structural integrity compromised. Rolling back changes.'));
|
|
44
|
+
await this.gitSandbox.rollback();
|
|
45
|
+
this.context.metrics.securityVulnerabilitiesMitigated = 0; // Reset metrics for failed cycle
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(ansis.bold.red(`\n🚨 Healing Cycle Aborted: ${error.message}`));
|
|
49
|
+
await this.gitSandbox.rollback();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|