pumuki-ast-hooks 5.5.60 → 5.5.65

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 (26) hide show
  1. package/README.md +254 -1140
  2. package/docs/ARCHITECTURE.md +66 -1
  3. package/docs/TODO.md +41 -0
  4. package/docs/images/ast_intelligence_01.svg +40 -0
  5. package/docs/images/ast_intelligence_02.svg +39 -0
  6. package/docs/images/ast_intelligence_03.svg +55 -0
  7. package/docs/images/ast_intelligence_04.svg +39 -0
  8. package/docs/images/ast_intelligence_05.svg +45 -0
  9. package/docs/images/logo.png +0 -0
  10. package/package.json +1 -1
  11. package/scripts/hooks-system/.audit_tmp/hook-metrics.jsonl +16 -0
  12. package/scripts/hooks-system/application/DIValidationService.js +43 -0
  13. package/scripts/hooks-system/application/__tests__/DIValidationService.spec.js +81 -0
  14. package/scripts/hooks-system/config/di-rules.json +42 -0
  15. package/scripts/hooks-system/domain/ports/FileSystemPort.js +19 -0
  16. package/scripts/hooks-system/domain/strategies/ConcreteDependencyStrategy.js +78 -0
  17. package/scripts/hooks-system/domain/strategies/DIStrategy.js +31 -0
  18. package/scripts/hooks-system/infrastructure/adapters/NodeFileSystemAdapter.js +28 -0
  19. package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +16 -0
  20. package/scripts/hooks-system/infrastructure/ast/backend/detectors/god-class-detector.js +28 -8
  21. package/scripts/hooks-system/infrastructure/ast/common/ast-common.js +133 -0
  22. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +3 -2
  23. package/scripts/hooks-system/infrastructure/ast/ios/ast-ios.js +1 -1
  24. package/scripts/hooks-system/infrastructure/ast/ios/detectors/ios-ast-intelligent-strategies.js +40 -46
  25. package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +87 -1
  26. package/scripts/hooks-system/infrastructure/registry/StrategyRegistry.js +63 -0
@@ -0,0 +1,63 @@
1
+ const path = require('path');
2
+
3
+ class StrategyRegistry {
4
+ constructor(fileSystemPort, configPath) {
5
+ this.strategies = new Map();
6
+ this.fileSystemPort = fileSystemPort;
7
+ this.configPath = configPath;
8
+ this.config = null;
9
+ }
10
+
11
+ async loadStrategies() {
12
+ this.config = await this._loadConfig();
13
+ const strategiesDir = this.fileSystemPort.resolvePath(__dirname, '../..', 'domain', 'strategies');
14
+
15
+ const exists = await this.fileSystemPort.exists(strategiesDir);
16
+ if (!exists) {
17
+ throw new Error(`Strategies directory not found at ${strategiesDir}`);
18
+ }
19
+
20
+ const files = await this.fileSystemPort.readDir(strategiesDir);
21
+
22
+ for (const file of files) {
23
+ if (file.endsWith('Strategy.js') && !file.includes('DIStrategy.js')) {
24
+ const strategyPath = path.join(strategiesDir, file);
25
+ const StrategyClass = require(strategyPath);
26
+
27
+ if (typeof StrategyClass === 'function') {
28
+ const strategy = new StrategyClass(this.config.dependencyInjection);
29
+ this.strategies.set(strategy.id, strategy);
30
+ }
31
+ }
32
+ }
33
+ }
34
+
35
+ getStrategy(id) {
36
+ return this.strategies.get(id);
37
+ }
38
+
39
+ getAllStrategies() {
40
+ return Array.from(this.strategies.values());
41
+ }
42
+
43
+ findStrategiesForNode(node, context) {
44
+ return this.getAllStrategies().filter(strategy =>
45
+ strategy.canHandle(node, context)
46
+ );
47
+ }
48
+
49
+ async _loadConfig() {
50
+ try {
51
+ const configContent = await this.fileSystemPort.readFile(
52
+ this.configPath,
53
+ 'utf8'
54
+ );
55
+ return JSON.parse(configContent);
56
+ } catch (error) {
57
+ console.error(`Failed to load config from ${this.configPath}:`, error);
58
+ return { dependencyInjection: {} };
59
+ }
60
+ }
61
+ }
62
+
63
+ module.exports = StrategyRegistry;