pumuki-ast-hooks 5.3.1
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/LICENSE +21 -0
- package/README.md +1105 -0
- package/bin/__tests__/auto-fix-violations.spec.js +132 -0
- package/bin/__tests__/auto-restart-guards.spec.js +11 -0
- package/bin/__tests__/check-doc-drift.spec.js +11 -0
- package/bin/__tests__/check-version.spec.js +240 -0
- package/bin/__tests__/cli.spec.js +11 -0
- package/bin/__tests__/guard-auto-manager.spec.js +11 -0
- package/bin/__tests__/guard-supervisor.spec.js +11 -0
- package/bin/__tests__/hook-status.spec.js +11 -0
- package/bin/__tests__/install.spec.js +11 -0
- package/bin/__tests__/nightly-metrics-report.spec.js +94 -0
- package/bin/__tests__/plan-review.spec.js +11 -0
- package/bin/__tests__/predictive-hooks.spec.js +11 -0
- package/bin/__tests__/run-ast-adapter.spec.js +11 -0
- package/bin/__tests__/run-orchestrator.spec.js +11 -0
- package/bin/__tests__/run-playbook.spec.js +11 -0
- package/bin/__tests__/setup-eslint.spec.js +11 -0
- package/bin/__tests__/violations-api.spec.js +11 -0
- package/bin/__tests__/watch-hooks.spec.js +11 -0
- package/bin/ai-commit.sh +5 -0
- package/bin/audit +5 -0
- package/bin/audit-library.js +6 -0
- package/bin/auto-fix-violations.js +19 -0
- package/bin/auto-restart-guards.js +6 -0
- package/bin/check-doc-drift.js +6 -0
- package/bin/check-version.js +19 -0
- package/bin/cleanup-branches.sh +5 -0
- package/bin/cli.js +6 -0
- package/bin/demo-recording.sh +5 -0
- package/bin/demo-violations +5 -0
- package/bin/fix-enforcer +5 -0
- package/bin/fix-gitflow-enforcement.sh +5 -0
- package/bin/generate-progress-report.sh +5 -0
- package/bin/git-analyze-pairs.sh +5 -0
- package/bin/git-leave-branch-check.sh +5 -0
- package/bin/gitflow +5 -0
- package/bin/gitflow-shell-integration.sh +5 -0
- package/bin/guard-auto-manager.js +6 -0
- package/bin/guard-autostart.sh +5 -0
- package/bin/guard-env.sh +5 -0
- package/bin/guard-supervisor.js +6 -0
- package/bin/hook-status.js +6 -0
- package/bin/install-git-wrapper.sh +5 -0
- package/bin/install.js +6 -0
- package/bin/kill-mcp-zombies.sh +5 -0
- package/bin/nightly-metrics-report.js +8 -0
- package/bin/plan-review.js +6 -0
- package/bin/predictive-hooks.js +6 -0
- package/bin/pumuki-audit.js +6 -0
- package/bin/pumuki-init.js +19 -0
- package/bin/pumuki-mcp-server.js +13 -0
- package/bin/pumuki-mcp.js +6 -0
- package/bin/pumuki-rules.js +6 -0
- package/bin/request-no-verify-approval.sh +5 -0
- package/bin/run-ast-adapter.js +6 -0
- package/bin/run-intelligent-audit.sh +5 -0
- package/bin/run-orchestrator.js +6 -0
- package/bin/run-playbook.js +6 -0
- package/bin/session-loader.sh +5 -0
- package/bin/setup-eslint.js +6 -0
- package/bin/start-guards.sh +5 -0
- package/bin/sync-autonomous-orchestrator.sh +5 -0
- package/bin/sync-to-library.sh +5 -0
- package/bin/update-evidence.sh +5 -0
- package/bin/update-session-context.sh +5 -0
- package/bin/verify-no-verify.sh +5 -0
- package/bin/violations +5 -0
- package/bin/violations-api.js +6 -0
- package/bin/watch-hooks.js +6 -0
- package/docs/API_REFERENCE.md +161 -0
- package/docs/ARCHITECTURE.md +236 -0
- package/docs/ARCHITECTURE_DETAILED.md +499 -0
- package/docs/BRANCH_PROTECTION_GUIDE.md +236 -0
- package/docs/CODE_STANDARDS.md +440 -0
- package/docs/CONTRIBUTING.md +246 -0
- package/docs/DEPENDENCIES.md +541 -0
- package/docs/HOW_IT_WORKS.md +716 -0
- package/docs/INSTALLATION.md +784 -0
- package/docs/MCP_SERVERS.md +786 -0
- package/docs/TESTING.md +423 -0
- package/docs/USAGE.md +856 -0
- package/docs/images/ast_intelligence_01.png +0 -0
- package/docs/images/ast_intelligence_02.png +0 -0
- package/docs/images/ast_intelligence_03.png +0 -0
- package/docs/images/ast_intelligence_04.png +0 -0
- package/docs/images/ast_intelligence_05.png +0 -0
- package/hooks/getSkillRulesPath.ts +52 -0
- package/hooks/git-status-monitor.ts +160 -0
- package/hooks/index.js +5 -0
- package/hooks/notify-macos.ts +42 -0
- package/hooks/package.json +16 -0
- package/hooks/post-tool-use-tracker.sh +89 -0
- package/hooks/pre-tool-use-evidence-validator.ts +252 -0
- package/hooks/pre-tool-use-guard.ts +151 -0
- package/hooks/skill-activation-prompt.sh +8 -0
- package/hooks/skill-activation-prompt.ts +307 -0
- package/index.js +49 -0
- package/package.json +117 -0
- package/presentation/cli/audit.sh +24 -0
- package/presentation/cli/autonomous-status.sh +92 -0
- package/presentation/cli/categorize-violations.sh +179 -0
- package/presentation/cli/direct-audit-option2.sh +23 -0
- package/presentation/cli/direct-audit.sh +33 -0
- package/scripts/hooks-system/.AI_TOKEN_STATUS.txt +16 -0
- package/scripts/hooks-system/.audit-reports/auto-recovery.log +1 -0
- package/scripts/hooks-system/.audit-reports/install-wizard.log +4 -0
- package/scripts/hooks-system/.audit-reports/notifications.log +425 -0
- package/scripts/hooks-system/.audit-reports/token-monitor.log +1275 -0
- package/scripts/hooks-system/.audit_tmp/intelligent-report.json +44953 -0
- package/scripts/hooks-system/.audit_tmp/intelligent-report.txt +1338 -0
- package/scripts/hooks-system/.audit_tmp/severity-history.jsonl +1 -0
- package/scripts/hooks-system/.audit_tmp/token-usage.jsonl +1 -0
- package/scripts/hooks-system/.hook-system/config.json +8 -0
- package/scripts/hooks-system/application/CompositionRoot.js +325 -0
- package/scripts/hooks-system/application/__tests__/CompositionRoot.spec.js +84 -0
- package/scripts/hooks-system/application/commands/index.js +64 -0
- package/scripts/hooks-system/application/queries/index.js +60 -0
- package/scripts/hooks-system/application/services/AutonomousOrchestrator.js +130 -0
- package/scripts/hooks-system/application/services/ContextDetectionEngine.js +181 -0
- package/scripts/hooks-system/application/services/DynamicRulesLoader.js +182 -0
- package/scripts/hooks-system/application/services/GitFlowService.js +156 -0
- package/scripts/hooks-system/application/services/GitTreeState.js +140 -0
- package/scripts/hooks-system/application/services/HookSystemScheduler.js +77 -0
- package/scripts/hooks-system/application/services/IntelligentCommitAnalyzer.js +151 -0
- package/scripts/hooks-system/application/services/IntelligentGitTreeMonitor.js +118 -0
- package/scripts/hooks-system/application/services/PlatformAnalysisService.js +173 -0
- package/scripts/hooks-system/application/services/PlatformDetectionService.js +168 -0
- package/scripts/hooks-system/application/services/PlaybookRunner.js +39 -0
- package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +56 -0
- package/scripts/hooks-system/application/services/RealtimeGuardPlugin.js +62 -0
- package/scripts/hooks-system/application/services/RealtimeGuardService.js +374 -0
- package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +63 -0
- package/scripts/hooks-system/application/services/__tests__/AutonomousOrchestrator.spec.js +36 -0
- package/scripts/hooks-system/application/services/__tests__/ContextDetectionEngine.spec.js +33 -0
- package/scripts/hooks-system/application/services/__tests__/DynamicRulesLoader.spec.js +43 -0
- package/scripts/hooks-system/application/services/__tests__/GitTreeState.spec.js +163 -0
- package/scripts/hooks-system/application/services/__tests__/HookSystemScheduler.spec.js +207 -0
- package/scripts/hooks-system/application/services/__tests__/IntelligentCommitAnalyzer.spec.js +365 -0
- package/scripts/hooks-system/application/services/__tests__/IntelligentGitTreeMonitor.spec.js +188 -0
- package/scripts/hooks-system/application/services/__tests__/PlatformDetectionService.spec.js +28 -0
- package/scripts/hooks-system/application/services/__tests__/PlaybookRunner.spec.js +143 -0
- package/scripts/hooks-system/application/services/__tests__/PredictiveHookAdvisor.spec.js +181 -0
- package/scripts/hooks-system/application/services/__tests__/RealtimeGuardPlugin.spec.js +45 -0
- package/scripts/hooks-system/application/services/__tests__/RealtimeGuardService.critical.spec.js +401 -0
- package/scripts/hooks-system/application/services/commit/CommitMessageGenerator.js +34 -0
- package/scripts/hooks-system/application/services/commit/FeatureDetector.js +101 -0
- package/scripts/hooks-system/application/services/evidence/EvidenceContextManager.js +163 -0
- package/scripts/hooks-system/application/services/evidence/__tests__/EvidenceContextManager.spec.js +98 -0
- package/scripts/hooks-system/application/services/guard/GuardAutoManagerService.js +169 -0
- package/scripts/hooks-system/application/services/guard/GuardConfig.js +15 -0
- package/scripts/hooks-system/application/services/guard/GuardEventLogger.js +70 -0
- package/scripts/hooks-system/application/services/guard/GuardHealthReminder.js +54 -0
- package/scripts/hooks-system/application/services/guard/GuardHeartbeatMonitor.js +94 -0
- package/scripts/hooks-system/application/services/guard/GuardLockManager.js +72 -0
- package/scripts/hooks-system/application/services/guard/GuardMonitorLoop.js +29 -0
- package/scripts/hooks-system/application/services/guard/GuardNotificationHandler.js +36 -0
- package/scripts/hooks-system/application/services/guard/GuardProcessManager.js +113 -0
- package/scripts/hooks-system/application/services/guard/GuardRecoveryService.js +90 -0
- package/scripts/hooks-system/application/services/guard/__tests__/GuardAutoManagerService.spec.js +77 -0
- package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +123 -0
- package/scripts/hooks-system/application/services/installation/FileSystemInstallerService.js +112 -0
- package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +166 -0
- package/scripts/hooks-system/application/services/installation/HookInstaller.js +197 -0
- package/scripts/hooks-system/application/services/installation/IdeIntegrationService.js +37 -0
- package/scripts/hooks-system/application/services/installation/InstallService.js +130 -0
- package/scripts/hooks-system/application/services/installation/McpConfigurator.js +172 -0
- package/scripts/hooks-system/application/services/installation/PlatformDetectorService.js +36 -0
- package/scripts/hooks-system/application/services/installation/VSCodeTaskConfigurator.js +97 -0
- package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +142 -0
- package/scripts/hooks-system/application/services/logging/__tests__/UnifiedLogger.spec.js +66 -0
- package/scripts/hooks-system/application/services/monitoring/ActivityMonitor.js +80 -0
- package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +140 -0
- package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +85 -0
- package/scripts/hooks-system/application/services/monitoring/EvidenceMonitor.js +103 -0
- package/scripts/hooks-system/application/services/monitoring/EvidenceMonitorService.js +162 -0
- package/scripts/hooks-system/application/services/monitoring/GitTreeMonitor.js +123 -0
- package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +114 -0
- package/scripts/hooks-system/application/services/monitoring/HealthCheckProviders.js +153 -0
- package/scripts/hooks-system/application/services/monitoring/HealthCheckService.js +118 -0
- package/scripts/hooks-system/application/services/monitoring/HeartbeatMonitorService.js +61 -0
- package/scripts/hooks-system/application/services/monitoring/TokenMonitor.js +60 -0
- package/scripts/hooks-system/application/services/monitoring/__tests__/EvidenceMonitorService.spec.js +107 -0
- package/scripts/hooks-system/application/services/monitoring/__tests__/GitTreeMonitorService.spec.js +27 -0
- package/scripts/hooks-system/application/services/monitoring/__tests__/HealthCheckProviders.spec.js +68 -0
- package/scripts/hooks-system/application/services/monitoring/__tests__/HealthCheckService.spec.js +69 -0
- package/scripts/hooks-system/application/services/monitoring/__tests__/HeartbeatMonitorService.spec.js +35 -0
- package/scripts/hooks-system/application/services/notification/MacNotificationSender.js +106 -0
- package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +221 -0
- package/scripts/hooks-system/application/services/notification/NotificationDispatcher.js +42 -0
- package/scripts/hooks-system/application/services/notification/__tests__/NotificationCenterService.spec.js +40 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationCooldownManager.js +62 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationDeduplicator.js +67 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationQueue.js +36 -0
- package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +58 -0
- package/scripts/hooks-system/application/services/platform/PlatformHeuristics.js +144 -0
- package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +137 -0
- package/scripts/hooks-system/application/services/recovery/__tests__/AutoRecoveryManager.spec.js +62 -0
- package/scripts/hooks-system/application/services/smart-commit/CommitMessageSuggester.js +97 -0
- package/scripts/hooks-system/application/services/smart-commit/FileContextGrouper.js +114 -0
- package/scripts/hooks-system/application/services/smart-commit/SmartCommitSummaryBuilder.js +53 -0
- package/scripts/hooks-system/application/services/token/CursorTokenService.js +44 -0
- package/scripts/hooks-system/application/services/token/TokenMetricsService.js +109 -0
- package/scripts/hooks-system/application/services/token/TokenMonitorService.js +160 -0
- package/scripts/hooks-system/application/services/token/TokenStatusReporter.js +56 -0
- package/scripts/hooks-system/application/services/token/__tests__/CursorTokenService.spec.js +69 -0
- package/scripts/hooks-system/application/services/token/__tests__/TokenMonitorService.spec.js +185 -0
- package/scripts/hooks-system/application/state/HookSystemStateMachine.js +59 -0
- package/scripts/hooks-system/application/state/__tests__/HookSystemStateMachine.spec.js +115 -0
- package/scripts/hooks-system/application/use-cases/AnalyzeCodebaseUseCase.js +54 -0
- package/scripts/hooks-system/application/use-cases/AnalyzeStagedFilesUseCase.js +61 -0
- package/scripts/hooks-system/application/use-cases/AutoExecuteAIStartUseCase.js +123 -0
- package/scripts/hooks-system/application/use-cases/BlockCommitUseCase.js +90 -0
- package/scripts/hooks-system/application/use-cases/GenerateAuditReportUseCase.js +184 -0
- package/scripts/hooks-system/application/use-cases/__tests__/AnalyzeCodebaseUseCase.spec.js +156 -0
- package/scripts/hooks-system/application/use-cases/__tests__/AnalyzeStagedFilesUseCase.spec.js +146 -0
- package/scripts/hooks-system/application/use-cases/__tests__/AutoExecuteAIStartUseCase.spec.js +89 -0
- package/scripts/hooks-system/application/use-cases/__tests__/BlockCommitUseCase.spec.js +171 -0
- package/scripts/hooks-system/application/use-cases/__tests__/GenerateAuditReportUseCase.spec.js +207 -0
- package/scripts/hooks-system/bin/__tests__/auto-fix-violations.spec.js +132 -0
- package/scripts/hooks-system/bin/__tests__/auto-restart-guards.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/check-doc-drift.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/check-version.spec.js +240 -0
- package/scripts/hooks-system/bin/__tests__/cli.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/guard-auto-manager.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/guard-supervisor.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/hook-status.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/install.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/nightly-metrics-report.spec.js +94 -0
- package/scripts/hooks-system/bin/__tests__/plan-review.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/predictive-hooks.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/run-ast-adapter.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/run-orchestrator.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/run-playbook.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/setup-eslint.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/violations-api.spec.js +11 -0
- package/scripts/hooks-system/bin/__tests__/watch-hooks.spec.js +11 -0
- package/scripts/hooks-system/bin/ai-commit.sh +63 -0
- package/scripts/hooks-system/bin/audit +463 -0
- package/scripts/hooks-system/bin/audit-library.js +54 -0
- package/scripts/hooks-system/bin/auto-fix-violations.js +130 -0
- package/scripts/hooks-system/bin/auto-restart-guards.js +93 -0
- package/scripts/hooks-system/bin/check-doc-drift.js +35 -0
- package/scripts/hooks-system/bin/check-version.js +201 -0
- package/scripts/hooks-system/bin/cleanup-branches.sh +106 -0
- package/scripts/hooks-system/bin/cli.js +208 -0
- package/scripts/hooks-system/bin/demo-recording.sh +57 -0
- package/scripts/hooks-system/bin/demo-violations +44 -0
- package/scripts/hooks-system/bin/fix-enforcer +27 -0
- package/scripts/hooks-system/bin/fix-gitflow-enforcement.sh +68 -0
- package/scripts/hooks-system/bin/generate-progress-report.sh +129 -0
- package/scripts/hooks-system/bin/git-analyze-pairs.sh +0 -0
- package/scripts/hooks-system/bin/git-leave-branch-check.sh +73 -0
- package/scripts/hooks-system/bin/gitflow +17 -0
- package/scripts/hooks-system/bin/gitflow-shell-integration.sh +64 -0
- package/scripts/hooks-system/bin/guard-auto-manager.js +44 -0
- package/scripts/hooks-system/bin/guard-autostart.sh +158 -0
- package/scripts/hooks-system/bin/guard-env.sh +40 -0
- package/scripts/hooks-system/bin/guard-supervisor.js +516 -0
- package/scripts/hooks-system/bin/hook-status.js +41 -0
- package/scripts/hooks-system/bin/install-git-wrapper.sh +53 -0
- package/scripts/hooks-system/bin/install.js +10 -0
- package/scripts/hooks-system/bin/kill-mcp-zombies.sh +48 -0
- package/scripts/hooks-system/bin/nightly-metrics-report.js +138 -0
- package/scripts/hooks-system/bin/plan-review.js +31 -0
- package/scripts/hooks-system/bin/predictive-hooks.js +18 -0
- package/scripts/hooks-system/bin/pumuki-audit.js +113 -0
- package/scripts/hooks-system/bin/pumuki-init.js +104 -0
- package/scripts/hooks-system/bin/pumuki-mcp.js +74 -0
- package/scripts/hooks-system/bin/pumuki-rules.js +74 -0
- package/scripts/hooks-system/bin/request-no-verify-approval.sh +116 -0
- package/scripts/hooks-system/bin/run-ast-adapter.js +86 -0
- package/scripts/hooks-system/bin/run-intelligent-audit.sh +67 -0
- package/scripts/hooks-system/bin/run-orchestrator.js +27 -0
- package/scripts/hooks-system/bin/run-playbook.js +23 -0
- package/scripts/hooks-system/bin/session-loader.sh +264 -0
- package/scripts/hooks-system/bin/setup-eslint.js +110 -0
- package/scripts/hooks-system/bin/start-guards.sh +190 -0
- package/scripts/hooks-system/bin/sync-autonomous-orchestrator.sh +32 -0
- package/scripts/hooks-system/bin/sync-to-library.sh +46 -0
- package/scripts/hooks-system/bin/update-evidence.sh +1167 -0
- package/scripts/hooks-system/bin/update-session-context.sh +261 -0
- package/scripts/hooks-system/bin/verify-no-verify.sh +68 -0
- package/scripts/hooks-system/bin/violations +20 -0
- package/scripts/hooks-system/bin/violations-api.js +345 -0
- package/scripts/hooks-system/bin/watch-hooks.js +20 -0
- package/scripts/hooks-system/config/project.config.json +36 -0
- package/scripts/hooks-system/config/state-map.json +12 -0
- package/scripts/hooks-system/domain/entities/AuditResult.js +139 -0
- package/scripts/hooks-system/domain/entities/Finding.js +116 -0
- package/scripts/hooks-system/domain/entities/SeverityConfig.js +73 -0
- package/scripts/hooks-system/domain/entities/SeverityConfig.ts +90 -0
- package/scripts/hooks-system/domain/entities/__tests__/AuditResult.spec.js +450 -0
- package/scripts/hooks-system/domain/entities/__tests__/Finding.spec.js +335 -0
- package/scripts/hooks-system/domain/entities/__tests__/SeverityConfig.spec.js +240 -0
- package/scripts/hooks-system/domain/entities/__tests__/entities.spec.js +29 -0
- package/scripts/hooks-system/domain/errors/__tests__/DomainErrors.spec.js +59 -0
- package/scripts/hooks-system/domain/errors/index.js +169 -0
- package/scripts/hooks-system/domain/events/__tests__/DomainEvents.spec.js +60 -0
- package/scripts/hooks-system/domain/events/index.js +121 -0
- package/scripts/hooks-system/domain/ports/IAstPort.js +67 -0
- package/scripts/hooks-system/domain/ports/IEvidencePort.js +86 -0
- package/scripts/hooks-system/domain/ports/IGitCommandPort.js +110 -0
- package/scripts/hooks-system/domain/ports/IGitPort.js +114 -0
- package/scripts/hooks-system/domain/ports/IGitQueryPort.js +93 -0
- package/scripts/hooks-system/domain/ports/INotificationPort.js +35 -0
- package/scripts/hooks-system/domain/ports/__tests__/ports.spec.js +36 -0
- package/scripts/hooks-system/domain/ports/index.js +14 -0
- package/scripts/hooks-system/domain/repositories/ICursorTokenRepository.js +13 -0
- package/scripts/hooks-system/domain/repositories/IFindingsRepository.js +30 -0
- package/scripts/hooks-system/domain/repositories/__tests__/IFindingsRepository.spec.js +18 -0
- package/scripts/hooks-system/domain/rules/CommitBlockingRules.js +142 -0
- package/scripts/hooks-system/domain/rules/__tests__/CommitBlockingRules.spec.js +18 -0
- package/scripts/hooks-system/domain/services/AuditAnalyzer.js +103 -0
- package/scripts/hooks-system/domain/services/AuditFilter.js +26 -0
- package/scripts/hooks-system/domain/services/AuditResultSerializer.js +35 -0
- package/scripts/hooks-system/domain/services/AuditScorer.js +38 -0
- package/scripts/hooks-system/domain/values/Severity.js +93 -0
- package/scripts/hooks-system/index.js +49 -0
- package/scripts/hooks-system/infrastructure/adapters/AstAnalyzerAdapter.js +150 -0
- package/scripts/hooks-system/infrastructure/adapters/FileEvidenceAdapter.js +140 -0
- package/scripts/hooks-system/infrastructure/adapters/GitCliAdapter.js +16 -0
- package/scripts/hooks-system/infrastructure/adapters/GitCommandAdapter.js +68 -0
- package/scripts/hooks-system/infrastructure/adapters/GitHubCliAdapter.js +85 -0
- package/scripts/hooks-system/infrastructure/adapters/GitQueryAdapter.js +58 -0
- package/scripts/hooks-system/infrastructure/adapters/LegacyAnalyzerAdapter.js +61 -0
- package/scripts/hooks-system/infrastructure/adapters/MacOSNotificationAdapter.js +99 -0
- package/scripts/hooks-system/infrastructure/adapters/__tests__/AstAnalyzerAdapter.spec.js +32 -0
- package/scripts/hooks-system/infrastructure/adapters/__tests__/FileEvidenceAdapter.spec.js +31 -0
- package/scripts/hooks-system/infrastructure/adapters/__tests__/GitCliAdapter.spec.js +39 -0
- package/scripts/hooks-system/infrastructure/adapters/__tests__/MacOSNotificationAdapter.spec.js +33 -0
- package/scripts/hooks-system/infrastructure/adapters/git/GitCommandRunner.js +78 -0
- package/scripts/hooks-system/infrastructure/adapters/git/GitCommandService.js +67 -0
- package/scripts/hooks-system/infrastructure/adapters/git/GitQueryService.js +50 -0
- package/scripts/hooks-system/infrastructure/adapters/index.js +14 -0
- package/scripts/hooks-system/infrastructure/ast/README.md +198 -0
- package/scripts/hooks-system/infrastructure/ast/__tests__/ast-core.spec.js +160 -0
- package/scripts/hooks-system/infrastructure/ast/__tests__/ast-intelligence.spec.js +20 -0
- package/scripts/hooks-system/infrastructure/ast/android/__tests__/ast-android.spec.js +33 -0
- package/scripts/hooks-system/infrastructure/ast/android/__tests__/clean-architecture-analyzer.spec.js +96 -0
- package/scripts/hooks-system/infrastructure/ast/android/__tests__/ddd-analyzer.spec.js +113 -0
- package/scripts/hooks-system/infrastructure/ast/android/__tests__/detekt-runner.spec.js +36 -0
- package/scripts/hooks-system/infrastructure/ast/android/__tests__/feature-first-analyzer.spec.js +80 -0
- package/scripts/hooks-system/infrastructure/ast/android/__tests__/native-bridge.spec.js +31 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTIntelligentAnalyzer.js +15 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidASTParser.js +157 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js +164 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidArchitectureDetector.js +334 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidClassAnalyzer.js +162 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidForbiddenLiteralsAnalyzer.js +261 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidSOLIDAnalyzer.js +287 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/__tests__/AndroidForbiddenLiteralsAnalyzer.spec.js +58 -0
- package/scripts/hooks-system/infrastructure/ast/android/analyzers/__tests__/AndroidSOLIDAnalyzer.spec.js +84 -0
- package/scripts/hooks-system/infrastructure/ast/android/ast-android.js +1785 -0
- package/scripts/hooks-system/infrastructure/ast/android/clean-architecture-analyzer.js +115 -0
- package/scripts/hooks-system/infrastructure/ast/android/ddd-analyzer.js +70 -0
- package/scripts/hooks-system/infrastructure/ast/android/detekt-runner.js +81 -0
- package/scripts/hooks-system/infrastructure/ast/android/feature-first-analyzer.js +53 -0
- package/scripts/hooks-system/infrastructure/ast/android/native-bridge.js +119 -0
- package/scripts/hooks-system/infrastructure/ast/archive/README.md +18 -0
- package/scripts/hooks-system/infrastructure/ast/archive/ast-intelligence.ts +276 -0
- package/scripts/hooks-system/infrastructure/ast/archive/ios-rules.js +329 -0
- package/scripts/hooks-system/infrastructure/ast/archive/kotlin-analyzer.js +332 -0
- package/scripts/hooks-system/infrastructure/ast/archive/kotlin-parser.js +303 -0
- package/scripts/hooks-system/infrastructure/ast/archive/swift-analyzer.js +390 -0
- package/scripts/hooks-system/infrastructure/ast/ast-core.js +594 -0
- package/scripts/hooks-system/infrastructure/ast/ast-intelligence.js +617 -0
- package/scripts/hooks-system/infrastructure/ast/backend/__tests__/ast-backend.spec.js +20 -0
- package/scripts/hooks-system/infrastructure/ast/backend/__tests__/clean-architecture-analyzer.spec.js +151 -0
- package/scripts/hooks-system/infrastructure/ast/backend/__tests__/ddd-analyzer.spec.js +124 -0
- package/scripts/hooks-system/infrastructure/ast/backend/__tests__/feature-first-analyzer.spec.js +128 -0
- package/scripts/hooks-system/infrastructure/ast/backend/__tests__/forbidden-literals-analyzer.spec.js +95 -0
- package/scripts/hooks-system/infrastructure/ast/backend/__tests__/nestjs-patterns-analyzer.spec.js +59 -0
- package/scripts/hooks-system/infrastructure/ast/backend/__tests__/solid-analyzer.spec.js +114 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendArchitectureDetector.js +141 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendPatternDetector.js +23 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/__tests__/BackendArchitectureDetector.spec.js +239 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/__tests__/BackendPatternDetector.spec.js +58 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/detectors/CQRSDetector.js +41 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/detectors/CleanArchitectureDetector.js +52 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/detectors/FeatureFirstCleanDetector.js +74 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/detectors/LayeredArchitectureDetector.js +25 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/detectors/MVCDetector.js +32 -0
- package/scripts/hooks-system/infrastructure/ast/backend/analyzers/detectors/OnionArchitectureDetector.js +32 -0
- package/scripts/hooks-system/infrastructure/ast/backend/ast-backend-clean.js +44 -0
- package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +2048 -0
- package/scripts/hooks-system/infrastructure/ast/backend/clean-architecture-analyzer.js +142 -0
- package/scripts/hooks-system/infrastructure/ast/backend/ddd-analyzer.js +256 -0
- package/scripts/hooks-system/infrastructure/ast/backend/feature-first-analyzer.js +70 -0
- package/scripts/hooks-system/infrastructure/ast/backend/forbidden-literals-analyzer.js +236 -0
- package/scripts/hooks-system/infrastructure/ast/backend/nestjs-patterns-analyzer.js +11 -0
- package/scripts/hooks-system/infrastructure/ast/backend/solid-analyzer.js +392 -0
- package/scripts/hooks-system/infrastructure/ast/common/BDDTDDWorkflowRules.js +52 -0
- package/scripts/hooks-system/infrastructure/ast/common/__tests__/BDDTDDWorkflowRules.spec.js +133 -0
- package/scripts/hooks-system/infrastructure/ast/common/__tests__/ast-common.spec.js +20 -0
- package/scripts/hooks-system/infrastructure/ast/common/__tests__/documentation-analyzer.spec.js +120 -0
- package/scripts/hooks-system/infrastructure/ast/common/__tests__/images-backend-analyzer.spec.js +123 -0
- package/scripts/hooks-system/infrastructure/ast/common/__tests__/monorepo-health-analyzer.spec.js +118 -0
- package/scripts/hooks-system/infrastructure/ast/common/__tests__/network-resilience-analyzer.spec.js +180 -0
- package/scripts/hooks-system/infrastructure/ast/common/__tests__/offline-backend-analyzer.spec.js +111 -0
- package/scripts/hooks-system/infrastructure/ast/common/__tests__/push-backend-analyzer.spec.js +124 -0
- package/scripts/hooks-system/infrastructure/ast/common/ast-common.js +345 -0
- package/scripts/hooks-system/infrastructure/ast/common/documentation-analyzer.js +217 -0
- package/scripts/hooks-system/infrastructure/ast/common/images-backend-analyzer.js +36 -0
- package/scripts/hooks-system/infrastructure/ast/common/monorepo-health-analyzer.js +452 -0
- package/scripts/hooks-system/infrastructure/ast/common/network-resilience-analyzer.js +178 -0
- package/scripts/hooks-system/infrastructure/ast/common/offline-backend-analyzer.js +53 -0
- package/scripts/hooks-system/infrastructure/ast/common/push-backend-analyzer.js +42 -0
- package/scripts/hooks-system/infrastructure/ast/common/rules/BDDRules.js +87 -0
- package/scripts/hooks-system/infrastructure/ast/common/rules/ImplementationRules.js +83 -0
- package/scripts/hooks-system/infrastructure/ast/common/rules/TDDRules.js +109 -0
- package/scripts/hooks-system/infrastructure/ast/common/rules/WorkflowRules.js +137 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/__tests__/ast-frontend.spec.js +20 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendArchitectureDetector.js +289 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendForbiddenLiteralsAnalyzer.js +257 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/FrontendSOLIDAnalyzer.js +274 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/__tests__/FrontendArchitectureDetector.spec.js +151 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/__tests__/FrontendForbiddenLiteralsAnalyzer.spec.js +20 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/__tests__/FrontendSOLIDAnalyzer.spec.js +108 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/ast-frontend-clean.js +42 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/ast-frontend.js +2094 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/clean-architecture-analyzer.js +88 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/ddd-analyzer.js +94 -0
- package/scripts/hooks-system/infrastructure/ast/frontend/feature-first-analyzer.js +51 -0
- package/scripts/hooks-system/infrastructure/ast/ios/__tests__/ast-ios.spec.js +40 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSArchitectureDetector.spec.js +20 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSArchitectureRules.spec.js +61 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSCICDRules.spec.js +10 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSEnterpriseAnalyzer.spec.js +36 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSForbiddenLiteralsAnalyzer.spec.js +64 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSNetworkingAdvancedRules.spec.js +10 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSPerformanceRules.spec.js +34 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSSPMRules.spec.js +10 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSSwiftUIAdvancedRules.spec.js +10 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +894 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureDetector.js +445 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureRules.js +700 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSCICDRules.js +431 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSEnterpriseAnalyzer.js +580 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSForbiddenLiteralsAnalyzer.js +261 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSNetworkingAdvancedRules.js +177 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSPerformanceRules.js +11 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSSPMRules.js +496 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSSwiftUIAdvancedRules.js +333 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSTestingAdvancedRules.js +225 -0
- package/scripts/hooks-system/infrastructure/ast/ios/ast-ios.js +2176 -0
- package/scripts/hooks-system/infrastructure/ast/ios/native-bridge.js +92 -0
- package/scripts/hooks-system/infrastructure/ast/ios/parsers/SourceKittenParser.js +471 -0
- package/scripts/hooks-system/infrastructure/ast/ios/parsers/__tests__/SourceKittenParser.spec.js +41 -0
- package/scripts/hooks-system/infrastructure/ast/text/__tests__/text-scanner.spec.js +20 -0
- package/scripts/hooks-system/infrastructure/ast/text/text-scanner.js +1120 -0
- package/scripts/hooks-system/infrastructure/cache/CacheService.js +160 -0
- package/scripts/hooks-system/infrastructure/cli/__tests__/install-wizard.spec.js +16 -0
- package/scripts/hooks-system/infrastructure/cli/install-wizard.js +74 -0
- package/scripts/hooks-system/infrastructure/core/GitOperations.js +50 -0
- package/scripts/hooks-system/infrastructure/core/GitOperations.ts +112 -0
- package/scripts/hooks-system/infrastructure/core/__tests__/GitOperations.spec.js +146 -0
- package/scripts/hooks-system/infrastructure/eslint/eslint-integration.sh +75 -0
- package/scripts/hooks-system/infrastructure/events/EventListeners.js +143 -0
- package/scripts/hooks-system/infrastructure/events/__tests__/events.spec.js +14 -0
- package/scripts/hooks-system/infrastructure/external-tools/GitOperations.js +54 -0
- package/scripts/hooks-system/infrastructure/external-tools/eslint/backend.config.template.mjs +58 -0
- package/scripts/hooks-system/infrastructure/git-hooks/pre-push +35 -0
- package/scripts/hooks-system/infrastructure/git-server/pre-receive-hook +253 -0
- package/scripts/hooks-system/infrastructure/guards/git-wrapper.sh +32 -0
- package/scripts/hooks-system/infrastructure/guards/master-validator.sh +247 -0
- package/scripts/hooks-system/infrastructure/guards/prevent-no-verify.sh +34 -0
- package/scripts/hooks-system/infrastructure/hooks/__tests__/skill-activation-prompt.spec.js +11 -0
- package/scripts/hooks-system/infrastructure/hooks/pre-tool-use-intelligent-enforcer.sh +489 -0
- package/scripts/hooks-system/infrastructure/hooks/skill-activation-prompt.js +244 -0
- package/scripts/hooks-system/infrastructure/logging/UnifiedLoggerFactory.js +40 -0
- package/scripts/hooks-system/infrastructure/logging/__tests__/logging.spec.js +9 -0
- package/scripts/hooks-system/infrastructure/mcp/README.md +116 -0
- package/scripts/hooks-system/infrastructure/mcp/__tests__/ast-intelligence-automation.spec.js +38 -0
- package/scripts/hooks-system/infrastructure/mcp/__tests__/evidence-watcher.spec.js +38 -0
- package/scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js +1097 -0
- package/scripts/hooks-system/infrastructure/mcp/evidence-watcher.js +128 -0
- package/scripts/hooks-system/infrastructure/mcp/package.json +17 -0
- package/scripts/hooks-system/infrastructure/mcp/services/EvidenceService.js +87 -0
- package/scripts/hooks-system/infrastructure/mcp/services/McpProtocolHandler.js +166 -0
- package/scripts/hooks-system/infrastructure/orchestration/__tests__/intelligent-audit.spec.js +11 -0
- package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +353 -0
- package/scripts/hooks-system/infrastructure/patterns/pattern-checks.sh +98 -0
- package/scripts/hooks-system/infrastructure/reporting/ReportImpactAnalyzer.js +109 -0
- package/scripts/hooks-system/infrastructure/reporting/ReportMetricsCalculator.js +114 -0
- package/scripts/hooks-system/infrastructure/reporting/ReportPresenter.js +86 -0
- package/scripts/hooks-system/infrastructure/reporting/__tests__/reporting.spec.js +15 -0
- package/scripts/hooks-system/infrastructure/reporting/report-generator.js +130 -0
- package/scripts/hooks-system/infrastructure/reporting/severity-tracker.js +105 -0
- package/scripts/hooks-system/infrastructure/repositories/CursorTokenRepository.js +76 -0
- package/scripts/hooks-system/infrastructure/repositories/FileFindingsRepository.js +88 -0
- package/scripts/hooks-system/infrastructure/repositories/__tests__/repositories.spec.js +20 -0
- package/scripts/hooks-system/infrastructure/repositories/datasources/CursorApiDataSource.js +73 -0
- package/scripts/hooks-system/infrastructure/repositories/datasources/CursorFileDataSource.js +55 -0
- package/scripts/hooks-system/infrastructure/severity/__tests__/severity-evaluator.spec.js +18 -0
- package/scripts/hooks-system/infrastructure/severity/analyzers/__tests__/maintainability-analyzer.spec.js +170 -0
- package/scripts/hooks-system/infrastructure/severity/analyzers/__tests__/performance-analyzer.spec.js +186 -0
- package/scripts/hooks-system/infrastructure/severity/analyzers/__tests__/security-analyzer.spec.js +151 -0
- package/scripts/hooks-system/infrastructure/severity/analyzers/__tests__/stability-analyzer.spec.js +143 -0
- package/scripts/hooks-system/infrastructure/severity/analyzers/maintainability-analyzer.js +100 -0
- package/scripts/hooks-system/infrastructure/severity/analyzers/performance-analyzer.js +109 -0
- package/scripts/hooks-system/infrastructure/severity/analyzers/security-analyzer.js +104 -0
- package/scripts/hooks-system/infrastructure/severity/analyzers/stability-analyzer.js +85 -0
- package/scripts/hooks-system/infrastructure/severity/context/analyzers/CodeClassificationAnalyzer.js +71 -0
- package/scripts/hooks-system/infrastructure/severity/context/analyzers/DataAnalyzer.js +64 -0
- package/scripts/hooks-system/infrastructure/severity/context/analyzers/ImpactAnalyzer.js +68 -0
- package/scripts/hooks-system/infrastructure/severity/context/analyzers/SafetyAnalyzer.js +82 -0
- package/scripts/hooks-system/infrastructure/severity/context/context-builder.js +88 -0
- package/scripts/hooks-system/infrastructure/severity/generators/RecommendationGenerator.js +153 -0
- package/scripts/hooks-system/infrastructure/severity/mappers/SeverityMapper.js +10 -0
- package/scripts/hooks-system/infrastructure/severity/policies/gate-policies.js +136 -0
- package/scripts/hooks-system/infrastructure/severity/policies/severity-policies.json +206 -0
- package/scripts/hooks-system/infrastructure/severity/scorers/ContextMultiplier.js +49 -0
- package/scripts/hooks-system/infrastructure/severity/severity-evaluator.js +117 -0
- package/scripts/hooks-system/infrastructure/shell/core/constants.sh +26 -0
- package/scripts/hooks-system/infrastructure/shell/core/utils.sh +45 -0
- package/scripts/hooks-system/infrastructure/shell/gitflow/git-wrapper.sh +646 -0
- package/scripts/hooks-system/infrastructure/shell/gitflow/gitflow-enforcer.sh +620 -0
- package/scripts/hooks-system/infrastructure/shell/gitflow/gitflow-state-manager.sh +235 -0
- package/scripts/hooks-system/infrastructure/shell/gitflow-state-manager.sh +225 -0
- package/scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh +1106 -0
- package/scripts/hooks-system/infrastructure/shell/security/detect-secrets.sh +26 -0
- package/scripts/hooks-system/infrastructure/shell/security/detect_secrets.py +182 -0
- package/scripts/hooks-system/infrastructure/shell/validate-clean-architecture.sh +254 -0
- package/scripts/hooks-system/infrastructure/shell/validators/check-doc-structure.sh +62 -0
- package/scripts/hooks-system/infrastructure/shell/validators/ensure-critical-docs.sh +26 -0
- package/scripts/hooks-system/infrastructure/shell/validators/validate-ai-protocol.sh +474 -0
- package/scripts/hooks-system/infrastructure/shell/validators/validate-clean-architecture.sh +303 -0
- package/scripts/hooks-system/infrastructure/shell/validators/validate-conventional-commit.sh +42 -0
- package/scripts/hooks-system/infrastructure/storage/file-operations.sh +31 -0
- package/scripts/hooks-system/infrastructure/telemetry/TelemetryService.js +165 -0
- package/scripts/hooks-system/infrastructure/telemetry/__tests__/telemetry.spec.js +15 -0
- package/scripts/hooks-system/infrastructure/telemetry/metrics-logger.js +66 -0
- package/scripts/hooks-system/infrastructure/telemetry/metrics-server.js +61 -0
- package/scripts/hooks-system/infrastructure/utils/__tests__/utils.spec.js +8 -0
- package/scripts/hooks-system/infrastructure/utils/error-utils.js +28 -0
- package/scripts/hooks-system/infrastructure/utils/timestamp-helper.sh +106 -0
- package/scripts/hooks-system/infrastructure/utils/token-manager.js +121 -0
- package/scripts/hooks-system/infrastructure/validators/__tests__/detect-commit-language.spec.js +16 -0
- package/scripts/hooks-system/infrastructure/validators/__tests__/enforce-english-literals.spec.js +67 -0
- package/scripts/hooks-system/infrastructure/validators/detect-commit-language.js +145 -0
- package/scripts/hooks-system/infrastructure/validators/enforce-english-literals.js +202 -0
- package/scripts/hooks-system/infrastructure/watchdog/__tests__/.audit-reports/token-monitor.log +18 -0
- package/scripts/hooks-system/infrastructure/watchdog/__tests__/auto-recovery.spec.js +14 -0
- package/scripts/hooks-system/infrastructure/watchdog/__tests__/token-monitor.spec.js +67 -0
- package/scripts/hooks-system/infrastructure/watchdog/__tests__/watchdog.spec.js +22 -0
- package/scripts/hooks-system/infrastructure/watchdog/ai-watchdog.sh +278 -0
- package/scripts/hooks-system/infrastructure/watchdog/auto-recovery.js +32 -0
- package/scripts/hooks-system/infrastructure/watchdog/health-check.js +58 -0
- package/scripts/hooks-system/infrastructure/watchdog/token-monitor-loop.sh +20 -0
- package/scripts/hooks-system/infrastructure/watchdog/token-monitor.js +69 -0
- package/scripts/hooks-system/infrastructure/watchdog/token-tracker.sh +208 -0
- package/scripts/hooks-system/presentation/cli/audit.sh +32 -0
- package/scripts/hooks-system/presentation/cli/autonomous-status.sh +92 -0
- package/scripts/hooks-system/presentation/cli/categorize-violations.sh +179 -0
- package/scripts/hooks-system/presentation/cli/direct-audit-option2.sh +23 -0
- package/scripts/hooks-system/presentation/cli/direct-audit.sh +33 -0
- package/skills/android-guidelines/SKILL.md +475 -0
- package/skills/android-guidelines/resources/advanced-topics.md +44 -0
- package/skills/android-guidelines/resources/architecture-overview.md +44 -0
- package/skills/backend-guidelines/SKILL.md +335 -0
- package/skills/backend-guidelines/resources/architecture-overview.md +48 -0
- package/skills/frontend-guidelines/SKILL.md +367 -0
- package/skills/frontend-guidelines/resources/architecture-overview.md +44 -0
- package/skills/ios-guidelines/SKILL.md +406 -0
- package/skills/ios-guidelines/resources/architecture-overview.md +47 -0
- package/skills/skill-rules.json +334 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# Clean Architecture Validator
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# Purpose: Auto-validate file paths against Clean Architecture rules
|
|
6
|
+
# Author: Carlos Merlos
|
|
7
|
+
# =============================================================================
|
|
8
|
+
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
RED='\033[0;31m'
|
|
12
|
+
GREEN='\033[0;32m'
|
|
13
|
+
YELLOW='\033[1;33m'
|
|
14
|
+
BLUE='\033[0;34m'
|
|
15
|
+
NC='\033[0m'
|
|
16
|
+
|
|
17
|
+
VIOLATIONS=0
|
|
18
|
+
|
|
19
|
+
# =============================================================================
|
|
20
|
+
# Check Forbidden Directories (ALL platforms)
|
|
21
|
+
# =============================================================================
|
|
22
|
+
check_forbidden_directories() {
|
|
23
|
+
local file="$1"
|
|
24
|
+
local dir=$(dirname "$file")
|
|
25
|
+
|
|
26
|
+
# Forbidden directories (match at start, middle, or end of path)
|
|
27
|
+
if [[ "$dir" =~ (^|/)lib(/|$) ]]; then
|
|
28
|
+
echo -e "${RED}❌ VIOLATION: lib/ is FORBIDDEN${NC}"
|
|
29
|
+
echo -e " File: $file"
|
|
30
|
+
echo -e " Fix: Use ${GREEN}infrastructure/${NC} or ${GREEN}presentation/${NC}"
|
|
31
|
+
((VIOLATIONS++))
|
|
32
|
+
return 1
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
if [[ "$dir" =~ (^|/)utils(/|$) ]]; then
|
|
36
|
+
echo -e "${RED}❌ VIOLATION: utils/ is FORBIDDEN${NC}"
|
|
37
|
+
echo -e " File: $file"
|
|
38
|
+
echo -e " Fix: Use ${GREEN}application/${NC} or ${GREEN}domain/${NC}"
|
|
39
|
+
((VIOLATIONS++))
|
|
40
|
+
return 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
if [[ "$dir" =~ (^|/)helpers(/|$) ]]; then
|
|
44
|
+
echo -e "${RED}❌ VIOLATION: helpers/ is FORBIDDEN${NC}"
|
|
45
|
+
echo -e " File: $file"
|
|
46
|
+
echo -e " Fix: Use ${GREEN}application/use-cases/${NC}"
|
|
47
|
+
((VIOLATIONS++))
|
|
48
|
+
return 1
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if [[ "$dir" =~ (^|/)docs(/|$) ]]; then
|
|
52
|
+
echo -e "${RED}❌ VIOLATION: docs/ is FORBIDDEN in Clean Architecture${NC}"
|
|
53
|
+
echo -e " File: $file"
|
|
54
|
+
echo -e " Fix: Documentation should be:"
|
|
55
|
+
echo -e " - README.md in root"
|
|
56
|
+
echo -e " - README.md in each module directory"
|
|
57
|
+
echo -e " - NOT in separate docs/ folder"
|
|
58
|
+
((VIOLATIONS++))
|
|
59
|
+
return 1
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
return 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# =============================================================================
|
|
66
|
+
# Frontend Rules (React/TypeScript/Next.js)
|
|
67
|
+
# =============================================================================
|
|
68
|
+
validate_frontend_file() {
|
|
69
|
+
local file="$1"
|
|
70
|
+
local filename=$(basename "$file")
|
|
71
|
+
local dir=$(dirname "$file")
|
|
72
|
+
|
|
73
|
+
# Hook files (allow both presentation/hooks and app/**/hooks for Next.js App Router)
|
|
74
|
+
if [[ "$filename" =~ ^use[A-Z].*\.(ts|tsx)$ ]]; then
|
|
75
|
+
if [[ ! "$dir" =~ presentation/hooks$ ]] && [[ ! "$dir" =~ app/.*/hooks$ ]]; then
|
|
76
|
+
echo -e "${RED}❌ VIOLATION: Hook file in wrong location${NC}"
|
|
77
|
+
echo -e " File: $file"
|
|
78
|
+
echo -e " Rule: Custom hooks → ${GREEN}presentation/hooks/${NC} or ${GREEN}app/**/hooks/${NC}"
|
|
79
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
80
|
+
echo -e " Fix: Move to presentation/hooks/ or keep in app feature directory"
|
|
81
|
+
((VIOLATIONS++))
|
|
82
|
+
return 1
|
|
83
|
+
fi
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
# Config files
|
|
87
|
+
if [[ "$filename" =~ \.config\.(ts|js)$ ]] || [[ "$filename" =~ ^(api|i18n|env)\.(ts|js)$ ]]; then
|
|
88
|
+
if [[ ! "$dir" =~ infrastructure/config$ ]]; then
|
|
89
|
+
echo -e "${RED}❌ VIOLATION: Config file in wrong location${NC}"
|
|
90
|
+
echo -e " File: $file"
|
|
91
|
+
echo -e " Rule: Configuration → ${GREEN}infrastructure/config/${NC}"
|
|
92
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
93
|
+
echo -e " Fix: Move to infrastructure/config/"
|
|
94
|
+
((VIOLATIONS++))
|
|
95
|
+
return 1
|
|
96
|
+
fi
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# Store files (Zustand/Redux)
|
|
100
|
+
if [[ "$filename" =~ Store\.(ts|tsx)$ ]] || [[ "$filename" =~ \.store\.(ts|tsx)$ ]]; then
|
|
101
|
+
if [[ ! "$dir" =~ presentation/stores$ ]]; then
|
|
102
|
+
echo -e "${RED}❌ VIOLATION: Store file in wrong location${NC}"
|
|
103
|
+
echo -e " File: $file"
|
|
104
|
+
echo -e " Rule: State stores → ${GREEN}presentation/stores/${NC}"
|
|
105
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
106
|
+
echo -e " Fix: Move to presentation/stores/"
|
|
107
|
+
((VIOLATIONS++))
|
|
108
|
+
return 1
|
|
109
|
+
fi
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
# Use Case files
|
|
113
|
+
if [[ "$filename" =~ UseCase\.(ts|js)$ ]]; then
|
|
114
|
+
if [[ ! "$dir" =~ application/use-cases$ ]]; then
|
|
115
|
+
echo -e "${RED}❌ VIOLATION: Use Case in wrong location${NC}"
|
|
116
|
+
echo -e " File: $file"
|
|
117
|
+
echo -e " Rule: Use Cases → ${GREEN}application/use-cases/${NC}"
|
|
118
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
119
|
+
echo -e " Fix: Move to application/use-cases/"
|
|
120
|
+
((VIOLATIONS++))
|
|
121
|
+
return 1
|
|
122
|
+
fi
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
# Repository implementations
|
|
126
|
+
if [[ "$filename" =~ Repository\.(ts|js)$ ]] && [[ ! "$filename" =~ ^I[A-Z] ]]; then
|
|
127
|
+
if [[ ! "$dir" =~ infrastructure/repositories$ ]]; then
|
|
128
|
+
echo -e "${RED}❌ VIOLATION: Repository implementation in wrong location${NC}"
|
|
129
|
+
echo -e " File: $file"
|
|
130
|
+
echo -e " Rule: Repository impl → ${GREEN}infrastructure/repositories/${NC}"
|
|
131
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
132
|
+
echo -e " Fix: Move to infrastructure/repositories/"
|
|
133
|
+
((VIOLATIONS++))
|
|
134
|
+
return 1
|
|
135
|
+
fi
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
# Repository interfaces
|
|
139
|
+
if [[ "$filename" =~ ^I[A-Z].*Repository\.(ts|js)$ ]]; then
|
|
140
|
+
if [[ ! "$dir" =~ domain/repositories$ ]]; then
|
|
141
|
+
echo -e "${RED}❌ VIOLATION: Repository interface in wrong location${NC}"
|
|
142
|
+
echo -e " File: $file"
|
|
143
|
+
echo -e " Rule: Repository interface → ${GREEN}domain/repositories/${NC}"
|
|
144
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
145
|
+
echo -e " Fix: Move to domain/repositories/"
|
|
146
|
+
((VIOLATIONS++))
|
|
147
|
+
return 1
|
|
148
|
+
fi
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
# FORBIDDEN DIRECTORIES
|
|
152
|
+
if [[ "$dir" =~ /lib/ ]] && [[ ! "$dir" =~ /node_modules/ ]]; then
|
|
153
|
+
echo -e "${RED}❌ VIOLATION: File in forbidden 'lib/' directory${NC}"
|
|
154
|
+
echo -e " File: $file"
|
|
155
|
+
echo -e " Rule: ${RED}NEVER use lib/${NC}"
|
|
156
|
+
echo -e " Use instead:"
|
|
157
|
+
echo -e " - infrastructure/ (for services, config)"
|
|
158
|
+
echo -e " - presentation/ (for hooks, components)"
|
|
159
|
+
((VIOLATIONS++))
|
|
160
|
+
return 1
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
if [[ "$dir" =~ /utils/ ]] && [[ ! "$dir" =~ /node_modules/ ]]; then
|
|
164
|
+
echo -e "${RED}❌ VIOLATION: File in forbidden 'utils/' directory${NC}"
|
|
165
|
+
echo -e " File: $file"
|
|
166
|
+
echo -e " Rule: ${RED}NEVER use utils/${NC}"
|
|
167
|
+
echo -e " Use instead:"
|
|
168
|
+
echo -e " - application/ (for business logic)"
|
|
169
|
+
echo -e " - domain/ (for domain logic)"
|
|
170
|
+
((VIOLATIONS++))
|
|
171
|
+
return 1
|
|
172
|
+
fi
|
|
173
|
+
|
|
174
|
+
if [[ "$dir" =~ /helpers/ ]] && [[ ! "$dir" =~ /node_modules/ ]]; then
|
|
175
|
+
echo -e "${RED}❌ VIOLATION: File in forbidden 'helpers/' directory${NC}"
|
|
176
|
+
echo -e " File: $file"
|
|
177
|
+
echo -e " Rule: ${RED}NEVER use helpers/${NC}"
|
|
178
|
+
echo -e " Use: ${GREEN}application/use-cases/${NC}"
|
|
179
|
+
((VIOLATIONS++))
|
|
180
|
+
return 1
|
|
181
|
+
fi
|
|
182
|
+
|
|
183
|
+
return 0
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
# =============================================================================
|
|
187
|
+
# Backend Rules (NestJS)
|
|
188
|
+
# =============================================================================
|
|
189
|
+
validate_backend_file() {
|
|
190
|
+
local file="$1"
|
|
191
|
+
local filename=$(basename "$file")
|
|
192
|
+
local dir=$(dirname "$file")
|
|
193
|
+
|
|
194
|
+
# Controller files
|
|
195
|
+
if [[ "$filename" =~ \.controller\.(ts|js)$ ]]; then
|
|
196
|
+
if [[ ! "$dir" =~ presentation/controllers$ ]] && [[ ! "$dir" =~ src/[^/]+$ ]]; then
|
|
197
|
+
echo -e "${YELLOW}⚠️ WARNING: Controller not in presentation/controllers${NC}"
|
|
198
|
+
echo -e " File: $file"
|
|
199
|
+
echo -e " Recommended: ${GREEN}presentation/controllers/${NC}"
|
|
200
|
+
echo -e " Current: $dir"
|
|
201
|
+
fi
|
|
202
|
+
fi
|
|
203
|
+
|
|
204
|
+
# Guard files
|
|
205
|
+
if [[ "$filename" =~ \.guard\.(ts|js)$ ]]; then
|
|
206
|
+
if [[ ! "$dir" =~ presentation/guards$ ]] && [[ ! "$dir" =~ src/guards$ ]]; then
|
|
207
|
+
echo -e "${YELLOW}⚠️ WARNING: Guard not in presentation/guards${NC}"
|
|
208
|
+
echo -e " File: $file"
|
|
209
|
+
echo -e " Recommended: ${GREEN}presentation/guards/${NC}"
|
|
210
|
+
fi
|
|
211
|
+
fi
|
|
212
|
+
|
|
213
|
+
# Use Case files
|
|
214
|
+
if [[ "$filename" =~ UseCase\.(ts|js)$ ]] || [[ "$filename" =~ \.use-case\.(ts|js)$ ]]; then
|
|
215
|
+
if [[ ! "$dir" =~ application/use-cases$ ]]; then
|
|
216
|
+
echo -e "${RED}❌ VIOLATION: Use Case in wrong location${NC}"
|
|
217
|
+
echo -e " File: $file"
|
|
218
|
+
echo -e " Rule: Use Cases → ${GREEN}application/use-cases/${NC}"
|
|
219
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
220
|
+
((VIOLATIONS++))
|
|
221
|
+
return 1
|
|
222
|
+
fi
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# DTO files
|
|
226
|
+
if [[ "$filename" =~ \.dto\.(ts|js)$ ]]; then
|
|
227
|
+
if [[ ! "$dir" =~ application/dtos$ ]] && [[ ! "$dir" =~ src/[^/]+/dto$ ]]; then
|
|
228
|
+
echo -e "${YELLOW}⚠️ WARNING: DTO not in application/dtos${NC}"
|
|
229
|
+
echo -e " File: $file"
|
|
230
|
+
echo -e " Recommended: ${GREEN}application/dtos/${NC}"
|
|
231
|
+
fi
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
# FORBIDDEN DIRECTORIES (same as frontend)
|
|
235
|
+
if [[ "$dir" =~ /lib/ ]] && [[ ! "$dir" =~ /node_modules/ ]]; then
|
|
236
|
+
echo -e "${RED}❌ VIOLATION: File in forbidden 'lib/' directory${NC}"
|
|
237
|
+
echo -e " File: $file"
|
|
238
|
+
echo -e " Rule: ${RED}NEVER use lib/${NC} → Use ${GREEN}infrastructure/${NC}"
|
|
239
|
+
((VIOLATIONS++))
|
|
240
|
+
return 1
|
|
241
|
+
fi
|
|
242
|
+
|
|
243
|
+
return 0
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
# =============================================================================
|
|
247
|
+
# Main Validator
|
|
248
|
+
# =============================================================================
|
|
249
|
+
|
|
250
|
+
validate_staged_files() {
|
|
251
|
+
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
252
|
+
echo -e "${BLUE}🏗️ Clean Architecture Validator${NC}"
|
|
253
|
+
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
254
|
+
echo ""
|
|
255
|
+
|
|
256
|
+
local staged_files=$(git diff --cached --name-only --diff-filter=ACM)
|
|
257
|
+
|
|
258
|
+
if [[ -z "$staged_files" ]]; then
|
|
259
|
+
echo -e "${GREEN}✅ No files to validate${NC}"
|
|
260
|
+
return 0
|
|
261
|
+
fi
|
|
262
|
+
|
|
263
|
+
local file_count=$(echo "$staged_files" | wc -l | tr -d ' ')
|
|
264
|
+
echo "📁 Validating $file_count staged file(s)..."
|
|
265
|
+
echo ""
|
|
266
|
+
|
|
267
|
+
while IFS= read -r file; do
|
|
268
|
+
# Skip non-source files
|
|
269
|
+
[[ "$file" =~ \.(md|json|yml|yaml|txt|lock)$ ]] && continue
|
|
270
|
+
[[ "$file" =~ node_modules/ ]] && continue
|
|
271
|
+
[[ "$file" =~ \.git/ ]] && continue
|
|
272
|
+
|
|
273
|
+
# First: Check forbidden directories (applies to ALL platforms)
|
|
274
|
+
check_forbidden_directories "$file" || continue
|
|
275
|
+
|
|
276
|
+
# Then: Detect platform and validate specific rules
|
|
277
|
+
if [[ "$file" =~ \.(ts|tsx|jsx)$ ]] && [[ "$file" =~ apps/(admin-dashboard|web)/ ]]; then
|
|
278
|
+
validate_frontend_file "$file"
|
|
279
|
+
elif [[ "$file" =~ \.(ts|js)$ ]] && [[ "$file" =~ apps/backend/ ]]; then
|
|
280
|
+
validate_backend_file "$file"
|
|
281
|
+
fi
|
|
282
|
+
done <<< "$staged_files"
|
|
283
|
+
|
|
284
|
+
echo ""
|
|
285
|
+
if [[ $VIOLATIONS -gt 0 ]]; then
|
|
286
|
+
echo -e "${RED}═══════════════════════════════════════════════════════════════${NC}"
|
|
287
|
+
echo -e "${RED}❌ CLEAN ARCHITECTURE VIOLATED: $VIOLATIONS violation(s)${NC}"
|
|
288
|
+
echo -e "${RED}═══════════════════════════════════════════════════════════════${NC}"
|
|
289
|
+
echo ""
|
|
290
|
+
echo -e "${YELLOW}Fix violations or move files to correct directories.${NC}"
|
|
291
|
+
echo ""
|
|
292
|
+
echo -e "${BLUE}Need help? Run:${NC}"
|
|
293
|
+
echo -e " ${GREEN}cat .cursorrules${NC} # See structure rules"
|
|
294
|
+
echo ""
|
|
295
|
+
return 1
|
|
296
|
+
else
|
|
297
|
+
echo -e "${GREEN}✅ Clean Architecture: All files in correct locations${NC}"
|
|
298
|
+
return 0
|
|
299
|
+
fi
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
# Run validation
|
|
303
|
+
validate_staged_files
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
MSG_FILE="${1:-}"
|
|
6
|
+
|
|
7
|
+
if [[ -z "$MSG_FILE" ]] || [[ ! -f "$MSG_FILE" ]]; then
|
|
8
|
+
exit 0
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
MSG=$(cat "$MSG_FILE")
|
|
12
|
+
|
|
13
|
+
# =============================================================================
|
|
14
|
+
# 1. VALIDATE CONVENTIONAL COMMITS FORMAT
|
|
15
|
+
# =============================================================================
|
|
16
|
+
CONVENTIONAL_HOOK="${HOME}/.cache/pre-commit/repokqr3d6ev/py_env-python3/bin/conventional-pre-commit"
|
|
17
|
+
|
|
18
|
+
if [[ ! -f "$CONVENTIONAL_HOOK" ]]; then
|
|
19
|
+
CONVENTIONAL_HOOK=$(find "${HOME}/.cache/pre-commit" -name "conventional-pre-commit" -type f 2>/dev/null | head -1)
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
if [[ -n "$CONVENTIONAL_HOOK" ]] && [[ -f "$CONVENTIONAL_HOOK" ]]; then
|
|
23
|
+
"$CONVENTIONAL_HOOK" -- "$MSG_FILE" || exit 1
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# =============================================================================
|
|
27
|
+
# 2. VALIDATE ENGLISH LANGUAGE (Intelligent Detection)
|
|
28
|
+
# =============================================================================
|
|
29
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
30
|
+
LANG_DETECTOR="${SCRIPT_DIR}/../../validators/detect-commit-language.js"
|
|
31
|
+
|
|
32
|
+
if [[ -f "$LANG_DETECTOR" ]] && command -v node >/dev/null 2>&1; then
|
|
33
|
+
node "$LANG_DETECTOR" "$MSG_FILE"
|
|
34
|
+
exit_code=$?
|
|
35
|
+
if [[ $exit_code -ne 0 ]]; then
|
|
36
|
+
exit $exit_code
|
|
37
|
+
fi
|
|
38
|
+
else
|
|
39
|
+
echo "⚠️ Language detector not available, skipping language validation"
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
exit 0
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# File Operations - Infrastructure Layer
|
|
3
|
+
# File listing and counting utilities
|
|
4
|
+
|
|
5
|
+
list_source_files() {
|
|
6
|
+
local dir="$1"
|
|
7
|
+
find "$dir" -type f \
|
|
8
|
+
\( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.mjs" -o -name "*.cjs" \) \
|
|
9
|
+
-not -path "*/node_modules/*" \
|
|
10
|
+
-not -path "*/dist/*" \
|
|
11
|
+
-not -path "*/.next/*" \
|
|
12
|
+
-not -path "*/.turbo/*" \
|
|
13
|
+
-not -path "*/.vercel/*" \
|
|
14
|
+
-not -path "*/coverage/*" \
|
|
15
|
+
-not -path "*/build/*" \
|
|
16
|
+
-not -path "*/out/*" \
|
|
17
|
+
-not -path "*/.cache/*" \
|
|
18
|
+
-not -name "*.d.ts" \
|
|
19
|
+
-not -name "*.map" \
|
|
20
|
+
-not -name "*.min.*" \
|
|
21
|
+
-not -name "*.snap"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
count_files() {
|
|
25
|
+
local list_file="$1"
|
|
26
|
+
if [[ -f "$list_file" ]]; then
|
|
27
|
+
wc -l < "$list_file" | tr -d ' '
|
|
28
|
+
else
|
|
29
|
+
echo 0
|
|
30
|
+
fi
|
|
31
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
class TelemetryService {
|
|
5
|
+
constructor(repoRoot) {
|
|
6
|
+
this.repoRoot = repoRoot || process.cwd();
|
|
7
|
+
this.logFile = path.join(this.repoRoot, '.audit_tmp/autonomous-decisions.jsonl');
|
|
8
|
+
this.thresholds = {
|
|
9
|
+
autoExecute: 90,
|
|
10
|
+
ask: 70
|
|
11
|
+
};
|
|
12
|
+
this.ensureLogDirectory();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
ensureLogDirectory() {
|
|
16
|
+
const dir = path.dirname(this.logFile);
|
|
17
|
+
if (!fs.existsSync(dir)) {
|
|
18
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
logDecision(context, decision, userFeedback = null) {
|
|
23
|
+
const entry = {
|
|
24
|
+
timestamp: Date.now(),
|
|
25
|
+
isoTimestamp: new Date().toISOString(),
|
|
26
|
+
platforms: context.platforms,
|
|
27
|
+
confidence: context.confidence,
|
|
28
|
+
decision: decision,
|
|
29
|
+
userCorrection: userFeedback,
|
|
30
|
+
accuracy: this.calculateAccuracy(),
|
|
31
|
+
contextHash: this.hashContext(context)
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
fs.appendFileSync(this.logFile, JSON.stringify(entry) + '\n', 'utf-8');
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('[TelemetryService] Failed to log decision:', error.message);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
hashContext(context) {
|
|
42
|
+
const str = JSON.stringify({
|
|
43
|
+
platforms: context.platforms,
|
|
44
|
+
branch: context.branchName,
|
|
45
|
+
filesCount: context.stagedFiles?.length || 0
|
|
46
|
+
});
|
|
47
|
+
return str.split('').reduce((hash, char) => {
|
|
48
|
+
return ((hash << 5) - hash) + char.charCodeAt(0);
|
|
49
|
+
}, 0).toString(36);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
analyzeDecisions(days = 7) {
|
|
53
|
+
try {
|
|
54
|
+
if (!fs.existsSync(this.logFile)) {
|
|
55
|
+
return {
|
|
56
|
+
totalDecisions: 0,
|
|
57
|
+
accuracy: 100,
|
|
58
|
+
falsePositives: 0,
|
|
59
|
+
falseNegatives: 0
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const cutoff = Date.now() - (days * 24 * 60 * 60 * 1000);
|
|
64
|
+
const lines = fs.readFileSync(this.logFile, 'utf-8').split('\n').filter(Boolean);
|
|
65
|
+
|
|
66
|
+
const recentDecisions = lines
|
|
67
|
+
.map(line => {
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(line);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
.filter(entry => entry && entry.timestamp >= cutoff);
|
|
75
|
+
|
|
76
|
+
if (recentDecisions.length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
totalDecisions: 0,
|
|
79
|
+
accuracy: 100,
|
|
80
|
+
falsePositives: 0,
|
|
81
|
+
falseNegatives: 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const decisionsWithFeedback = recentDecisions.filter(d => d.userCorrection !== null);
|
|
86
|
+
|
|
87
|
+
if (decisionsWithFeedback.length === 0) {
|
|
88
|
+
return {
|
|
89
|
+
totalDecisions: recentDecisions.length,
|
|
90
|
+
accuracy: null,
|
|
91
|
+
falsePositives: 0,
|
|
92
|
+
falseNegatives: 0,
|
|
93
|
+
note: 'No user feedback yet'
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const correct = decisionsWithFeedback.filter(d => d.userCorrection === true).length;
|
|
98
|
+
const falsePositives = decisionsWithFeedback.filter(d =>
|
|
99
|
+
d.decision === 'auto-executed' && d.userCorrection === false
|
|
100
|
+
).length;
|
|
101
|
+
const falseNegatives = decisionsWithFeedback.filter(d =>
|
|
102
|
+
d.decision === 'ignored' && d.userCorrection === false
|
|
103
|
+
).length;
|
|
104
|
+
|
|
105
|
+
const accuracy = (correct / decisionsWithFeedback.length) * 100;
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
totalDecisions: recentDecisions.length,
|
|
109
|
+
decisionsWithFeedback: decisionsWithFeedback.length,
|
|
110
|
+
accuracy: Math.round(accuracy),
|
|
111
|
+
falsePositives,
|
|
112
|
+
falseNegatives,
|
|
113
|
+
falsePositiveRate: (falsePositives / decisionsWithFeedback.length) * 100
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error('[TelemetryService] Error analyzing decisions:', error.message);
|
|
118
|
+
return {
|
|
119
|
+
totalDecisions: 0,
|
|
120
|
+
accuracy: null,
|
|
121
|
+
error: error.message
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
calculateAccuracy() {
|
|
127
|
+
const stats = this.analyzeDecisions(7);
|
|
128
|
+
return stats.accuracy || null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async adjustThresholds() {
|
|
132
|
+
const stats = this.analyzeDecisions(30);
|
|
133
|
+
|
|
134
|
+
if (!stats.accuracy || stats.decisionsWithFeedback < 10) {
|
|
135
|
+
console.log('[TelemetryService] Insufficient data to adjust thresholds');
|
|
136
|
+
return { adjusted: false, reason: 'insufficient-data', stats };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (stats.falsePositiveRate > 15) {
|
|
140
|
+
this.thresholds.autoExecute = Math.min(95, this.thresholds.autoExecute + 5);
|
|
141
|
+
console.log(`[TelemetryService] Raising autoExecute threshold to ${this.thresholds.autoExecute}% (too many false positives)`);
|
|
142
|
+
return { adjusted: true, newThreshold: this.thresholds.autoExecute, stats };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (stats.accuracy >= 95 && this.thresholds.autoExecute > 85) {
|
|
146
|
+
this.thresholds.autoExecute = Math.max(85, this.thresholds.autoExecute - 2);
|
|
147
|
+
console.log(`[TelemetryService] Lowering autoExecute threshold to ${this.thresholds.autoExecute}% (high accuracy)`);
|
|
148
|
+
return { adjusted: true, newThreshold: this.thresholds.autoExecute, stats };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return { adjusted: false, reason: 'thresholds-ok', stats };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getStats(days = 7) {
|
|
155
|
+
const analysis = this.analyzeDecisions(days);
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
period: `${days} days`,
|
|
159
|
+
...analysis,
|
|
160
|
+
currentThresholds: { ...this.thresholds }
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
module.exports = TelemetryService;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
describe('telemetry', () => {
|
|
2
|
+
describe('TelemetryService', () => {
|
|
3
|
+
it('should export class', () => {
|
|
4
|
+
const TelemetryService = require('../TelemetryService');
|
|
5
|
+
expect(TelemetryService).toBeDefined();
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe('metrics-logger', () => {
|
|
10
|
+
it('should export module', () => {
|
|
11
|
+
const mod = require('../metrics-logger');
|
|
12
|
+
expect(mod).toBeDefined();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Simple metrics logger stub for the hook-system platform.
|
|
5
|
+
* Usage (programmatic):
|
|
6
|
+
* const { recordMetric } = require('./metrics-logger');
|
|
7
|
+
* recordMetric({ hook: 'validate-ai-evidence', status: 'success', durationMs: 123 });
|
|
8
|
+
*
|
|
9
|
+
* Usage (CLI):
|
|
10
|
+
* node scripts/hooks-system/infrastructure/telemetry/metrics-logger.js \
|
|
11
|
+
* --hook validate-ai-evidence --status success --duration 123
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
|
|
17
|
+
const METRICS_FILE = path.join(process.cwd(), '.audit_tmp', 'hook-metrics.jsonl');
|
|
18
|
+
|
|
19
|
+
function ensureDir() {
|
|
20
|
+
const dir = path.dirname(METRICS_FILE);
|
|
21
|
+
if (!fs.existsSync(dir)) {
|
|
22
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function recordMetric(entry) {
|
|
27
|
+
ensureDir();
|
|
28
|
+
const payload = {
|
|
29
|
+
timestamp: Date.now(),
|
|
30
|
+
...entry,
|
|
31
|
+
};
|
|
32
|
+
fs.appendFileSync(METRICS_FILE, `${JSON.stringify(payload)}\n`, 'utf8');
|
|
33
|
+
return payload;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function parseArgs(argv) {
|
|
37
|
+
const args = {};
|
|
38
|
+
for (let i = 2; i < argv.length; i++) {
|
|
39
|
+
const arg = argv[i];
|
|
40
|
+
if (arg.startsWith('--')) {
|
|
41
|
+
const key = arg.slice(2);
|
|
42
|
+
const value = argv[i + 1];
|
|
43
|
+
args[key] = value;
|
|
44
|
+
i++;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return args;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (require.main === module) {
|
|
51
|
+
const args = parseArgs(process.argv);
|
|
52
|
+
const { hook, status, duration } = args;
|
|
53
|
+
|
|
54
|
+
if (!hook || !status) {
|
|
55
|
+
console.error('Usage: metrics-logger --hook <name> --status <success|failure> [--duration <ms>]');
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const durationMs = duration ? Number(duration) : undefined;
|
|
60
|
+
recordMetric({ hook, status, durationMs });
|
|
61
|
+
console.log('Metric recorded');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
recordMetric,
|
|
66
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const PORT = Number(process.env.HOOK_METRICS_PORT || 9464);
|
|
8
|
+
const METRICS_FILE = path.join(process.cwd(), '.audit_tmp', 'hook-metrics.jsonl');
|
|
9
|
+
|
|
10
|
+
function loadMetrics() {
|
|
11
|
+
if (!fs.existsSync(METRICS_FILE)) return [];
|
|
12
|
+
return fs
|
|
13
|
+
.readFileSync(METRICS_FILE, 'utf8')
|
|
14
|
+
.trim()
|
|
15
|
+
.split('\n')
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.map(line => {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(line);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
.filter(Boolean);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function buildPrometheusMetrics() {
|
|
28
|
+
const metrics = loadMetrics();
|
|
29
|
+
const counters = {};
|
|
30
|
+
|
|
31
|
+
for (const metric of metrics) {
|
|
32
|
+
const hook = metric.hook || 'unknown';
|
|
33
|
+
const status = metric.status || 'unknown';
|
|
34
|
+
const key = `${hook}:${status}`;
|
|
35
|
+
counters[key] = (counters[key] || 0) + 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let output = '# HELP hook_events_total Total number of hook events\n';
|
|
39
|
+
output += '# TYPE hook_events_total counter\n';
|
|
40
|
+
for (const [key, value] of Object.entries(counters)) {
|
|
41
|
+
const [hook, status] = key.split(':');
|
|
42
|
+
output += `hook_events_total{hook="${hook}",status="${status}"} ${value}\n`;
|
|
43
|
+
}
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const server = http.createServer((req, res) => {
|
|
48
|
+
if (req.url === '/metrics') {
|
|
49
|
+
const body = buildPrometheusMetrics();
|
|
50
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
51
|
+
res.end(body);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
res.writeHead(404);
|
|
56
|
+
res.end();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
server.listen(PORT, () => {
|
|
60
|
+
console.log(`Hook-System metrics server running on http://localhost:${PORT}/metrics`);
|
|
61
|
+
});
|