pumuki-ast-hooks 5.4.5 → 5.4.6

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 (164) hide show
  1. package/package.json +2 -2
  2. package/scripts/hooks-system/application/services/AutonomousOrchestrator.js +2 -0
  3. package/scripts/hooks-system/application/services/ContextDetectionEngine.js +2 -0
  4. package/scripts/hooks-system/application/services/DynamicRulesLoader.js +3 -1
  5. package/scripts/hooks-system/application/services/GitFlowService.js +2 -0
  6. package/scripts/hooks-system/application/services/GitTreeState.js +1 -0
  7. package/scripts/hooks-system/application/services/HookSystemScheduler.js +2 -0
  8. package/scripts/hooks-system/application/services/IntelligentCommitAnalyzer.js +4 -1
  9. package/scripts/hooks-system/application/services/IntelligentGitTreeMonitor.js +2 -0
  10. package/scripts/hooks-system/application/services/PlatformAnalysisService.js +2 -0
  11. package/scripts/hooks-system/application/services/PlatformDetectionService.js +3 -1
  12. package/scripts/hooks-system/application/services/PlaybookRunner.js +3 -0
  13. package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +2 -0
  14. package/scripts/hooks-system/application/services/RealtimeGuardPlugin.js +2 -0
  15. package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +2 -0
  16. package/scripts/hooks-system/application/services/commit/CommitMessageGenerator.js +3 -1
  17. package/scripts/hooks-system/application/services/commit/FeatureDetector.js +5 -1
  18. package/scripts/hooks-system/application/services/evidence/EvidenceContextManager.js +1 -0
  19. package/scripts/hooks-system/application/services/guard/GuardAutoManagerService.js +1 -0
  20. package/scripts/hooks-system/application/services/guard/GuardConfig.js +3 -1
  21. package/scripts/hooks-system/application/services/guard/GuardEventLogger.js +2 -0
  22. package/scripts/hooks-system/application/services/guard/GuardHealthReminder.js +5 -1
  23. package/scripts/hooks-system/application/services/guard/GuardHeartbeatMonitor.js +2 -0
  24. package/scripts/hooks-system/application/services/guard/GuardLockManager.js +2 -0
  25. package/scripts/hooks-system/application/services/guard/GuardMonitorLoop.js +3 -1
  26. package/scripts/hooks-system/application/services/guard/GuardNotificationHandler.js +4 -0
  27. package/scripts/hooks-system/application/services/guard/GuardNotifier.js +3 -1
  28. package/scripts/hooks-system/application/services/guard/GuardProcessManager.js +2 -0
  29. package/scripts/hooks-system/application/services/guard/GuardRecoveryService.js +3 -0
  30. package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +4 -0
  31. package/scripts/hooks-system/application/services/installation/FileSystemInstallerService.js +3 -0
  32. package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +3 -0
  33. package/scripts/hooks-system/application/services/installation/HookInstaller.js +4 -0
  34. package/scripts/hooks-system/application/services/installation/IdeIntegrationService.js +3 -0
  35. package/scripts/hooks-system/application/services/installation/InstallService.js +3 -0
  36. package/scripts/hooks-system/application/services/installation/McpConfigurator.js +1 -0
  37. package/scripts/hooks-system/application/services/installation/PlatformDetectorService.js +4 -0
  38. package/scripts/hooks-system/application/services/installation/VSCodeTaskConfigurator.js +4 -0
  39. package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +2 -0
  40. package/scripts/hooks-system/application/services/monitoring/ActivityMonitor.js +2 -0
  41. package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +2 -0
  42. package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +2 -0
  43. package/scripts/hooks-system/application/services/monitoring/EvidenceMonitor.js +2 -0
  44. package/scripts/hooks-system/application/services/monitoring/EvidenceMonitorService.js +1 -0
  45. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitor.js +2 -0
  46. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +3 -0
  47. package/scripts/hooks-system/application/services/monitoring/HealthCheckService.js +2 -0
  48. package/scripts/hooks-system/application/services/monitoring/HeartbeatMonitorService.js +2 -0
  49. package/scripts/hooks-system/application/services/monitoring/TokenMonitor.js +2 -0
  50. package/scripts/hooks-system/application/services/notification/MacNotificationSender.js +2 -0
  51. package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +2 -0
  52. package/scripts/hooks-system/application/services/notification/NotificationDispatcher.js +3 -0
  53. package/scripts/hooks-system/application/services/notification/components/NotificationCooldownManager.js +3 -0
  54. package/scripts/hooks-system/application/services/notification/components/NotificationDeduplicator.js +2 -0
  55. package/scripts/hooks-system/application/services/notification/components/NotificationQueue.js +3 -0
  56. package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +4 -0
  57. package/scripts/hooks-system/application/services/platform/PlatformHeuristics.js +2 -0
  58. package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +2 -0
  59. package/scripts/hooks-system/application/services/smart-commit/CommitMessageSuggester.js +4 -0
  60. package/scripts/hooks-system/application/services/smart-commit/FileContextGrouper.js +2 -0
  61. package/scripts/hooks-system/application/services/smart-commit/SmartCommitSummaryBuilder.js +6 -0
  62. package/scripts/hooks-system/application/services/token/CursorTokenService.js +1 -0
  63. package/scripts/hooks-system/application/services/token/TokenMetricsService.js +4 -0
  64. package/scripts/hooks-system/application/services/token/TokenMonitorService.js +1 -0
  65. package/scripts/hooks-system/application/services/token/TokenStatusReporter.js +2 -0
  66. package/scripts/hooks-system/application/state/HookSystemStateMachine.js +2 -0
  67. package/scripts/hooks-system/application/use-cases/AnalyzeCodebaseUseCase.js +2 -0
  68. package/scripts/hooks-system/application/use-cases/AnalyzeStagedFilesUseCase.js +2 -0
  69. package/scripts/hooks-system/application/use-cases/AutoExecuteAIStartUseCase.js +2 -0
  70. package/scripts/hooks-system/application/use-cases/BlockCommitUseCase.js +2 -0
  71. package/scripts/hooks-system/application/use-cases/GenerateAuditReportUseCase.js +3 -0
  72. package/scripts/hooks-system/bin/audit-library.js +5 -4
  73. package/scripts/hooks-system/bin/auto-fix-violations.js +1 -0
  74. package/scripts/hooks-system/bin/auto-restart-guards.js +3 -2
  75. package/scripts/hooks-system/bin/check-doc-drift.js +1 -0
  76. package/scripts/hooks-system/bin/check-version.js +26 -25
  77. package/scripts/hooks-system/bin/cli.js +1 -0
  78. package/scripts/hooks-system/bin/guard-auto-manager.js +1 -0
  79. package/scripts/hooks-system/bin/guard-supervisor.js +1 -0
  80. package/scripts/hooks-system/bin/hook-status.js +1 -0
  81. package/scripts/hooks-system/bin/install.js +1 -0
  82. package/scripts/hooks-system/bin/nightly-metrics-report.js +1 -0
  83. package/scripts/hooks-system/bin/plan-review.js +1 -0
  84. package/scripts/hooks-system/bin/predictive-hooks.js +1 -0
  85. package/scripts/hooks-system/bin/pumuki-audit.js +1 -0
  86. package/scripts/hooks-system/bin/pumuki-init.js +1 -0
  87. package/scripts/hooks-system/bin/pumuki-mcp.js +1 -0
  88. package/scripts/hooks-system/bin/pumuki-rules.js +1 -0
  89. package/scripts/hooks-system/bin/run-ast-adapter.js +2 -0
  90. package/scripts/hooks-system/bin/run-orchestrator.js +1 -0
  91. package/scripts/hooks-system/bin/run-playbook.js +1 -0
  92. package/scripts/hooks-system/bin/setup-eslint.js +1 -0
  93. package/scripts/hooks-system/bin/violations-api.js +1 -0
  94. package/scripts/hooks-system/bin/watch-hooks.js +1 -0
  95. package/scripts/hooks-system/domain/errors/index.js +2 -0
  96. package/scripts/hooks-system/domain/services/AuditAnalyzer.js +2 -0
  97. package/scripts/hooks-system/domain/services/AuditFilter.js +5 -0
  98. package/scripts/hooks-system/domain/services/AuditResultSerializer.js +5 -0
  99. package/scripts/hooks-system/domain/services/AuditScorer.js +6 -0
  100. package/scripts/hooks-system/infrastructure/adapters/AstAnalyzerAdapter.js +3 -0
  101. package/scripts/hooks-system/infrastructure/adapters/FileEvidenceAdapter.js +2 -0
  102. package/scripts/hooks-system/infrastructure/adapters/GitCliAdapter.js +4 -0
  103. package/scripts/hooks-system/infrastructure/adapters/GitCommandAdapter.js +4 -0
  104. package/scripts/hooks-system/infrastructure/adapters/GitHubCliAdapter.js +2 -0
  105. package/scripts/hooks-system/infrastructure/adapters/GitQueryAdapter.js +4 -0
  106. package/scripts/hooks-system/infrastructure/adapters/LegacyAnalyzerAdapter.js +2 -0
  107. package/scripts/hooks-system/infrastructure/adapters/MacOSNotificationAdapter.js +4 -0
  108. package/scripts/hooks-system/infrastructure/adapters/git/GitCommandRunner.js +2 -0
  109. package/scripts/hooks-system/infrastructure/adapters/git/GitCommandService.js +3 -0
  110. package/scripts/hooks-system/infrastructure/adapters/git/GitQueryService.js +3 -0
  111. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTIntelligentAnalyzer.js +2 -0
  112. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTParser.js +2 -0
  113. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js +2 -0
  114. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidArchitectureDetector.js +7 -5
  115. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidClassAnalyzer.js +3 -0
  116. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidForbiddenLiteralsAnalyzer.js +1 -0
  117. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidSOLIDAnalyzer.js +2 -0
  118. package/scripts/hooks-system/infrastructure/ast/archive/ios-rules.js +2 -0
  119. package/scripts/hooks-system/infrastructure/ast/archive/kotlin-analyzer.js +2 -0
  120. package/scripts/hooks-system/infrastructure/ast/archive/kotlin-parser.js +2 -0
  121. package/scripts/hooks-system/infrastructure/ast/archive/swift-analyzer.js +2 -0
  122. package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendArchitectureDetector.js +2 -0
  123. package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendPatternDetector.js +2 -0
  124. package/scripts/hooks-system/infrastructure/ast/common/BDDTDDWorkflowRules.js +2 -0
  125. package/scripts/hooks-system/infrastructure/ast/common/rules/BDDRules.js +2 -0
  126. package/scripts/hooks-system/infrastructure/ast/common/rules/ImplementationRules.js +2 -0
  127. package/scripts/hooks-system/infrastructure/ast/common/rules/TDDRules.js +2 -0
  128. package/scripts/hooks-system/infrastructure/ast/common/rules/WorkflowRules.js +2 -0
  129. package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendArchitectureDetector.js +16 -14
  130. package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendForbiddenLiteralsAnalyzer.js +5 -0
  131. package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendSOLIDAnalyzer.js +2 -0
  132. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +2 -0
  133. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureDetector.js +12 -10
  134. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureRules.js +2 -0
  135. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSCICDRules.js +2 -0
  136. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSEnterpriseAnalyzer.js +2 -0
  137. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSForbiddenLiteralsAnalyzer.js +1 -0
  138. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSNetworkingAdvancedRules.js +2 -0
  139. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSPerformanceRules.js +3 -0
  140. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSSPMRules.js +2 -0
  141. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSSwiftUIAdvancedRules.js +2 -0
  142. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSTestingAdvancedRules.js +2 -0
  143. package/scripts/hooks-system/infrastructure/ast/ios/native-bridge.js +1 -0
  144. package/scripts/hooks-system/infrastructure/ast/ios/parsers/SourceKittenParser.js +2 -0
  145. package/scripts/hooks-system/infrastructure/cli/install-wizard.js +1 -0
  146. package/scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js +96 -41
  147. package/scripts/hooks-system/infrastructure/mcp/evidence-watcher.js +1 -0
  148. package/scripts/hooks-system/infrastructure/mcp/services/EvidenceService.js +4 -0
  149. package/scripts/hooks-system/infrastructure/mcp/services/McpProtocolHandler.js +2 -0
  150. package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +1 -1
  151. package/scripts/hooks-system/infrastructure/reporting/report-generator.js +2 -0
  152. package/scripts/hooks-system/infrastructure/repositories/CursorTokenRepository.js +4 -0
  153. package/scripts/hooks-system/infrastructure/repositories/FileFindingsRepository.js +2 -0
  154. package/scripts/hooks-system/infrastructure/repositories/datasources/CursorApiDataSource.js +4 -0
  155. package/scripts/hooks-system/infrastructure/repositories/datasources/CursorFileDataSource.js +2 -0
  156. package/scripts/hooks-system/infrastructure/severity/policies/gate-policies.js +1 -0
  157. package/scripts/hooks-system/infrastructure/severity/severity-evaluator.js +2 -0
  158. package/scripts/hooks-system/infrastructure/telemetry/TelemetryService.js +2 -0
  159. package/scripts/hooks-system/infrastructure/telemetry/metrics-logger.js +2 -0
  160. package/scripts/hooks-system/infrastructure/utils/token-manager.js +2 -0
  161. package/scripts/hooks-system/infrastructure/validators/detect-commit-language.js +1 -0
  162. package/scripts/hooks-system/infrastructure/watchdog/auto-recovery.js +1 -0
  163. package/scripts/hooks-system/infrastructure/watchdog/health-check.js +1 -0
  164. package/scripts/hooks-system/infrastructure/watchdog/token-monitor.js +2 -0
@@ -1,5 +1,6 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
+ const AuditLogger = require('../logging/AuditLogger');
3
4
 
4
5
  class HealthCheckService {
5
6
  constructor({
@@ -13,6 +14,7 @@ class HealthCheckService {
13
14
  timers = { setInterval, clearInterval }
14
15
  } = {}) {
15
16
  this.repoRoot = repoRoot;
17
+ this.auditLogger = new AuditLogger({ repoRoot, logger });
16
18
  this.providers = Array.isArray(providers) ? providers : [];
17
19
  this.notificationCenter = notificationCenter;
18
20
  this.logger = logger || console;
@@ -1,5 +1,6 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
+ const AuditLogger = require('../logging/AuditLogger');
3
4
 
4
5
  class HeartbeatMonitorService {
5
6
  constructor({
@@ -10,6 +11,7 @@ class HeartbeatMonitorService {
10
11
  logger = console
11
12
  } = {}) {
12
13
  this.repoRoot = repoRoot;
14
+ this.auditLogger = new AuditLogger({ repoRoot, logger });
13
15
  this.heartbeatPath = heartbeatPath;
14
16
  this.intervalMs = intervalMs;
15
17
  this.statusProvider = statusProvider;
@@ -2,10 +2,12 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { spawn, spawnSync } = require('child_process');
4
4
  const { ConfigurationError } = require('../../../domain/errors');
5
+ const AuditLogger = require('../logging/AuditLogger');
5
6
 
6
7
  class TokenMonitor {
7
8
  constructor(repoRoot, options = {}) {
8
9
  this.repoRoot = repoRoot;
10
+ this.auditLogger = new AuditLogger({ repoRoot });
9
11
  this.scriptPath = path.join(repoRoot, 'infrastructure', 'watchdog', 'token-monitor-loop.sh');
10
12
  this.process = null;
11
13
  }
@@ -1,9 +1,11 @@
1
1
  const { spawnSync } = require('child_process');
2
2
  const fs = require('fs');
3
+ const AuditLogger = require('../logging/AuditLogger');
3
4
 
4
5
  class MacNotificationSender {
5
6
  constructor(logger) {
6
7
  this.logger = logger;
8
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd(), logger });
7
9
  this.terminalNotifierPath = this.resolveTerminalNotifier();
8
10
  this.osascriptPath = this.resolveOsascript();
9
11
  }
@@ -8,6 +8,8 @@
8
8
  * - Orchestrate notification flow
9
9
  * - Delegate specific logic to components (Queue, Dedupe, Cooldown, Retry)
10
10
  */
11
+ const env = require('../../../config/env');
12
+ const AuditLogger = require('../logging/AuditLogger');
11
13
 
12
14
  const crypto = require('crypto');
13
15
  const fs = require('fs');
@@ -1,9 +1,12 @@
1
+ const AuditLogger = require('../logging/AuditLogger');
2
+
1
3
  class NotificationDispatcher {
2
4
  constructor(sender, retryExecutor, cooldownManager, logger) {
3
5
  this.sender = sender;
4
6
  this.retryExecutor = retryExecutor;
5
7
  this.cooldownManager = cooldownManager;
6
8
  this.logger = logger;
9
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd(), logger });
7
10
  }
8
11
 
9
12
  async dispatch(notification, stats) {
@@ -1,9 +1,12 @@
1
+ const AuditLogger = require('../../logging/AuditLogger');
2
+
1
3
  class NotificationCooldownManager {
2
4
  constructor(defaultCooldownMs = 60000, cooldownsByType = {}, logger = null) {
3
5
  this.cooldowns = new Map();
4
6
  this.defaultCooldownMs = defaultCooldownMs;
5
7
  this.cooldownsByType = cooldownsByType;
6
8
  this.logger = logger;
9
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd(), logger });
7
10
  }
8
11
 
9
12
  isInCooldown(notification) {
@@ -1,10 +1,12 @@
1
1
  const crypto = require('crypto');
2
+ const AuditLogger = require('../../logging/AuditLogger');
2
3
 
3
4
  class NotificationDeduplicator {
4
5
  constructor(windowMs = 5000, logger = null) {
5
6
  this.deduplicationMap = new Map();
6
7
  this.windowMs = windowMs;
7
8
  this.logger = logger;
9
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd(), logger });
8
10
  }
9
11
 
10
12
  isDuplicate(notification) {
@@ -1,7 +1,10 @@
1
+ const AuditLogger = require('../../logging/AuditLogger');
2
+
1
3
  class NotificationQueue {
2
4
  constructor(maxSize = 100) {
3
5
  this.maxSize = maxSize;
4
6
  this.items = [];
7
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
5
8
  }
6
9
 
7
10
  enqueue(item) {
@@ -1,9 +1,13 @@
1
+ const env = require('../../config/env');
2
+ const AuditLogger = require('../../logging/AuditLogger');
3
+
1
4
  class NotificationRetryExecutor {
2
5
  constructor(sender, config = {}, logger = null) {
3
6
  this.sender = sender;
4
7
  this.maxRetries = config.maxRetries || 2;
5
8
  this.retryDelayMs = config.retryDelayMs || 1000;
6
9
  this.logger = logger;
10
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd(), logger });
7
11
  }
8
12
 
9
13
  async execute(notification, options = {}) {
@@ -1,9 +1,11 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
+ const AuditLogger = require('../logging/AuditLogger');
3
4
 
4
5
  class PlatformHeuristics {
5
6
  constructor(platformDetector) {
6
7
  this.platformDetector = platformDetector;
8
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
7
9
  }
8
10
 
9
11
  detectFromASTSystemFiles(files) {
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const AuditLogger = require('../logging/AuditLogger');
2
3
 
3
4
  class AutoRecoveryManager {
4
5
  constructor({
@@ -13,6 +14,7 @@ class AutoRecoveryManager {
13
14
  } = {}) {
14
15
  this.repoRoot = repoRoot;
15
16
  this.logger = logger || console;
17
+ this.auditLogger = new AuditLogger({ repoRoot, logger });
16
18
  this.notificationCenter = notificationCenter;
17
19
  this.timers = timers;
18
20
  this.maxAttempts = maxAttempts;
@@ -1,8 +1,12 @@
1
+ const env = require('../../config/env');
2
+ const AuditLogger = require('../logging/AuditLogger');
3
+
1
4
  const path = require('path');
2
5
 
3
6
  class CommitMessageSuggester {
4
7
  constructor(featureDetector) {
5
8
  this.featureDetector = featureDetector;
9
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
6
10
  this.commitTypePatterns = {
7
11
  feat: ['feature/', 'feat/', 'add', 'new', 'create', 'implement'],
8
12
  fix: ['fix/', 'bugfix/', 'hotfix/', 'patch'],
@@ -1,9 +1,11 @@
1
1
  const path = require('path');
2
+ const AuditLogger = require('../logging/AuditLogger');
2
3
 
3
4
  class FileContextGrouper {
4
5
  constructor(featureDetector, platformDetector = null) {
5
6
  this.featureDetector = featureDetector;
6
7
  this.platformDetector = platformDetector;
8
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
7
9
  }
8
10
 
9
11
  group(files) {
@@ -1,4 +1,10 @@
1
+ const AuditLogger = require('../logging/AuditLogger');
2
+
1
3
  class SmartCommitSummaryBuilder {
4
+ constructor() {
5
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
6
+ }
7
+
2
8
  build(suggestions, orphans) {
3
9
  const lines = [];
4
10
 
@@ -1,4 +1,5 @@
1
1
  const CursorTokenRepository = require('../../../infrastructure/repositories/CursorTokenRepository');
2
+ const AuditLogger = require('../logging/AuditLogger');
2
3
 
3
4
  class CursorTokenService {
4
5
  constructor({
@@ -1,3 +1,6 @@
1
+ const env = require('../../config/env');
2
+ const AuditLogger = require('../logging/AuditLogger');
3
+
1
4
  const { execSync } = require('child_process');
2
5
 
3
6
  class TokenMetricsService {
@@ -6,6 +9,7 @@ class TokenMetricsService {
6
9
  this.thresholds = thresholds;
7
10
  this.logger = logger;
8
11
  this.repoRoot = process.cwd();
12
+ this.auditLogger = new AuditLogger({ repoRoot: this.repoRoot, logger });
9
13
  }
10
14
 
11
15
  async collectMetrics(fallbackEstimator) {
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { execSync } = require('child_process');
4
+ const AuditLogger = require('../logging/AuditLogger');
4
5
 
5
6
  const fsPromises = fs.promises;
6
7
  const CursorTokenService = require('./CursorTokenService');
@@ -1,9 +1,11 @@
1
1
  const fs = require('fs');
2
2
  const fsPromises = fs.promises;
3
+ const AuditLogger = require('../logging/AuditLogger');
3
4
 
4
5
  class TokenStatusReporter {
5
6
  constructor(stateFile) {
6
7
  this.stateFile = stateFile;
8
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
7
9
  }
8
10
 
9
11
  async writeStatusFile(metrics) {
@@ -1,3 +1,5 @@
1
+ const env = require('../../config/env');
2
+
1
3
  const fs = require('fs');
2
4
  const path = require('path');
3
5
  const { toErrorMessage } = require('../../infrastructure/utils/error-utils');
@@ -1,10 +1,12 @@
1
1
  const AuditResult = require('../../domain/entities/AuditResult');
2
+ const AuditLogger = require('../logging/AuditLogger');
2
3
 
3
4
  class AnalyzeCodebaseUseCase {
4
5
  constructor(platformAnalyzers, findingsRepository, platformDetectionService) {
5
6
  this.platformAnalyzers = platformAnalyzers;
6
7
  this.findingsRepository = findingsRepository;
7
8
  this.platformDetectionService = platformDetectionService;
9
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
8
10
  }
9
11
 
10
12
  async execute(targetPath, options = {}) {
@@ -1,11 +1,13 @@
1
1
 
2
2
  const AuditResult = require('../../domain/entities/AuditResult');
3
+ const AuditLogger = require('../logging/AuditLogger');
3
4
 
4
5
  class AnalyzeStagedFilesUseCase {
5
6
  constructor(platformAnalyzers, gitOperations, platformDetectionService) {
6
7
  this.platformAnalyzers = platformAnalyzers;
7
8
  this.gitOperations = gitOperations;
8
9
  this.platformDetectionService = platformDetectionService;
10
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
9
11
  }
10
12
 
11
13
  async execute(options = {}) {
@@ -1,6 +1,7 @@
1
1
  const { execSync } = require('child_process');
2
2
  const path = require('path');
3
3
  const { ValidationError, ConfigurationError } = require('../../domain/errors');
4
+ const AuditLogger = require('../../application/services/logging/AuditLogger');
4
5
 
5
6
  function resolveUpdateEvidenceScript(repoRoot) {
6
7
  const candidates = [
@@ -24,6 +25,7 @@ class AutoExecuteAIStartUseCase {
24
25
  this.orchestrator = orchestrator;
25
26
  this.repoRoot = repoRoot || process.cwd();
26
27
  this.logger = logger;
28
+ this.auditLogger = new AuditLogger({ repoRoot: this.repoRoot, logger });
27
29
  this.updateEvidenceScript = resolveUpdateEvidenceScript(this.repoRoot);
28
30
  }
29
31
 
@@ -1,9 +1,11 @@
1
1
 
2
2
  const CommitBlockingRules = require('../../domain/rules/CommitBlockingRules');
3
+ const AuditLogger = require('../logging/AuditLogger');
3
4
 
4
5
  class BlockCommitUseCase {
5
6
  constructor(commitBlockingRules) {
6
7
  this.commitBlockingRules = commitBlockingRules || new CommitBlockingRules();
8
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
7
9
  }
8
10
 
9
11
  async execute(auditResult, options = {}) {
@@ -1,9 +1,12 @@
1
1
 
2
+ const AuditLogger = require('../logging/AuditLogger');
3
+
2
4
  class GenerateAuditReportUseCase {
3
5
  constructor(outputFormatter, auditAnalyzer, auditScorer) {
4
6
  this.outputFormatter = outputFormatter;
5
7
  this.auditAnalyzer = auditAnalyzer; // Inject Analyzer
6
8
  this.auditScorer = auditScorer; // Inject Scorer
9
+ this.auditLogger = new AuditLogger({ repoRoot: process.cwd() });
7
10
  }
8
11
 
9
12
  async execute(auditResult, options = {}) {
@@ -6,6 +6,7 @@
6
6
  * it follows its own rules (practice what we preach)
7
7
  */
8
8
 
9
+ const env = require('../config/env');
9
10
  const path = require('path');
10
11
  const { execSync } = require('child_process');
11
12
 
@@ -32,9 +33,9 @@ console.log(`${COLORS.cyan}📋 Auditing library code at: ${libraryRoot}${COLORS
32
33
 
33
34
  try {
34
35
  process.chdir(libraryRoot);
35
-
36
+
36
37
  console.log(`${COLORS.cyan}🔍 Running AST intelligence...${COLORS.reset}\n`);
37
-
38
+
38
39
  execSync(`node "${astScript}"`, {
39
40
  stdio: 'inherit',
40
41
  cwd: libraryRoot,
@@ -43,10 +44,10 @@ try {
43
44
  AUDIT_LIBRARY: 'true'
44
45
  }
45
46
  });
46
-
47
+
47
48
  console.log(`\n${COLORS.green}✅ Library audit completed${COLORS.reset}`);
48
49
  console.log(`${COLORS.yellow}📊 Check ast-summary.json for detailed results${COLORS.reset}\n`);
49
-
50
+
50
51
  } catch (error) {
51
52
  console.error(`${COLORS.red}❌ Audit failed: ${error.message}${COLORS.reset}`);
52
53
  process.exit(1);
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const env = require('../config/env');
3
4
  const fs = require('fs');
4
5
  const path = require('path');
5
6
 
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ const env = require('../config/env');
2
3
  const fs = require('fs');
3
4
  const path = require('path');
4
5
  const { spawn } = require('child_process');
@@ -79,7 +80,7 @@ function shutdown() {
79
80
  try {
80
81
  w.close();
81
82
  } catch (error) {
82
- log(`Error closing watcher: ${error.message}`);
83
+ log(`Error closing watcher: ${error.message}`);
83
84
  }
84
85
  });
85
86
  }
@@ -90,4 +91,4 @@ process.on('SIGTERM', shutdown);
90
91
  log('Auto-restart guard running');
91
92
  targets.forEach(watchFile);
92
93
 
93
- setInterval(() => {}, 1 << 30);
94
+ setInterval(() => { }, 1 << 30);
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const env = require('../config/env');
3
4
  const fs = require('fs');
4
5
  const path = require('path');
5
6
 
@@ -5,6 +5,7 @@
5
5
  * Helps detect when updates are available
6
6
  */
7
7
 
8
+ const env = require('../config/env');
8
9
  const fs = require('fs');
9
10
  const path = require('path');
10
11
  const { execSync } = require('child_process');
@@ -20,37 +21,37 @@ const COLORS = {
20
21
 
21
22
  function getInstalledVersion() {
22
23
  const projectRoot = process.cwd();
23
-
24
+
24
25
  try {
25
26
  const packageJsonPath = require.resolve('@pumuki/ast-intelligence-hooks/package.json');
26
27
  const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
27
28
  const packageRoot = path.dirname(path.dirname(packageJsonPath));
28
-
29
+
29
30
  const projectPkgPath = path.join(projectRoot, 'package.json');
30
31
  if (fs.existsSync(projectPkgPath)) {
31
32
  const projectPkg = JSON.parse(fs.readFileSync(projectPkgPath, 'utf-8'));
32
33
  const deps = { ...projectPkg.dependencies, ...projectPkg.devDependencies };
33
34
  const depVersion = deps['@pumuki/ast-intelligence-hooks'];
34
-
35
+
35
36
  if (depVersion && depVersion.startsWith('file:')) {
36
37
  return { version: pkg.version, type: 'local', path: packageRoot };
37
38
  }
38
39
  }
39
-
40
+
40
41
  return { version: pkg.version, type: 'npm', path: packageRoot };
41
42
  } catch (err) {
42
43
  err = null;
43
44
  // Fallback: continue with local project dependency checks
44
45
  }
45
-
46
+
46
47
  const projectPkgPath = path.join(projectRoot, 'package.json');
47
48
  if (fs.existsSync(projectPkgPath)) {
48
49
  const projectPkg = JSON.parse(fs.readFileSync(projectPkgPath, 'utf-8'));
49
50
  const deps = { ...projectPkg.dependencies, ...projectPkg.devDependencies };
50
-
51
+
51
52
  if (deps['@pumuki/ast-intelligence-hooks']) {
52
53
  let version = deps['@pumuki/ast-intelligence-hooks'];
53
-
54
+
54
55
  if (version.startsWith('file:')) {
55
56
  const libPath = path.resolve(projectRoot, version.replace('file:', ''));
56
57
  const libPackageJson = path.join(libPath, 'package.json');
@@ -60,35 +61,35 @@ function getInstalledVersion() {
60
61
  }
61
62
  return { version: 'unknown (local)', type: 'local', path: libPath };
62
63
  }
63
-
64
+
64
65
  const nodeModulesPath = path.join(projectRoot, 'node_modules', '@pumuki', 'ast-intelligence-hooks', 'package.json');
65
66
  if (fs.existsSync(nodeModulesPath)) {
66
67
  const installedPkg = JSON.parse(fs.readFileSync(nodeModulesPath, 'utf-8'));
67
68
  return { version: installedPkg.version, type: 'npm', declaredVersion: version };
68
69
  }
69
-
70
+
70
71
  return { version: version.replace(/^[\^~]/, ''), type: 'npm', declaredVersion: version };
71
72
  }
72
73
  }
73
-
74
+
74
75
  const nodeModulesPath = path.join(projectRoot, 'node_modules', '@pumuki', 'ast-intelligence-hooks', 'package.json');
75
76
  if (fs.existsSync(nodeModulesPath)) {
76
77
  const pkg = JSON.parse(fs.readFileSync(nodeModulesPath, 'utf-8'));
77
78
  return { version: pkg.version, type: 'npm' };
78
79
  }
79
-
80
+
80
81
  const scriptsPath = path.join(projectRoot, 'scripts', 'hooks-system');
81
82
  if (fs.existsSync(scriptsPath)) {
82
83
  return { version: 'unknown', type: 'partial', message: 'Scripts installed but package not found in node_modules' };
83
84
  }
84
-
85
+
85
86
  return null;
86
87
  }
87
88
 
88
89
  function getLatestVersion() {
89
90
  try {
90
91
  // Try npm view
91
- const output = execSync('npm view @pumuki/ast-intelligence-hooks version', {
92
+ const output = execSync('npm view @pumuki/ast-intelligence-hooks version', {
92
93
  encoding: 'utf-8',
93
94
  stdio: ['ignore', 'pipe', 'ignore'],
94
95
  timeout: 5000
@@ -102,7 +103,7 @@ function getLatestVersion() {
102
103
  function compareVersions(v1, v2) {
103
104
  const parts1 = v1.split('.').map(Number);
104
105
  const parts2 = v2.split('.').map(Number);
105
-
106
+
106
107
  for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
107
108
  const p1 = parts1[i] || 0;
108
109
  const p2 = parts2[i] || 0;
@@ -116,9 +117,9 @@ function main() {
116
117
  console.log(`${COLORS.blue}╔══════════════════════════════════════════════════════════════╗${COLORS.reset}`);
117
118
  console.log(`${COLORS.blue}║ AST Intelligence Hooks - Version Check ║${COLORS.reset}`);
118
119
  console.log(`${COLORS.blue}╚══════════════════════════════════════════════════════════════╝${COLORS.reset}\n`);
119
-
120
+
120
121
  const installed = getInstalledVersion();
121
-
122
+
122
123
  if (!installed) {
123
124
  console.log(`${COLORS.red}❌ ast-intelligence-hooks not found in this project${COLORS.reset}`);
124
125
  console.log(`\n${COLORS.cyan}Install it with:${COLORS.reset}`);
@@ -126,7 +127,7 @@ function main() {
126
127
  console.log(` npm run install-hooks\n`);
127
128
  process.exit(1);
128
129
  }
129
-
130
+
130
131
  console.log(`${COLORS.cyan}Installed version:${COLORS.reset}`);
131
132
  console.log(` ${COLORS.green}${installed.version}${COLORS.reset} (${installed.type})`);
132
133
  if (installed.path) {
@@ -139,13 +140,13 @@ function main() {
139
140
  console.log(` ${COLORS.yellow}âš ī¸ ${installed.message}${COLORS.reset}`);
140
141
  }
141
142
  console.log();
142
-
143
+
143
144
  if (installed.type === 'local') {
144
145
  console.log(`${COLORS.yellow}â„šī¸ Using local installation (development mode)${COLORS.reset}`);
145
146
  console.log(` Updates come from the linked library directory.\n`);
146
147
  process.exit(0);
147
148
  }
148
-
149
+
149
150
  if (installed.type === 'partial') {
150
151
  console.log(`${COLORS.yellow}âš ī¸ Partial installation detected${COLORS.reset}`);
151
152
  console.log(` It seems hooks are installed but the package is missing.\n`);
@@ -154,24 +155,24 @@ function main() {
154
155
  console.log(` npm run install-hooks\n`);
155
156
  process.exit(0);
156
157
  }
157
-
158
+
158
159
  if (installed.version === 'unknown') {
159
160
  console.log(`${COLORS.red}❌ Cannot determine installed version${COLORS.reset}\n`);
160
161
  process.exit(1);
161
162
  }
162
-
163
+
163
164
  console.log(`${COLORS.cyan}Checking latest version on npm...${COLORS.reset}`);
164
165
  const latest = getLatestVersion();
165
-
166
+
166
167
  if (!latest) {
167
168
  console.log(`${COLORS.yellow}âš ī¸ Could not check latest version (network issue or package not published)${COLORS.reset}\n`);
168
169
  process.exit(0);
169
170
  }
170
-
171
+
171
172
  console.log(` Latest: ${COLORS.green}${latest}${COLORS.reset}\n`);
172
-
173
+
173
174
  const comparison = compareVersions(installed.version, latest);
174
-
175
+
175
176
  if (comparison < 0) {
176
177
  console.log(`${COLORS.yellow}âš ī¸ UPDATE AVAILABLE${COLORS.reset}`);
177
178
  console.log(`\n${COLORS.cyan}To update:${COLORS.reset}`);
@@ -9,6 +9,7 @@
9
9
  const { execSync } = require('child_process');
10
10
  const fs = require('fs');
11
11
  const path = require('path');
12
+ const env = require('../config/env');
12
13
 
13
14
  const command = process.argv[2];
14
15
  const args = process.argv.slice(3);
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ const env = require('../config/env');
2
3
  const { createUnifiedLogger } = require('../infrastructure/logging/UnifiedLoggerFactory');
3
4
  const NotificationCenterService = require('../application/services/notification/NotificationCenterService');
4
5
  const { GuardAutoManagerService } = require('../application/services/guard/GuardAutoManagerService');
@@ -3,4 +3,5 @@
3
3
  * Script Wrapper
4
4
  * Redirects to the centralized implementation in scripts/hooks-system
5
5
  */
6
+ const env = require('../config/env');
6
7
  require('../scripts/hooks-system/bin/guard-supervisor.js');
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const env = require('../config/env');
3
4
  const fs = require('fs');
4
5
  const path = require('path');
5
6
 
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const env = require('../config/env');
3
4
  const InstallService = require('../application/services/installation/InstallService');
4
5
 
5
6
  // Run installation
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ const env = require('../config/env');
4
5
  const fs = require('fs');
5
6
  const path = require('path');
6
7
 
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const env = require('../config/env');
3
4
  const fs = require('fs');
4
5
  const path = require('path');
5
6
 
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const env = require('../config/env');
3
4
  const PredictiveHookAdvisor = require('../application/services/PredictiveHookAdvisor');
4
5
 
5
6
  const advisor = new PredictiveHookAdvisor();
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ const env = require('../config/env');
2
3
  const path = require('path');
3
4
  const fs = require('fs');
4
5
  const { toErrorMessage } = require('../infrastructure/utils/error-utils');
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ const env = require('../config/env');
2
3
  const fs = require('fs');
3
4
  const path = require('path');
4
5
  const { execSync } = require('child_process');