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
package/README.md
ADDED
|
@@ -0,0 +1,1105 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/logo.png" alt="PUMUKI - AST Intelligence" width="350" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">@pumuki/ast-intelligence-hooks</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@pumuki/ast-intelligence-hooks"><img src="https://img.shields.io/npm/v/@pumuki/ast-intelligence-hooks.svg?label=npm" alt="npm version" /></a>
|
|
9
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
|
|
10
|
+
<a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg" alt="Node.js Version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/"><img src="https://img.shields.io/badge/npm-%3E%3D9.0.0-red.svg" alt="npm" /></a>
|
|
12
|
+
<img src="https://img.shields.io/badge/platforms-iOS%20%7C%20Android%20%7C%20Backend%20%7C%20Frontend-blue.svg" alt="Platforms" />
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
### Visual Overview
|
|
16
|
+
|
|
17
|
+
<img src="./docs/images/ast_intelligence_01.png" alt="AST Intelligence System Overview" width="100%" />
|
|
18
|
+
|
|
19
|
+
<img src="./docs/images/ast_intelligence_02.png" alt="AST Intelligence Workflow" width="100%" />
|
|
20
|
+
|
|
21
|
+
<img src="./docs/images/ast_intelligence_03.png" alt="AST Intelligence Audit - Part 1" width="100%" />
|
|
22
|
+
|
|
23
|
+
<img src="./docs/images/ast_intelligence_04.png" alt="AST Intelligence Audit - Part 2" width="100%" />
|
|
24
|
+
|
|
25
|
+
<img src="./docs/images/ast_intelligence_05.png" alt="AST Intelligence Audit - Part 3" width="100%" />
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🧠 The Vision: Solving AI Context Loss in Software Development
|
|
30
|
+
|
|
31
|
+
### The Fundamental Problem
|
|
32
|
+
|
|
33
|
+
In modern AI-assisted development, a critical limitation emerges: **AI assistants lose context**. Whether due to token limits, session resets, or conversation boundaries, AI agents repeatedly forget:
|
|
34
|
+
|
|
35
|
+
- **Project architecture**: "What's the structure here? Clean Architecture? DDD? Feature-First?"
|
|
36
|
+
- **Active rules**: "Which validation rules apply? What are the coding standards?"
|
|
37
|
+
- **Current work**: "What branch am I on? What files were recently changed? What patterns exist?"
|
|
38
|
+
- **Quality gates**: "Are there blocking violations? What needs to be fixed?"
|
|
39
|
+
|
|
40
|
+
This forces developers into a **repetitive, inefficient cycle** of re-explaining context, re-loading rules, and re-establishing project understanding—defeating the purpose of AI assistance.
|
|
41
|
+
|
|
42
|
+
### The Solution: Permanent Context Persistence
|
|
43
|
+
|
|
44
|
+
This library was conceived to solve this fundamental problem by creating a **permanent, always-on context system** for AI assistants. It transforms AI from a "stateless helper" into a **context-aware collaborator** that maintains deep, persistent understanding of your project.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🔄 How It Works: The Complete Flow
|
|
49
|
+
|
|
50
|
+
### Phase 1: Context Initialization (`ai_start` Protocol)
|
|
51
|
+
|
|
52
|
+
**When**: Before any code editing begins, or when context becomes stale (>3 minutes)
|
|
53
|
+
|
|
54
|
+
**What Happens**:
|
|
55
|
+
|
|
56
|
+
1. **Developer runs `ai-start`** (or it auto-executes via MCP):
|
|
57
|
+
```bash
|
|
58
|
+
ai-start feature/user-authentication
|
|
59
|
+
# or automatically via MCP: auto_execute_ai_start
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. **The system answers three critical questions**:
|
|
63
|
+
- **Q1: What file types am I working with?**
|
|
64
|
+
- Analyzes staged/modified files
|
|
65
|
+
- Detects platforms (iOS, Android, Backend, Frontend)
|
|
66
|
+
- Identifies target Clean Architecture layers (Domain, Application, Infrastructure, Presentation)
|
|
67
|
+
- Example: `"Code task on branch 'feature/auth'. Modifying typescript, kotlin in: auth, users. Target layer: Domain."`
|
|
68
|
+
|
|
69
|
+
- **Q2: Does similar code already exist?**
|
|
70
|
+
- Analyzes recent Git commits
|
|
71
|
+
- Identifies affected modules
|
|
72
|
+
- Suggests existing patterns to follow
|
|
73
|
+
- Example: `"Modules affected: auth, users. Recent commits: abc123 feat: Add JWT validation. Check for existing patterns before adding new code."`
|
|
74
|
+
|
|
75
|
+
- **Q3: How does this fit in Clean Architecture?**
|
|
76
|
+
- Validates layer dependencies
|
|
77
|
+
- Ensures dependencies point inward (Domain ← Application ← Infrastructure)
|
|
78
|
+
- Example: `"Code changes in Domain layer affecting auth, users. Ensure dependencies point inward."`
|
|
79
|
+
|
|
80
|
+
3. **Rules are automatically loaded**:
|
|
81
|
+
- `DynamicRulesLoader` scans agentic IDE rules directories (`.cursor/rules/`, `.ast-intelligence/skills/`, `.windsurf/rules/`, `.vscode/rules/`, `.kilo/rules/`, `.cline/rules/`) for platform-specific rules
|
|
82
|
+
- **Always loads `rulesgold.mdc` first** (generic rules that apply to all projects)
|
|
83
|
+
- Then loads platform-specific rules: `rulesbackend.mdc`, `rulesios.mdc`, `rulesandroid.mdc`, `rulesfront.mdc`
|
|
84
|
+
- Aggregates all 798+ validation rules into a single context
|
|
85
|
+
- Creates `auto-context.mdc` with all active rules
|
|
86
|
+
|
|
87
|
+
4. **`.AI_EVIDENCE.json` is created/updated**:
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"timestamp": "2025-12-13T23:07:19.632Z",
|
|
91
|
+
"session_id": "feature/user-authentication",
|
|
92
|
+
"protocol_3_questions": {
|
|
93
|
+
"answered": true,
|
|
94
|
+
"question_1_file_type": "Code task on branch 'feature/auth'. Modifying typescript, kotlin in: auth, users. Target layer: Domain.",
|
|
95
|
+
"question_2_similar_exists": "Modules affected: auth, users. Recent commits: abc123 feat: Add JWT validation. Check for existing patterns before adding new code.",
|
|
96
|
+
"question_3_clean_architecture": "Code changes in Domain layer affecting auth, users. Ensure dependencies point inward."
|
|
97
|
+
},
|
|
98
|
+
"rules_read": [
|
|
99
|
+
{ "file": "rulesgold.mdc", "verified": true, "summary": "IDE Rules: ### ANTES de implementar CUALQUIER cosa (aplicables en todas las tecnologías):;### Reglas de Arquitectura:;### Seguridad y Validación:;### Performance y Escalabilidad:;### Testing y Calidad:;### Observabilidad y Debugging:;### Arquitectura y Diseño:;### Control de Versiones y Colaboración:;### i18n y Accesibilidad:;### Error Handling:; | AST: Files: 96, Rules: types.any,debug.console,security.secret,security.sql.raw,performance.pagination,performance.nplus1,architecture.layering,ios.force_unwrapping" },
|
|
100
|
+
{ "file": "rulesbackend.mdc", "verified": true, "summary": "IDE Rules: ### NestJS Architecture:;### Repository Pattern:;### Use Cases Pattern:;### DTOs y Validación:;### Database y ORM:;### Autenticación y Autorización:;### Event-Driven Architecture:;### Caché (Redis):;### Logging y Observabilidad:;### Testing Backend:;### Error Handling:;### Seguridad:;### Performance:;### API Design:;### Configuración:;### Documentación:; | AST: Files: 16, Rules: backend.error_handling.untyped_catch,backend.security.pii_in_logs,backend.performance.nplus1" },
|
|
101
|
+
{ "file": "rulesios.mdc", "verified": true, "summary": "IDE Rules: ### Swift Moderno:;### SwiftUI (Preferido):;### UIKit (Legacy/Necesario):;### Protocol-Oriented Programming:;### Value Types:;### Memory Management:;### Optionals:;### Clean Architecture en iOS:;### Dependency Injection:;### Networking:;### Persistence:;### Combine (Reactive):;### Concurrency:;### Testing:;### Security:;### Accessibility:;### Localization:; | AST: Files: 24, Rules: ios.force_unwrapping,ios.singleton,ios.massive_view_controller" }
|
|
102
|
+
],
|
|
103
|
+
"current_context": {
|
|
104
|
+
"branch": "feature/user-authentication",
|
|
105
|
+
"last_commits": "abc123 feat: Add JWT validation"
|
|
106
|
+
},
|
|
107
|
+
"platforms": ["backend", "ios"],
|
|
108
|
+
"ai_gate": {
|
|
109
|
+
"status": "BLOCKED",
|
|
110
|
+
"last_check": "2025-12-13T23:16:39.736Z",
|
|
111
|
+
"violations": [
|
|
112
|
+
{
|
|
113
|
+
"file": "/path/to/project/src/auth/user.service.ts",
|
|
114
|
+
"line": 45,
|
|
115
|
+
"severity": "HIGH",
|
|
116
|
+
"rule": "backend.error_handling.untyped_catch",
|
|
117
|
+
"message": "Catch parameter MUST be typed as ': unknown' - use type guards (error instanceof HttpException/Error)",
|
|
118
|
+
"category": "Error Handling",
|
|
119
|
+
"intelligent_evaluation": false,
|
|
120
|
+
"severity_score": 50
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"file": "/path/to/project/src/auth/auth.controller.ts",
|
|
124
|
+
"line": 12,
|
|
125
|
+
"severity": "CRITICAL",
|
|
126
|
+
"rule": "backend.security.pii_in_logs",
|
|
127
|
+
"message": "🚨 CRITICAL: Potential PII in logs. Never log: passwords, tokens, SSN, credit cards. Sanitize: logger.info({ userId, action }) - don't include sensitive fields. GDPR violation risk.",
|
|
128
|
+
"category": "Security",
|
|
129
|
+
"intelligent_evaluation": true,
|
|
130
|
+
"severity_score": 100
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"instruction": "🚨 AI MUST call mcp_ast-intelligence-automation_ai_gate_check BEFORE any action. If BLOCKED, fix violations first!",
|
|
134
|
+
"mandatory": true
|
|
135
|
+
},
|
|
136
|
+
"severity_metrics": {
|
|
137
|
+
"last_updated": "2025-12-13T23:16:39.726Z",
|
|
138
|
+
"total_violations": 2,
|
|
139
|
+
"by_severity": {
|
|
140
|
+
"CRITICAL": 1,
|
|
141
|
+
"HIGH": 1,
|
|
142
|
+
"MEDIUM": 0,
|
|
143
|
+
"LOW": 0
|
|
144
|
+
},
|
|
145
|
+
"average_severity_score": 75,
|
|
146
|
+
"gate_status": "FAILED",
|
|
147
|
+
"blocked_by": "CRITICAL"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Phase 2: Continuous Context Maintenance
|
|
153
|
+
|
|
154
|
+
**When**: Throughout the development session
|
|
155
|
+
|
|
156
|
+
**What Happens**:
|
|
157
|
+
|
|
158
|
+
1. **Pre-Tool-Use Validation** (`pre-tool-use-evidence-validator.ts`):
|
|
159
|
+
- **Before every AI edit operation**, validates `.AI_EVIDENCE.json`:
|
|
160
|
+
- ✅ File exists
|
|
161
|
+
- ✅ Valid JSON structure
|
|
162
|
+
- ✅ Timestamp is fresh (<180 seconds old)
|
|
163
|
+
- ✅ Rules were read
|
|
164
|
+
- ✅ Protocol 3 questions answered
|
|
165
|
+
- ✅ AI gate is not BLOCKED
|
|
166
|
+
- **If stale or missing**: Blocks the edit and prompts to run `ai-start`
|
|
167
|
+
- **If BLOCKED**: Shows violations and requires fixing before proceeding
|
|
168
|
+
|
|
169
|
+
2. **Real-Time Monitoring** (`RealtimeGuardService`):
|
|
170
|
+
- Polls `.AI_EVIDENCE.json` every 30 seconds
|
|
171
|
+
- Detects staleness (>180 seconds)
|
|
172
|
+
- **Auto-refreshes** evidence if stale (`HOOK_GUARD_AUTO_REFRESH=true` by default)
|
|
173
|
+
- **Auto-executes ai-start** when code files detected (`HOOK_GUARD_AI_START=true` by default)
|
|
174
|
+
- Monitors Git tree state with differentiated thresholds:
|
|
175
|
+
- **Staged files**: Warning at >10 files (configurable via `HOOK_GUARD_DIRTY_TREE_STAGED_LIMIT`)
|
|
176
|
+
- **Unstaged files**: Warning at >15 files (configurable via `HOOK_GUARD_DIRTY_TREE_UNSTAGED_LIMIT`)
|
|
177
|
+
- **Total files**: Warning at >20 files (configurable via `HOOK_GUARD_DIRTY_TREE_TOTAL_LIMIT`)
|
|
178
|
+
- Sends macOS notifications for critical events
|
|
179
|
+
|
|
180
|
+
3. **Automatic Rule Updates**:
|
|
181
|
+
- When new rules are added to any agentic IDE rules directory, they're automatically detected
|
|
182
|
+
- `DynamicRulesLoader` reloads rules on next `ai-start`
|
|
183
|
+
- `auto-context.mdc` is regenerated with latest rules
|
|
184
|
+
|
|
185
|
+
### Phase 3: Code Quality Enforcement
|
|
186
|
+
|
|
187
|
+
**When**: Before commits, during development, via MCP tools
|
|
188
|
+
|
|
189
|
+
**What Happens**:
|
|
190
|
+
|
|
191
|
+
1. **Pre-Commit Analysis** (Git Hook):
|
|
192
|
+
- Analyzes staged files using AST (Abstract Syntax Tree)
|
|
193
|
+
- Applies 798+ validation rules
|
|
194
|
+
- Checks Clean Architecture violations
|
|
195
|
+
- Validates SOLID principles
|
|
196
|
+
- Detects security issues, performance problems, maintainability issues
|
|
197
|
+
- **Blocks commit** if CRITICAL/HIGH violations found
|
|
198
|
+
|
|
199
|
+
2. **AI Gate Check** (`ai_gate_check` MCP tool):
|
|
200
|
+
- **Called at the start of every AI response** (enforced by Cursor rules)
|
|
201
|
+
- Reads `.AI_EVIDENCE.json` → `ai_gate.status`
|
|
202
|
+
- Returns `BLOCKED` or `ALLOWED`
|
|
203
|
+
- If `BLOCKED`: Shows violations, requires fixing before proceeding
|
|
204
|
+
- If `ALLOWED`: AI can proceed with user's task
|
|
205
|
+
|
|
206
|
+
3. **Violation Detection**:
|
|
207
|
+
- AST analyzers scan code for:
|
|
208
|
+
- Architecture violations (wrong layer dependencies)
|
|
209
|
+
- SOLID violations (God classes, tight coupling)
|
|
210
|
+
- Security issues (PII in logs, SQL injection risks)
|
|
211
|
+
- Performance issues (N+1 queries, missing pagination)
|
|
212
|
+
- Code quality (comments, magic numbers, force unwrapping)
|
|
213
|
+
- Findings are aggregated into `AuditResult`
|
|
214
|
+
- Severity-based blocking (CRITICAL/HIGH block, MEDIUM/LOW warn)
|
|
215
|
+
|
|
216
|
+
### Phase 4: Evidence Update Before Commits
|
|
217
|
+
|
|
218
|
+
**When**: Before every Git commit
|
|
219
|
+
|
|
220
|
+
**What Happens**:
|
|
221
|
+
|
|
222
|
+
1. **`ai-commit.sh` is executed** (via Git alias or directly):
|
|
223
|
+
```bash
|
|
224
|
+
git commit -m "feat: Add user authentication"
|
|
225
|
+
# Internally calls: ai-commit.sh
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
2. **Evidence is refreshed**:
|
|
229
|
+
- Updates `.AI_EVIDENCE.json` timestamp
|
|
230
|
+
- Re-analyzes current context (branch, files, commits)
|
|
231
|
+
- Updates violation status
|
|
232
|
+
- Ensures evidence is fresh for next AI interaction
|
|
233
|
+
|
|
234
|
+
3. **Commit proceeds** with fresh evidence
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 🛠️ Tools & Technologies
|
|
239
|
+
|
|
240
|
+
### Core Components
|
|
241
|
+
|
|
242
|
+
1. **Git Hooks**:
|
|
243
|
+
- `pre-commit`: AST analysis before commits
|
|
244
|
+
- `pre-push`: Additional validation before pushing
|
|
245
|
+
- `post-commit`: Evidence update after commits
|
|
246
|
+
|
|
247
|
+
2. **MCP (Model Context Protocol) Server**:
|
|
248
|
+
- `ast-intelligence-automation`: Provides AI tools via MCP
|
|
249
|
+
- Tools: `ai_gate_check`, `auto_execute_ai_start`, `auto_complete_gitflow`, `sync_branches`, `cleanup_stale_branches`, `validate_and_fix`
|
|
250
|
+
- Enables Cursor, Claude Desktop, and other MCP-compatible IDEs to interact with the system
|
|
251
|
+
|
|
252
|
+
3. **AST Analysis Engine**:
|
|
253
|
+
- `ts-morph`: TypeScript AST parsing
|
|
254
|
+
- Custom analyzers for each platform:
|
|
255
|
+
- `BackendArchitectureDetector`: Detects NestJS patterns, Clean Architecture
|
|
256
|
+
- `FrontendArchitectureDetector`: Detects React/Next.js patterns, Feature-First
|
|
257
|
+
- `iOSArchitectureDetector`: Detects multiple iOS architecture patterns (MVVM, MVVM-C, MVP, VIPER, TCA, Clean Swift, Feature-First + Clean + DDD, MVC Legacy)
|
|
258
|
+
- `AndroidClassAnalyzer`: Detects Kotlin/Jetpack Compose patterns
|
|
259
|
+
- `MaintainabilityAnalyzer`, `PerformanceAnalyzer`, `SecurityAnalyzer`, `StabilityAnalyzer`
|
|
260
|
+
|
|
261
|
+
4. **Context Management**:
|
|
262
|
+
- `DynamicRulesLoader`: Loads and aggregates rules from any agentic IDE rules directory (Cursor, Claude, Windsurf, VS Code, Kilo, Cline, etc.)
|
|
263
|
+
- `ContextDetectionEngine`: Detects project structure and patterns
|
|
264
|
+
- `PlatformDetectionService`: Identifies platforms (iOS, Android, Backend, Frontend)
|
|
265
|
+
- `AutonomousOrchestrator`: Coordinates context detection and rule loading
|
|
266
|
+
|
|
267
|
+
5. **Real-Time Services**:
|
|
268
|
+
- `RealtimeGuardService`: Monitors evidence freshness, Git tree state
|
|
269
|
+
- `IntelligentGitTreeMonitor`: Tracks Git changes and suggests actions
|
|
270
|
+
- `EvidenceMonitorService`: Watches for evidence staleness
|
|
271
|
+
|
|
272
|
+
6. **Use Cases** (Clean Architecture):
|
|
273
|
+
- `AnalyzeCodebaseUseCase`: Full codebase analysis
|
|
274
|
+
- `AnalyzeStagedFilesUseCase`: Staged files only
|
|
275
|
+
- `BlockCommitUseCase`: Determines if commit should be blocked
|
|
276
|
+
- `AutoExecuteAIStartUseCase`: Auto-executes `ai-start` based on confidence
|
|
277
|
+
- `GenerateAuditReportUseCase`: Creates audit reports (console, JSON, HTML)
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 📊 What, How, and When: The Developer's Perspective
|
|
282
|
+
|
|
283
|
+
### **What** Does This Library Provide?
|
|
284
|
+
|
|
285
|
+
1. **Permanent AI Context**: `.AI_EVIDENCE.json` that never gets lost
|
|
286
|
+
2. **798+ Validation Rules**: Platform-specific code quality rules
|
|
287
|
+
3. **Automatic Architecture Detection**: Identifies multiple patterns per platform (iOS: MVVM, MVVM-C, MVP, VIPER, TCA, Clean Swift, Feature-First + Clean + DDD; Backend: Clean Architecture, DDD, CQRS; Frontend: Feature-First, Component-Based, Atomic Design; Android: MVVM, MVI, MVP, Clean Architecture)
|
|
288
|
+
4. **Quality Gates**: Blocks commits with CRITICAL/HIGH violations
|
|
289
|
+
5. **Git Flow Automation**: Complete workflow automation (commit → push → PR → merge)
|
|
290
|
+
6. **MCP Integration**: Standard protocol for any agentic IDE
|
|
291
|
+
|
|
292
|
+
### **How** Does It Work?
|
|
293
|
+
|
|
294
|
+
1. **Installation**: `npm install --save-dev @pumuki/ast-intelligence-hooks && npm run install-hooks`
|
|
295
|
+
2. **Initialization**: Run `ai-start` before coding (or it auto-executes)
|
|
296
|
+
3. **Development**: System monitors and validates automatically
|
|
297
|
+
4. **Commits**: Pre-commit hooks analyze and block if needed
|
|
298
|
+
5. **AI Interaction**: AI always has fresh context via `.AI_EVIDENCE.json`
|
|
299
|
+
|
|
300
|
+
### **When** Does It Activate?
|
|
301
|
+
|
|
302
|
+
- **On Installation**: Sets up Git hooks, MCP server, rules
|
|
303
|
+
- **Before Coding**: `ai-start` initializes context (manual or auto)
|
|
304
|
+
- **During Editing**: Pre-tool-use hooks validate evidence freshness
|
|
305
|
+
- **Before Commits**: Pre-commit hooks analyze staged files
|
|
306
|
+
- **On AI Requests**: `ai_gate_check` validates before AI actions
|
|
307
|
+
- **Continuously**: `RealtimeGuardService` monitors and auto-refreshes
|
|
308
|
+
|
|
309
|
+
### **Why** Does It Matter?
|
|
310
|
+
|
|
311
|
+
- **Efficiency**: AI never asks "What's the architecture?" again
|
|
312
|
+
- **Quality**: Catches violations before they reach production
|
|
313
|
+
- **Consistency**: Enforces standards across entire team
|
|
314
|
+
- **Automation**: Reduces manual Git Flow tasks
|
|
315
|
+
- **Context Persistence**: Survives token limits, session resets, conversation boundaries
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## 🎯 The Result: Never Lose Context Again
|
|
320
|
+
|
|
321
|
+
With this library, your AI assistant **always knows**:
|
|
322
|
+
|
|
323
|
+
- ✅ **What you're working on**: Current branch, recent commits, active modules
|
|
324
|
+
- ✅ **What rules apply**: All 798+ platform-specific rules loaded automatically
|
|
325
|
+
- ✅ **What patterns exist**: Architecture patterns detected and documented
|
|
326
|
+
- ✅ **What violations need fixing**: Real-time violation tracking with severity
|
|
327
|
+
- ✅ **How the architecture should be structured**: Clean Architecture, DDD, Feature-First validation
|
|
328
|
+
|
|
329
|
+
**This is not just a validation tool**—it's a **context persistence system** that transforms AI assistants from forgetful helpers into **permanent, context-aware collaborators**.
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## 📖 Table of Contents
|
|
334
|
+
|
|
335
|
+
- [The Vision: Solving AI Context Loss](#-the-vision-solving-ai-context-loss-in-software-development)
|
|
336
|
+
- [The Fundamental Problem](#the-fundamental-problem)
|
|
337
|
+
- [The Solution: Permanent Context Persistence](#the-solution-permanent-context-persistence)
|
|
338
|
+
- [How It Works: The Complete Flow](#-how-it-works-the-complete-flow)
|
|
339
|
+
- [Phase 1: Context Initialization (`ai_start` Protocol)](#phase-1-context-initialization-ai_start-protocol)
|
|
340
|
+
- [Phase 2: Continuous Context Maintenance](#phase-2-continuous-context-maintenance)
|
|
341
|
+
- [Phase 3: Code Quality Enforcement](#phase-3-code-quality-enforcement)
|
|
342
|
+
- [Phase 4: Evidence Update Before Commits](#phase-4-evidence-update-before-commits)
|
|
343
|
+
- [Tools & Technologies](#️-tools--technologies)
|
|
344
|
+
- [What, How, and When: The Developer's Perspective](#-what-how-and-when-the-developers-perspective)
|
|
345
|
+
- [The Result: Never Lose Context Again](#-the-result-never-lose-context-again)
|
|
346
|
+
- [What is it?](#what-is-it)
|
|
347
|
+
- [What problems does it solve?](#what-problems-does-it-solve)
|
|
348
|
+
- [Features](#features)
|
|
349
|
+
- [Use Cases](#use-cases)
|
|
350
|
+
- [Installation](#installation)
|
|
351
|
+
- [Quick Start](#quick-start)
|
|
352
|
+
- [📚 Documentation Guide - Step by Step](#-documentation-guide---step-by-step)
|
|
353
|
+
- [Architecture](#architecture)
|
|
354
|
+
- [MCP Servers](#mcp-servers)
|
|
355
|
+
- [API Reference](#api-reference)
|
|
356
|
+
- [Configuration](#configuration)
|
|
357
|
+
- [Best Practices](#best-practices)
|
|
358
|
+
- [FAQ](#faq)
|
|
359
|
+
- [Contributing](#contributing)
|
|
360
|
+
- [License](#license)
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## What is it?
|
|
365
|
+
|
|
366
|
+
`ast-intelligence-hooks` is an intelligent static analysis system that automatically validates that your code complies with **Clean Architecture**, **Domain-Driven Design (DDD)**, and **Feature-First Architecture** principles.
|
|
367
|
+
|
|
368
|
+
**But more importantly**, it's a **context persistence system** that ensures AI assistants maintain permanent understanding of your project through the `ai_start` protocol, automatic rule loading, and continuously updated `.AI_EVIDENCE.json`.
|
|
369
|
+
|
|
370
|
+
### Key Features
|
|
371
|
+
|
|
372
|
+
#### 🧠 Context Persistence (Core Purpose)
|
|
373
|
+
- ✅ **`ai_start` Protocol**: Automatically answers the three critical questions for AI context
|
|
374
|
+
- ✅ **`.AI_EVIDENCE.json`**: Permanent context file that never goes stale
|
|
375
|
+
- ✅ **Automatic rule loading**: All 798+ rules loaded automatically for AI awareness
|
|
376
|
+
- ✅ **Context detection**: Real-time understanding of what you're working on
|
|
377
|
+
|
|
378
|
+
#### 🔍 Code Validation
|
|
379
|
+
- ✅ **798+ validation rules** across all platforms with severity-based quality gates
|
|
380
|
+
- ✅ **Multi-platform support**: iOS (Swift/SwiftUI), Android (Kotlin/Jetpack Compose), Backend (TypeScript/NestJS), Frontend (React/Next.js)
|
|
381
|
+
- ✅ **Automatic architecture detection**: Detects multiple patterns per platform (iOS: MVVM, MVVM-C, MVP, VIPER, TCA, Clean Swift, Feature-First + Clean + DDD; Backend: Clean Architecture, DDD, CQRS; Frontend: Feature-First, Component-Based, Atomic Design; Android: MVVM, MVI, MVP, Clean Architecture)
|
|
382
|
+
- ✅ **BDD→TDD workflow enforcement**: CRITICAL priority - ensures feature files exist before implementation and tests before code
|
|
383
|
+
- ✅ **Pre-commit Git hooks**: Automatic validation blocks commits with CRITICAL/HIGH violations
|
|
384
|
+
- ✅ **AST analysis engine**: Deep static code analysis using Abstract Syntax Trees
|
|
385
|
+
- ✅ **Clean Architecture enforcement**: Strict SOLID principles validation and dependency rules
|
|
386
|
+
|
|
387
|
+
#### 🤖 Automation & Integration
|
|
388
|
+
- ✅ **Git Flow automation**: Complete workflow automation via MCP (commit → push → PR → merge)
|
|
389
|
+
- ✅ **MCP integration**: Standard Model Context Protocol (MCP) support for any agentic IDE or AI client (Cursor, Claude Desktop, etc.)
|
|
390
|
+
- ✅ **Version checking**: Automatic detection of library updates
|
|
391
|
+
- ✅ **CI/CD ready**: Seamless integration with GitHub Actions and other CI systems
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## What problems does it solve?
|
|
396
|
+
|
|
397
|
+
### ❌ Common Problems
|
|
398
|
+
|
|
399
|
+
1. **Clean Architecture Violations**
|
|
400
|
+
- Domain layer importing frameworks
|
|
401
|
+
- Infrastructure coupled to Presentation
|
|
402
|
+
- Circular dependencies
|
|
403
|
+
|
|
404
|
+
2. **Undetected Code Smells**
|
|
405
|
+
- Magic numbers without constants
|
|
406
|
+
- Functions that are too long
|
|
407
|
+
- Classes with too many responsibilities
|
|
408
|
+
|
|
409
|
+
3. **Lack of Architectural Consistency**
|
|
410
|
+
- Incorrect folder structure
|
|
411
|
+
- Forbidden imports between layers
|
|
412
|
+
- Missing separation of concerns
|
|
413
|
+
|
|
414
|
+
4. **Production-time Errors**
|
|
415
|
+
- Security violations (passwords without hash)
|
|
416
|
+
- Performance issues
|
|
417
|
+
- Untestable code
|
|
418
|
+
|
|
419
|
+
### ✅ Solutions
|
|
420
|
+
|
|
421
|
+
- **Automatic validation** before each commit
|
|
422
|
+
- **798+ rules** specific to each platform
|
|
423
|
+
- **Detailed reports** with correction suggestions
|
|
424
|
+
- **CI/CD integration** for continuous validation
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## Features
|
|
429
|
+
|
|
430
|
+
### 🎯 Platform-specific Analysis
|
|
431
|
+
|
|
432
|
+
#### Backend (TypeScript/NestJS)
|
|
433
|
+
- 150+ Clean Architecture rules
|
|
434
|
+
- **Automatic architecture detection**: Clean Architecture, Onion, Layered, Feature-First + Clean + DDD, CQRS
|
|
435
|
+
- DDD pattern validation
|
|
436
|
+
- Circular dependency detection
|
|
437
|
+
- Decorator and module analysis
|
|
438
|
+
|
|
439
|
+
#### Frontend (React/Next.js)
|
|
440
|
+
- 200+ architecture rules
|
|
441
|
+
- **Automatic architecture detection**: Component-Based, Atomic Design, Feature-First + Clean + DDD, State Management patterns
|
|
442
|
+
- Server/Client Components validation
|
|
443
|
+
- Hooks and state management analysis
|
|
444
|
+
- Prop drilling detection
|
|
445
|
+
|
|
446
|
+
#### iOS (Swift/SwiftUI)
|
|
447
|
+
- 150+ iOS-specific rules
|
|
448
|
+
- **Automatic architecture detection**: MVVM-C, MVVM, MVP, VIPER, TCA, Clean Swift, Feature-First + Clean + DDD
|
|
449
|
+
- SwiftUI best practices analysis
|
|
450
|
+
- Potential memory leak detection
|
|
451
|
+
|
|
452
|
+
#### Android (Kotlin/Jetpack Compose)
|
|
453
|
+
- 200+ Android-specific rules
|
|
454
|
+
- **Automatic architecture detection**: MVVM, MVI, MVP, Clean Architecture, Feature-First + Clean + DDD
|
|
455
|
+
- Compose pattern analysis
|
|
456
|
+
- Common anti-pattern detection
|
|
457
|
+
|
|
458
|
+
### 🏗️ Automatic Architecture Detection
|
|
459
|
+
|
|
460
|
+
All platforms now support **automatic architecture pattern detection**:
|
|
461
|
+
- **No configuration needed** - works out of the box
|
|
462
|
+
- Detects patterns by analyzing project structure, imports, and code
|
|
463
|
+
- Supports manual override via `.ast-architecture.json` (optional)
|
|
464
|
+
- Works for iOS, Android, Backend, and Frontend
|
|
465
|
+
|
|
466
|
+
See [HOW_IT_WORKS.md](./docs/HOW_IT_WORKS.md#architecture-detection-by-platform) for details on detected patterns per platform.
|
|
467
|
+
|
|
468
|
+
### 🤖 MCP Integration
|
|
469
|
+
|
|
470
|
+
- **evidence-watcher**: Automatic monitoring of `.AI_EVIDENCE.json`
|
|
471
|
+
- **ast-intelligence-automation**: Complete Git Flow automation and context detection
|
|
472
|
+
- **Standard MCP protocol**: Works with any MCP-compatible agentic IDE (Cursor, Claude Desktop, and others)
|
|
473
|
+
|
|
474
|
+
### 🔒 Quality Gates
|
|
475
|
+
|
|
476
|
+
- **CRITICAL/HIGH**: Automatically block commits
|
|
477
|
+
- **MEDIUM/LOW**: Generate warnings in reports
|
|
478
|
+
- **Configurable**: Adjust levels according to your project
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Use Cases
|
|
483
|
+
|
|
484
|
+
### 1. Automatic Validation on Pre-commit
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
# Runs automatically on each git commit
|
|
488
|
+
git commit -m "feat: add new feature"
|
|
489
|
+
# → Analyzes only staged files
|
|
490
|
+
# → Blocks commit if CRITICAL/HIGH violations found
|
|
491
|
+
# → Generates violation report
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### 2. Full Project Analysis
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
# Analyzes entire codebase
|
|
498
|
+
npm run audit
|
|
499
|
+
|
|
500
|
+
# Or using CLI
|
|
501
|
+
ast-hooks analyze
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### 3. CI/CD Integration
|
|
505
|
+
|
|
506
|
+
```yaml
|
|
507
|
+
# .github/workflows/ci.yml
|
|
508
|
+
- name: Run AST Analysis
|
|
509
|
+
run: npm run audit
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
### 4. Programmatic Usage
|
|
513
|
+
|
|
514
|
+
```javascript
|
|
515
|
+
const { runASTIntelligence } = require('@pumuki/ast-intelligence-hooks');
|
|
516
|
+
|
|
517
|
+
const result = await runASTIntelligence({
|
|
518
|
+
files: ['src/**/*.ts'],
|
|
519
|
+
platforms: ['backend'],
|
|
520
|
+
strict: true
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
if (result.hasCriticalViolations()) {
|
|
524
|
+
console.error('❌ Critical violations found!');
|
|
525
|
+
process.exit(1);
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### 5. Continuous Monitoring
|
|
530
|
+
|
|
531
|
+
```bash
|
|
532
|
+
# Watch mode for development
|
|
533
|
+
hook-watch
|
|
534
|
+
|
|
535
|
+
# System status
|
|
536
|
+
hook-status
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
---
|
|
540
|
+
|
|
541
|
+
## Installation
|
|
542
|
+
|
|
543
|
+
### Prerequisites
|
|
544
|
+
|
|
545
|
+
- **Node.js** ≥18.0.0
|
|
546
|
+
- **npm** ≥9.0.0
|
|
547
|
+
- **Git** (for hooks)
|
|
548
|
+
|
|
549
|
+
### Option 1: Installation via npm (Recommended)
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
npm install --save-dev @pumuki/ast-intelligence-hooks
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### Option 2: Installation via Git
|
|
556
|
+
|
|
557
|
+
```bash
|
|
558
|
+
npm install --save-dev git+https://github.com/carlos/ast-intelligence-hooks.git
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### Option 3: Manual Installation
|
|
562
|
+
|
|
563
|
+
```bash
|
|
564
|
+
git clone https://github.com/carlos/ast-intelligence-hooks.git
|
|
565
|
+
cd ast-intelligence-hooks
|
|
566
|
+
npm install
|
|
567
|
+
npm link
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### Configure Git Hooks
|
|
571
|
+
|
|
572
|
+
```bash
|
|
573
|
+
# Install hooks automatically
|
|
574
|
+
npm run install-hooks
|
|
575
|
+
|
|
576
|
+
# Or manually
|
|
577
|
+
ast-install
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
For more details, see [INSTALLATION.md](./docs/INSTALLATION.md).
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
## Quick Start
|
|
585
|
+
|
|
586
|
+
### 1. Install the library
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
npm install --save-dev @pumuki/ast-intelligence-hooks
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### 2. Configure hooks
|
|
593
|
+
|
|
594
|
+
```bash
|
|
595
|
+
npm run install-hooks
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### 3. Make a test commit
|
|
599
|
+
|
|
600
|
+
```bash
|
|
601
|
+
git add .
|
|
602
|
+
git commit -m "test: verify hooks"
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
The hooks will run automatically and validate your code.
|
|
606
|
+
|
|
607
|
+
### 4. View full report
|
|
608
|
+
|
|
609
|
+
```bash
|
|
610
|
+
npm run audit
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### 5. Check violations
|
|
614
|
+
|
|
615
|
+
```bash
|
|
616
|
+
# List all violations
|
|
617
|
+
npm run violations:list
|
|
618
|
+
|
|
619
|
+
# View summary
|
|
620
|
+
npm run violations:summary
|
|
621
|
+
|
|
622
|
+
# Top violations
|
|
623
|
+
npm run violations:top
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
---
|
|
627
|
+
|
|
628
|
+
## 📚 Documentation Guide - Step by Step
|
|
629
|
+
|
|
630
|
+
This section provides a recommended reading order to fully understand the library and its capabilities.
|
|
631
|
+
|
|
632
|
+
### For New Users (Start Here)
|
|
633
|
+
|
|
634
|
+
1. **[HOW_IT_WORKS.md](./docs/HOW_IT_WORKS.md)** ⭐ **START HERE**
|
|
635
|
+
- Complete step-by-step explanation of what the library does
|
|
636
|
+
- Installation process breakdown
|
|
637
|
+
- How each component works (Git hooks, MCP servers, AST analysis)
|
|
638
|
+
- Execution flows and real-world examples
|
|
639
|
+
- **Read this first to understand the system!**
|
|
640
|
+
|
|
641
|
+
1. **[INSTALLATION.md](./docs/INSTALLATION.md)** - Start here! Complete installation guide with platform-specific instructions
|
|
642
|
+
- Prerequisites and requirements
|
|
643
|
+
- Installation methods (npm, Git, manual)
|
|
644
|
+
- Initial configuration
|
|
645
|
+
- Verification steps
|
|
646
|
+
|
|
647
|
+
2. **[USAGE.md](./docs/USAGE.md)** - Learn how to use the library
|
|
648
|
+
- Minimal example (5 minutes)
|
|
649
|
+
- Basic commands
|
|
650
|
+
- Git hooks integration
|
|
651
|
+
- Programmatic usage
|
|
652
|
+
- Advanced examples
|
|
653
|
+
- CI/CD integration
|
|
654
|
+
|
|
655
|
+
3. **[Quick Start](#quick-start)** (this README) - Get up and running quickly
|
|
656
|
+
- Fast setup in 5 steps
|
|
657
|
+
- First test commit
|
|
658
|
+
|
|
659
|
+
### For Understanding the System
|
|
660
|
+
|
|
661
|
+
4. **[ARCHITECTURE.md](./docs/ARCHITECTURE.md)** - High-level architecture overview
|
|
662
|
+
- System layers
|
|
663
|
+
- Data flow
|
|
664
|
+
- Key components
|
|
665
|
+
- Quality gates
|
|
666
|
+
|
|
667
|
+
5. **[ARCHITECTURE_DETAILED.md](./docs/ARCHITECTURE_DETAILED.md)** - Deep dive into architecture
|
|
668
|
+
- Detailed layer architecture
|
|
669
|
+
- Module dependencies
|
|
670
|
+
- Extension points
|
|
671
|
+
- Key files mapping
|
|
672
|
+
|
|
673
|
+
### For Integration and Advanced Usage
|
|
674
|
+
|
|
675
|
+
6. **[MCP_SERVERS.md](./docs/MCP_SERVERS.md)** - MCP integration for agentic IDEs
|
|
676
|
+
- evidence-watcher setup
|
|
677
|
+
- ast-intelligence-automation setup
|
|
678
|
+
- Usage examples
|
|
679
|
+
- Troubleshooting
|
|
680
|
+
|
|
681
|
+
7. **[API_REFERENCE.md](./docs/API_REFERENCE.md)** - Complete API documentation
|
|
682
|
+
- Core services
|
|
683
|
+
- Use Cases
|
|
684
|
+
- Domain entities
|
|
685
|
+
- Entry points
|
|
686
|
+
|
|
687
|
+
### For Configuration and Customization
|
|
688
|
+
|
|
689
|
+
8. **[CODE_STANDARDS.md](./docs/CODE_STANDARDS.md)** - Code style and conventions
|
|
690
|
+
- ESLint configuration
|
|
691
|
+
- TypeScript conventions
|
|
692
|
+
- Clean code principles
|
|
693
|
+
- Git commit format
|
|
694
|
+
|
|
695
|
+
9. **[DEPENDENCIES.md](./docs/DEPENDENCIES.md)** - Dependencies analysis
|
|
696
|
+
- Runtime dependencies
|
|
697
|
+
- Development dependencies
|
|
698
|
+
- Optional tools
|
|
699
|
+
- Platform compatibility
|
|
700
|
+
|
|
701
|
+
### For Development and Testing
|
|
702
|
+
|
|
703
|
+
10. **[TESTING.md](./docs/TESTING.md)** - Testing guide
|
|
704
|
+
- Test structure
|
|
705
|
+
- Running tests
|
|
706
|
+
- Writing new tests
|
|
707
|
+
- Best practices
|
|
708
|
+
|
|
709
|
+
### Quick Reference
|
|
710
|
+
|
|
711
|
+
- **Need to install?** → [INSTALLATION.md](./docs/INSTALLATION.md)
|
|
712
|
+
- **Need examples?** → [USAGE.md](./docs/USAGE.md) or `examples/` folder
|
|
713
|
+
- **Need API docs?** → [API_REFERENCE.md](./docs/API_REFERENCE.md)
|
|
714
|
+
- **Need to configure?** → [USAGE.md](./docs/USAGE.md#rule-configuration)
|
|
715
|
+
- **Need to understand architecture?** → [ARCHITECTURE.md](./docs/ARCHITECTURE.md)
|
|
716
|
+
|
|
717
|
+
---
|
|
718
|
+
|
|
719
|
+
## Architecture
|
|
720
|
+
|
|
721
|
+
The project follows **strict Clean Architecture** with 4 well-defined layers:
|
|
722
|
+
|
|
723
|
+
```
|
|
724
|
+
┌─────────────────────────────────────────┐
|
|
725
|
+
│ PRESENTATION LAYER │
|
|
726
|
+
│ - CLI Interface │
|
|
727
|
+
│ - Git Hooks │
|
|
728
|
+
│ - MCP Servers │
|
|
729
|
+
└──────────────┬──────────────────────────┘
|
|
730
|
+
│
|
|
731
|
+
┌──────────────▼──────────────────────────┐
|
|
732
|
+
│ APPLICATION LAYER │
|
|
733
|
+
│ - Use Cases │
|
|
734
|
+
│ - Services │
|
|
735
|
+
└──────────────┬──────────────────────────┘
|
|
736
|
+
│
|
|
737
|
+
┌──────────────▼──────────────────────────┐
|
|
738
|
+
│ DOMAIN LAYER │
|
|
739
|
+
│ - Entities │
|
|
740
|
+
│ - Business Rules │
|
|
741
|
+
│ - Repository Interfaces │
|
|
742
|
+
└──────────────┬──────────────────────────┘
|
|
743
|
+
▲
|
|
744
|
+
┌──────────────┴──────────────────────────┐
|
|
745
|
+
│ INFRASTRUCTURE LAYER │
|
|
746
|
+
│ - AST Analyzers │
|
|
747
|
+
│ - Repository Implementations │
|
|
748
|
+
│ - External Tools │
|
|
749
|
+
└─────────────────────────────────────────┘
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
**Principles:**
|
|
753
|
+
- **Dependencies inward**: Presentation → Application → Domain
|
|
754
|
+
- **Domain without dependencies**: Zero external dependencies
|
|
755
|
+
- **Dependency Inversion**: Interfaces in Domain, implementations in Infrastructure
|
|
756
|
+
|
|
757
|
+
For more details, see [ARCHITECTURE.md](./docs/ARCHITECTURE.md) and [ARCHITECTURE_DETAILED.md](./docs/ARCHITECTURE_DETAILED.md).
|
|
758
|
+
|
|
759
|
+
---
|
|
760
|
+
|
|
761
|
+
## MCP Servers
|
|
762
|
+
|
|
763
|
+
The project includes MCP (Model Context Protocol) servers for integration with any agentic IDE or AI client:
|
|
764
|
+
|
|
765
|
+
### evidence-watcher
|
|
766
|
+
|
|
767
|
+
Monitors the status of `.AI_EVIDENCE.json` and allows AI to verify if it's up to date.
|
|
768
|
+
|
|
769
|
+
**Resources:**
|
|
770
|
+
- `evidence://status`: Evidence status (fresh/stale/missing)
|
|
771
|
+
|
|
772
|
+
**Tools:**
|
|
773
|
+
- `check_evidence_status`: Checks if the evidence is stale
|
|
774
|
+
|
|
775
|
+
### ast-intelligence-automation
|
|
776
|
+
|
|
777
|
+
Automates the complete Git Flow cycle: commit → push → PR → merge, plus context detection and AI gate checks.
|
|
778
|
+
|
|
779
|
+
**Resources:**
|
|
780
|
+
- `evidence://status`: Evidence status
|
|
781
|
+
- `gitflow://state`: Git Flow workflow state
|
|
782
|
+
- `context://active`: Active project context
|
|
783
|
+
|
|
784
|
+
**Tools:**
|
|
785
|
+
- `auto_complete_gitflow`: Automatically completes Git Flow cycle
|
|
786
|
+
- `sync_branches`: Syncs develop/main branches
|
|
787
|
+
- `cleanup_stale_branches`: Cleans up merged branches
|
|
788
|
+
- `auto_execute_ai_start`: Automatically executes ai-start
|
|
789
|
+
- `validate_and_fix`: Validates and fixes common issues
|
|
790
|
+
- `ai_gate_check`: Gate check before tasks
|
|
791
|
+
|
|
792
|
+
For more details, see [MCP_SERVERS.md](./docs/MCP_SERVERS.md).
|
|
793
|
+
|
|
794
|
+
---
|
|
795
|
+
|
|
796
|
+
## API Reference
|
|
797
|
+
|
|
798
|
+
### Main Functions
|
|
799
|
+
|
|
800
|
+
#### `runASTIntelligence(options)`
|
|
801
|
+
|
|
802
|
+
Analyzes code using AST Intelligence.
|
|
803
|
+
|
|
804
|
+
```javascript
|
|
805
|
+
const { runASTIntelligence } = require('@pumuki/ast-intelligence-hooks');
|
|
806
|
+
|
|
807
|
+
const result = await runASTIntelligence({
|
|
808
|
+
files: ['src/**/*.ts'],
|
|
809
|
+
platforms: ['backend', 'frontend'],
|
|
810
|
+
strict: false
|
|
811
|
+
});
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
**Options:**
|
|
815
|
+
- `files` (string[]): File patterns to analyze
|
|
816
|
+
- `platforms` (string[]): Platforms to analyze (`ios`, `android`, `backend`, `frontend`)
|
|
817
|
+
- `strict` (boolean): If true, blocks on any violation
|
|
818
|
+
|
|
819
|
+
**Returns:** `AuditResult`
|
|
820
|
+
|
|
821
|
+
---
|
|
822
|
+
|
|
823
|
+
#### `AnalyzeCodebaseUseCase`
|
|
824
|
+
|
|
825
|
+
Use Case for full codebase analysis.
|
|
826
|
+
|
|
827
|
+
```javascript
|
|
828
|
+
const { AnalyzeCodebaseUseCase } = require('@pumuki/ast-intelligence-hooks');
|
|
829
|
+
|
|
830
|
+
const useCase = new AnalyzeCodebaseUseCase(/* dependencies */);
|
|
831
|
+
const result = await useCase.execute('/path/to/codebase');
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
---
|
|
835
|
+
|
|
836
|
+
#### `AnalyzeStagedFilesUseCase`
|
|
837
|
+
|
|
838
|
+
Use Case for analyzing only staged files.
|
|
839
|
+
|
|
840
|
+
```javascript
|
|
841
|
+
const { AnalyzeStagedFilesUseCase } = require('@pumuki/ast-intelligence-hooks');
|
|
842
|
+
|
|
843
|
+
const useCase = new AnalyzeStagedFilesUseCase(/* dependencies */);
|
|
844
|
+
const result = await useCase.execute();
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
---
|
|
848
|
+
|
|
849
|
+
### Domain Entities
|
|
850
|
+
|
|
851
|
+
#### `AuditResult`
|
|
852
|
+
|
|
853
|
+
Aggregated result of an analysis.
|
|
854
|
+
|
|
855
|
+
```javascript
|
|
856
|
+
const { AuditResult } = require('@pumuki/ast-intelligence-hooks');
|
|
857
|
+
|
|
858
|
+
result.getFindings(); // All violations
|
|
859
|
+
result.getCriticalFindings(); // Only CRITICAL
|
|
860
|
+
result.hasCriticalViolations(); // Boolean
|
|
861
|
+
result.getTechnicalDebtHours(); // Estimated hours
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
#### `Finding`
|
|
865
|
+
|
|
866
|
+
Individual violation found.
|
|
867
|
+
|
|
868
|
+
```javascript
|
|
869
|
+
const { Finding } = require('@pumuki/ast-intelligence-hooks');
|
|
870
|
+
|
|
871
|
+
finding.getSeverity(); // 'critical' | 'high' | 'medium' | 'low'
|
|
872
|
+
finding.getRule(); // Rule ID
|
|
873
|
+
finding.getMessage(); // Descriptive message
|
|
874
|
+
finding.getFile(); // File where it was found
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
For more details, see [API_REFERENCE.md](./docs/API_REFERENCE.md).
|
|
878
|
+
|
|
879
|
+
---
|
|
880
|
+
|
|
881
|
+
## Configuration
|
|
882
|
+
|
|
883
|
+
### Environment Variables
|
|
884
|
+
|
|
885
|
+
```bash
|
|
886
|
+
# Repository root
|
|
887
|
+
export REPO_ROOT=/path/to/project
|
|
888
|
+
|
|
889
|
+
# Evidence stale threshold (milliseconds, default: 180000 = 3 minutes)
|
|
890
|
+
export HOOK_GUARD_EVIDENCE_STALE_THRESHOLD=180000
|
|
891
|
+
|
|
892
|
+
# Auto ai-start execution (enabled by default)
|
|
893
|
+
export HOOK_GUARD_AI_START=true
|
|
894
|
+
export HOOK_GUARD_AI_START_COOLDOWN=60000
|
|
895
|
+
|
|
896
|
+
# Auto-refresh evidence when stale (enabled by default)
|
|
897
|
+
export HOOK_GUARD_AUTO_REFRESH=true
|
|
898
|
+
|
|
899
|
+
# Auto-commit in Git Flow
|
|
900
|
+
export AUTO_COMMIT_ENABLED=true
|
|
901
|
+
export AUTO_PUSH_ENABLED=true
|
|
902
|
+
export AUTO_PR_ENABLED=false
|
|
903
|
+
|
|
904
|
+
# Analysis mode
|
|
905
|
+
export AUDIT_STRICT=false
|
|
906
|
+
export AUDIT_STAGED_ONLY=false
|
|
907
|
+
export AUDIT_CRITICAL_HIGH_ONLY=false
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
### Configuration Files
|
|
911
|
+
|
|
912
|
+
- `config/ast-exclusions.json`: Exclude files from analysis
|
|
913
|
+
- `config/language-guard.json`: Language-specific guard configuration
|
|
914
|
+
- `config/doc-standards.json`: Documentation standards
|
|
915
|
+
- `.cursor/mcp.json` or client-specific config: MCP Servers configuration (see [MCP_SERVERS.md](./docs/MCP_SERVERS.md))
|
|
916
|
+
|
|
917
|
+
### Customize Rules
|
|
918
|
+
|
|
919
|
+
Rules are in `skills/` by platform:
|
|
920
|
+
- `skills/backend-guidelines/`
|
|
921
|
+
- `skills/frontend-guidelines/`
|
|
922
|
+
- `skills/ios-guidelines/`
|
|
923
|
+
- `skills/android-guidelines/`
|
|
924
|
+
|
|
925
|
+
For more details, see [USAGE.md](./docs/USAGE.md).
|
|
926
|
+
|
|
927
|
+
---
|
|
928
|
+
|
|
929
|
+
## Best Practices
|
|
930
|
+
|
|
931
|
+
### 1. Install Hooks in All Projects
|
|
932
|
+
|
|
933
|
+
```bash
|
|
934
|
+
# In each new project
|
|
935
|
+
npm install --save-dev @pumuki/ast-intelligence-hooks
|
|
936
|
+
npm run install-hooks
|
|
937
|
+
```
|
|
938
|
+
|
|
939
|
+
### 2. Use in CI/CD
|
|
940
|
+
|
|
941
|
+
```yaml
|
|
942
|
+
# .github/workflows/ci.yml
|
|
943
|
+
- name: AST Analysis
|
|
944
|
+
run: npm run audit
|
|
945
|
+
```
|
|
946
|
+
|
|
947
|
+
### 3. Review Violations Regularly
|
|
948
|
+
|
|
949
|
+
```bash
|
|
950
|
+
# Weekly
|
|
951
|
+
npm run violations:summary
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
### 4. Configure Appropriate Exclusions
|
|
955
|
+
|
|
956
|
+
```json
|
|
957
|
+
// config/ast-exclusions.json
|
|
958
|
+
{
|
|
959
|
+
"patterns": [
|
|
960
|
+
"node_modules/**",
|
|
961
|
+
"dist/**",
|
|
962
|
+
"build/**"
|
|
963
|
+
]
|
|
964
|
+
}
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
### 5. Use MCP Servers with Agentic IDEs
|
|
968
|
+
|
|
969
|
+
Configure MCP Servers in your IDE's MCP configuration file (e.g., `.cursor/mcp.json` for Cursor, or client-specific location) for complete automation.
|
|
970
|
+
|
|
971
|
+
---
|
|
972
|
+
|
|
973
|
+
## FAQ
|
|
974
|
+
|
|
975
|
+
### Can I use this in existing projects?
|
|
976
|
+
|
|
977
|
+
Yes, it's backward compatible. Hooks only validate new code you commit.
|
|
978
|
+
|
|
979
|
+
### How to temporarily disable hooks?
|
|
980
|
+
|
|
981
|
+
```bash
|
|
982
|
+
# For a specific commit
|
|
983
|
+
GIT_BYPASS_HOOK=1 git commit -m "emergency fix"
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
### Does it work with monorepos?
|
|
987
|
+
|
|
988
|
+
Yes, automatically detects monorepo structure and analyzes each module.
|
|
989
|
+
|
|
990
|
+
### Can I add custom rules?
|
|
991
|
+
|
|
992
|
+
Yes, you can extend rules in `skills/` or create your own analyzers.
|
|
993
|
+
|
|
994
|
+
### Does it work on Windows?
|
|
995
|
+
|
|
996
|
+
Works with WSL2 or Git Bash. Not tested on native Windows.
|
|
997
|
+
|
|
998
|
+
### What if I have many violations?
|
|
999
|
+
|
|
1000
|
+
Start by fixing CRITICAL and HIGH. MEDIUM and LOW are warnings and don't block commits.
|
|
1001
|
+
|
|
1002
|
+
### How to update evidence?
|
|
1003
|
+
|
|
1004
|
+
```bash
|
|
1005
|
+
# Automatically via MCP
|
|
1006
|
+
# Or manually
|
|
1007
|
+
./bin/update-evidence.sh --auto --platforms backend,frontend
|
|
1008
|
+
```
|
|
1009
|
+
|
|
1010
|
+
For more questions, check the issues on GitHub.
|
|
1011
|
+
|
|
1012
|
+
---
|
|
1013
|
+
|
|
1014
|
+
## Available Commands
|
|
1015
|
+
|
|
1016
|
+
### CLI Commands
|
|
1017
|
+
|
|
1018
|
+
```bash
|
|
1019
|
+
# Analysis
|
|
1020
|
+
ast-hooks analyze # Full analysis
|
|
1021
|
+
ast-hooks analyze --staged # Only staged files
|
|
1022
|
+
|
|
1023
|
+
# Violations
|
|
1024
|
+
ast-violations list # List all
|
|
1025
|
+
ast-violations summary # Summary
|
|
1026
|
+
ast-violations top # Top violations
|
|
1027
|
+
ast-violations show <id> # Show specific violation
|
|
1028
|
+
|
|
1029
|
+
# Hooks
|
|
1030
|
+
hook-status # System status
|
|
1031
|
+
hook-watch # Watch mode
|
|
1032
|
+
hook-predict # Violation prediction
|
|
1033
|
+
hook-playbook # Execute playbook
|
|
1034
|
+
|
|
1035
|
+
# Git Flow
|
|
1036
|
+
gitflow check # Verify Git Flow
|
|
1037
|
+
gitflow status # Current status
|
|
1038
|
+
gitflow workflow # View full workflow
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
### npm Scripts
|
|
1042
|
+
|
|
1043
|
+
```bash
|
|
1044
|
+
npm run audit # Full analysis
|
|
1045
|
+
npm run install-hooks # Install hooks
|
|
1046
|
+
npm test # Run tests
|
|
1047
|
+
npm run lint # Linter
|
|
1048
|
+
npm run typecheck # Type checking
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
---
|
|
1052
|
+
|
|
1053
|
+
## Contributing
|
|
1054
|
+
|
|
1055
|
+
Contributions are welcome. Please:
|
|
1056
|
+
|
|
1057
|
+
1. Fork the repository
|
|
1058
|
+
2. Create a branch for your feature (`git checkout -b feature/amazing-feature`)
|
|
1059
|
+
3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
|
|
1060
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
1061
|
+
5. Open a Pull Request
|
|
1062
|
+
|
|
1063
|
+
### Contribution Guidelines
|
|
1064
|
+
|
|
1065
|
+
- Follow the code of conduct
|
|
1066
|
+
- Ensure tests pass (`npm test`)
|
|
1067
|
+
- Add tests for new features
|
|
1068
|
+
- Update documentation if necessary
|
|
1069
|
+
|
|
1070
|
+
For coding standards, see [CODE_STANDARDS.md](./docs/CODE_STANDARDS.md).
|
|
1071
|
+
|
|
1072
|
+
---
|
|
1073
|
+
|
|
1074
|
+
## License
|
|
1075
|
+
|
|
1076
|
+
This project is licensed under the **MIT License** - see [LICENSE](./LICENSE) for more details.
|
|
1077
|
+
|
|
1078
|
+
---
|
|
1079
|
+
|
|
1080
|
+
## Credits
|
|
1081
|
+
|
|
1082
|
+
Developed by **Pumuki Team®**
|
|
1083
|
+
|
|
1084
|
+
- **Author**: Juan Carlos Merlos Albarracín (Senior Software Architect - AI-Driven Development)
|
|
1085
|
+
- **Contact**: freelancemerlos@gmail.com
|
|
1086
|
+
- **Version**: 5.3.1
|
|
1087
|
+
- **Repository**: [GitHub](https://github.com/carlos/ast-intelligence-hooks)
|
|
1088
|
+
|
|
1089
|
+
---
|
|
1090
|
+
|
|
1091
|
+
## Useful Links
|
|
1092
|
+
|
|
1093
|
+
- 📚 [Complete Documentation](./docs/)
|
|
1094
|
+
- 🏗️ [Detailed Architecture](./docs/ARCHITECTURE.md) | [Architecture Detailed](./docs/ARCHITECTURE_DETAILED.md)
|
|
1095
|
+
- 🔌 [MCP Servers](./docs/MCP_SERVERS.md)
|
|
1096
|
+
- 📖 [API Reference](./docs/API_REFERENCE.md)
|
|
1097
|
+
- 📦 [Installation Guide](./docs/INSTALLATION.md)
|
|
1098
|
+
- 💡 [Usage Guide](./docs/USAGE.md)
|
|
1099
|
+
- 🔍 [Dependencies Analysis](./docs/DEPENDENCIES.md)
|
|
1100
|
+
- 🧪 [Testing Guide](./docs/TESTING.md)
|
|
1101
|
+
- 📋 [Code Standards](./docs/CODE_STANDARDS.md)
|
|
1102
|
+
|
|
1103
|
+
---
|
|
1104
|
+
|
|
1105
|
+
**⭐ If this project is useful to you, please consider giving it a star on GitHub.**
|