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,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
REPO_ROOT=${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}
|
|
6
|
+
BASELINE_PATH=${BASELINE_PATH:-"$REPO_ROOT/scripts/hooks-system/config/detect-secrets-baseline.json"}
|
|
7
|
+
MODE="${1:-scan}"
|
|
8
|
+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
9
|
+
PYTHON_SCRIPT="$SCRIPT_DIR/detect_secrets.py"
|
|
10
|
+
|
|
11
|
+
PYTHON3=""
|
|
12
|
+
if [[ -x "/opt/homebrew/bin/python3" ]]; then
|
|
13
|
+
PYTHON3="/opt/homebrew/bin/python3"
|
|
14
|
+
elif command -v python3 >/dev/null 2>&1; then
|
|
15
|
+
PYTHON3="python3"
|
|
16
|
+
else
|
|
17
|
+
echo "detect-secrets.sh: se requiere python3" >&2
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
if [[ ! -f "$PYTHON_SCRIPT" ]]; then
|
|
22
|
+
echo "detect-secrets.sh: no se encuentra $PYTHON_SCRIPT" >&2
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
exec "$PYTHON3" "$PYTHON_SCRIPT" "$MODE" "$REPO_ROOT" "$BASELINE_PATH"
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from datetime import datetime, timezone
|
|
3
|
+
import hashlib
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import sys
|
|
8
|
+
from typing import Dict, Iterable, List, Set
|
|
9
|
+
|
|
10
|
+
INCLUDE_EXTENSIONS: Set[str] = {
|
|
11
|
+
".ts", ".tsx", ".js", ".jsx", ".kt", ".kts", ".swift",
|
|
12
|
+
".env", ".py", ".rb", ".php", ".json", ".java", ".cs",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
EXCLUDE_DIRECTORIES: Set[str] = {
|
|
16
|
+
"node_modules", ".git", "dist", "build", ".next", "coverage",
|
|
17
|
+
".turbo", ".idea", ".vscode", ".gradle", "DerivedData",
|
|
18
|
+
".audit_tmp", ".audit-reports",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
PATTERN = re.compile(r"(password|secret|api[_-]?key|token|bearer)\s*[:=]\s*[\"']?[^\"';\s]+", re.IGNORECASE)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get_staged_files(root: str) -> Set[str]:
|
|
25
|
+
import subprocess
|
|
26
|
+
try:
|
|
27
|
+
result = subprocess.run(
|
|
28
|
+
["git", "diff", "--cached", "--name-only", "--diff-filter=ACM"],
|
|
29
|
+
cwd=root,
|
|
30
|
+
capture_output=True,
|
|
31
|
+
text=True,
|
|
32
|
+
check=True
|
|
33
|
+
)
|
|
34
|
+
return {os.path.join(root, f.strip()) for f in result.stdout.splitlines() if f.strip()}
|
|
35
|
+
except subprocess.CalledProcessError:
|
|
36
|
+
return set()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def iter_candidate_files(root: str, ignored_files: Set[str], staged_only: bool = True) -> Iterable[str]:
|
|
40
|
+
staged_files = get_staged_files(root) if staged_only else set()
|
|
41
|
+
|
|
42
|
+
for dirpath, dirnames, filenames in os.walk(root):
|
|
43
|
+
dirnames[:] = [
|
|
44
|
+
name for name in dirnames
|
|
45
|
+
if name not in EXCLUDE_DIRECTORIES and not name.startswith(".git")
|
|
46
|
+
]
|
|
47
|
+
for filename in filenames:
|
|
48
|
+
extension = os.path.splitext(filename)[1].lower()
|
|
49
|
+
if extension not in INCLUDE_EXTENSIONS:
|
|
50
|
+
continue
|
|
51
|
+
path = os.path.join(dirpath, filename)
|
|
52
|
+
if os.path.abspath(path) in ignored_files:
|
|
53
|
+
continue
|
|
54
|
+
if staged_only and path not in staged_files:
|
|
55
|
+
continue
|
|
56
|
+
yield path
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def collect_matches(path: str) -> Iterable[Dict[str, str]]:
|
|
60
|
+
try:
|
|
61
|
+
with open(path, "r", encoding="utf-8", errors="ignore") as handle:
|
|
62
|
+
for index, line in enumerate(handle, start=1):
|
|
63
|
+
if PATTERN.search(line):
|
|
64
|
+
snippet = line.rstrip()
|
|
65
|
+
yield {
|
|
66
|
+
"path": path,
|
|
67
|
+
"line": index,
|
|
68
|
+
"snippet": snippet,
|
|
69
|
+
}
|
|
70
|
+
except (OSError, UnicodeDecodeError):
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def gather_matches(root: str, ignored_files: Set[str], staged_only: bool = True) -> List[Dict[str, str]]:
|
|
75
|
+
collected: List[Dict[str, str]] = []
|
|
76
|
+
for candidate in iter_candidate_files(root, ignored_files, staged_only):
|
|
77
|
+
for match in collect_matches(candidate):
|
|
78
|
+
collected.append(match)
|
|
79
|
+
return collected
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def fingerprint(item: Dict[str, str]) -> str:
|
|
83
|
+
base = f"{item['path']}:{item['line']}:{item['snippet'].strip()}"
|
|
84
|
+
return hashlib.sha256(base.encode()).hexdigest()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def load_baseline(path: str) -> Dict[str, Dict[str, str]]:
|
|
88
|
+
import subprocess
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
result = subprocess.run(
|
|
92
|
+
["git", "show", f":scripts/hooks-system/config/detect-secrets-baseline.json"],
|
|
93
|
+
capture_output=True,
|
|
94
|
+
text=True,
|
|
95
|
+
check=True
|
|
96
|
+
)
|
|
97
|
+
payload = json.loads(result.stdout)
|
|
98
|
+
return {entry["fingerprint"]: entry for entry in payload.get("matches", [])}
|
|
99
|
+
except (subprocess.CalledProcessError, json.JSONDecodeError):
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
if not os.path.exists(path):
|
|
103
|
+
return {}
|
|
104
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
105
|
+
payload = json.load(handle)
|
|
106
|
+
return {entry["fingerprint"]: entry for entry in payload.get("matches", [])}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def write_baseline(path: str, matches: List[Dict[str, str]]) -> None:
|
|
110
|
+
data = []
|
|
111
|
+
for item in matches:
|
|
112
|
+
rel_path = os.path.relpath(item["path"])
|
|
113
|
+
normalized_item = {
|
|
114
|
+
"path": rel_path,
|
|
115
|
+
"line": item["line"],
|
|
116
|
+
"snippet": item["snippet"],
|
|
117
|
+
}
|
|
118
|
+
data.append(
|
|
119
|
+
{
|
|
120
|
+
"path": rel_path,
|
|
121
|
+
"line": item["line"],
|
|
122
|
+
"fingerprint": fingerprint(normalized_item),
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
data.sort(key=lambda entry: (entry["path"], entry["line"], entry["fingerprint"]))
|
|
126
|
+
payload = {
|
|
127
|
+
"generated_at": datetime.now(timezone.utc).isoformat(),
|
|
128
|
+
"matches": data,
|
|
129
|
+
}
|
|
130
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
131
|
+
with open(path, "w", encoding="utf-8") as handle:
|
|
132
|
+
json.dump(payload, handle, indent=2, ensure_ascii=False)
|
|
133
|
+
print(f"Baseline actualizado con {len(data)} coincidencias -> {path}")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def run_scan(root: str, baseline_path: str, ignored_files: Set[str]) -> int:
|
|
137
|
+
baseline = load_baseline(baseline_path)
|
|
138
|
+
findings = gather_matches(root, ignored_files, staged_only=True)
|
|
139
|
+
|
|
140
|
+
if not findings:
|
|
141
|
+
return 0
|
|
142
|
+
|
|
143
|
+
missing = []
|
|
144
|
+
for item in findings:
|
|
145
|
+
rel_path = os.path.relpath(item["path"], root)
|
|
146
|
+
normalized_item = {
|
|
147
|
+
"path": rel_path,
|
|
148
|
+
"line": item["line"],
|
|
149
|
+
"snippet": item["snippet"],
|
|
150
|
+
}
|
|
151
|
+
if fingerprint(normalized_item) not in baseline:
|
|
152
|
+
missing.append(normalized_item)
|
|
153
|
+
|
|
154
|
+
if not missing:
|
|
155
|
+
return 0
|
|
156
|
+
|
|
157
|
+
print("Nuevos posibles secretos detectados en archivos staged:")
|
|
158
|
+
for item in missing:
|
|
159
|
+
print(f" - {item['path']}:{item['line']} -> {item['snippet'].strip()}")
|
|
160
|
+
print("Actualiza el baseline si se trata de falsos positivos.")
|
|
161
|
+
return 1
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def main() -> int:
|
|
165
|
+
parser = argparse.ArgumentParser(description="Detector simple de secretos con baseline")
|
|
166
|
+
parser.add_argument("mode", choices=["scan", "baseline"], help="Modo de ejecución")
|
|
167
|
+
parser.add_argument("root", help="Ruta del repositorio")
|
|
168
|
+
parser.add_argument("baseline", help="Ruta del archivo baseline")
|
|
169
|
+
args = parser.parse_args()
|
|
170
|
+
|
|
171
|
+
ignored_files = {os.path.abspath(args.baseline)}
|
|
172
|
+
|
|
173
|
+
if args.mode == "baseline":
|
|
174
|
+
collected = gather_matches(args.root, ignored_files, staged_only=False)
|
|
175
|
+
write_baseline(args.baseline, collected)
|
|
176
|
+
return 0
|
|
177
|
+
|
|
178
|
+
return run_scan(args.root, args.baseline, ignored_files)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
if __name__ == "__main__":
|
|
182
|
+
sys.exit(main())
|
|
@@ -0,0 +1,254 @@
|
|
|
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
|
+
# Frontend Rules (React/TypeScript/Next.js)
|
|
21
|
+
# =============================================================================
|
|
22
|
+
validate_frontend_file() {
|
|
23
|
+
local file="$1"
|
|
24
|
+
local filename=$(basename "$file")
|
|
25
|
+
local dir=$(dirname "$file")
|
|
26
|
+
|
|
27
|
+
# Hook files
|
|
28
|
+
if [[ "$filename" =~ ^use[A-Z].*\.(ts|tsx)$ ]]; then
|
|
29
|
+
if [[ ! "$dir" =~ presentation/hooks$ ]]; then
|
|
30
|
+
echo -e "${RED}❌ VIOLATION: Hook file in wrong location${NC}"
|
|
31
|
+
echo -e " File: $file"
|
|
32
|
+
echo -e " Rule: Custom hooks → ${GREEN}presentation/hooks/${NC}"
|
|
33
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
34
|
+
echo -e " Fix: Move to presentation/hooks/"
|
|
35
|
+
((VIOLATIONS++))
|
|
36
|
+
return 1
|
|
37
|
+
fi
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Config files
|
|
41
|
+
if [[ "$filename" =~ \.config\.(ts|js)$ ]] || [[ "$filename" =~ ^(api|i18n|env)\.(ts|js)$ ]]; then
|
|
42
|
+
if [[ ! "$dir" =~ infrastructure/config$ ]]; then
|
|
43
|
+
echo -e "${RED}❌ VIOLATION: Config file in wrong location${NC}"
|
|
44
|
+
echo -e " File: $file"
|
|
45
|
+
echo -e " Rule: Configuration → ${GREEN}infrastructure/config/${NC}"
|
|
46
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
47
|
+
echo -e " Fix: Move to infrastructure/config/"
|
|
48
|
+
((VIOLATIONS++))
|
|
49
|
+
return 1
|
|
50
|
+
fi
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Store files (Zustand/Redux)
|
|
54
|
+
if [[ "$filename" =~ Store\.(ts|tsx)$ ]] || [[ "$filename" =~ \.store\.(ts|tsx)$ ]]; then
|
|
55
|
+
if [[ ! "$dir" =~ presentation/stores$ ]]; then
|
|
56
|
+
echo -e "${RED}❌ VIOLATION: Store file in wrong location${NC}"
|
|
57
|
+
echo -e " File: $file"
|
|
58
|
+
echo -e " Rule: State stores → ${GREEN}presentation/stores/${NC}"
|
|
59
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
60
|
+
echo -e " Fix: Move to presentation/stores/"
|
|
61
|
+
((VIOLATIONS++))
|
|
62
|
+
return 1
|
|
63
|
+
fi
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# Use Case files
|
|
67
|
+
if [[ "$filename" =~ UseCase\.(ts|js)$ ]]; then
|
|
68
|
+
if [[ ! "$dir" =~ application/use-cases$ ]]; then
|
|
69
|
+
echo -e "${RED}❌ VIOLATION: Use Case in wrong location${NC}"
|
|
70
|
+
echo -e " File: $file"
|
|
71
|
+
echo -e " Rule: Use Cases → ${GREEN}application/use-cases/${NC}"
|
|
72
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
73
|
+
echo -e " Fix: Move to application/use-cases/"
|
|
74
|
+
((VIOLATIONS++))
|
|
75
|
+
return 1
|
|
76
|
+
fi
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# Repository implementations
|
|
80
|
+
if [[ "$filename" =~ Repository\.(ts|js)$ ]] && [[ ! "$filename" =~ ^I[A-Z] ]]; then
|
|
81
|
+
if [[ ! "$dir" =~ infrastructure/repositories$ ]]; then
|
|
82
|
+
echo -e "${RED}❌ VIOLATION: Repository implementation in wrong location${NC}"
|
|
83
|
+
echo -e " File: $file"
|
|
84
|
+
echo -e " Rule: Repository impl → ${GREEN}infrastructure/repositories/${NC}"
|
|
85
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
86
|
+
echo -e " Fix: Move to infrastructure/repositories/"
|
|
87
|
+
((VIOLATIONS++))
|
|
88
|
+
return 1
|
|
89
|
+
fi
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
# Repository interfaces
|
|
93
|
+
if [[ "$filename" =~ ^I[A-Z].*Repository\.(ts|js)$ ]]; then
|
|
94
|
+
if [[ ! "$dir" =~ domain/repositories$ ]]; then
|
|
95
|
+
echo -e "${RED}❌ VIOLATION: Repository interface in wrong location${NC}"
|
|
96
|
+
echo -e " File: $file"
|
|
97
|
+
echo -e " Rule: Repository interface → ${GREEN}domain/repositories/${NC}"
|
|
98
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
99
|
+
echo -e " Fix: Move to domain/repositories/"
|
|
100
|
+
((VIOLATIONS++))
|
|
101
|
+
return 1
|
|
102
|
+
fi
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
# FORBIDDEN DIRECTORIES
|
|
106
|
+
if [[ "$dir" =~ /lib/ ]] && [[ ! "$dir" =~ /node_modules/ ]]; then
|
|
107
|
+
echo -e "${RED}❌ VIOLATION: File in forbidden 'lib/' directory${NC}"
|
|
108
|
+
echo -e " File: $file"
|
|
109
|
+
echo -e " Rule: ${RED}NEVER use lib/${NC}"
|
|
110
|
+
echo -e " Use instead:"
|
|
111
|
+
echo -e " - infrastructure/ (for services, config)"
|
|
112
|
+
echo -e " - presentation/ (for hooks, components)"
|
|
113
|
+
((VIOLATIONS++))
|
|
114
|
+
return 1
|
|
115
|
+
fi
|
|
116
|
+
|
|
117
|
+
if [[ "$dir" =~ /utils/ ]] && [[ ! "$dir" =~ /node_modules/ ]]; then
|
|
118
|
+
echo -e "${RED}❌ VIOLATION: File in forbidden 'utils/' directory${NC}"
|
|
119
|
+
echo -e " File: $file"
|
|
120
|
+
echo -e " Rule: ${RED}NEVER use utils/${NC}"
|
|
121
|
+
echo -e " Use instead:"
|
|
122
|
+
echo -e " - application/ (for business logic)"
|
|
123
|
+
echo -e " - domain/ (for domain logic)"
|
|
124
|
+
((VIOLATIONS++))
|
|
125
|
+
return 1
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
if [[ "$dir" =~ /helpers/ ]] && [[ ! "$dir" =~ /node_modules/ ]]; then
|
|
129
|
+
echo -e "${RED}❌ VIOLATION: File in forbidden 'helpers/' directory${NC}"
|
|
130
|
+
echo -e " File: $file"
|
|
131
|
+
echo -e " Rule: ${RED}NEVER use helpers/${NC}"
|
|
132
|
+
echo -e " Use: ${GREEN}application/use-cases/${NC}"
|
|
133
|
+
((VIOLATIONS++))
|
|
134
|
+
return 1
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
return 0
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
# =============================================================================
|
|
141
|
+
# Backend Rules (NestJS)
|
|
142
|
+
# =============================================================================
|
|
143
|
+
validate_backend_file() {
|
|
144
|
+
local file="$1"
|
|
145
|
+
local filename=$(basename "$file")
|
|
146
|
+
local dir=$(dirname "$file")
|
|
147
|
+
|
|
148
|
+
# Controller files
|
|
149
|
+
if [[ "$filename" =~ \.controller\.(ts|js)$ ]]; then
|
|
150
|
+
if [[ ! "$dir" =~ presentation/controllers$ ]] && [[ ! "$dir" =~ src/[^/]+$ ]]; then
|
|
151
|
+
echo -e "${YELLOW}⚠️ WARNING: Controller not in presentation/controllers${NC}"
|
|
152
|
+
echo -e " File: $file"
|
|
153
|
+
echo -e " Recommended: ${GREEN}presentation/controllers/${NC}"
|
|
154
|
+
echo -e " Current: $dir"
|
|
155
|
+
fi
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
# Guard files
|
|
159
|
+
if [[ "$filename" =~ \.guard\.(ts|js)$ ]]; then
|
|
160
|
+
if [[ ! "$dir" =~ presentation/guards$ ]] && [[ ! "$dir" =~ src/guards$ ]]; then
|
|
161
|
+
echo -e "${YELLOW}⚠️ WARNING: Guard not in presentation/guards${NC}"
|
|
162
|
+
echo -e " File: $file"
|
|
163
|
+
echo -e " Recommended: ${GREEN}presentation/guards/${NC}"
|
|
164
|
+
fi
|
|
165
|
+
fi
|
|
166
|
+
|
|
167
|
+
# Use Case files
|
|
168
|
+
if [[ "$filename" =~ UseCase\.(ts|js)$ ]] || [[ "$filename" =~ \.use-case\.(ts|js)$ ]]; then
|
|
169
|
+
if [[ ! "$dir" =~ application/use-cases$ ]]; then
|
|
170
|
+
echo -e "${RED}❌ VIOLATION: Use Case in wrong location${NC}"
|
|
171
|
+
echo -e " File: $file"
|
|
172
|
+
echo -e " Rule: Use Cases → ${GREEN}application/use-cases/${NC}"
|
|
173
|
+
echo -e " Found in: ${RED}$dir${NC}"
|
|
174
|
+
((VIOLATIONS++))
|
|
175
|
+
return 1
|
|
176
|
+
fi
|
|
177
|
+
fi
|
|
178
|
+
|
|
179
|
+
# DTO files
|
|
180
|
+
if [[ "$filename" =~ \.dto\.(ts|js)$ ]]; then
|
|
181
|
+
if [[ ! "$dir" =~ application/dtos$ ]] && [[ ! "$dir" =~ src/[^/]+/dto$ ]]; then
|
|
182
|
+
echo -e "${YELLOW}⚠️ WARNING: DTO not in application/dtos${NC}"
|
|
183
|
+
echo -e " File: $file"
|
|
184
|
+
echo -e " Recommended: ${GREEN}application/dtos/${NC}"
|
|
185
|
+
fi
|
|
186
|
+
fi
|
|
187
|
+
|
|
188
|
+
# FORBIDDEN DIRECTORIES (same as frontend)
|
|
189
|
+
if [[ "$dir" =~ /lib/ ]] && [[ ! "$dir" =~ /node_modules/ ]]; then
|
|
190
|
+
echo -e "${RED}❌ VIOLATION: File in forbidden 'lib/' directory${NC}"
|
|
191
|
+
echo -e " File: $file"
|
|
192
|
+
echo -e " Rule: ${RED}NEVER use lib/${NC} → Use ${GREEN}infrastructure/${NC}"
|
|
193
|
+
((VIOLATIONS++))
|
|
194
|
+
return 1
|
|
195
|
+
fi
|
|
196
|
+
|
|
197
|
+
return 0
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
# =============================================================================
|
|
201
|
+
# Main Validator
|
|
202
|
+
# =============================================================================
|
|
203
|
+
|
|
204
|
+
validate_staged_files() {
|
|
205
|
+
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
206
|
+
echo -e "${BLUE}🏗️ Clean Architecture Validator${NC}"
|
|
207
|
+
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
208
|
+
echo ""
|
|
209
|
+
|
|
210
|
+
local staged_files=$(git diff --cached --name-only --diff-filter=ACM)
|
|
211
|
+
|
|
212
|
+
if [[ -z "$staged_files" ]]; then
|
|
213
|
+
echo -e "${GREEN}✅ No files to validate${NC}"
|
|
214
|
+
return 0
|
|
215
|
+
fi
|
|
216
|
+
|
|
217
|
+
local file_count=$(echo "$staged_files" | wc -l | tr -d ' ')
|
|
218
|
+
echo "📁 Validating $file_count staged file(s)..."
|
|
219
|
+
echo ""
|
|
220
|
+
|
|
221
|
+
while IFS= read -r file; do
|
|
222
|
+
# Skip non-source files
|
|
223
|
+
[[ "$file" =~ \.(md|json|yml|yaml|txt|lock)$ ]] && continue
|
|
224
|
+
[[ "$file" =~ node_modules/ ]] && continue
|
|
225
|
+
[[ "$file" =~ \.git/ ]] && continue
|
|
226
|
+
|
|
227
|
+
# Detect platform and validate
|
|
228
|
+
if [[ "$file" =~ \.(ts|tsx|jsx)$ ]] && [[ "$file" =~ apps/(admin-dashboard|web)/ ]]; then
|
|
229
|
+
validate_frontend_file "$file"
|
|
230
|
+
elif [[ "$file" =~ \.(ts|js)$ ]] && [[ "$file" =~ apps/backend/ ]]; then
|
|
231
|
+
validate_backend_file "$file"
|
|
232
|
+
fi
|
|
233
|
+
done <<< "$staged_files"
|
|
234
|
+
|
|
235
|
+
echo ""
|
|
236
|
+
if [[ $VIOLATIONS -gt 0 ]]; then
|
|
237
|
+
echo -e "${RED}═══════════════════════════════════════════════════════════════${NC}"
|
|
238
|
+
echo -e "${RED}❌ CLEAN ARCHITECTURE VIOLATED: $VIOLATIONS violation(s)${NC}"
|
|
239
|
+
echo -e "${RED}═══════════════════════════════════════════════════════════════${NC}"
|
|
240
|
+
echo ""
|
|
241
|
+
echo -e "${YELLOW}Fix violations or move files to correct directories.${NC}"
|
|
242
|
+
echo ""
|
|
243
|
+
echo -e "${BLUE}Need help? Run:${NC}"
|
|
244
|
+
echo -e " ${GREEN}cat .cursorrules${NC} # See structure rules"
|
|
245
|
+
echo ""
|
|
246
|
+
return 1
|
|
247
|
+
else
|
|
248
|
+
echo -e "${GREEN}✅ Clean Architecture: All files in correct locations${NC}"
|
|
249
|
+
return 0
|
|
250
|
+
fi
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
# Run validation
|
|
254
|
+
validate_staged_files
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
ROOT_DIR="$(git rev-parse --show-toplevel)"
|
|
6
|
+
EXIT_CODE=0
|
|
7
|
+
|
|
8
|
+
# git diff --cached --name-status includes lines like:
|
|
9
|
+
# A path/file
|
|
10
|
+
# R100 old/path new/path
|
|
11
|
+
# Use read with up to 3 columns to capture rename targets.
|
|
12
|
+
|
|
13
|
+
while IFS=$'\t' read -r status path_a path_b; do
|
|
14
|
+
[[ -z "${status:-}" ]] && continue
|
|
15
|
+
|
|
16
|
+
case "$status" in
|
|
17
|
+
A*|C*)
|
|
18
|
+
target="$path_a"
|
|
19
|
+
;;
|
|
20
|
+
R*)
|
|
21
|
+
target="$path_b"
|
|
22
|
+
;;
|
|
23
|
+
*)
|
|
24
|
+
continue
|
|
25
|
+
;;
|
|
26
|
+
esac
|
|
27
|
+
|
|
28
|
+
[[ "${target:-}" != *.md ]] && continue
|
|
29
|
+
|
|
30
|
+
if [[ "$target" == scripts/hooks-system/* ]]; then
|
|
31
|
+
echo "❌ Documentación nueva detectada en '$target'. Usa docs/technical/hook-system/ como ubicación." >&2
|
|
32
|
+
EXIT_CODE=1
|
|
33
|
+
continue
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
if [[ "$status" == R* ]]; then
|
|
37
|
+
# Renames mantienen el contenido previo; sólo validamos ubicación prohibida.
|
|
38
|
+
continue
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
if [[ "$target" == docs/technical/hook-system/* ]]; then
|
|
42
|
+
line1="$(sed -n '1p' "$ROOT_DIR/$target" | tr -d '\r')"
|
|
43
|
+
line2="$(sed -n '2p' "$ROOT_DIR/$target" | tr -d '\r')"
|
|
44
|
+
line3="$(sed -n '3p' "$ROOT_DIR/$target" | tr -d '\r')"
|
|
45
|
+
|
|
46
|
+
if [[ "$line1" != Location:* || "$line2" != Related\ to:* || "$line3" != Owner:* ]]; then
|
|
47
|
+
echo "❌ '$target' debe comenzar con cabecera de metadatos (Location, Related to, Owner). Usa docs/templates/HOOK_DOC_TEMPLATE.md." >&2
|
|
48
|
+
EXIT_CODE=1
|
|
49
|
+
continue
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# Validar que Location coincide con ruta real
|
|
53
|
+
expected="Location: $target"
|
|
54
|
+
if [[ "$line1" != "$expected" ]]; then
|
|
55
|
+
echo "❌ '$target' → el campo Location debe ser '$expected'." >&2
|
|
56
|
+
EXIT_CODE=1
|
|
57
|
+
fi
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
done < <(git diff --cached --name-status --diff-filter=ACR)
|
|
61
|
+
|
|
62
|
+
exit $EXIT_CODE
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Protect critical documentation from accidental deletion
|
|
3
|
+
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
# List of critical documents that must exist
|
|
7
|
+
CRITICAL_DOCS=(
|
|
8
|
+
"docs/planning/ROADMAP.md"
|
|
9
|
+
"docs/planning/LIBRARY_FIVE_STARS_ROADMAP.md"
|
|
10
|
+
"docs/technical/hook-system/README.md"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
# Check each critical document
|
|
14
|
+
for TARGET in "${CRITICAL_DOCS[@]}"; do
|
|
15
|
+
if [[ ! -f "$TARGET" ]]; then
|
|
16
|
+
echo "❌ Required document '$TARGET' is missing."
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
if git diff --cached --name-only --diff-filter=D | grep -q "^${TARGET}$"; then
|
|
21
|
+
echo "❌ Cannot delete critical document '$TARGET'."
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
done
|
|
25
|
+
|
|
26
|
+
exit 0
|