pumuki-ast-hooks 5.5.60 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +361 -1101
  2. package/bin/__tests__/check-version.spec.js +32 -57
  3. package/docs/ARCHITECTURE.md +66 -1
  4. package/docs/TODO.md +41 -0
  5. package/docs/images/ast_intelligence_01.svg +40 -0
  6. package/docs/images/ast_intelligence_02.svg +39 -0
  7. package/docs/images/ast_intelligence_03.svg +55 -0
  8. package/docs/images/ast_intelligence_04.svg +39 -0
  9. package/docs/images/ast_intelligence_05.svg +45 -0
  10. package/docs/images/logo.png +0 -0
  11. package/package.json +1 -1
  12. package/scripts/hooks-system/.audit_tmp/hook-metrics.jsonl +20 -0
  13. package/scripts/hooks-system/application/DIValidationService.js +43 -0
  14. package/scripts/hooks-system/application/__tests__/DIValidationService.spec.js +81 -0
  15. package/scripts/hooks-system/bin/__tests__/check-version.spec.js +37 -57
  16. package/scripts/hooks-system/bin/cli.js +109 -0
  17. package/scripts/hooks-system/config/di-rules.json +42 -0
  18. package/scripts/hooks-system/domain/ports/FileSystemPort.js +19 -0
  19. package/scripts/hooks-system/domain/strategies/ConcreteDependencyStrategy.js +78 -0
  20. package/scripts/hooks-system/domain/strategies/DIStrategy.js +31 -0
  21. package/scripts/hooks-system/infrastructure/adapters/NodeFileSystemAdapter.js +28 -0
  22. package/scripts/hooks-system/infrastructure/ast/ast-core.js +124 -0
  23. package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +19 -1
  24. package/scripts/hooks-system/infrastructure/ast/backend/detectors/god-class-detector.js +28 -8
  25. package/scripts/hooks-system/infrastructure/ast/common/ast-common.js +133 -0
  26. package/scripts/hooks-system/infrastructure/ast/frontend/analyzers/__tests__/FrontendArchitectureDetector.spec.js +4 -1
  27. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSASTIntelligentAnalyzer.spec.js +3 -1
  28. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +3 -2
  29. package/scripts/hooks-system/infrastructure/ast/ios/ast-ios.js +1 -1
  30. package/scripts/hooks-system/infrastructure/ast/ios/detectors/ios-ast-intelligent-strategies.js +40 -46
  31. package/scripts/hooks-system/infrastructure/cascade-hooks/README.md +114 -0
  32. package/scripts/hooks-system/infrastructure/cascade-hooks/cascade-hooks-config.json +20 -0
  33. package/scripts/hooks-system/infrastructure/cascade-hooks/claude-code-hook.sh +127 -0
  34. package/scripts/hooks-system/infrastructure/cascade-hooks/post-write-code-hook.js +72 -0
  35. package/scripts/hooks-system/infrastructure/cascade-hooks/pre-write-code-hook.js +167 -0
  36. package/scripts/hooks-system/infrastructure/cascade-hooks/universal-hook-adapter.js +186 -0
  37. package/scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js +739 -24
  38. package/scripts/hooks-system/infrastructure/observability/MetricsCollector.js +221 -0
  39. package/scripts/hooks-system/infrastructure/observability/index.js +23 -0
  40. package/scripts/hooks-system/infrastructure/orchestration/__tests__/intelligent-audit.spec.js +177 -0
  41. package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +87 -1
  42. package/scripts/hooks-system/infrastructure/registry/StrategyRegistry.js +63 -0
  43. package/scripts/hooks-system/infrastructure/resilience/CircuitBreaker.js +229 -0
  44. package/scripts/hooks-system/infrastructure/resilience/RetryPolicy.js +141 -0
  45. package/scripts/hooks-system/infrastructure/resilience/index.js +34 -0
package/README.md CHANGED
@@ -8,8 +8,8 @@
8
8
  <a href="https://www.npmjs.com/package/pumuki-ast-hooks"><img src="https://img.shields.io/npm/v/pumuki-ast-hooks.svg?style=flat-square&label=npm&color=CB3837" alt="npm version" /></a>
9
9
  <a href="https://www.npmjs.com/package/pumuki-ast-hooks"><img src="https://img.shields.io/npm/dm/pumuki-ast-hooks.svg?style=flat-square&color=CB3837" alt="npm downloads" /></a>
10
10
  <a href="https://github.com/SwiftEnProfundidad/ast-intelligence-hooks/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT" /></a>
11
- <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg?style=flat-square&logo=node.js" alt="Node.js Version" /></a>
12
- <a href="https://www.npmjs.com/"><img src="https://img.shields.io/badge/npm-%3E%3D9.0.0-red.svg?style=flat-square&logo=npm" alt="npm" /></a>
11
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-20.x-brightgreen.svg?style=flat-square&logo=node.js" alt="Node.js Version" /></a>
12
+ <a href="https://www.npmjs.com/"><img src="https://img.shields.io/badge/npm-10%2B-red.svg?style=flat-square&logo=npm" alt="npm" /></a>
13
13
  <img src="https://img.shields.io/badge/platforms-iOS%20%7C%20Android%20%7C%20Backend%20%7C%20Frontend-blue.svg?style=flat-square" alt="Platforms" />
14
14
  <a href="https://github.com/SwiftEnProfundidad/ast-intelligence-hooks/releases"><img src="https://img.shields.io/github/release-date/SwiftEnProfundidad/ast-intelligence-hooks.svg?style=flat-square&label=last%20release" alt="Last Release" /></a>
15
15
  <a href="https://github.com/SwiftEnProfundidad/ast-intelligence-hooks/issues"><img src="https://img.shields.io/github/issues/SwiftEnProfundidad/ast-intelligence-hooks.svg?style=flat-square" alt="GitHub Issues" /></a>
@@ -19,1364 +19,624 @@
19
19
  <strong>Enterprise-grade AST Intelligence System for multi-platform code quality enforcement</strong>
20
20
  </p>
21
21
 
22
- <p align="center">
23
- <a href="#-quick-start">Quick Start</a> •
24
- <a href="#-features">Features</a> •
25
- <a href="./docs/INSTALLATION.md">Installation</a> •
26
- <a href="./docs/API_REFERENCE.md">API Reference</a> •
27
- <a href="./CHANGELOG.md">Changelog</a> •
28
- <a href="./docs/CONTRIBUTING.md">Contributing</a>
29
- </p>
30
-
31
- ## 📖 Table of Contents
32
-
33
- - [The Vision: Solving AI Context Loss](#-the-vision-solving-ai-context-loss-in-software-development)
34
- - [The Fundamental Problem](#the-fundamental-problem)
35
- - [The Solution: Permanent Context Persistence](#the-solution-permanent-context-persistence)
36
- - [How It Works: The Complete Flow](#-how-it-works-the-complete-flow)
37
- - [Phase 1: Context Initialization (`ai_start` Protocol)](#phase-1-context-initialization-ai_start-protocol)
38
- - [Phase 2: Continuous Context Maintenance](#phase-2-continuous-context-maintenance)
39
- - [Phase 3: Code Quality Enforcement](#phase-3-code-quality-enforcement)
40
- - [Phase 4: Evidence Update Before Commits](#phase-4-evidence-update-before-commits)
41
- - [Tools & Technologies](#️-tools--technologies)
42
- - [What, How, and When: The Developer's Perspective](#-what-how-and-when-the-developers-perspective)
43
- - [Complete Architecture and Workflow](#complete-architecture-and-workflow)
44
- - [What is it?](#what-is-it)
45
- - [What problems does it solve?](#what-problems-does-it-solve)
46
- - [Git Flow Automation](#git-flow-automation)
47
- - [Features](#features)
48
- - [Use Cases](#use-cases)
49
- - [Installation](#installation)
50
- - [Quick Start](#quick-start)
51
- - [📚 Documentation Guide - Step by Step](#-documentation-guide---step-by-step)
52
- - [Architecture](#architecture)
53
- - [MCP Servers](#mcp-servers)
54
- - [API Reference](#api-reference)
55
- - [Configuration](#configuration)
56
- - [Best Practices](#best-practices)
57
- - [FAQ](#faq)
58
- - [Contributing](#contributing)
59
- - [License](#license)
22
+ ### Navigation
60
23
 
61
- ---
24
+ | Section | Description |
25
+ |---------|-------------|
26
+ | [Quick Start](#quick-start) | Get started in 30 seconds |
27
+ | [Features](#features) | Main capabilities |
28
+ | [Installation](./docs/INSTALLATION.md) | Full installation guide |
29
+ | [Architecture](./docs/ARCHITECTURE.md) | System design & contracts |
30
+ | [API Reference](./docs/API_REFERENCE.md) | Programmatic interface |
31
+ | [Roadmap](./docs/TODO.md) | Planned improvements |
32
+ | [Changelog](./CHANGELOG.md) | Version history |
33
+ | [Contributing](./docs/CONTRIBUTING.md) | How to contribute |
62
34
 
63
- ### Visual Overview
35
+ # Pumuki AST Intelligence Framework
64
36
 
65
- <img src="https://raw.githubusercontent.com/SwiftEnProfundidad/ast-intelligence-hooks/main/docs/images/ast_intelligence_01.png" alt="AST Intelligence System Overview" width="100%" />
37
+ ## Enterprise AI Context Governance & Code Quality Enforcement
66
38
 
67
- <img src="https://raw.githubusercontent.com/SwiftEnProfundidad/ast-intelligence-hooks/main/docs/images/ast_intelligence_02.png" alt="AST Intelligence Workflow" width="100%" />
39
+ Pumuki AST Intelligence Framework is a **portable, enterprise-grade framework** designed to **govern AI-assisted software development** in large, long-lived, multi-platform projects.
68
40
 
69
- <img src="https://raw.githubusercontent.com/SwiftEnProfundidad/ast-intelligence-hooks/main/docs/images/ast_intelligence_03.png" alt="AST Intelligence Audit - Part 1" width="100%" />
41
+ It provides a **deterministic control layer** over AI behavior by combining:
70
42
 
71
- <img src="https://raw.githubusercontent.com/SwiftEnProfundidad/ast-intelligence-hooks/main/docs/images/ast_intelligence_04.png" alt="AST Intelligence Audit - Part 2" width="100%" />
43
+ * AST-based static analysis
44
+ * Persistent AI context evidence
45
+ * Rule-based validation
46
+ * Hard AI gating (block / allow)
47
+ * Native Git workflow integration
72
48
 
73
- <img src="https://raw.githubusercontent.com/SwiftEnProfundidad/ast-intelligence-hooks/main/docs/images/ast_intelligence_05.png" alt="AST Intelligence Audit - Part 3" width="100%" />
49
+ The framework is **project-agnostic** by design and can be adopted by any organization seeking to use AI **safely, predictably, and at scale**.
74
50
 
75
51
  ---
76
52
 
77
- ## 🧠 The Vision: Solving AI Context Loss in Software Development
53
+ ## Problem Statement
78
54
 
79
- ### The Fundamental Problem
55
+ AI assistants are powerful but fundamentally unreliable when used in real-world, enterprise codebases:
80
56
 
81
- 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:
57
+ * Context degrades across sessions, chats, and tools
58
+ * Architectural rules are suggested but not enforced
59
+ * AI hallucinations introduce subtle, high-impact defects
60
+ * There is no persistent or auditable source of truth
61
+ * Long-running features suffer from context drift
82
62
 
83
- - **Project architecture**: "What's the structure here? Clean Architecture? DDD? Feature-First?"
84
- - **Active rules**: "Which validation rules apply? What are the coding standards?"
85
- - **Current work**: "What branch am I on? What files were recently changed? What patterns exist?"
86
- - **Quality gates**: "Are there blocking violations? What needs to be fixed?"
63
+ Pumuki addresses these issues by **removing trust from the AI** and replacing it with **evidence, validation, and enforcement**.
87
64
 
88
- 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.
65
+ ---
89
66
 
90
- ### The Solution: Permanent Context Persistence
67
+ ## Quick Start
91
68
 
92
- 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.
69
+ 1. Instala dependencias: `npm install`
70
+ 2. Usa los ganchos: `npx ast-hooks` (menú interactivo)
71
+ 3. Modo CI/CD: `bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh`
72
+ 4. Consulta la guía: [docs/INSTALLATION.md](./docs/INSTALLATION.md)
93
73
 
94
74
  ---
95
75
 
96
- ## 🔄 How It Works: The Complete Flow
97
-
98
- ### Phase 1: Context Initialization (`ai_start` Protocol)
99
-
100
- **When**: Before any code editing begins, or when context becomes stale (>3 minutes)
101
-
102
- **What Happens**:
103
-
104
- 1. **Developer runs `ai-start`** (or it auto-executes via MCP):
105
- ```bash
106
- ai-start feature/user-authentication
107
- # or automatically via MCP: auto_execute_ai_start
108
- ```
109
-
110
- 2. **The system answers three critical questions**:
111
- - **Q1: What file types am I working with?**
112
- - Analyzes staged/modified files
113
- - Detects platforms (iOS, Android, Backend, Frontend)
114
- - Identifies target Clean Architecture layers (Domain, Application, Infrastructure, Presentation)
115
- - Example: `"Code task on branch 'feature/auth'. Modifying typescript, kotlin in: auth, users. Target layer: Domain."`
116
-
117
- - **Q2: Does similar code already exist?**
118
- - Analyzes recent Git commits
119
- - Identifies affected modules
120
- - Suggests existing patterns to follow
121
- - Example: `"Modules affected: auth, users. Recent commits: abc123 feat: Add JWT validation. Check for existing patterns before adding new code."`
122
-
123
- - **Q3: How does this fit in Clean Architecture?**
124
- - Validates layer dependencies
125
- - Ensures dependencies point inward (Domain ← Application ← Infrastructure)
126
- - Example: `"Code changes in Domain layer affecting auth, users. Ensure dependencies point inward."`
127
-
128
- 3. **Rules are automatically loaded**:
129
- - `DynamicRulesLoader` scans agentic IDE rules directories (`.cursor/rules/`, `.ast-intelligence/skills/`, `.windsurf/rules/`, `.vscode/rules/`, `.kilo/rules/`, `.cline/rules/`) for platform-specific rules
130
- - **Always loads `rulesgold.mdc` first** (generic rules that apply to all projects)
131
- - Then loads platform-specific rules: `rulesbackend.mdc`, `rulesios.mdc`, `rulesandroid.mdc`, `rulesfront.mdc`
132
- - Aggregates all 798+ validation rules into a single context
133
- - Creates `auto-context.mdc` with all active rules
134
-
135
- 4. **`.AI_EVIDENCE.json` is created/updated**:
136
- ```json
137
- {
138
- "timestamp": "2025-12-13T23:07:19.632Z",
139
- "session_id": "feature/user-authentication",
140
- "protocol_3_questions": {
141
- "answered": true,
142
- "question_1_file_type": "Code task on branch 'feature/auth'. Modifying typescript, kotlin in: auth, users. Target layer: Domain.",
143
- "question_2_similar_exists": "Modules affected: auth, users. Recent commits: abc123 feat: Add JWT validation. Check for existing patterns before adding new code.",
144
- "question_3_clean_architecture": "Code changes in Domain layer affecting auth, users. Ensure dependencies point inward."
145
- },
146
- "rules_read": [
147
- { "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" },
148
- { "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" },
149
- { "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" }
150
- ],
151
- "current_context": {
152
- "branch": "feature/user-authentication",
153
- "last_commits": "abc123 feat: Add JWT validation"
154
- },
155
- "platforms": ["backend", "ios"],
156
- "ai_gate": {
157
- "status": "BLOCKED",
158
- "last_check": "2025-12-13T23:16:39.736Z",
159
- "violations": [
160
- {
161
- "file": "/path/to/project/src/auth/user.service.ts",
162
- "line": 45,
163
- "severity": "HIGH",
164
- "rule": "backend.error_handling.untyped_catch",
165
- "message": "Catch parameter MUST be typed as ': unknown' - use type guards (error instanceof HttpException/Error)",
166
- "category": "Error Handling",
167
- "intelligent_evaluation": false,
168
- "severity_score": 50
169
- },
170
- {
171
- "file": "/path/to/project/src/auth/auth.controller.ts",
172
- "line": 12,
173
- "severity": "CRITICAL",
174
- "rule": "backend.security.pii_in_logs",
175
- "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.",
176
- "category": "Security",
177
- "intelligent_evaluation": true,
178
- "severity_score": 100
179
- }
180
- ],
181
- "instruction": "🚨 AI MUST call mcp_ast-intelligence-automation_ai_gate_check BEFORE any action. If BLOCKED, fix violations first!",
182
- "mandatory": true
183
- },
184
- "severity_metrics": {
185
- "last_updated": "2025-12-13T23:16:39.726Z",
186
- "total_violations": 2,
187
- "by_severity": {
188
- "CRITICAL": 1,
189
- "HIGH": 1,
190
- "MEDIUM": 0,
191
- "LOW": 0
192
- },
193
- "average_severity_score": 75,
194
- "gate_status": "FAILED",
195
- "blocked_by": "CRITICAL"
196
- }
197
- }
198
- ```
199
-
200
- ### Phase 2: Continuous Context Maintenance
201
-
202
- **When**: Throughout the development session
203
-
204
- **What Happens**:
205
-
206
- 1. **Pre-Tool-Use Validation** (`pre-tool-use-evidence-validator.ts`):
207
- - **Before every AI edit operation**, validates `.AI_EVIDENCE.json`:
208
- - ✅ File exists
209
- - ✅ Valid JSON structure
210
- - ✅ Timestamp is fresh (<180 seconds old)
211
- - ✅ Rules were read
212
- - ✅ Protocol 3 questions answered
213
- - ✅ AI gate is not BLOCKED
214
- - **If stale or missing**: Blocks the edit and prompts to run `ai-start`
215
- - **If BLOCKED**: Shows violations and requires fixing before proceeding
216
-
217
- 2. **Real-Time Monitoring** (`RealtimeGuardService`):
218
- - Polls `.AI_EVIDENCE.json` every 30 seconds
219
- - Detects staleness (>180 seconds)
220
- - **Auto-refreshes** evidence if stale (`HOOK_GUARD_AUTO_REFRESH=true` by default)
221
- - **Auto-executes ai-start** when code files detected (`HOOK_GUARD_AI_START=true` by default)
222
- - Monitors Git tree state with differentiated thresholds:
223
- - **Staged files**: Warning at >10 files (configurable via `HOOK_GUARD_DIRTY_TREE_STAGED_LIMIT`)
224
- - **Unstaged files**: Warning at >15 files (configurable via `HOOK_GUARD_DIRTY_TREE_UNSTAGED_LIMIT`)
225
- - **Total files**: Warning at >20 files (configurable via `HOOK_GUARD_DIRTY_TREE_TOTAL_LIMIT`)
226
- - Sends macOS notifications for critical events
227
-
228
- 3. **Automatic Rule Updates**:
229
- - When new rules are added to any agentic IDE rules directory, they're automatically detected
230
- - `DynamicRulesLoader` reloads rules on next `ai-start`
231
- - `auto-context.mdc` is regenerated with latest rules
232
-
233
- ### Phase 3: Code Quality Enforcement
234
-
235
- **When**: Before commits, during development, via MCP tools
236
-
237
- **What Happens**:
238
-
239
- 1. **Pre-Commit Analysis** (Git Hook):
240
- - Analyzes staged files using AST (Abstract Syntax Tree)
241
- - Applies 798+ validation rules
242
- - Checks Clean Architecture violations
243
- - Validates SOLID principles
244
- - Detects security issues, performance problems, maintainability issues
245
- - **Blocks commit** if CRITICAL/HIGH violations found
246
-
247
- 2. **AI Gate Check** (`ai_gate_check` MCP tool):
248
- - **Called at the start of every AI response** (enforced by Cursor rules)
249
- - Reads `.AI_EVIDENCE.json` → `ai_gate.status`
250
- - Returns `BLOCKED` or `ALLOWED`
251
- - If `BLOCKED`: Shows violations, requires fixing before proceeding
252
- - If `ALLOWED`: AI can proceed with user's task
253
-
254
- 3. **Violation Detection**:
255
- - AST analyzers scan code for:
256
- - Architecture violations (wrong layer dependencies)
257
- - SOLID violations (God classes, tight coupling)
258
- - Security issues (PII in logs, SQL injection risks)
259
- - Performance issues (N+1 queries, missing pagination)
260
- - Code quality (comments, magic numbers, force unwrapping)
261
- - Findings are aggregated into `AuditResult`
262
- - Severity-based blocking (CRITICAL/HIGH block, MEDIUM/LOW warn)
263
-
264
- ### Phase 4: Evidence Update Before Commits
265
-
266
- **When**: Before every Git commit
267
-
268
- **What Happens**:
269
-
270
- 1. **`ai-commit.sh` is executed** (via Git alias or directly):
271
- ```bash
272
- git commit -m "feat: Add user authentication"
273
- # Internally calls: ai-commit.sh
274
- ```
275
-
276
- 2. **Evidence is refreshed**:
277
- - Updates `.AI_EVIDENCE.json` timestamp
278
- - Re-analyzes current context (branch, files, commits)
279
- - Updates violation status
280
- - Ensures evidence is fresh for next AI interaction
281
-
282
- 3. **Commit proceeds** with fresh evidence
76
+ ## Installation & Hooks CLI
77
+
78
+ * Install (dev): `npm install --save-dev @pumuki/ast-intelligence-hooks`
79
+ * Update to latest: `npm install --save-dev @pumuki/ast-intelligence-hooks@latest && npm run install-hooks`
80
+ * Uninstall: `npm uninstall @pumuki/ast-intelligence-hooks`
81
+ * Install/reinstall hooks: `npm run install-hooks` (alias `npx ast-install`)
82
+ * Interactive menu (hook-system): `npx ast-hooks`
83
+ * Evidence guard daemon: `npm run ast:guard:start|stop|restart|status|logs`
84
+ * Refresh evidence: `npm run ast:refresh`
85
+ * Check installed vs latest version: `npm run ast:check-version`
283
86
 
284
87
  ---
285
88
 
286
- ## 🛠️ Tools & Technologies
287
-
288
- ### Core Components
289
-
290
- 1. **Git Hooks**:
291
- - `pre-commit`: AST analysis before commits
292
- - `pre-push`: Additional validation before pushing
293
- - `post-commit`: Evidence update after commits
294
-
295
- 2. **MCP (Model Context Protocol) Server**:
296
- - `ast-intelligence-automation`: Provides AI tools via MCP
297
- - Tools: `ai_gate_check`, `auto_execute_ai_start`, `auto_complete_gitflow`, `sync_branches`, `cleanup_stale_branches`, `validate_and_fix`
298
- - Enables Cursor, Claude Desktop, and other MCP-compatible IDEs to interact with the system
299
-
300
- 3. **AST Analysis Engine**:
301
- - `ts-morph`: TypeScript AST parsing
302
- - Custom analyzers for each platform:
303
- - `BackendArchitectureDetector`: Detects NestJS patterns, Clean Architecture
304
- - `FrontendArchitectureDetector`: Detects React/Next.js patterns, Feature-First
305
- - `iOSArchitectureDetector`: Detects multiple iOS architecture patterns (MVVM, MVVM-C, MVP, VIPER, TCA, Clean Swift, Feature-First + Clean + DDD, MVC Legacy)
306
- - `AndroidClassAnalyzer`: Detects Kotlin/Jetpack Compose patterns
307
- - `MaintainabilityAnalyzer`, `PerformanceAnalyzer`, `SecurityAnalyzer`, `StabilityAnalyzer`
308
-
309
- 4. **Context Management**:
310
- - `DynamicRulesLoader`: Loads and aggregates rules from any agentic IDE rules directory (Cursor, Claude, Windsurf, VS Code, Kilo, Cline, etc.)
311
- - `ContextDetectionEngine`: Detects project structure and patterns
312
- - `PlatformDetectionService`: Identifies platforms (iOS, Android, Backend, Frontend)
313
- - `AutonomousOrchestrator`: Coordinates context detection and rule loading
314
-
315
- 5. **Real-Time Services**:
316
- - `RealtimeGuardService`: Monitors evidence freshness, Git tree state
317
- - `IntelligentGitTreeMonitor`: Tracks Git changes and suggests actions
318
- - `EvidenceMonitorService`: Watches for evidence staleness
319
-
320
- 6. **Use Cases** (Clean Architecture):
321
- - `AnalyzeCodebaseUseCase`: Full codebase analysis
322
- - `AnalyzeStagedFilesUseCase`: Staged files only
323
- - `BlockCommitUseCase`: Determines if commit should be blocked
324
- - `AutoExecuteAIStartUseCase`: Auto-executes `ai-start` based on confidence
325
- - `GenerateAuditReportUseCase`: Creates audit reports (console, JSON, HTML)
89
+ ## Features
326
90
 
327
- ---
91
+ ### Core
328
92
 
329
- ## 📊 What, How, and When: The Developer's Perspective
93
+ * **AST Intelligence** multi-platform (iOS, Android, Backend, Frontend)
94
+ * **Evidence file** `.AI_EVIDENCE.json` as single source of truth
95
+ * **AI Gate** (block/allow) with metrics and enforcement
330
96
 
331
- ### **What** Does This Library Provide?
97
+ ### NEW: Pre-Write Enforcement
332
98
 
333
- 1. **Permanent AI Context**: `.AI_EVIDENCE.json` that never gets lost
334
- 2. **798+ Validation Rules**: Platform-specific code quality rules
335
- 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)
336
- 4. **Quality Gates**: Blocks commits with CRITICAL/HIGH violations
337
- 5. **Git Flow Automation**: Complete workflow automation (commit → push → PR → merge)
338
- 6. **MCP Integration**: Standard protocol for any agentic IDE
99
+ * **Pre-Flight Validation**: Analyze code BEFORE writing to files
100
+ * **In-Memory AST Analysis**: `analyzeCodeInMemory()` for proposed code validation
101
+ * **IDE Hooks**: Real-time blocking in Windsurf, Claude Code, OpenCode
339
102
 
340
- ### **How** Does It Work?
103
+ ### NEW: MCP Integration
341
104
 
342
- 1. **Installation**: `npm install --save-dev pumuki-ast-hooks && npm run install-hooks`
343
- 2. **Initialization**: Run `ai-start` before coding (or it auto-executes)
344
- 3. **Development**: System monitors and validates automatically
345
- 4. **Commits**: Pre-commit hooks analyze and block if needed
346
- 5. **AI Interaction**: AI always has fresh context via `.AI_EVIDENCE.json`
105
+ * **MCP Server**: Full Model Context Protocol integration
106
+ * **ai_gate_check**: Mandatory gate before AI operations
107
+ * **pre_flight_check**: Validate proposed code before writing
108
+ * **set_human_intent**: Track user goals across sessions
347
109
 
348
- ### **When** Does It Activate?
110
+ ### NEW: Cognitive Layers
349
111
 
350
- - **On Installation**: Sets up Git hooks, MCP server, rules
351
- - **Before Coding**: `ai-start` initializes context (manual or auto)
352
- - **During Editing**: Pre-tool-use hooks validate evidence freshness
353
- - **Before Commits**: Pre-commit hooks analyze staged files
354
- - **On AI Requests**: `ai_gate_check` validates before AI actions
355
- - **Continuously**: `RealtimeGuardService` monitors and auto-refreshes
112
+ * **Human Intent**: Persistent user goal tracking with confidence levels
113
+ * **Semantic Snapshot**: Project state awareness for AI context
356
114
 
357
- ### **Why** Does It Matter?
115
+ ### Automation
358
116
 
359
- - **Efficiency**: AI never asks "What's the architecture?" again
360
- - **Quality**: Catches violations before they reach production
361
- - **Consistency**: Enforces standards across entire team
362
- - **Automation**: Reduces manual Git Flow tasks
363
- - **Context Persistence**: Survives token limits, session resets, conversation boundaries
117
+ * **Git-native**: pre-commit / pre-push / CI integration
118
+ * **Git Flow**: `ast:gitflow` for features, `ast:release` for releases
119
+ * **macOS Notifications**: Real-time alerts and guardrails
364
120
 
365
121
  ---
366
122
 
367
- ## Complete Architecture and Workflow
123
+ ## Visual Overview
368
124
 
369
- The library operates through a multi-phase process that integrates with Git and development workflows to ensure code quality and context persistence. Below is a high-level overview of the architecture and key components:
125
+ <img src="./docs/images/ast_intelligence_01.svg" alt="AST Intelligence System Overview" width="100%" />
370
126
 
371
- ### Architectural Diagram
127
+ <img src="./docs/images/ast_intelligence_02.svg" alt="AST Intelligence Workflow" width="100%" />
372
128
 
373
- ```mermaid
374
- graph LR
375
- A[Developer] -->|Runs `ai-start`| B(AI Evidence Initialization)
376
- B --> C[.AI_EVIDENCE.json]
377
- C --> D[Pre-Tool-Use Validator]
378
- D --> E[AI Gate Check]
379
- E --> F[Allow/Block Actions]
380
- F --> G[Code Editing]
381
- G --> H[Pre-Commit Analysis]
382
- H --> I[Block Commit if Violations]
383
- I --> J[Update Evidence]
384
- J --> K[Commit]
385
- ```
386
-
387
- ### Key Components
388
- 1. **AI Evidence Initialization (`ai-start`)**
389
- - Generates `.AI_EVIDENCE.json` with project context and rules.
390
- - Answers three critical questions about the task.
391
- - Example:
392
- ```bash
393
- ai-start feature/user-authentication
394
- ```
129
+ <img src="./docs/images/ast_intelligence_03.svg" alt="AST Intelligence Audit - Part 1" width="100%" />
395
130
 
396
- 2. **Pre-Tool-Use Validator**
397
- - Validates `.AI_EVIDENCE.json` before every AI edit operation.
398
- - Ensures context is fresh and rules are loaded.
131
+ <img src="./docs/images/ast_intelligence_04.svg" alt="AST Intelligence Audit - Part 2" width="100%" />
399
132
 
400
- 3. **AI Gate Check**
401
- - Checks for blocking violations before allowing actions.
402
- - Enforces quality gates.
133
+ <img src="./docs/images/ast_intelligence_05.svg" alt="AST Intelligence Audit - Part 3" width="100%" />
403
134
 
404
- 4. **Pre-Commit Analysis**
405
- - Runs AST analysis on staged files.
406
- - Blocks commits with critical violations.
135
+ ---
407
136
 
408
- 5. **Evidence Update**
409
- - Updates `.AI_EVIDENCE.json` before commits to maintain context.
137
+ ## Design Philosophy
410
138
 
411
- ### Example Workflow
412
- 1. Developer runs `ai-start` to initialize context.
413
- 2. AI uses context to perform edits.
414
- 3. Pre-commit hook analyzes code and blocks if violations exist.
415
- 4. Developer fixes violations and commits.
139
+ Pumuki is built on a few non-negotiable principles:
416
140
 
417
- For a detailed architecture, see [ARCHITECTURE.md](ARCHITECTURE.md).
141
+ * **Evidence over conversation**
142
+ AI does not rely on chat memory. All decisions depend on a persistent evidence file.
418
143
 
419
- ---
144
+ * **Gated intelligence**
145
+ AI actions are explicitly allowed or blocked based on project state.
420
146
 
421
- ## What is it?
147
+ * **AST, not heuristics**
148
+ Code is analyzed structurally, not via regex or conventions.
422
149
 
423
- `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.
150
+ * **Fail fast, block early**
151
+ Unsafe or invalid AI actions are prevented before code changes occur.
424
152
 
425
- **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`.
153
+ * **Platform-agnostic governance**
154
+ The same rules apply consistently across iOS, Android, backend, and frontend.
426
155
 
427
156
  ---
428
157
 
429
- ## What problems does it solve?
430
-
431
- ### ❌ Common Problems
432
-
433
- 1. **Clean Architecture Violations**
434
- - Domain layer importing frameworks
435
- - Infrastructure coupled to Presentation
436
- - Circular dependencies
158
+ ## Core Capabilities
437
159
 
438
- 2. **Undetected Code Smells**
439
- - Magic numbers without constants
440
- - Functions that are too long
441
- - Classes with too many responsibilities
160
+ ### 1. AI Evidence System
442
161
 
443
- 3. **Lack of Architectural Consistency**
444
- - Incorrect folder structure
445
- - Forbidden imports between layers
446
- - Missing separation of concerns
162
+ Pumuki introduces a mandatory, versioned **AI Evidence File** (`.AI_EVIDENCE.json`) that acts as the **single source of truth** for AI-assisted development.
447
163
 
448
- 4. **Production-time Errors**
449
- - Security violations (passwords without hash)
450
- - Performance issues
451
- - Untestable code
164
+ It stores:
452
165
 
453
- ### Solutions
166
+ * Active platforms and scopes
167
+ * Architectural and quality rules
168
+ * Detected violations and severities
169
+ * Session and workflow metadata
170
+ * AI gate state
454
171
 
455
- - **Automatic validation** before each commit
456
- - **798+ rules** specific to each platform
457
- - **Detailed reports** with correction suggestions
458
- - **CI/CD integration** for continuous validation
172
+ The AI **cannot operate** without valid and fresh evidence.
459
173
 
460
174
  ---
461
175
 
462
- ## Features
463
-
464
- ### 🎯 Platform-specific Analysis
465
-
466
- #### Backend (TypeScript/NestJS)
467
- - 150+ Clean Architecture rules
468
- - **Automatic architecture detection**: Clean Architecture, Onion, Layered, Feature-First + Clean + DDD, CQRS
469
- - DDD pattern validation
470
- - Circular dependency detection
471
- - Decorator and module analysis
176
+ ### 2. AI Gate (Control Primitive)
472
177
 
473
- #### Frontend (React/Next.js)
474
- - 200+ architecture rules
475
- - **Automatic architecture detection**: Component-Based, Atomic Design, Feature-First + Clean + DDD, State Management patterns
476
- - Server/Client Components validation
477
- - Hooks and state management analysis
478
- - Prop drilling detection
178
+ The AI Gate is the core control mechanism of the framework.
479
179
 
480
- #### iOS (Swift/SwiftUI)
481
- - 150+ iOS-specific rules
482
- - **Automatic architecture detection**: MVVM-C, MVVM, MVP, VIPER, TCA, Clean Swift, Feature-First + Clean + DDD
483
- - SwiftUI best practices analysis
484
- - Potential memory leak detection
180
+ Before any AI-assisted operation:
485
181
 
486
- #### Android (Kotlin/Jetpack Compose)
487
- - 200+ Android-specific rules
488
- - **Automatic architecture detection**: MVVM, MVI, MVP, Clean Architecture, Feature-First + Clean + DDD
489
- - Compose pattern analysis
490
- - Common anti-pattern detection
182
+ * Evidence freshness is validated
491
183
 
492
- ### 🏗️ Automatic Architecture Detection
184
+ * Violations are evaluated
493
185
 
494
- All platforms now support **automatic architecture pattern detection**:
495
- - **No configuration needed** - works out of the box
496
- - Detects patterns by analyzing project structure, imports, and code
497
- - Supports manual override via `.ast-architecture.json` (optional)
498
- - Works for iOS, Android, Backend, and Frontend
186
+ * A deterministic decision is made:
499
187
 
500
- See [HOW_IT_WORKS.md](./docs/HOW_IT_WORKS.md#architecture-detection-by-platform) for details on detected patterns per platform.
188
+ * **ALLOWED** operation may proceed
501
189
 
502
- ### 🤖 MCP Integration
190
+ * **BLOCKED** operation is rejected with actionable feedback
503
191
 
504
- - **evidence-watcher**: Automatic monitoring of `.AI_EVIDENCE.json`
505
- - **ast-intelligence-automation**: Complete Git Flow automation and context detection
506
- - **Standard MCP protocol**: Works with any MCP-compatible agentic IDE (Cursor, Claude Desktop, and others)
192
+ This transforms AI from an advisory tool into a **controlled execution actor**.
507
193
 
508
- ### 🔒 Quality Gates
509
-
510
- - **CRITICAL/HIGH**: Automatically block commits
511
- - **MEDIUM/LOW**: Generate warnings in reports
512
- - **Configurable**: Adjust levels according to your project
194
+ ---
513
195
 
514
- ### 🔄 Git Flow Automation
196
+ ### 3. AST Intelligence Engine
515
197
 
516
- **Complete Git Flow workflow automation** with automatic enforcement:
198
+ The AST Intelligence Engine performs deep, language-aware analysis across platforms.
517
199
 
518
- - **Protected Branch Blocking**: Automatically blocks commits and pushes to `main`, `master`, and `develop` branches
519
- - **Auto-Create Feature Branch**: Automatically creates feature branch when on `develop`/`main` based on changes
520
- - **Smart Branch Naming**: Generates branch names based on file types (feature/, fix/, chore/, docs/, etc.)
521
- - **Feature Cycle**: Execute complete Git Flow with `npm run ast:gitflow`
522
- - **Release Cycle**: Create release PR from develop to main with `npm run ast:release`
523
- - **Automatic PR Creation**: Creates Pull Requests using GitHub CLI (requires `gh`)
524
- - **Optional Auto-Merge**: Automatically merges PRs with `--auto-merge` flag
525
- - **Branch Cleanup**: Automatically deletes merged branches (local and remote)
526
- - **Branch Synchronization**: Syncs `develop` and `main` with remote
200
+ Capabilities include:
527
201
 
528
- **Feature Development Workflow:**
529
- ```bash
530
- # Work on develop/main (changes detected)
202
+ * Architectural rule enforcement
203
+ * Security and data safety validation
204
+ * Performance anti-pattern detection
205
+ * Detection of forbidden constructs and flows
531
206
 
532
- # Run complete cycle (auto-creates feature branch)
533
- npm run ast:gitflow -- --auto-merge
534
- ```
207
+ The engine operates on **real ASTs**, not text approximations.
535
208
 
536
- **Release Workflow:**
537
- ```bash
538
- # Switch to develop branch
539
- git checkout develop
209
+ ---
540
210
 
541
- # Create release PR (develop → main)
542
- npm run ast:release -- --auto-merge
211
+ ### 4. Git-Native Enforcement
543
212
 
544
- # Or with version tag
545
- npm run ast:release -- --tag 5.5.35 --auto-merge
546
- ```
213
+ Pumuki integrates directly with Git workflows:
547
214
 
548
- **Branch Naming Logic:**
549
- - `fix/` - Files containing "fix", "bug", "error"
550
- - `test/` - Test files or "spec" files
551
- - `docs/` - Documentation files (README, CHANGELOG)
552
- - `refactor/` - Files containing "refactor", "cleanup"
553
- - `ci/` - CI/CD files (workflow, github actions)
554
- - `chore/` - Config files, package.json
555
- - `feature/` - Default for other changes
215
+ * Pre-commit hooks
216
+ * Pre-push hooks
217
+ * Branch and flow validation
556
218
 
557
- **Feature Cycle Options:**
558
- ```bash
559
- npm run ast:gitflow # Basic cycle (auto-creates branch if needed)
560
- npm run ast:gitflow -- -m "feat: new feature" # Custom commit message
561
- npm run ast:gitflow -- --auto-merge # Auto-merge PR
562
- npm run ast:gitflow -- --skip-cleanup # Skip branch cleanup
563
- npm run ast:gitflow -- --skip-sync # Skip branch sync
564
- ```
219
+ Violations can:
565
220
 
566
- **Release Cycle Options:**
567
- ```bash
568
- npm run ast:release # Create release PR
569
- npm run ast:release -- --auto-merge # Auto-merge release PR
570
- npm run ast:release -- --tag 5.5.35 # Create and push git tag
571
- npm run ast:release -- --pr-title "Release v5.5.35" # Custom PR title
572
- ```
221
+ * Block commits
222
+ * Block pushes
223
+ * Prevent unsafe changes from reaching CI/CD
573
224
 
574
- **Hooks:**
575
- - `pre-commit`: Blocks commits on protected branches + AST analysis
576
- - `pre-push`: Blocks push to protected branches + validates naming
225
+ Governance happens **before** code reaches production.
577
226
 
578
227
  ---
579
228
 
580
- ## Use Cases
581
-
582
- ### 1. Automatic Validation on Pre-commit
583
-
584
- ```bash
585
- # Runs automatically on each git commit
586
- git commit -m "feat: add new feature"
587
- # → Analyzes only staged files
588
- # → Blocks commit if CRITICAL/HIGH violations found
589
- # → Generates violation report
590
- ```
591
-
592
- ### 2. Full Project Analysis
229
+ ### 5. Pre-Flight Validation (NEW)
593
230
 
594
- ```bash
595
- # Analyzes entire codebase
596
- bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
597
- # Or using CLI
598
- ast-hooks analyze
599
- ```
600
-
601
- ### 3. CI/CD Integration
602
-
603
- ```yaml
604
- # .github/workflows/ci.yml
605
- - name: Run AST Analysis
606
- run: bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
607
- ```
608
-
609
- ### 4. Programmatic Usage
231
+ The Pre-Flight Validation system analyzes code **BEFORE** it is written to disk:
610
232
 
611
233
  ```javascript
612
- const { runASTIntelligence } = require('@pumuki/ast-intelligence-hooks');
234
+ const { analyzeCodeInMemory } = require('./ast-core');
613
235
 
614
- const result = await runASTIntelligence({
615
- files: ['src/**/*.ts'],
616
- platforms: ['backend'],
617
- strict: true
618
- });
236
+ // Analyze proposed code without writing to file
237
+ const result = analyzeCodeInMemory(proposedCode, virtualFilePath);
619
238
 
620
- if (result.hasCriticalViolations()) {
621
- console.error('❌ Critical violations found!');
622
- process.exit(1);
239
+ if (result.hasCritical) {
240
+ // BLOCK the write - violations detected
241
+ console.log('❌ BLOCKED:', result.violations);
242
+ } else {
243
+ // ALLOW the write
244
+ console.log('✅ ALLOWED');
623
245
  }
624
246
  ```
625
247
 
626
- ### 5. Continuous Monitoring
627
-
628
- ```bash
629
- # Watch mode for development
630
- hook-watch
631
-
632
- # System status
633
- hook-status
634
- ```
635
-
636
- ### 6. Git Flow Automation
248
+ **Key capabilities:**
637
249
 
638
- ```bash
639
- # Complete Git Flow cycle
640
- npm run ast:gitflow
641
-
642
- # With options
643
- npm run ast:gitflow -- -m "feat: new feature" --auto-merge
644
-
645
- # Using MCP tools (from IDE)
646
- mcp0_auto_complete_gitflow
647
- mcp0_sync_branches
648
- mcp0_cleanup_stale_branches
649
- ```
250
+ * Analyze code strings without file I/O
251
+ * Detect critical violations before code is written
252
+ * Platform-aware analysis (iOS, Android, Backend, Frontend)
253
+ * Integration with IDE hooks for real-time blocking
650
254
 
651
255
  ---
652
256
 
653
- ## Quick Start
654
-
655
- ### Prerequisites
656
-
657
- - **Node.js** ≥18.0.0
658
- - **npm** ≥9.0.0
659
- - **Git** (for hooks)
660
-
661
- ### 1. Install the library
662
-
663
- ```bash
664
- npm install --save-dev pumuki-ast-hooks
665
- ```
257
+ ### 6. MCP Server Integration (NEW)
666
258
 
667
- ### 2. Configure hooks
259
+ Pumuki exposes a full **Model Context Protocol (MCP)** server for AI agent integration:
668
260
 
669
- ```bash
670
- npm run install-hooks
671
- ```
261
+ | Tool | Purpose | Blocking |
262
+ |------|---------|----------|
263
+ | `ai_gate_check` | Mandatory gate before any AI operation | ✅ Yes |
264
+ | `pre_flight_check` | Validate proposed code before writing | ✅ Yes |
265
+ | `read_platform_rules` | Load platform-specific rules | No |
266
+ | `set_human_intent` | Track user goals across sessions | No |
267
+ | `get_human_intent` | Retrieve current user intent | No |
268
+ | `auto_complete_gitflow` | Automate Git Flow cycle | No |
672
269
 
673
- ### 3. Make a test commit
270
+ **Usage:**
674
271
 
675
272
  ```bash
676
- git add .
677
- git commit -m "test: verify hooks"
273
+ # Start MCP server
274
+ node scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js
678
275
  ```
679
276
 
680
- The hooks will run automatically and validate your code.
681
-
682
- ### 4. View full report
683
-
684
- ```bash
685
- bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
686
- ```
277
+ ---
687
278
 
688
- ### 5. Check violations
279
+ ### 7. Cognitive Layers (NEW)
689
280
 
690
- ```bash
691
- # List all violations
692
- npm run violations
281
+ Pumuki introduces **Cognitive Layers** to maintain AI context across sessions:
693
282
 
694
- # View summary
695
- bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
283
+ **Human Intent:**
696
284
 
697
- # Top violations
698
- npm run violations:top
285
+ ```json
286
+ {
287
+ "human_intent": {
288
+ "primary_goal": "Implement user authentication with OAuth2",
289
+ "secondary_goals": ["Add unit tests", "Update documentation"],
290
+ "constraints": ["Must use existing User model", "No breaking changes"],
291
+ "non_goals": ["UI redesign"],
292
+ "confidence_level": "high",
293
+ "expires_at": "2026-01-10T12:00:00Z"
294
+ }
295
+ }
699
296
  ```
700
297
 
701
- ---
298
+ **Semantic Snapshot:**
702
299
 
703
- ## 📚 Documentation Guide - Step by Step
704
-
705
- This section provides a recommended reading order to fully understand the library and its capabilities.
706
-
707
- ### For New Users (Start Here)
708
-
709
- 1. **[HOW_IT_WORKS.md](./docs/HOW_IT_WORKS.md)** ⭐ **START HERE**
710
- - Complete step-by-step explanation of what the library does
711
- - Installation process breakdown
712
- - How each component works (Git hooks, MCP servers, AST analysis)
713
- - Execution flows and real-world examples
714
- - **Read this first to understand the system!**
715
-
716
- 1. **[INSTALLATION.md](./docs/INSTALLATION.md)** - Start here! Complete installation guide with platform-specific instructions
717
- - Prerequisites and requirements
718
- - Installation methods (npm, Git, manual)
719
- - Initial configuration
720
- - Verification steps
721
-
722
- 2. **[USAGE.md](./docs/USAGE.md)** - Learn how to use the library
723
- - Minimal example (5 minutes)
724
- - Basic commands
725
- - Git hooks integration
726
- - Programmatic usage
727
- - Advanced examples
728
- - CI/CD integration
729
-
730
- 3. **[Quick Start](#quick-start)** (this README) - Get up and running quickly
731
- - Fast setup in 5 steps
732
- - First test commit
733
-
734
- ### For Understanding the System
735
-
736
- 4. **[ARCHITECTURE.md](./docs/ARCHITECTURE.md)** - High-level architecture overview
737
- - System layers
738
- - Data flow
739
- - Key components
740
- - Quality gates
741
-
742
- 5. **[ARCHITECTURE_DETAILED.md](./docs/ARCHITECTURE_DETAILED.md)** - Deep dive into architecture
743
- - Detailed layer architecture
744
- - Module dependencies
745
- - Extension points
746
- - Key files mapping
747
-
748
- ### For Integration and Advanced Usage
749
-
750
- 6. **[MCP_SERVERS.md](./docs/MCP_SERVERS.md)** - MCP integration for agentic IDEs
751
- - evidence-watcher setup
752
- - ast-intelligence-automation setup
753
- - Usage examples
754
- - Troubleshooting
755
-
756
- 7. **[API_REFERENCE.md](./docs/API_REFERENCE.md)** - Complete API documentation
757
- - Core services
758
- - Use Cases
759
- - Domain entities
760
- - Entry points
761
-
762
- ### For Configuration and Customization
763
-
764
- 8. **[CODE_STANDARDS.md](./docs/CODE_STANDARDS.md)** - Code style and conventions
765
- - ESLint configuration
766
- - TypeScript conventions
767
- - Clean code principles
768
- - Git commit format
769
-
770
- 9. **[DEPENDENCIES.md](./docs/DEPENDENCIES.md)** - Dependencies analysis
771
- - Runtime dependencies
772
- - Development dependencies
773
- - Optional tools
774
- - Platform compatibility
775
-
776
- ### For Development and Testing
777
-
778
- 10. **[TESTING.md](./docs/TESTING.md)** - Testing guide
779
- - Test structure
780
- - Running tests
781
- - Writing new tests
782
- - Best practices
783
-
784
- ### Quick Reference
785
-
786
- - **Need to install?** → [INSTALLATION.md](./docs/INSTALLATION.md)
787
- - **Need examples?** → [USAGE.md](./docs/USAGE.md) or `examples/` folder
788
- - **Need API docs?** → [API_REFERENCE.md](./docs/API_REFERENCE.md)
789
- - **Need to configure?** → [USAGE.md](./docs/USAGE.md#rule-configuration)
790
- - **Need to understand architecture?** → [ARCHITECTURE.md](./docs/ARCHITECTURE.md)
300
+ * Current project state awareness
301
+ * Active platforms and detected patterns
302
+ * Architectural context for AI decisions
791
303
 
792
304
  ---
793
305
 
794
- ## Architecture
795
-
796
- The project follows **strict Clean Architecture** with 4 well-defined layers:
306
+ ## Supported Platforms
797
307
 
798
- ```
799
- ┌─────────────────────────────────────────┐
800
- │ PRESENTATION LAYER │
801
- │ - CLI Interface │
802
- │ - Git Hooks │
803
- │ - MCP Servers │
804
- └──────────────┬──────────────────────────┘
805
-
806
- ┌──────────────▼──────────────────────────┐
807
- │ APPLICATION LAYER │
808
- │ - Use Cases │
809
- │ - Services │
810
- └──────────────┬──────────────────────────┘
811
-
812
- ┌──────────────▼──────────────────────────┐
813
- │ DOMAIN LAYER │
814
- │ - Entities │
815
- │ - Business Rules │
816
- │ - Repository Interfaces │
817
- └──────────────┬──────────────────────────┘
818
-
819
- ┌──────────────┴──────────────────────────┐
820
- │ INFRASTRUCTURE LAYER │
821
- │ - AST Analyzers │
822
- │ - Repository Implementations │
823
- │ - External Tools │
824
- └─────────────────────────────────────────┘
825
- ```
308
+ Pumuki is multi-platform by default:
826
309
 
827
- **Principles:**
828
- - **Dependencies inward**: Presentation → Application → Domain
829
- - **Domain without dependencies**: Zero external dependencies
830
- - **Dependency Inversion**: Interfaces in Domain, implementations in Infrastructure
310
+ * iOS (Swift)
311
+ * Android (Kotlin)
312
+ * Backend (Node.js / NestJS)
313
+ * Frontend (React / Next.js)
831
314
 
832
- For more details, see [ARCHITECTURE.md](./docs/ARCHITECTURE.md) and [ARCHITECTURE_DETAILED.md](./docs/ARCHITECTURE_DETAILED.md).
315
+ The framework is extensible to additional platforms and languages.
833
316
 
834
317
  ---
835
318
 
836
- ## MCP Servers
837
-
838
- The project includes MCP (Model Context Protocol) servers for integration with any agentic IDE or AI client:
839
-
840
- ### evidence-watcher
319
+ ## AI IDE Compatibility (Pre-Write Enforcement)
841
320
 
842
- Monitors the status of `.AI_EVIDENCE.json` and allows AI to verify if it's up to date.
321
+ Pumuki supports **real-time code blocking** in IDEs with pre-write hooks:
843
322
 
844
- **Resources:**
845
- - `evidence://status`: Evidence status (fresh/stale/missing)
323
+ | IDE | Hook Support | Blocks Before Write? | Fallback |
324
+ |-----|--------------|---------------------|----------|
325
+ | **Windsurf** | `pre_write_code` | ✅ YES | Git pre-commit |
326
+ | **Claude Code** | `PreToolUse` (Write/Edit) | ✅ YES | Git pre-commit |
327
+ | **OpenCode** | Plugin `tool.execute.before` | ✅ YES | Git pre-commit |
328
+ | **Codex CLI** | Approval policies only | ⚠️ Manual | Git pre-commit |
329
+ | **Cursor** | `afterFileEdit` only | ⚠️ Post-write | Git pre-commit |
330
+ | **Kilo Code** | Not documented | ⚠️ No | Git pre-commit |
846
331
 
847
- **Tools:**
848
- - `check_evidence_status`: Checks if the evidence is stale
332
+ ### How It Works
849
333
 
850
- ### ast-intelligence-automation
334
+ ```text
335
+ AI generates code → IDE Hook intercepts → AST Intelligence analyzes →
336
+ ├─ Critical violations? → ❌ BLOCKED (code not written)
337
+ └─ No violations? → ✅ ALLOWED (code written)
338
+ ```
851
339
 
852
- Automates the complete Git Flow cycle: commit → push → PR → merge, plus context detection and AI gate checks.
340
+ ### Enforcement Layers
853
341
 
854
- **Resources:**
855
- - `evidence://status`: Evidence status
856
- - `gitflow://state`: Git Flow workflow state
857
- - `context://active`: Active project context
342
+ 1. **IDE Hooks** (Windsurf, Claude Code, OpenCode): Block BEFORE code is written
343
+ 2. **Git Pre-Commit**: Block commits with violations (100% fallback for all IDEs)
344
+ 3. **MCP Gate**: AI cannot proceed without passing `ai_gate_check`
858
345
 
859
- **Tools:**
860
- - `auto_complete_gitflow`: Automatically completes Git Flow cycle
861
- - `sync_branches`: Syncs develop/main branches
862
- - `cleanup_stale_branches`: Cleans up merged branches
863
- - `auto_execute_ai_start`: Automatically executes ai-start
864
- - `validate_and_fix`: Validates and fixes common issues
865
- - `ai_gate_check`: Gate check before tasks
346
+ > **Note**: For IDEs without pre-write hooks, the Git pre-commit hook provides 100% enforcement at commit time.
866
347
 
867
- For more details, see [MCP_SERVERS.md](./docs/MCP_SERVERS.md).
348
+ See [`scripts/hooks-system/infrastructure/cascade-hooks/README.md`](./scripts/hooks-system/infrastructure/cascade-hooks/README.md) for installation instructions.
868
349
 
869
- #### Troubleshooting
350
+ ---
870
351
 
871
- If `ai_gate_check` behaves inconsistently (stale branch name, missing rules, or intermittent transport errors), verify you are not running multiple `ast-intelligence-automation` servers across different repositories.
352
+ ## Typical Enterprise Use Cases
872
353
 
873
- - Prefer enabling a single MCP server for the repository you are working on.
874
- - Verify the active process points to this repository path:
875
- - `.../ast-intelligence-hooks/scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js`
876
- - If you detect multiple processes, stop the duplicates and restart your IDE/MCP servers.
354
+ * Long-running feature development with AI assistance
355
+ * Multi-day or multi-chat workflows
356
+ * Large monorepos and distributed teams
357
+ * Strict Clean Architecture enforcement
358
+ * Regulated or compliance-sensitive environments
877
359
 
878
360
  ---
879
361
 
880
- ## API Reference
881
-
882
- ### Main Functions
362
+ ## Installation
883
363
 
884
- #### `runASTIntelligence(options)`
364
+ **Requirements**
885
365
 
886
- Analyzes code using AST Intelligence.
366
+ * Node.js 20 (see `.nvmrc`)
367
+ * npm 10+
887
368
 
888
- ```javascript
889
- const { runASTIntelligence } = require('@pumuki/ast-intelligence-hooks');
369
+ Install as a development dependency:
890
370
 
891
- const result = await runASTIntelligence({
892
- files: ['src/**/*.ts'],
893
- platforms: ['backend', 'frontend'],
894
- strict: false
895
- });
371
+ ```bash
372
+ npm install --save-dev @pumuki/ast-intelligence-hooks
896
373
  ```
897
374
 
898
- **Options:**
899
- - `files` (string[]): File patterns to analyze
900
- - `platforms` (string[]): Platforms to analyze (`ios`, `android`, `backend`, `frontend`)
901
- - `strict` (boolean): If true, blocks on any violation
902
-
903
- **Returns:** `AuditResult`
904
-
905
- ---
906
-
907
- #### `AnalyzeCodebaseUseCase`
375
+ Legacy (deprecated):
908
376
 
909
- Use Case for full codebase analysis.
910
-
911
- ```javascript
912
- const { AnalyzeCodebaseUseCase } = require('@pumuki/ast-intelligence-hooks');
913
-
914
- const useCase = new AnalyzeCodebaseUseCase(/* dependencies */);
915
- const result = await useCase.execute('/path/to/codebase');
377
+ ```bash
378
+ npm install --save-dev pumuki-ast-hooks
916
379
  ```
917
380
 
918
- ---
919
-
920
- #### `AnalyzeStagedFilesUseCase`
921
-
922
- Use Case for analyzing only staged files.
923
-
924
- ```javascript
925
- const { AnalyzeStagedFilesUseCase } = require('@pumuki/ast-intelligence-hooks');
381
+ Initialize AI evidence:
926
382
 
927
- const useCase = new AnalyzeStagedFilesUseCase(/* dependencies */);
928
- const result = await useCase.execute();
383
+ ```bash
384
+ npx ai-start
929
385
  ```
930
386
 
931
387
  ---
932
388
 
933
- ### Domain Entities
389
+ ## Installation & Lifecycle Commands
934
390
 
935
- #### `AuditResult`
391
+ ### Update to latest version
936
392
 
937
- Aggregated result of an analysis.
393
+ ```bash
394
+ npm install --save-dev @pumuki/ast-intelligence-hooks@latest
395
+ npm run install-hooks
396
+ ````
938
397
 
939
- ```javascript
940
- const { AuditResult } = require('@pumuki/ast-intelligence-hooks');
398
+ ### Uninstall
941
399
 
942
- result.getFindings(); // All violations
943
- result.getCriticalFindings(); // Only CRITICAL
944
- result.hasCriticalViolations(); // Boolean
945
- result.getTechnicalDebtHours(); // Estimated hours
400
+ ```bash
401
+ npm uninstall @pumuki/ast-intelligence-hooks
946
402
  ```
947
403
 
948
- #### `Finding`
949
-
950
- Individual violation found.
951
-
952
- ```javascript
953
- const { Finding } = require('@pumuki/ast-intelligence-hooks');
404
+ Legacy:
954
405
 
955
- finding.getSeverity(); // 'critical' | 'high' | 'medium' | 'low'
956
- finding.getRule(); // Rule ID
957
- finding.getMessage(); // Descriptive message
958
- finding.getFile(); // File where it was found
406
+ ```bash
407
+ npm uninstall pumuki-ast-hooks
959
408
  ```
960
409
 
961
- For more details, see [API_REFERENCE.md](./docs/API_REFERENCE.md).
962
-
963
410
  ---
964
411
 
965
- ## Configuration
412
+ ## Hook Installation & Management
966
413
 
967
- ### Environment Variables
414
+ Install or update Git hooks (wizard-driven):
968
415
 
969
416
  ```bash
970
- # Repository root
971
- export REPO_ROOT=/path/to/project
972
-
973
- # Evidence stale threshold (milliseconds, default: 180000 = 3 minutes)
974
- export HOOK_GUARD_EVIDENCE_STALE_THRESHOLD=180000
975
-
976
- # Auto ai-start execution (enabled by default)
977
- export HOOK_GUARD_AI_START=true
978
- export HOOK_GUARD_AI_START_COOLDOWN=60000
417
+ npm run install-hooks
418
+ ```
979
419
 
980
- # Auto-refresh evidence when stale (enabled by default)
981
- export HOOK_GUARD_AUTO_REFRESH=true
420
+ (Equivalent to `npx ast-install`)
982
421
 
983
- # Auto-commit in Git Flow
984
- export AUTO_COMMIT_ENABLED=true
985
- export AUTO_PUSH_ENABLED=true
986
- export AUTO_PR_ENABLED=false
987
- ```
422
+ ---
988
423
 
989
- ### Configuration Files
424
+ ## Operational Commands
990
425
 
991
- - `config/ast-exclusions.json`: Exclude files from analysis
992
- - `config/language-guard.json`: Language-specific guard configuration
993
- - `config/doc-standards.json`: Documentation standards
994
- - `.cursor/mcp.json` or client-specific config: MCP Servers configuration (see [MCP_SERVERS.md](./docs/MCP_SERVERS.md))
426
+ ### Check installed version vs. latest published
995
427
 
996
- ### Customize Rules
428
+ ```bash
429
+ npm run ast:check-version
430
+ ```
997
431
 
998
- Rules are in `skills/` by platform:
999
- - `skills/backend-guidelines/`
1000
- - `skills/frontend-guidelines/`
1001
- - `skills/ios-guidelines/`
1002
- - `skills/android-guidelines/`
432
+ ### Run hook system with interactive menu
1003
433
 
1004
- For more details, see [USAGE.md](./docs/USAGE.md).
434
+ ```bash
435
+ npx ast-hooks
436
+ ```
1005
437
 
1006
438
  ---
1007
439
 
1008
- ## Best Practices
440
+ ## Manual Hook-System (Interactive Menu)
1009
441
 
1010
- ### 1. Install Hooks in All Projects
442
+ Pumuki can be used fully manually (without waiting for Git hooks) via the interactive audit menu.
443
+
444
+ ### Recommended
1011
445
 
1012
446
  ```bash
1013
- # on each new project
1014
- npm install --save-dev pumuki-ast-hooks
1015
- npm run install-hooks
447
+ npx ast-hooks
1016
448
  ```
1017
449
 
1018
- ### 2. Use in CI/CD
450
+ ### Direct CLI (explicit)
1019
451
 
1020
- ```yaml
1021
- # .github/workflows/ci.yml
1022
- - name: AST Analysis
1023
- run: bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
452
+ ```bash
453
+ ast-hooks audit
1024
454
  ```
1025
455
 
1026
- ### 3. Review Violations Regularly
456
+ ### Run the orchestrator directly (local repository)
1027
457
 
1028
458
  ```bash
1029
- # Weekly
1030
459
  bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
1031
460
  ```
1032
461
 
1033
- ### 4. Configure Appropriate Exclusions
1034
-
1035
- ```json
1036
- // config/ast-exclusions.json
1037
- {
1038
- "patterns": [
1039
- "node_modules/**",
1040
- "dist/**",
1041
- "build/**"
1042
- ]
1043
- }
1044
- ```
1045
-
1046
- ### 5. Use MCP Servers with Agentic IDEs
1047
-
1048
- Configure MCP Servers in your IDE's MCP configuration file (e.g., `.cursor/mcp.json` for Cursor, or client-specific location) for complete automation.
1049
-
1050
- ---
462
+ ### Non-interactive mode
1051
463
 
1052
- ## FAQ
464
+ You can run specific audit modes without the menu:
1053
465
 
1054
- ### Can I use this in existing projects?
466
+ ```bash
467
+ # Example: run AST Intelligence directly
468
+ AUDIT_OPTION=7 bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
1055
469
 
1056
- Yes, it's backward compatible. Hooks only validate new code you commit.
470
+ # Example: analyze staged files only (pre-commit equivalent)
471
+ AUDIT_OPTION=3 bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
472
+ ```
1057
473
 
1058
- ### How to temporarily disable hooks?
474
+ If defined as scripts:
1059
475
 
1060
476
  ```bash
1061
- # For a specific commit
1062
- GIT_BYPASS_HOOK=1 git commit -m "emergency fix"
477
+ npm run ast:gitflow # guided Git flow
478
+ npm run ast:release # guided release flow (develop → main)
479
+ npm run ast:audit # direct audit
1063
480
  ```
1064
481
 
1065
- ### Does it work with monorepos?
1066
-
1067
- Yes, automatically detects monorepo structure and analyzes each module.
1068
-
1069
- ### Can I add custom rules?
1070
-
1071
- Yes, you can extend rules in `skills/` or create your own analyzers.
1072
-
1073
- ### Does it work on Windows?
1074
-
1075
- Works with WSL2 or Git Bash. Not tested on native Windows.
482
+ ---
1076
483
 
1077
- ### What if I have many violations?
484
+ ## Git Governance & Flow Automation
1078
485
 
1079
- Start by fixing CRITICAL and HIGH. MEDIUM and LOW are warnings and don't block commits.
486
+ Pumuki includes first-class Git governance commands to enforce a consistent workflow across teams and repositories.
1080
487
 
1081
- ### How to update evidence?
488
+ ### Daily Development Flow
1082
489
 
1083
490
  ```bash
1084
- # Automatically via MCP
1085
- # Or manually
1086
- bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
491
+ npm run ast:gitflow
1087
492
  ```
1088
493
 
1089
- For more questions, check the issues on GitHub.
1090
-
1091
- ---
1092
-
1093
- ## Available Commands
1094
-
1095
- ### CLI Commands
494
+ With optional auto-merge:
1096
495
 
1097
496
  ```bash
1098
- # Analysis
1099
- ast-hooks analyze # Full analysis
1100
- ast-hooks analyze --staged # Only staged files
1101
-
1102
- # Violations
1103
- ast-violations list # List all
1104
- ast-violations summary # Summary
1105
- ast-violations top # Top violations
1106
- ast-violations show <id> # Show specific violation
1107
-
1108
- # Hooks
1109
- hook-status # System status
1110
- hook-watch # Watch mode
1111
- hook-predict # Violation prediction
1112
- hook-playbook # Execute playbook
1113
-
1114
- # Git Flow
1115
- npm run ast:gitflow # Complete Git Flow cycle
1116
- npm run ast:gitflow -- -m "msg" # With commit message
1117
- npm run ast:gitflow -- --auto-merge # Auto-merge PR
1118
- gitflow check # Verify Git Flow
1119
- gitflow status # Current status
1120
- gitflow workflow # View full workflow
497
+ npm run ast:gitflow -- --auto-merge
1121
498
  ```
1122
499
 
1123
- ### npm Scripts
500
+ ### Release Flow (develop → main)
1124
501
 
1125
502
  ```bash
1126
- npm run audit # Full analysis
1127
- npm run install-hooks # Install hooks
1128
- npm run ast:gitflow # Complete Git Flow cycle
1129
- npm test # Run tests
1130
- npm run lint # Linter
1131
- npm run typecheck # Type checking
1132
- npm run violations # List violations
1133
- npm run violations:top # Top violations
503
+ npm run ast:release
1134
504
  ```
1135
505
 
1136
- ---
506
+ With optional auto-merge:
1137
507
 
1138
- ## Contributing
508
+ ```bash
509
+ npm run ast:release -- --auto-merge
510
+ ```
1139
511
 
1140
- Contributions are welcome. Please:
512
+ ### Git Flow Cycle (ast:gitflow)
1141
513
 
1142
- 1. Fork the repository
1143
- 2. Create a branch for your feature (`git checkout -b feature/amazing-feature`)
1144
- 3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
1145
- 4. Push to the branch (`git push origin feature/amazing-feature`)
1146
- 5. Open a Pull Request
514
+ Pumuki runs a complete Git Flow cycle:
1147
515
 
1148
- ### Contribution Guidelines
516
+ * Step 1: Validate Branch (must be feature/, fix/, etc.)
517
+ * Step 2: Commit Changes (if uncommitted)
518
+ * Step 3: Push to Origin
519
+ * Step 4: Create Pull Request
520
+ * Step 5: Merge Pull Request (optional)
521
+ * Step 6: Cleanup Merged Branches
522
+ * Step 7: Sync Branches
523
+ * Git Flow Cycle Complete
1149
524
 
1150
- - Follow the code of conduct
1151
- - Ensure tests pass (`npm test`)
1152
- - Add tests for new features
1153
- - Update documentation if necessary
525
+ ### Options
1154
526
 
1155
- For coding standards, see [CODE_STANDARDS.md](./docs/CODE_STANDARDS.md).
527
+ ```bash
528
+ npm run ast:gitflow
529
+ npm run ast:gitflow -- -m "feat: new feature"
530
+ npm run ast:gitflow -- --auto-merge
531
+ npm run ast:gitflow -- --skip-cleanup
532
+ npm run ast:gitflow -- --skip-sync
533
+ ```
1156
534
 
1157
535
  ---
1158
536
 
1159
- ## 📝 Recent Changes
537
+ ## Evidence Guard (Daemon)
1160
538
 
1161
- ### Version 5.5.35 (2026-01-04)
539
+ The evidence guard ensures AI evidence freshness during long work sessions.
1162
540
 
1163
- **✨ New Features:**
1164
- - **Git Flow Release Cycle**: New `npm run ast:release` command for creating release PRs (develop → main)
1165
- - **Release Automation**: Automatic PR creation from develop to main with optional auto-merge
1166
- - **Git Tag Support**: Optional git tag creation with `--tag` flag
1167
-
1168
- **Technical Details:**
1169
- - Separation of concerns: `ast:gitflow` for features, `ast:release` for releases
1170
- - Release cycle steps:
1171
- 1. Validates branch (must be develop)
1172
- 2. Syncs develop with origin
1173
- 3. Syncs main with origin
1174
- 4. Creates PR: develop → main
1175
- 5. Optionally auto-merges PR
1176
- 6. Optionally creates git tag
1177
- - Follows Git Flow best practices with clear separation between development and release workflows
541
+ ```bash
542
+ npm run ast:guard:start
543
+ npm run ast:guard:stop
544
+ npm run ast:guard:restart
545
+ npm run ast:guard:status
546
+ npm run ast:guard:logs
547
+ ```
1178
548
 
1179
549
  ---
1180
550
 
1181
- ### Version 5.5.34 (2026-01-04)
1182
-
1183
- **✨ New Features:**
1184
- - **Git Flow Auto-Create Branch**: Automatically creates feature branch when on `develop`/`main` based on changes
1185
- - **Smart Branch Naming**: Generates branch names based on file types (feature/, fix/, chore/, docs/, etc.)
1186
-
1187
- **Technical Details:**
1188
- - When running `npm run ast:gitflow` on protected branch, script now:
1189
- - Analyzes changed files to infer branch type
1190
- - Generates descriptive branch name with timestamp
1191
- - Creates and switches to new feature branch automatically
1192
- - Continues with complete Git Flow cycle
1193
- - Branch naming logic:
1194
- - `fix/` - Files containing "fix", "bug", "error"
1195
- - `test/` - Test files or "spec" files
1196
- - `docs/` - Documentation files (README, CHANGELOG)
1197
- - `refactor/` - Files containing "refactor", "cleanup"
1198
- - `ci/` - CI/CD files (workflow, github actions)
1199
- - `chore/` - Config files, package.json
1200
- - `feature/` - Default for other changes
551
+ ## Developer Experience: Notifications & Guardrails
1201
552
 
1202
- ---
553
+ Pumuki includes a built-in notification and guardrail layer to keep long work sessions safe and predictable.
1203
554
 
1204
- ### Version 5.5.33 (2026-01-04)
555
+ ### macOS Notifications
1205
556
 
1206
- **🐛 Bug Fixes:**
1207
- - **iOS Security Analyzer**: Fixed false positive in `ios.security.missing_ssl_pinning` rule
1208
- - Now recognizes SSL pinning implementations using `URLSessionDelegate` + `URLAuthenticationChallenge`
1209
- - **iOS Enterprise Analyzer**: Fixed same false positive in `ios.networking.missing_ssl_pinning` rule
557
+ On macOS, notifications are delivered using:
1210
558
 
1211
- **Technical Details:**
1212
- - Previous implementation only checked for `ServerTrustPolicy` or `pinning` keywords
1213
- - Files implementing SSL pinning with `URLSessionDelegate` were incorrectly flagged
1214
- - Added detection for `URLSessionDelegate` + `URLAuthenticationChallenge` pattern
1215
- - This fixes false positives on files like `SSLPinningDelegate.swift` that properly implement SSL pinning
559
+ * `terminal-notifier` (preferred, if installed)
560
+ * `osascript` fallback (built-in)
1216
561
 
1217
- ---
562
+ The notification system includes deduplication, cooldowns, and retry logic to avoid spam during long sessions.
1218
563
 
1219
- ### Version 5.5.32 (2026-01-04)
564
+ ### Evidence Freshness Alerts (SLA)
1220
565
 
1221
- **✨ New Features:**
1222
- - **Git Flow Automation**: Complete Git Flow cycle with `npm run ast:gitflow`
1223
- - **Protected Branch Blocking**: Pre-commit hook now blocks commits on `main`, `master`, and `develop`
1224
- - **Pre-Push Hook**: Automatically installed, blocks push to protected branches and validates naming conventions
1225
- - **Auto PR Creation**: Creates Pull Requests using GitHub CLI (`gh`)
1226
- - **Auto-Merge Support**: Optional auto-merge with `--auto-merge` flag
1227
- - **Branch Cleanup**: Automatically deletes merged branches (local + remote)
1228
- - **Branch Synchronization**: Syncs `develop` and `main` with remote
566
+ When `.AI_EVIDENCE.json` becomes stale beyond the configured threshold, the guard will:
1229
567
 
1230
- **🔧 Improvements:**
1231
- - Added `ast-gitflow` binary to package.json
1232
- - Added `ast:gitflow` npm script
1233
- - Updated GitEnvironmentService to install pre-push hook
1234
- - Updated pre-commit hook to validate protected branches
568
+ * Notify that evidence is stale (including how many seconds)
569
+ * Optionally attempt an auto-refresh depending on guard configuration
1235
570
 
1236
- ---
571
+ When evidence returns to a fresh state (back within SLA), the guard can notify that evidence is healthy again.
1237
572
 
1238
- ### Version 5.5.25 (2026-01-04)
573
+ ### AI Evidence Refresh Notifications
1239
574
 
1240
- **⚡ Performance Fix:**
1241
- - Removed slow full AST analysis (35 minutes) from evidence guard refresh loop
1242
- - Evidence guard now uses fast `update-evidence.sh` (seconds) instead of `intelligent-audit.js`
1243
- - Evidence refreshes every 3 minutes as intended, notifications work correctly
575
+ When evidence is refreshed, the orchestration layer updates `.AI_EVIDENCE.json` and sends a macOS notification:
1244
576
 
1245
- ---
577
+ * If gate is **ALLOWED**: `AI Evidence has been refreshed automatically`
578
+ * If gate is **BLOCKED**: `AI Gate BLOCKED - <N> violations need fixing`
1246
579
 
1247
- ### Version 5.5.24 (2026-01-04)
580
+ ### Git Tree Guardrails (Atomic Commits)
1248
581
 
1249
- **🔔 Notifications Fix:**
1250
- - Replaced empty catch blocks with proper error handling via `MacNotificationSender`
1251
- - macOS notifications now sent on every evidence update with proper error management
1252
- - Notifications show "AI Evidence has been refreshed automatically" or "AI Gate BLOCKED"
582
+ Pumuki monitors the working tree and staging area and can notify when there are too many changes at once.
1253
583
 
1254
- ---
584
+ Typical behavior:
1255
585
 
1256
- ### Version 5.5.22 (2026-01-04)
586
+ * Warn/error when the git tree exceeds configured limits (total/staged/unstaged)
587
+ * Suggest splitting work into smaller, atomic commits
588
+ * Provide grouped commit suggestions when it can infer feature-based groupings
1257
589
 
1258
- **🔴 CRITICAL Fix:**
1259
- - Replaced self-referential wrapper with complete session-loader implementation
1260
- - Root cause: wrapper called itself causing infinite recursion
1261
- - Session loader now works correctly in all consuming projects
590
+ Configuration (environment variables):
1262
591
 
1263
- ---
592
+ * `HOOK_GUARD_DIRTY_TREE_STAGED_LIMIT` (default: 10)
593
+ * `HOOK_GUARD_DIRTY_TREE_UNSTAGED_LIMIT` (default: 15)
594
+ * `HOOK_GUARD_DIRTY_TREE_TOTAL_LIMIT` (default: 20)
595
+ * `HOOK_GUARD_DIRTY_TREE_INTERVAL` (default: 60000 ms)
596
+ * `HOOK_GUARD_DIRTY_TREE_REMINDER` (default: 300000 ms)
1264
597
 
1265
- ### Version 5.5.21 (2026-01-04)
598
+ ### Failure Modes (Visibility)
1266
599
 
1267
- **🐛 Bug Fixes:**
1268
- - Fixed fork bomb caused by wrapper scripts being copied to incorrect location
1269
- - Excluded wrapper scripts from bin/ copy to prevent recursive calls
1270
- - Session loader now works correctly without causing resource exhaustion
600
+ If the framework cannot read or parse `.AI_EVIDENCE.json`, evidence reads will safely fail (returning `null`) and the guard will record debug entries to help diagnose the issue.
1271
601
 
1272
602
  ---
1273
603
 
1274
- ### Version 5.5.20 (2026-01-04)
604
+ ## Evidence Maintenance
1275
605
 
1276
- **🐛 Bug Fixes:**
1277
- - Restored comprehensive session context report on IDE startup
1278
- - Fixed evidence age calculation for ISO 8601 timestamps with timezone offsets
1279
- - Removed `exec "$SHELL"` that caused infinite loop on macOS
1280
- - Added Python-based timestamp parsing for reliable timezone conversion
606
+ Manually refresh AI evidence:
1281
607
 
1282
- **🔧 Improvements:**
1283
- - Session loader now displays branch, recent commits, session context, violations summary, and evidence freshness
1284
- - Added quick commands section for user convenience
1285
- - Violations summary now reads from `ast-summary.json` with severity breakdown
608
+ ```bash
609
+ npm run ast:refresh
610
+ ```
1286
611
 
1287
612
  ---
1288
613
 
1289
- ### Version 5.5.16 (2026-01-04)
614
+ ## Daily Workflow (High Level)
1290
615
 
1291
- **✨ New Features:**
1292
- - Restored evidence fields: `protocol_3_questions`, `rules_read`, `current_context`, `platforms`, `session_id`
1293
- - Added macOS notifications when AI Gate status=BLOCKED
1294
- - Comprehensive notification types documentation in MCP_SERVERS.md
1295
- - E2E tests for notification system
616
+ ## Maturity & Stability
1296
617
 
1297
- **🔧 Improvements:**
1298
- - Reorganized README with Table of Contents at the beginning
1299
- - Consolidated duplicate Features sections
1300
- - Removed duplicate architectural diagrams
1301
- - Enhanced documentation structure for better navigation
618
+ * Production usage
619
+ * CI/CD integration
620
+ * Changelog-driven evolution
621
+ * Designed for long-lived codebases
1302
622
 
1303
- **🐛 Bug Fixes:**
1304
- - Fixed evidence staleness detection in RealtimeGuardService
1305
- - Improved notification error handling with graceful fallbacks
623
+ Frequent updates are expected and encouraged at this stage.
1306
624
 
1307
625
  ---
1308
626
 
1309
- ## ⚠️ Known Issues
1310
-
1311
- ### Current Limitations
627
+ ## Intended Audience
1312
628
 
1313
- 1. **macOS Notifications Only**
1314
- - Notifications currently use osascript (macOS-only)
1315
- - Other platforms fall back gracefully without errors
1316
- - Future versions will add cross-platform notification support
629
+ Pumuki is intentionally opinionated and designed for:
1317
630
 
1318
- 2. **Evidence Staleness Threshold**
1319
- - Default threshold is 180 seconds (3 minutes)
1320
- - May need adjustment for slower systems
1321
- - Configure via `HOOK_GUARD_EVIDENCE_STALE_THRESHOLD` environment variable
631
+ * Senior engineers
632
+ * Tech leads
633
+ * Software architects
634
+ * Platform and infrastructure teams
1322
635
 
1323
- 3. **Token Monitor Integration**
1324
- - Token monitor requires explicit environment variable `HOOK_GUARD_EMBEDDED_TOKEN_MONITOR=true`
1325
- - Not enabled by default to avoid overhead
1326
-
1327
- ### Workarounds
1328
-
1329
- - For non-macOS systems: Disable notifications via `HOOK_GUARD_MACOS_NOTIFICATIONS=false`
1330
- - For slower systems: Increase staleness threshold via environment variable
1331
- - For token monitoring: Enable explicitly if needed for your workflow
636
+ It is not optimized for casual or experimental AI usage.
1332
637
 
1333
638
  ---
1334
639
 
1335
640
  ## License
1336
641
 
1337
- This project is licensed under the **MIT License** - see [LICENSE](./LICENSE) for more details.
1338
-
1339
- ---
1340
-
1341
- ## Credits
1342
-
1343
- Developed by **Pumuki Team®**
1344
-
1345
- - **Author**: Juan Carlos Merlos Albarracín (Senior Software Architect - AI-Driven Development)
1346
- - **Contact**: freelancemerlos@gmail.com
1347
- - **Version**: 5.5.35
1348
- - **Repository**: [GitHub](https://github.com/SwiftEnProfundidad/ast-intelligence-hooks)
1349
-
1350
- ---
1351
-
1352
- ## Useful Links
1353
-
1354
- - 📚 [Complete Documentation](./docs/)
1355
- - 🏗️ [Detailed Architecture](./docs/ARCHITECTURE.md) | [Architecture Detailed](./docs/ARCHITECTURE_DETAILED.md)
1356
- - 🔌 [MCP Servers](./docs/MCP_SERVERS.md)
1357
- - 📖 [API Reference](./docs/API_REFERENCE.md)
1358
- - 📦 [Installation Guide](./docs/INSTALLATION.md)
1359
- - 💡 [Usage Guide](./docs/USAGE.md)
1360
- - 🔍 [Dependencies Analysis](./docs/DEPENDENCIES.md)
1361
- - 🧪 [Testing Guide](./docs/TESTING.md)
1362
- - 📋 [Code Standards](./docs/CODE_STANDARDS.md)
1363
-
1364
- ---
1365
-
1366
- **⭐ If this project is useful to you, please consider giving it a star on GitHub.**
1367
-
1368
- ### Run the Audit
1369
-
1370
- To start the interactive audit menu, run:
1371
-
1372
- ```bash
1373
- bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
1374
- ```
1375
-
1376
- This will present a menu with options for different audit modes.
1377
-
1378
- For non-interactive use, specify the mode directly:
1379
-
1380
- ```bash
1381
- bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh analyze # Full repository analysis
1382
- bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh staged # Analyze only staged files (pre-commit mode)
642
+ © Pumuki 2025. All rights reserved.