pumuki-ast-hooks 5.5.3 → 5.5.5

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 (80) hide show
  1. package/package.json +2 -2
  2. package/scripts/hooks-system/.audit-reports/auto-recovery.log +2 -0
  3. package/scripts/hooks-system/.audit-reports/install-wizard.log +8 -0
  4. package/scripts/hooks-system/.audit_tmp/audit.log +0 -0
  5. package/scripts/hooks-system/.audit_tmp/hook-metrics.jsonl +48 -0
  6. package/scripts/hooks-system/.hook-system/config.json +8 -0
  7. package/scripts/hooks-system/application/CompositionRoot.js +31 -19
  8. package/scripts/hooks-system/application/factories/AdapterFactory.js +6 -6
  9. package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +0 -2
  10. package/scripts/hooks-system/application/services/RealtimeGuardService.js +146 -2
  11. package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +0 -1
  12. package/scripts/hooks-system/application/services/guard/EvidenceManager.js +31 -7
  13. package/scripts/hooks-system/application/services/guard/GitTreeManager.js +43 -11
  14. package/scripts/hooks-system/application/services/guard/GuardNotifier.js +2 -2
  15. package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +0 -2
  16. package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +0 -3
  17. package/scripts/hooks-system/application/services/installation/InstallService.js +2 -4
  18. package/scripts/hooks-system/application/services/installation/McpConfigurator.js +9 -2
  19. package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +1 -1
  20. package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +0 -2
  21. package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +0 -2
  22. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +0 -3
  23. package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +22 -0
  24. package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +1 -1
  25. package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +0 -1
  26. package/scripts/hooks-system/application/services/token/TokenMetricsService.js +1 -1
  27. package/scripts/hooks-system/application/services/token/TokenMonitorService.js +0 -1
  28. package/scripts/hooks-system/application/use-cases/AnalyzeCodebaseUseCase.js +0 -2
  29. package/scripts/hooks-system/application/use-cases/AnalyzeStagedFilesUseCase.js +0 -2
  30. package/scripts/hooks-system/application/use-cases/AutoExecuteAIStartUseCase.js +0 -1
  31. package/scripts/hooks-system/application/use-cases/BlockCommitUseCase.js +0 -2
  32. package/scripts/hooks-system/application/use-cases/GenerateAuditReportUseCase.js +0 -3
  33. package/scripts/hooks-system/bin/cli.js +16 -0
  34. package/scripts/hooks-system/domain/services/AuditResultSerializer.js +0 -5
  35. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTIntelligentAnalyzer.js +0 -2
  36. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTParser.js +0 -2
  37. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js +0 -2
  38. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidArchitectureDetector.js +5 -7
  39. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidClassAnalyzer.js +0 -3
  40. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidForbiddenLiteralsAnalyzer.js +0 -1
  41. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidSOLIDAnalyzer.js +0 -2
  42. package/scripts/hooks-system/infrastructure/ast/archive/ios-rules.js +0 -2
  43. package/scripts/hooks-system/infrastructure/ast/archive/kotlin-analyzer.js +0 -2
  44. package/scripts/hooks-system/infrastructure/ast/archive/kotlin-parser.js +0 -2
  45. package/scripts/hooks-system/infrastructure/ast/archive/swift-analyzer.js +0 -2
  46. package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendArchitectureDetector.js +0 -2
  47. package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendPatternDetector.js +0 -2
  48. package/scripts/hooks-system/infrastructure/ast/common/BDDTDDWorkflowRules.js +0 -2
  49. package/scripts/hooks-system/infrastructure/ast/common/rules/BDDRules.js +0 -2
  50. package/scripts/hooks-system/infrastructure/ast/common/rules/ImplementationRules.js +0 -2
  51. package/scripts/hooks-system/infrastructure/ast/common/rules/TDDRules.js +0 -2
  52. package/scripts/hooks-system/infrastructure/ast/common/rules/WorkflowRules.js +0 -2
  53. package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendArchitectureDetector.js +14 -16
  54. package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendForbiddenLiteralsAnalyzer.js +0 -5
  55. package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendSOLIDAnalyzer.js +0 -2
  56. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +17 -2
  57. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureDetector.js +10 -12
  58. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureRules.js +0 -2
  59. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSCICDRules.js +0 -2
  60. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSEnterpriseAnalyzer.js +0 -2
  61. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSForbiddenLiteralsAnalyzer.js +0 -1
  62. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSNetworkingAdvancedRules.js +0 -2
  63. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSPerformanceRules.js +0 -3
  64. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSSPMRules.js +0 -2
  65. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSSwiftUIAdvancedRules.js +0 -2
  66. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSTestingAdvancedRules.js +0 -2
  67. package/scripts/hooks-system/infrastructure/ast/ios/native-bridge.js +0 -1
  68. package/scripts/hooks-system/infrastructure/ast/ios/parsers/SourceKittenParser.js +0 -2
  69. package/scripts/hooks-system/infrastructure/logging/UnifiedLoggerFactory.js +1 -1
  70. package/scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js +149 -57
  71. package/scripts/hooks-system/infrastructure/mcp/services/McpProtocolHandler.js +14 -6
  72. package/scripts/hooks-system/infrastructure/repositories/CursorTokenRepository.js +0 -2
  73. package/scripts/hooks-system/infrastructure/repositories/FileFindingsRepository.js +0 -2
  74. package/scripts/hooks-system/infrastructure/repositories/datasources/CursorApiDataSource.js +1 -3
  75. package/scripts/hooks-system/infrastructure/repositories/datasources/CursorFileDataSource.js +0 -2
  76. package/scripts/hooks-system/infrastructure/severity/severity-evaluator.js +0 -2
  77. package/scripts/hooks-system/infrastructure/telemetry/TelemetryService.js +0 -2
  78. package/scripts/hooks-system/infrastructure/utils/token-manager.js +0 -2
  79. package/scripts/hooks-system/infrastructure/validators/enforce-english-literals.js +1 -1
  80. package/scripts/hooks-system/infrastructure/watchdog/__tests__/.audit-reports/token-monitor.log +9 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki-ast-hooks",
3
- "version": "5.5.3",
3
+ "version": "5.5.5",
4
4
  "description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -123,4 +123,4 @@
123
123
  "./skills": "./skills/skill-rules.json",
124
124
  "./hooks": "./hooks/index.js"
125
125
  }
126
- }
126
+ }
@@ -2,3 +2,5 @@
2
2
  {"timestamp":"2025-12-29T14:01:15.120Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
3
3
  {"timestamp":"2025-12-30T08:17:43.107Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
4
4
  {"timestamp":"2025-12-30T08:18:14.228Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
5
+ {"timestamp":"2026-01-03T13:32:38.778Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
6
+ {"timestamp":"2026-01-03T13:47:40.470Z","level":"info","component":"AutoRecovery","event":"NotificationCenterService shutdown","data":{"totalEnqueued":0,"totalSent":0,"totalDeduplicated":0,"totalCooldownSkipped":0,"totalFailed":0,"totalRetries":0,"queueSize":0,"deduplication":{"size":0},"cooldowns":{"activeCooldowns":0}},"context":{}}
@@ -14,3 +14,11 @@
14
14
  {"timestamp":"2025-12-30T08:18:14.294Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_CONFIG_EXISTS","data":{"configPath":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.hook-system/config.json"},"context":{}}
15
15
  {"timestamp":"2025-12-30T08:18:14.294Z","level":"error","component":"InstallWizard","event":"INSTALL_WIZARD_SYMLINK_FAILED","data":{"error":"EEXIST: file already exists, symlink '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/scripts/hooks-system/bin/guard-supervisor.js' -> '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.git/hooks/guard-supervisor'"},"context":{}}
16
16
  {"timestamp":"2025-12-30T08:18:14.294Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_COMPLETED","data":{},"context":{}}
17
+ {"timestamp":"2026-01-03T13:32:37.619Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_START","data":{"repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"},"context":{}}
18
+ {"timestamp":"2026-01-03T13:32:37.624Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_CONFIG_CREATED","data":{"configPath":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.hook-system/config.json"},"context":{}}
19
+ {"timestamp":"2026-01-03T13:32:37.625Z","level":"error","component":"InstallWizard","event":"INSTALL_WIZARD_SYMLINK_FAILED","data":{"error":"EEXIST: file already exists, symlink '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/scripts/hooks-system/bin/guard-supervisor.js' -> '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.git/hooks/guard-supervisor'"},"context":{}}
20
+ {"timestamp":"2026-01-03T13:32:37.625Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_COMPLETED","data":{},"context":{}}
21
+ {"timestamp":"2026-01-03T13:47:40.566Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_START","data":{"repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"},"context":{}}
22
+ {"timestamp":"2026-01-03T13:47:40.570Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_CONFIG_EXISTS","data":{"configPath":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.hook-system/config.json"},"context":{}}
23
+ {"timestamp":"2026-01-03T13:47:40.571Z","level":"error","component":"InstallWizard","event":"INSTALL_WIZARD_SYMLINK_FAILED","data":{"error":"EEXIST: file already exists, symlink '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/scripts/hooks-system/bin/guard-supervisor.js' -> '/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system/.git/hooks/guard-supervisor'"},"context":{}}
24
+ {"timestamp":"2026-01-03T13:47:40.571Z","level":"info","component":"InstallWizard","event":"INSTALL_WIZARD_COMPLETED","data":{},"context":{}}
File without changes
@@ -0,0 +1,48 @@
1
+ {"timestamp":1767447158775,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
2
+ {"timestamp":1767447158776,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
3
+ {"timestamp":1767447158776,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
4
+ {"timestamp":1767447158776,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
5
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
6
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
7
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
8
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
9
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
10
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
11
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
12
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
13
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
14
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
15
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
16
+ {"timestamp":1767447158777,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
17
+ {"timestamp":1767447158778,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
18
+ {"timestamp":1767447158778,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
19
+ {"timestamp":1767447158778,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
20
+ {"timestamp":1767447158778,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
21
+ {"timestamp":1767447158778,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
22
+ {"timestamp":1767447158778,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
23
+ {"timestamp":1767447158778,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
24
+ {"timestamp":1767447158778,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
25
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
26
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
27
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
28
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
29
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
30
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
31
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
32
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
33
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
34
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
35
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
36
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
37
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
38
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
39
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
40
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
41
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
42
+ {"timestamp":1767448060469,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
43
+ {"timestamp":1767448060470,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
44
+ {"timestamp":1767448060470,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
45
+ {"timestamp":1767448060470,"hook":"audit_logger","operation":"constructor","status":"started","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
46
+ {"timestamp":1767448060470,"hook":"audit_logger","operation":"ensure_dir","status":"started"}
47
+ {"timestamp":1767448060470,"hook":"audit_logger","operation":"ensure_dir","status":"success"}
48
+ {"timestamp":1767448060470,"hook":"audit_logger","operation":"constructor","status":"success","repoRoot":"/Users/juancarlosmerlosalbarracin/Developer/Projects/ast-intelligence-hooks/scripts/hooks-system"}
@@ -0,0 +1,8 @@
1
+ {
2
+ "notification": {
3
+ "enabled": true
4
+ },
5
+ "recovery": {
6
+ "maxAttempts": 5
7
+ }
8
+ }
@@ -19,29 +19,32 @@ class CompositionRoot {
19
19
  this._serviceFactory = null;
20
20
  this._monitorFactory = null;
21
21
 
22
- // Create dynamic proxy for automatic delegation
23
22
  return new Proxy(this, {
24
23
  get(target, prop) {
25
- // If method exists in CompositionRoot, use it
26
- if (typeof target[prop] === 'function' && target.hasOwnProperty(prop)) {
24
+ if (typeof target[prop] === 'function' && Object.prototype.hasOwnProperty.call(target, prop)) {
27
25
  return target[prop].bind(target);
28
26
  }
29
27
 
30
- // Delegate to specialized factories
31
- if (target._serviceFactory && typeof target._serviceFactory[prop] === 'function') {
32
- return target._serviceFactory[prop].bind(target._serviceFactory);
28
+ if (prop === '_serviceFactory') return target._getServiceFactory();
29
+ if (prop === '_adapterFactory') return target._getAdapterFactory();
30
+ if (prop === '_monitorFactory') return target._getMonitorFactory();
31
+
32
+ if (typeof prop === 'string' && prop.startsWith('get')) {
33
+ const serviceFactory = target._getServiceFactory();
34
+ if (serviceFactory && typeof serviceFactory[prop] === 'function') {
35
+ return serviceFactory[prop].bind(serviceFactory);
36
+ }
37
+
38
+ const adapterFactory = target._getAdapterFactory();
39
+ if (adapterFactory && typeof adapterFactory[prop] === 'function') {
40
+ return adapterFactory[prop].bind(adapterFactory);
41
+ }
42
+
43
+ const monitorFactory = target._getMonitorFactory();
44
+ if (monitorFactory && typeof monitorFactory[prop] === 'function') {
45
+ return monitorFactory[prop].bind(monitorFactory);
46
+ }
33
47
  }
34
- if (target._adapterFactory && typeof target._adapterFactory[prop] === 'function') {
35
- return target._adapterFactory[prop].bind(target._adapterFactory);
36
- }
37
- if (target._monitorFactory && typeof target._monitorFactory[prop] === 'function') {
38
- return target._monitorFactory[prop].bind(target._monitorFactory);
39
- }
40
-
41
- // Para acceso a propiedades de factories
42
- if (prop === '_serviceFactory') return target._serviceFactory;
43
- if (prop === '_adapterFactory') return target._adapterFactory;
44
- if (prop === '_monitorFactory') return target._monitorFactory;
45
48
 
46
49
  return target[prop];
47
50
  }
@@ -58,14 +61,23 @@ class CompositionRoot {
58
61
 
59
62
  _getAdapterFactory() {
60
63
  if (!this._adapterFactory) {
61
- this._adapterFactory = new AdapterFactory(this.repoRoot, this.instances, this.getLogger());
64
+ this._adapterFactory = new AdapterFactory(this.repoRoot, this.instances, null);
62
65
  }
63
66
  return this._adapterFactory;
64
67
  }
65
68
 
66
69
  _getServiceFactory() {
67
70
  if (!this._serviceFactory) {
68
- this._serviceFactory = new ServiceFactory(this.repoRoot, this.instances, this._getAdapterFactory());
71
+ const adapterFactory = this._getAdapterFactory();
72
+ this._serviceFactory = new ServiceFactory(this.repoRoot, this.instances, adapterFactory);
73
+ try {
74
+ if (adapterFactory && !adapterFactory.logger) {
75
+ adapterFactory.logger = this._serviceFactory.getLogger();
76
+ }
77
+ } catch (error) {
78
+ const msg = error && error.message ? error.message : String(error);
79
+ this._serviceFactory?.getLogger?.()?.debug?.('COMPOSITIONROOT_ADAPTER_LOGGER_BIND_FAILED', { error: msg });
80
+ }
69
81
  }
70
82
  return this._serviceFactory;
71
83
  }
@@ -1,9 +1,9 @@
1
- const MacOSNotificationAdapter = require('../../adapters/MacOSNotificationAdapter');
2
- const FileEvidenceAdapter = require('../../adapters/FileEvidenceAdapter');
3
- const GitQueryAdapter = require('../../adapters/GitQueryAdapter');
4
- const GitCommandAdapter = require('../../adapters/GitCommandAdapter');
5
- const GitHubCliAdapter = require('../../adapters/GitHubCliAdapter');
6
- const AstAnalyzerAdapter = require('../../adapters/AstAnalyzerAdapter');
1
+ const MacOSNotificationAdapter = require('../../infrastructure/adapters/MacOSNotificationAdapter');
2
+ const FileEvidenceAdapter = require('../../infrastructure/adapters/FileEvidenceAdapter');
3
+ const GitQueryAdapter = require('../../infrastructure/adapters/GitQueryAdapter');
4
+ const GitCommandAdapter = require('../../infrastructure/adapters/GitCommandAdapter');
5
+ const GitHubCliAdapter = require('../../infrastructure/adapters/GitHubCliAdapter');
6
+ const AstAnalyzerAdapter = require('../../infrastructure/adapters/AstAnalyzerAdapter');
7
7
 
8
8
  class AdapterFactory {
9
9
  constructor(repoRoot, instances, logger) {
@@ -1,13 +1,11 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
- const AuditLogger = require('./logging/AuditLogger');
4
3
 
5
4
  const METRICS_FILE = path.join(process.cwd(), '.audit_tmp', 'hook-metrics.jsonl');
6
5
 
7
6
  class PredictiveHookAdvisor {
8
7
  constructor({ windowSize = 200 } = {}) {
9
8
  this.windowSize = windowSize;
10
- this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
11
9
  }
12
10
 
13
11
  loadMetrics() {
@@ -50,12 +50,156 @@ class RealtimeGuardService {
50
50
  );
51
51
  this.notifier.setDebugLogPath(this.config.debugLogPath);
52
52
 
53
- this.evidenceManager = new EvidenceManager(this.evidencePath, this.notifier, this.auditLogger);
54
- this.gitTreeManager = new GitTreeManager(this.notifier, this.auditLogger);
53
+ this.evidenceManager = new EvidenceManager(this.evidencePath, this.notifier, this.auditLogger, this);
54
+ this.gitTreeManager = new GitTreeManager(this.notifier, this.auditLogger, this);
55
55
 
56
56
  this.watchers = [];
57
57
  }
58
58
 
59
+ get staleThresholdMs() {
60
+ return this.evidenceManager.staleThresholdMs;
61
+ }
62
+
63
+ set staleThresholdMs(value) {
64
+ this.evidenceManager.staleThresholdMs = value;
65
+ }
66
+
67
+ get reminderIntervalMs() {
68
+ return this.evidenceManager.reminderIntervalMs;
69
+ }
70
+
71
+ set reminderIntervalMs(value) {
72
+ this.evidenceManager.reminderIntervalMs = value;
73
+ }
74
+
75
+ get pollIntervalMs() {
76
+ return this.evidenceManager.pollIntervalMs;
77
+ }
78
+
79
+ set pollIntervalMs(value) {
80
+ this.evidenceManager.pollIntervalMs = value;
81
+ }
82
+
83
+ get pollTimer() {
84
+ return this.evidenceManager.pollTimer;
85
+ }
86
+
87
+ set pollTimer(value) {
88
+ this.evidenceManager.pollTimer = value;
89
+ }
90
+
91
+ get lastStaleNotification() {
92
+ return this.evidenceManager.lastStaleNotification;
93
+ }
94
+
95
+ set lastStaleNotification(value) {
96
+ this.evidenceManager.lastStaleNotification = value;
97
+ }
98
+
99
+ get lastUserActivityAt() {
100
+ return this.evidenceManager.lastUserActivityAt;
101
+ }
102
+
103
+ set lastUserActivityAt(value) {
104
+ this.evidenceManager.lastUserActivityAt = value;
105
+ }
106
+
107
+ get inactivityGraceMs() {
108
+ return this.evidenceManager.inactivityGraceMs;
109
+ }
110
+
111
+ set inactivityGraceMs(value) {
112
+ this.evidenceManager.inactivityGraceMs = value;
113
+ }
114
+
115
+ get autoRefreshCooldownMs() {
116
+ return this.evidenceManager.autoRefreshCooldownMs;
117
+ }
118
+
119
+ set autoRefreshCooldownMs(value) {
120
+ this.evidenceManager.autoRefreshCooldownMs = value;
121
+ }
122
+
123
+ get lastAutoRefresh() {
124
+ return this.evidenceManager.lastAutoRefresh;
125
+ }
126
+
127
+ set lastAutoRefresh(value) {
128
+ this.evidenceManager.lastAutoRefresh = value;
129
+ }
130
+
131
+ get autoRefreshInFlight() {
132
+ return this.evidenceManager.autoRefreshInFlight;
133
+ }
134
+
135
+ set autoRefreshInFlight(value) {
136
+ this.evidenceManager.autoRefreshInFlight = value;
137
+ }
138
+
139
+ get gitTreeStagedThreshold() {
140
+ return this.gitTreeManager.gitTreeStagedThreshold;
141
+ }
142
+
143
+ set gitTreeStagedThreshold(value) {
144
+ this.gitTreeManager.gitTreeStagedThreshold = value;
145
+ }
146
+
147
+ get gitTreeUnstagedThreshold() {
148
+ return this.gitTreeManager.gitTreeUnstagedThreshold;
149
+ }
150
+
151
+ set gitTreeUnstagedThreshold(value) {
152
+ this.gitTreeManager.gitTreeUnstagedThreshold = value;
153
+ }
154
+
155
+ get gitTreeTotalThreshold() {
156
+ return this.gitTreeManager.gitTreeTotalThreshold;
157
+ }
158
+
159
+ set gitTreeTotalThreshold(value) {
160
+ this.gitTreeManager.gitTreeTotalThreshold = value;
161
+ }
162
+
163
+ get gitTreeCheckIntervalMs() {
164
+ return this.gitTreeManager.gitTreeCheckIntervalMs;
165
+ }
166
+
167
+ set gitTreeCheckIntervalMs(value) {
168
+ this.gitTreeManager.gitTreeCheckIntervalMs = value;
169
+ }
170
+
171
+ get gitTreeReminderMs() {
172
+ return this.gitTreeManager.gitTreeReminderMs;
173
+ }
174
+
175
+ set gitTreeReminderMs(value) {
176
+ this.gitTreeManager.gitTreeReminderMs = value;
177
+ }
178
+
179
+ get gitTreeTimer() {
180
+ return this.gitTreeManager.gitTreeTimer;
181
+ }
182
+
183
+ set gitTreeTimer(value) {
184
+ this.gitTreeManager.gitTreeTimer = value;
185
+ }
186
+
187
+ get lastDirtyTreeNotification() {
188
+ return this.gitTreeManager.lastDirtyTreeNotification;
189
+ }
190
+
191
+ set lastDirtyTreeNotification(value) {
192
+ this.gitTreeManager.lastDirtyTreeNotification = value;
193
+ }
194
+
195
+ get dirtyTreeActive() {
196
+ return this.gitTreeManager.dirtyTreeActive;
197
+ }
198
+
199
+ set dirtyTreeActive(value) {
200
+ this.gitTreeManager.dirtyTreeActive = value;
201
+ }
202
+
59
203
  start() {
60
204
  this.logger.info('Starting RealtimeGuardService...');
61
205
  this.auditLogger.record({ action: 'guard.realtime.start', resource: 'realtime_guard', status: 'success' });
@@ -12,7 +12,6 @@ class SmartDirtyTreeAnalyzer {
12
12
  } = {}) {
13
13
  this.repoRoot = repoRoot;
14
14
  this.logger = logger;
15
- this.auditLogger = new AuditLogger({ repoRoot, logger });
16
15
 
17
16
  this.featureDetector = new FeatureDetector(logger);
18
17
  this.grouper = new FileContextGrouper(this.featureDetector, platformDetector);
@@ -4,10 +4,11 @@ const { recordMetric } = require('../../../infrastructure/telemetry/metrics-logg
4
4
  const env = require('../../../config/env.js');
5
5
 
6
6
  class EvidenceManager {
7
- constructor(evidencePath, notifier, auditLogger) {
7
+ constructor(evidencePath, notifier, auditLogger, delegate = null) {
8
8
  this.evidencePath = evidencePath;
9
9
  this.notifier = notifier;
10
10
  this.auditLogger = auditLogger;
11
+ this.delegate = delegate;
11
12
  this.staleThresholdMs = env.getNumber('HOOK_GUARD_EVIDENCE_STALE_THRESHOLD', 60000);
12
13
  this.reminderIntervalMs = env.getNumber('HOOK_GUARD_EVIDENCE_REMINDER_INTERVAL', 60000);
13
14
  this.inactivityGraceMs = env.getNumber('HOOK_GUARD_INACTIVITY_GRACE_MS', 120000);
@@ -31,7 +32,11 @@ class EvidenceManager {
31
32
  if (this.pollIntervalMs <= 0) return;
32
33
 
33
34
  this.pollTimer = setInterval(() => {
34
- this.evaluateEvidenceAge('polling');
35
+ if (this.delegate && typeof this.delegate.evaluateEvidenceAge === 'function') {
36
+ this.delegate.evaluateEvidenceAge('polling');
37
+ } else {
38
+ this.evaluateEvidenceAge('polling');
39
+ }
35
40
  }, this.pollIntervalMs);
36
41
  }
37
42
 
@@ -63,7 +68,9 @@ class EvidenceManager {
63
68
 
64
69
  evaluateEvidenceAge(source = 'manual', notifyFresh = false) {
65
70
  const now = Date.now();
66
- const timestamp = this.readEvidenceTimestamp();
71
+ const timestamp = (this.delegate && typeof this.delegate.readEvidenceTimestamp === 'function')
72
+ ? this.delegate.readEvidenceTimestamp()
73
+ : this.readEvidenceTimestamp();
67
74
  if (!timestamp) return;
68
75
 
69
76
  const ageMs = now - timestamp;
@@ -71,12 +78,20 @@ class EvidenceManager {
71
78
  const isRecentlyActive = this.lastUserActivityAt && (now - this.lastUserActivityAt) < this.inactivityGraceMs;
72
79
 
73
80
  if (isStale && !isRecentlyActive) {
74
- this.triggerStaleAlert(source, ageMs);
81
+ if (this.delegate && typeof this.delegate.triggerStaleAlert === 'function') {
82
+ this.delegate.triggerStaleAlert(source, ageMs);
83
+ } else {
84
+ this.triggerStaleAlert(source, ageMs);
85
+ }
75
86
  return;
76
87
  }
77
88
 
78
89
  if (notifyFresh && this.lastStaleNotification > 0 && !isStale) {
79
- this.notifier.notify('Evidence updated; back within SLA.', 'info');
90
+ if (this.delegate && typeof this.delegate.notify === 'function') {
91
+ this.delegate.notify('Evidence updated; back within SLA.', 'info');
92
+ } else {
93
+ this.notifier.notify('Evidence updated; back within SLA.', 'info');
94
+ }
80
95
  this.lastStaleNotification = 0;
81
96
  }
82
97
  }
@@ -89,7 +104,12 @@ class EvidenceManager {
89
104
 
90
105
  this.lastStaleNotification = now;
91
106
  const ageSec = Math.floor(ageMs / 1000);
92
- this.notifier.notify(`Evidence has been stale for ${ageSec}s (source: ${source}).`, 'warn', { forceDialog: true });
107
+ const message = `Evidence has been stale for ${ageSec}s (source: ${source}).`;
108
+ if (this.delegate && typeof this.delegate.notify === 'function') {
109
+ this.delegate.notify(message, 'warn', { forceDialog: true });
110
+ } else {
111
+ this.notifier.notify(message, 'warn', { forceDialog: true });
112
+ }
93
113
  this.auditLogger.record({
94
114
  action: 'guard.evidence.stale',
95
115
  resource: 'evidence',
@@ -97,7 +117,11 @@ class EvidenceManager {
97
117
  meta: { ageSec, source }
98
118
  });
99
119
  recordMetric({ hook: 'evidence', status: 'stale', ageSec, source });
100
- this.attemptAutoRefresh('stale');
120
+ if (this.delegate && typeof this.delegate.attemptAutoRefresh === 'function') {
121
+ this.delegate.attemptAutoRefresh('stale');
122
+ } else {
123
+ this.attemptAutoRefresh('stale');
124
+ }
101
125
 
102
126
  if (this.onStale) this.onStale();
103
127
  }
@@ -5,9 +5,10 @@ const path = require('path');
5
5
  const fs = require('fs');
6
6
 
7
7
  class GitTreeManager {
8
- constructor(notifier, auditLogger) {
8
+ constructor(notifier, auditLogger, delegate = null) {
9
9
  this.notifier = notifier;
10
10
  this.auditLogger = auditLogger;
11
+ this.delegate = delegate;
11
12
  this.gitTreeStagedThreshold = env.getNumber('HOOK_GUARD_DIRTY_TREE_STAGED_LIMIT', 10);
12
13
  this.gitTreeUnstagedThreshold = env.getNumber('HOOK_GUARD_DIRTY_TREE_UNSTAGED_LIMIT', 15);
13
14
  this.gitTreeTotalThreshold = env.getNumber('HOOK_GUARD_DIRTY_TREE_TOTAL_LIMIT', 20);
@@ -30,9 +31,17 @@ class GitTreeManager {
30
31
  const thresholdsValid = this.gitTreeStagedThreshold > 0 || this.gitTreeUnstagedThreshold > 0 || this.gitTreeTotalThreshold > 0;
31
32
  if (!thresholdsValid || this.gitTreeCheckIntervalMs <= 0) return;
32
33
 
33
- this.evaluateGitTree();
34
- this.gitTreeTimer = setInterval(() => {
34
+ if (this.delegate && typeof this.delegate.evaluateGitTree === 'function') {
35
+ this.delegate.evaluateGitTree();
36
+ } else {
35
37
  this.evaluateGitTree();
38
+ }
39
+ this.gitTreeTimer = setInterval(() => {
40
+ if (this.delegate && typeof this.delegate.evaluateGitTree === 'function') {
41
+ this.delegate.evaluateGitTree();
42
+ } else {
43
+ this.evaluateGitTree();
44
+ }
36
45
  }, this.gitTreeCheckIntervalMs);
37
46
  }
38
47
 
@@ -53,10 +62,18 @@ class GitTreeManager {
53
62
  };
54
63
 
55
64
  if (isTreeBeyondLimit(state, limits)) {
56
- this.handleDirtyTree(state, limits);
65
+ if (this.delegate && typeof this.delegate.handleDirtyTree === 'function') {
66
+ this.delegate.handleDirtyTree(state, limits);
67
+ } else {
68
+ this.handleDirtyTree(state, limits);
69
+ }
57
70
  return;
58
71
  }
59
- this.resolveDirtyTree(state, limits);
72
+ if (this.delegate && typeof this.delegate.resolveDirtyTree === 'function') {
73
+ this.delegate.resolveDirtyTree(state, limits);
74
+ } else {
75
+ this.resolveDirtyTree(state, limits);
76
+ }
60
77
  } catch (error) {
61
78
  this.notifier.appendDebugLog(`DIRTY_TREE_ERROR|${error.message}`);
62
79
  }
@@ -64,7 +81,11 @@ class GitTreeManager {
64
81
 
65
82
  resolveDirtyTree(_state, _limits) {
66
83
  this.dirtyTreeActive = false;
67
- this.notifier.notify('✅ Git tree is clean', 'success');
84
+ if (this.delegate && typeof this.delegate.notify === 'function') {
85
+ this.delegate.notify('✅ Git tree is clean', 'success');
86
+ } else {
87
+ this.notifier.notify('✅ Git tree is clean', 'success');
88
+ }
68
89
  this.auditLogger.record({
69
90
  action: 'guard.git_tree.clean',
70
91
  resource: 'git_tree',
@@ -89,16 +110,27 @@ class GitTreeManager {
89
110
 
90
111
  this.lastDirtyTreeNotification = now;
91
112
  this.dirtyTreeActive = true;
92
- const message = `Git tree has too many files: ${_state.total} total (${_state.staged} staged, ${_state.unstaged} unstaged)`;
93
- this.notifier.notify(message, 'error', { forceDialog: true, ...limits });
113
+ const staged = Number.isFinite(_state?.stagedCount) ? _state.stagedCount : (_state?.staged ?? 0);
114
+ const working = Number.isFinite(_state?.workingCount) ? _state.workingCount : (_state?.unstaged ?? 0);
115
+ const unique = Number.isFinite(_state?.uniqueCount) ? _state.uniqueCount : (_state?.total ?? 0);
116
+ const message = `Git tree has too many files: ${unique} total (${staged} staged, ${working} unstaged)`;
117
+ if (this.delegate && typeof this.delegate.notify === 'function') {
118
+ this.delegate.notify(message, 'error', { forceDialog: true, ...limits });
119
+ } else {
120
+ this.notifier.notify(message, 'error', { forceDialog: true, ...limits });
121
+ }
94
122
  this.auditLogger.record({
95
123
  action: 'guard.git_tree.dirty',
96
124
  resource: 'git_tree',
97
125
  status: 'warning',
98
- meta: { total: _state.total, staged: _state.staged, unstaged: _state.unstaged }
126
+ meta: { total: unique, staged, unstaged: working }
99
127
  });
100
- recordMetric({ hook: 'git_tree', status: 'dirty', total: _state.total, staged: _state.staged, unstaged: _state.unstaged });
101
- this.persistDirtyTreeState();
128
+ recordMetric({ hook: 'git_tree', status: 'dirty', total: unique, staged, unstaged: working });
129
+ if (this.delegate && typeof this.delegate.persistDirtyTreeState === 'function') {
130
+ this.delegate.persistDirtyTreeState();
131
+ } else {
132
+ this.persistDirtyTreeState();
133
+ }
102
134
 
103
135
  if (this.onStateChange) {
104
136
  this.onStateChange({ isBeyondLimit: true, ..._state });
@@ -4,8 +4,8 @@ const AuditLogger = require('../logging/AuditLogger');
4
4
 
5
5
  class GuardNotifier {
6
6
  constructor(logger, notificationService, notifier = null, notificationsEnabled = true) {
7
-
8
- this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });this.logger = logger;
7
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
8
+ this.logger = logger;
9
9
  this.notificationService = notificationService;
10
10
  this.notifier = typeof notifier === 'function' ? notifier : null;
11
11
  this.notificationsEnabled = notificationsEnabled;
@@ -1,5 +1,4 @@
1
1
  const env = require('../../config/env');
2
- const AuditLogger = require('../logging/AuditLogger');
3
2
 
4
3
  const fs = require('fs');
5
4
  const path = require('path');
@@ -14,7 +13,6 @@ const COLORS = {
14
13
  class ConfigurationGeneratorService {
15
14
  constructor(targetRoot, hookSystemRoot) {
16
15
  this.targetRoot = targetRoot || process.cwd();
17
- this.auditLogger = new AuditLogger({ repoRoot: this.targetRoot });
18
16
  this.hookSystemRoot = hookSystemRoot;
19
17
  }
20
18
 
@@ -1,7 +1,6 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { execSync, spawnSync } = require('child_process');
4
- const AuditLogger = require('../logging/AuditLogger');
5
4
 
6
5
  const COLORS = {
7
6
  reset: '\x1b[0m',
@@ -14,8 +13,6 @@ const COLORS = {
14
13
 
15
14
  class GitEnvironmentService {
16
15
  constructor(targetRoot, version = 'unknown') {
17
- this.targetRoot = targetRoot || process.cwd();
18
- this.auditLogger = new AuditLogger({ repoRoot: this.targetRoot });
19
16
  this.targetRoot = targetRoot || process.cwd();
20
17
  this.version = version;
21
18
  }
@@ -1,8 +1,6 @@
1
- const env = require('../../config/env');
2
- const AuditLogger = require('../logging/AuditLogger');
3
-
4
- const path = require('path');
1
+ const env = require('../../../config/env.js');
5
2
  const fs = require('fs');
3
+ const path = require('path');
6
4
 
7
5
  const GitEnvironmentService = require('./GitEnvironmentService');
8
6
  const PlatformDetectorService = require('./PlatformDetectorService');