pumuki-ast-hooks 5.5.58 → 5.5.65
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/README.md +254 -1140
- package/docs/ARCHITECTURE.md +66 -1
- package/docs/TODO.md +41 -0
- package/docs/images/ast_intelligence_01.svg +40 -0
- package/docs/images/ast_intelligence_02.svg +39 -0
- package/docs/images/ast_intelligence_03.svg +55 -0
- package/docs/images/ast_intelligence_04.svg +39 -0
- package/docs/images/ast_intelligence_05.svg +45 -0
- package/docs/images/logo.png +0 -0
- package/package.json +2 -2
- package/scripts/hooks-system/.audit_tmp/hook-metrics.jsonl +16 -0
- package/scripts/hooks-system/application/DIValidationService.js +43 -0
- package/scripts/hooks-system/application/__tests__/DIValidationService.spec.js +81 -0
- package/scripts/hooks-system/application/services/installation/McpConfigurator.js +0 -3
- package/scripts/hooks-system/config/di-rules.json +42 -0
- package/scripts/hooks-system/domain/ports/FileSystemPort.js +19 -0
- package/scripts/hooks-system/domain/strategies/ConcreteDependencyStrategy.js +78 -0
- package/scripts/hooks-system/domain/strategies/DIStrategy.js +31 -0
- package/scripts/hooks-system/infrastructure/adapters/NodeFileSystemAdapter.js +28 -0
- package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +16 -0
- package/scripts/hooks-system/infrastructure/ast/backend/detectors/god-class-detector.js +28 -8
- package/scripts/hooks-system/infrastructure/ast/common/ast-common.js +138 -0
- package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +3 -2
- package/scripts/hooks-system/infrastructure/ast/ios/ast-ios.js +1 -1
- package/scripts/hooks-system/infrastructure/ast/ios/detectors/ios-ast-intelligent-strategies.js +41 -40
- package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +87 -1
- package/scripts/hooks-system/infrastructure/registry/StrategyRegistry.js +63 -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
|
|
12
|
-
<a href="https://www.npmjs.com/"><img src="https://img.shields.io/badge/npm
|
|
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,478 @@
|
|
|
19
19
|
<strong>Enterprise-grade AST Intelligence System for multi-platform code quality enforcement</strong>
|
|
20
20
|
</p>
|
|
21
21
|
|
|
22
|
-
|
|
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>
|
|
22
|
+
### Navigation
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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)
|
|
60
|
-
|
|
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
|
-
|
|
35
|
+
# Pumuki AST Intelligence Framework
|
|
64
36
|
|
|
65
|
-
|
|
37
|
+
## Enterprise AI Context Governance & Code Quality Enforcement
|
|
66
38
|
|
|
67
|
-
|
|
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
|
-
|
|
41
|
+
It provides a **deterministic control layer** over AI behavior by combining:
|
|
70
42
|
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
78
|
-
|
|
79
|
-
### The Fundamental Problem
|
|
80
|
-
|
|
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:
|
|
82
|
-
|
|
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?"
|
|
53
|
+
## Problem Statement
|
|
87
54
|
|
|
88
|
-
|
|
55
|
+
AI assistants are powerful but fundamentally unreliable when used in real-world, enterprise codebases:
|
|
89
56
|
|
|
90
|
-
|
|
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
|
|
91
62
|
|
|
92
|
-
|
|
63
|
+
Pumuki addresses these issues by **removing trust from the AI** and replacing it with **evidence, validation, and enforcement**.
|
|
93
64
|
|
|
94
65
|
---
|
|
95
66
|
|
|
96
|
-
##
|
|
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
|
|
283
|
-
|
|
284
|
-
---
|
|
67
|
+
## Quick Start
|
|
285
68
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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)
|
|
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)
|
|
326
73
|
|
|
327
74
|
---
|
|
328
75
|
|
|
329
|
-
##
|
|
76
|
+
## Features
|
|
330
77
|
|
|
331
|
-
|
|
78
|
+
* AST intelligence multi-plataforma (iOS, Android, Backend, Frontend)
|
|
79
|
+
* Evidence file `.AI_EVIDENCE.json` como fuente de verdad
|
|
80
|
+
* AI Gate (block/allow) con métricas
|
|
81
|
+
* Git-native (pre-commit / pre-push / CI)
|
|
82
|
+
* Notificaciones macOS + guardrails de árbol Git
|
|
83
|
+
* Automatización Git Flow (`ast:gitflow`, `ast:release`)
|
|
332
84
|
|
|
333
|
-
|
|
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
|
|
85
|
+
---
|
|
339
86
|
|
|
340
|
-
|
|
87
|
+
## Visual Overview
|
|
341
88
|
|
|
342
|
-
|
|
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`
|
|
89
|
+
<img src="./docs/images/ast_intelligence_01.svg" alt="AST Intelligence System Overview" width="100%" />
|
|
347
90
|
|
|
348
|
-
|
|
91
|
+
<img src="./docs/images/ast_intelligence_02.svg" alt="AST Intelligence Workflow" width="100%" />
|
|
349
92
|
|
|
350
|
-
|
|
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
|
|
93
|
+
<img src="./docs/images/ast_intelligence_03.svg" alt="AST Intelligence Audit - Part 1" width="100%" />
|
|
356
94
|
|
|
357
|
-
|
|
95
|
+
<img src="./docs/images/ast_intelligence_04.svg" alt="AST Intelligence Audit - Part 2" width="100%" />
|
|
358
96
|
|
|
359
|
-
|
|
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
|
|
97
|
+
<img src="./docs/images/ast_intelligence_05.svg" alt="AST Intelligence Audit - Part 3" width="100%" />
|
|
364
98
|
|
|
365
99
|
---
|
|
366
100
|
|
|
367
|
-
##
|
|
368
|
-
|
|
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:
|
|
101
|
+
## Design Philosophy
|
|
370
102
|
|
|
371
|
-
|
|
103
|
+
Pumuki is built on a few non-negotiable principles:
|
|
372
104
|
|
|
373
|
-
|
|
374
|
-
|
|
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
|
-
```
|
|
105
|
+
* **Evidence over conversation**
|
|
106
|
+
AI does not rely on chat memory. All decisions depend on a persistent evidence file.
|
|
386
107
|
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
```
|
|
108
|
+
* **Gated intelligence**
|
|
109
|
+
AI actions are explicitly allowed or blocked based on project state.
|
|
395
110
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
- Ensures context is fresh and rules are loaded.
|
|
111
|
+
* **AST, not heuristics**
|
|
112
|
+
Code is analyzed structurally, not via regex or conventions.
|
|
399
113
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
- Enforces quality gates.
|
|
114
|
+
* **Fail fast, block early**
|
|
115
|
+
Unsafe or invalid AI actions are prevented before code changes occur.
|
|
403
116
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
- Blocks commits with critical violations.
|
|
117
|
+
* **Platform-agnostic governance**
|
|
118
|
+
The same rules apply consistently across iOS, Android, backend, and frontend.
|
|
407
119
|
|
|
408
|
-
|
|
409
|
-
- Updates `.AI_EVIDENCE.json` before commits to maintain context.
|
|
120
|
+
---
|
|
410
121
|
|
|
411
|
-
|
|
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.
|
|
122
|
+
## Core Capabilities
|
|
416
123
|
|
|
417
|
-
|
|
124
|
+
### 1. AI Evidence System
|
|
418
125
|
|
|
419
|
-
|
|
126
|
+
Pumuki introduces a mandatory, versioned **AI Evidence File** (`.AI_EVIDENCE.json`) that acts as the **single source of truth** for AI-assisted development.
|
|
420
127
|
|
|
421
|
-
|
|
128
|
+
It stores:
|
|
422
129
|
|
|
423
|
-
|
|
130
|
+
* Active platforms and scopes
|
|
131
|
+
* Architectural and quality rules
|
|
132
|
+
* Detected violations and severities
|
|
133
|
+
* Session and workflow metadata
|
|
134
|
+
* AI gate state
|
|
424
135
|
|
|
425
|
-
|
|
136
|
+
The AI **cannot operate** without valid and fresh evidence.
|
|
426
137
|
|
|
427
138
|
---
|
|
428
139
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
### ❌ Common Problems
|
|
140
|
+
### 2. AI Gate (Control Primitive)
|
|
432
141
|
|
|
433
|
-
|
|
434
|
-
- Domain layer importing frameworks
|
|
435
|
-
- Infrastructure coupled to Presentation
|
|
436
|
-
- Circular dependencies
|
|
142
|
+
The AI Gate is the core control mechanism of the framework.
|
|
437
143
|
|
|
438
|
-
|
|
439
|
-
- Magic numbers without constants
|
|
440
|
-
- Functions that are too long
|
|
441
|
-
- Classes with too many responsibilities
|
|
144
|
+
Before any AI-assisted operation:
|
|
442
145
|
|
|
443
|
-
|
|
444
|
-
- Incorrect folder structure
|
|
445
|
-
- Forbidden imports between layers
|
|
446
|
-
- Missing separation of concerns
|
|
146
|
+
* Evidence freshness is validated
|
|
447
147
|
|
|
448
|
-
|
|
449
|
-
- Security violations (passwords without hash)
|
|
450
|
-
- Performance issues
|
|
451
|
-
- Untestable code
|
|
148
|
+
* Violations are evaluated
|
|
452
149
|
|
|
453
|
-
|
|
150
|
+
* A deterministic decision is made:
|
|
454
151
|
|
|
455
|
-
|
|
456
|
-
- **798+ rules** specific to each platform
|
|
457
|
-
- **Detailed reports** with correction suggestions
|
|
458
|
-
- **CI/CD integration** for continuous validation
|
|
152
|
+
* **ALLOWED** → operation may proceed
|
|
459
153
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
## Features
|
|
154
|
+
* **BLOCKED** → operation is rejected with actionable feedback
|
|
463
155
|
|
|
464
|
-
|
|
156
|
+
This transforms AI from an advisory tool into a **controlled execution actor**.
|
|
465
157
|
|
|
466
|
-
|
|
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
|
|
472
|
-
|
|
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
|
|
479
|
-
|
|
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
|
|
158
|
+
---
|
|
485
159
|
|
|
486
|
-
|
|
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
|
|
160
|
+
### 3. AST Intelligence Engine
|
|
491
161
|
|
|
492
|
-
|
|
162
|
+
The AST Intelligence Engine performs deep, language-aware analysis across platforms.
|
|
493
163
|
|
|
494
|
-
|
|
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
|
|
164
|
+
Capabilities include:
|
|
499
165
|
|
|
500
|
-
|
|
166
|
+
* Architectural rule enforcement
|
|
167
|
+
* Security and data safety validation
|
|
168
|
+
* Performance anti-pattern detection
|
|
169
|
+
* Detection of forbidden constructs and flows
|
|
501
170
|
|
|
502
|
-
|
|
171
|
+
The engine operates on **real ASTs**, not text approximations.
|
|
503
172
|
|
|
504
|
-
|
|
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)
|
|
173
|
+
---
|
|
507
174
|
|
|
508
|
-
###
|
|
175
|
+
### 4. Git-Native Enforcement
|
|
509
176
|
|
|
510
|
-
|
|
511
|
-
- **MEDIUM/LOW**: Generate warnings in reports
|
|
512
|
-
- **Configurable**: Adjust levels according to your project
|
|
177
|
+
Pumuki integrates directly with Git workflows:
|
|
513
178
|
|
|
514
|
-
|
|
179
|
+
* Pre-commit hooks
|
|
180
|
+
* Pre-push hooks
|
|
181
|
+
* Branch and flow validation
|
|
515
182
|
|
|
516
|
-
|
|
183
|
+
Violations can:
|
|
517
184
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
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
|
|
185
|
+
* Block commits
|
|
186
|
+
* Block pushes
|
|
187
|
+
* Prevent unsafe changes from reaching CI/CD
|
|
527
188
|
|
|
528
|
-
**
|
|
529
|
-
```bash
|
|
530
|
-
# Work on develop/main (changes detected)
|
|
189
|
+
Governance happens **before** code reaches production.
|
|
531
190
|
|
|
532
|
-
|
|
533
|
-
npm run ast:gitflow -- --auto-merge
|
|
534
|
-
```
|
|
191
|
+
---
|
|
535
192
|
|
|
536
|
-
|
|
537
|
-
```bash
|
|
538
|
-
# Switch to develop branch
|
|
539
|
-
git checkout develop
|
|
193
|
+
## Supported Platforms
|
|
540
194
|
|
|
541
|
-
|
|
542
|
-
npm run ast:release -- --auto-merge
|
|
195
|
+
Pumuki is multi-platform by default:
|
|
543
196
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
197
|
+
* iOS (Swift)
|
|
198
|
+
* Android (Kotlin)
|
|
199
|
+
* Backend (Node.js / NestJS)
|
|
200
|
+
* Frontend (React / Next.js)
|
|
547
201
|
|
|
548
|
-
|
|
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
|
|
202
|
+
The framework is extensible to additional platforms and languages.
|
|
556
203
|
|
|
557
|
-
|
|
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
|
-
```
|
|
204
|
+
---
|
|
565
205
|
|
|
566
|
-
|
|
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
|
-
```
|
|
206
|
+
## Typical Enterprise Use Cases
|
|
573
207
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
208
|
+
* Long-running feature development with AI assistance
|
|
209
|
+
* Multi-day or multi-chat workflows
|
|
210
|
+
* Large monorepos and distributed teams
|
|
211
|
+
* Strict Clean Architecture enforcement
|
|
212
|
+
* Regulated or compliance-sensitive environments
|
|
577
213
|
|
|
578
214
|
---
|
|
579
215
|
|
|
580
|
-
##
|
|
216
|
+
## Installation
|
|
581
217
|
|
|
582
|
-
|
|
218
|
+
**Requirements**
|
|
583
219
|
|
|
584
|
-
|
|
585
|
-
|
|
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
|
-
```
|
|
220
|
+
* Node.js 20 (see `.nvmrc`)
|
|
221
|
+
* npm 10+
|
|
591
222
|
|
|
592
|
-
|
|
223
|
+
Install as a development dependency:
|
|
593
224
|
|
|
594
225
|
```bash
|
|
595
|
-
|
|
596
|
-
bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
|
|
597
|
-
# Or using CLI
|
|
598
|
-
ast-hooks analyze
|
|
226
|
+
npm install --save-dev @pumuki/ast-intelligence-hooks
|
|
599
227
|
```
|
|
600
228
|
|
|
601
|
-
|
|
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
|
|
610
|
-
|
|
611
|
-
```javascript
|
|
612
|
-
const { runASTIntelligence } = require('@pumuki/ast-intelligence-hooks');
|
|
613
|
-
|
|
614
|
-
const result = await runASTIntelligence({
|
|
615
|
-
files: ['src/**/*.ts'],
|
|
616
|
-
platforms: ['backend'],
|
|
617
|
-
strict: true
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
if (result.hasCriticalViolations()) {
|
|
621
|
-
console.error('❌ Critical violations found!');
|
|
622
|
-
process.exit(1);
|
|
623
|
-
}
|
|
624
|
-
```
|
|
625
|
-
|
|
626
|
-
### 5. Continuous Monitoring
|
|
229
|
+
Legacy (deprecated):
|
|
627
230
|
|
|
628
231
|
```bash
|
|
629
|
-
|
|
630
|
-
hook-watch
|
|
631
|
-
|
|
632
|
-
# System status
|
|
633
|
-
hook-status
|
|
232
|
+
npm install --save-dev pumuki-ast-hooks
|
|
634
233
|
```
|
|
635
234
|
|
|
636
|
-
|
|
235
|
+
Initialize AI evidence:
|
|
637
236
|
|
|
638
237
|
```bash
|
|
639
|
-
|
|
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
|
|
238
|
+
npx ai-start
|
|
649
239
|
```
|
|
650
240
|
|
|
651
241
|
---
|
|
652
242
|
|
|
653
|
-
##
|
|
654
|
-
|
|
655
|
-
### Prerequisites
|
|
656
|
-
|
|
657
|
-
- **Node.js** ≥18.0.0
|
|
658
|
-
- **npm** ≥9.0.0
|
|
659
|
-
- **Git** (for hooks)
|
|
243
|
+
## Installation & Lifecycle Commands
|
|
660
244
|
|
|
661
|
-
###
|
|
662
|
-
|
|
663
|
-
```bash
|
|
664
|
-
npm install --save-dev pumuki-ast-hooks
|
|
665
|
-
```
|
|
666
|
-
|
|
667
|
-
### 2. Configure hooks
|
|
245
|
+
### Update to latest version
|
|
668
246
|
|
|
669
247
|
```bash
|
|
248
|
+
npm install --save-dev @pumuki/ast-intelligence-hooks@latest
|
|
670
249
|
npm run install-hooks
|
|
671
|
-
|
|
250
|
+
````
|
|
672
251
|
|
|
673
|
-
###
|
|
252
|
+
### Uninstall
|
|
674
253
|
|
|
675
254
|
```bash
|
|
676
|
-
|
|
677
|
-
git commit -m "test: verify hooks"
|
|
255
|
+
npm uninstall @pumuki/ast-intelligence-hooks
|
|
678
256
|
```
|
|
679
257
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
### 4. View full report
|
|
258
|
+
Legacy:
|
|
683
259
|
|
|
684
260
|
```bash
|
|
685
|
-
|
|
686
|
-
```
|
|
687
|
-
|
|
688
|
-
### 5. Check violations
|
|
689
|
-
|
|
690
|
-
```bash
|
|
691
|
-
# List all violations
|
|
692
|
-
npm run violations
|
|
693
|
-
|
|
694
|
-
# View summary
|
|
695
|
-
bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
|
|
696
|
-
|
|
697
|
-
# Top violations
|
|
698
|
-
npm run violations:top
|
|
699
|
-
```
|
|
700
|
-
|
|
701
|
-
---
|
|
702
|
-
|
|
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)
|
|
791
|
-
|
|
792
|
-
---
|
|
793
|
-
|
|
794
|
-
## Architecture
|
|
795
|
-
|
|
796
|
-
The project follows **strict Clean Architecture** with 4 well-defined layers:
|
|
797
|
-
|
|
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
|
-
└─────────────────────────────────────────┘
|
|
261
|
+
npm uninstall pumuki-ast-hooks
|
|
825
262
|
```
|
|
826
263
|
|
|
827
|
-
**Principles:**
|
|
828
|
-
- **Dependencies inward**: Presentation → Application → Domain
|
|
829
|
-
- **Domain without dependencies**: Zero external dependencies
|
|
830
|
-
- **Dependency Inversion**: Interfaces in Domain, implementations in Infrastructure
|
|
831
|
-
|
|
832
|
-
For more details, see [ARCHITECTURE.md](./docs/ARCHITECTURE.md) and [ARCHITECTURE_DETAILED.md](./docs/ARCHITECTURE_DETAILED.md).
|
|
833
|
-
|
|
834
264
|
---
|
|
835
265
|
|
|
836
|
-
##
|
|
837
|
-
|
|
838
|
-
The project includes MCP (Model Context Protocol) servers for integration with any agentic IDE or AI client:
|
|
839
|
-
|
|
840
|
-
### evidence-watcher
|
|
841
|
-
|
|
842
|
-
Monitors the status of `.AI_EVIDENCE.json` and allows AI to verify if it's up to date.
|
|
843
|
-
|
|
844
|
-
**Resources:**
|
|
845
|
-
- `evidence://status`: Evidence status (fresh/stale/missing)
|
|
846
|
-
|
|
847
|
-
**Tools:**
|
|
848
|
-
- `check_evidence_status`: Checks if the evidence is stale
|
|
849
|
-
|
|
850
|
-
### ast-intelligence-automation
|
|
851
|
-
|
|
852
|
-
Automates the complete Git Flow cycle: commit → push → PR → merge, plus context detection and AI gate checks.
|
|
853
|
-
|
|
854
|
-
**Resources:**
|
|
855
|
-
- `evidence://status`: Evidence status
|
|
856
|
-
- `gitflow://state`: Git Flow workflow state
|
|
857
|
-
- `context://active`: Active project context
|
|
858
|
-
|
|
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
|
|
866
|
-
|
|
867
|
-
For more details, see [MCP_SERVERS.md](./docs/MCP_SERVERS.md).
|
|
868
|
-
|
|
869
|
-
#### Troubleshooting
|
|
870
|
-
|
|
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.
|
|
872
|
-
|
|
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.
|
|
877
|
-
|
|
878
|
-
---
|
|
879
|
-
|
|
880
|
-
## API Reference
|
|
881
|
-
|
|
882
|
-
### Main Functions
|
|
883
|
-
|
|
884
|
-
#### `runASTIntelligence(options)`
|
|
885
|
-
|
|
886
|
-
Analyzes code using AST Intelligence.
|
|
266
|
+
## Hook Installation & Management
|
|
887
267
|
|
|
888
|
-
|
|
889
|
-
const { runASTIntelligence } = require('@pumuki/ast-intelligence-hooks');
|
|
268
|
+
Install or update Git hooks (wizard-driven):
|
|
890
269
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
platforms: ['backend', 'frontend'],
|
|
894
|
-
strict: false
|
|
895
|
-
});
|
|
270
|
+
```bash
|
|
271
|
+
npm run install-hooks
|
|
896
272
|
```
|
|
897
273
|
|
|
898
|
-
|
|
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`
|
|
274
|
+
(Equivalent to `npx ast-install`)
|
|
904
275
|
|
|
905
276
|
---
|
|
906
277
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
Use Case for full codebase analysis.
|
|
278
|
+
## Operational Commands
|
|
910
279
|
|
|
911
|
-
|
|
912
|
-
const { AnalyzeCodebaseUseCase } = require('@pumuki/ast-intelligence-hooks');
|
|
280
|
+
### Check installed version vs. latest published
|
|
913
281
|
|
|
914
|
-
|
|
915
|
-
|
|
282
|
+
```bash
|
|
283
|
+
npm run ast:check-version
|
|
916
284
|
```
|
|
917
285
|
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
#### `AnalyzeStagedFilesUseCase`
|
|
286
|
+
### Run hook system with interactive menu
|
|
921
287
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
```javascript
|
|
925
|
-
const { AnalyzeStagedFilesUseCase } = require('@pumuki/ast-intelligence-hooks');
|
|
926
|
-
|
|
927
|
-
const useCase = new AnalyzeStagedFilesUseCase(/* dependencies */);
|
|
928
|
-
const result = await useCase.execute();
|
|
288
|
+
```bash
|
|
289
|
+
npx ast-hooks
|
|
929
290
|
```
|
|
930
291
|
|
|
931
292
|
---
|
|
932
293
|
|
|
933
|
-
|
|
294
|
+
## Manual Hook-System (Interactive Menu)
|
|
934
295
|
|
|
935
|
-
|
|
296
|
+
Pumuki can be used fully manually (without waiting for Git hooks) via the interactive audit menu.
|
|
936
297
|
|
|
937
|
-
|
|
298
|
+
### Recommended
|
|
938
299
|
|
|
939
|
-
```
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
result.getFindings(); // All violations
|
|
943
|
-
result.getCriticalFindings(); // Only CRITICAL
|
|
944
|
-
result.hasCriticalViolations(); // Boolean
|
|
945
|
-
result.getTechnicalDebtHours(); // Estimated hours
|
|
300
|
+
```bash
|
|
301
|
+
npx ast-hooks
|
|
946
302
|
```
|
|
947
303
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
Individual violation found.
|
|
304
|
+
### Direct CLI (explicit)
|
|
951
305
|
|
|
952
|
-
```
|
|
953
|
-
|
|
954
|
-
|
|
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
|
|
306
|
+
```bash
|
|
307
|
+
ast-hooks audit
|
|
959
308
|
```
|
|
960
309
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
---
|
|
964
|
-
|
|
965
|
-
## Configuration
|
|
966
|
-
|
|
967
|
-
### Environment Variables
|
|
310
|
+
### Run the orchestrator directly (local repository)
|
|
968
311
|
|
|
969
312
|
```bash
|
|
970
|
-
|
|
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
|
|
979
|
-
|
|
980
|
-
# Auto-refresh evidence when stale (enabled by default)
|
|
981
|
-
export HOOK_GUARD_AUTO_REFRESH=true
|
|
982
|
-
|
|
983
|
-
# Auto-commit in Git Flow
|
|
984
|
-
export AUTO_COMMIT_ENABLED=true
|
|
985
|
-
export AUTO_PUSH_ENABLED=true
|
|
986
|
-
export AUTO_PR_ENABLED=false
|
|
313
|
+
bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
|
|
987
314
|
```
|
|
988
315
|
|
|
989
|
-
###
|
|
990
|
-
|
|
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))
|
|
316
|
+
### Non-interactive mode
|
|
995
317
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
Rules are in `skills/` by platform:
|
|
999
|
-
- `skills/backend-guidelines/`
|
|
1000
|
-
- `skills/frontend-guidelines/`
|
|
1001
|
-
- `skills/ios-guidelines/`
|
|
1002
|
-
- `skills/android-guidelines/`
|
|
1003
|
-
|
|
1004
|
-
For more details, see [USAGE.md](./docs/USAGE.md).
|
|
1005
|
-
|
|
1006
|
-
---
|
|
1007
|
-
|
|
1008
|
-
## Best Practices
|
|
1009
|
-
|
|
1010
|
-
### 1. Install Hooks in All Projects
|
|
318
|
+
You can run specific audit modes without the menu:
|
|
1011
319
|
|
|
1012
320
|
```bash
|
|
1013
|
-
#
|
|
1014
|
-
|
|
1015
|
-
npm run install-hooks
|
|
1016
|
-
```
|
|
1017
|
-
|
|
1018
|
-
### 2. Use in CI/CD
|
|
321
|
+
# Example: run AST Intelligence directly
|
|
322
|
+
AUDIT_OPTION=7 bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
|
|
1019
323
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
- name: AST Analysis
|
|
1023
|
-
run: bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
|
|
324
|
+
# Example: analyze staged files only (pre-commit equivalent)
|
|
325
|
+
AUDIT_OPTION=3 bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
|
|
1024
326
|
```
|
|
1025
327
|
|
|
1026
|
-
|
|
328
|
+
If defined as scripts:
|
|
1027
329
|
|
|
1028
330
|
```bash
|
|
1029
|
-
#
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
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
|
-
}
|
|
331
|
+
npm run ast:gitflow # guided Git flow
|
|
332
|
+
npm run ast:release # guided release flow (develop → main)
|
|
333
|
+
npm run ast:audit # direct audit
|
|
1044
334
|
```
|
|
1045
335
|
|
|
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
336
|
---
|
|
1051
337
|
|
|
1052
|
-
##
|
|
1053
|
-
|
|
1054
|
-
### Can I use this in existing projects?
|
|
338
|
+
## Git Governance & Flow Automation
|
|
1055
339
|
|
|
1056
|
-
|
|
340
|
+
Pumuki includes first-class Git governance commands to enforce a consistent workflow across teams and repositories.
|
|
1057
341
|
|
|
1058
|
-
###
|
|
342
|
+
### Daily Development Flow
|
|
1059
343
|
|
|
1060
344
|
```bash
|
|
1061
|
-
|
|
1062
|
-
GIT_BYPASS_HOOK=1 git commit -m "emergency fix"
|
|
345
|
+
npm run ast:gitflow
|
|
1063
346
|
```
|
|
1064
347
|
|
|
1065
|
-
|
|
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.
|
|
1076
|
-
|
|
1077
|
-
### What if I have many violations?
|
|
1078
|
-
|
|
1079
|
-
Start by fixing CRITICAL and HIGH. MEDIUM and LOW are warnings and don't block commits.
|
|
1080
|
-
|
|
1081
|
-
### How to update evidence?
|
|
348
|
+
With optional auto-merge:
|
|
1082
349
|
|
|
1083
350
|
```bash
|
|
1084
|
-
|
|
1085
|
-
# Or manually
|
|
1086
|
-
bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh
|
|
351
|
+
npm run ast:gitflow -- --auto-merge
|
|
1087
352
|
```
|
|
1088
353
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
---
|
|
1092
|
-
|
|
1093
|
-
## Available Commands
|
|
1094
|
-
|
|
1095
|
-
### CLI Commands
|
|
354
|
+
### Release Flow (develop → main)
|
|
1096
355
|
|
|
1097
356
|
```bash
|
|
1098
|
-
|
|
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
|
|
357
|
+
npm run ast:release
|
|
1121
358
|
```
|
|
1122
359
|
|
|
1123
|
-
|
|
360
|
+
With optional auto-merge:
|
|
1124
361
|
|
|
1125
362
|
```bash
|
|
1126
|
-
npm run
|
|
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
|
|
363
|
+
npm run ast:release -- --auto-merge
|
|
1134
364
|
```
|
|
1135
365
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
## Contributing
|
|
1139
|
-
|
|
1140
|
-
Contributions are welcome. Please:
|
|
366
|
+
### Git Flow Cycle (ast:gitflow)
|
|
1141
367
|
|
|
1142
|
-
|
|
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
|
|
368
|
+
Pumuki runs a complete Git Flow cycle:
|
|
1147
369
|
|
|
1148
|
-
|
|
370
|
+
* Step 1: Validate Branch (must be feature/, fix/, etc.)
|
|
371
|
+
* Step 2: Commit Changes (if uncommitted)
|
|
372
|
+
* Step 3: Push to Origin
|
|
373
|
+
* Step 4: Create Pull Request
|
|
374
|
+
* Step 5: Merge Pull Request (optional)
|
|
375
|
+
* Step 6: Cleanup Merged Branches
|
|
376
|
+
* Step 7: Sync Branches
|
|
377
|
+
* Git Flow Cycle Complete
|
|
1149
378
|
|
|
1150
|
-
|
|
1151
|
-
- Ensure tests pass (`npm test`)
|
|
1152
|
-
- Add tests for new features
|
|
1153
|
-
- Update documentation if necessary
|
|
379
|
+
### Options
|
|
1154
380
|
|
|
1155
|
-
|
|
381
|
+
```bash
|
|
382
|
+
npm run ast:gitflow
|
|
383
|
+
npm run ast:gitflow -- -m "feat: new feature"
|
|
384
|
+
npm run ast:gitflow -- --auto-merge
|
|
385
|
+
npm run ast:gitflow -- --skip-cleanup
|
|
386
|
+
npm run ast:gitflow -- --skip-sync
|
|
387
|
+
```
|
|
1156
388
|
|
|
1157
389
|
---
|
|
1158
390
|
|
|
1159
|
-
##
|
|
1160
|
-
|
|
1161
|
-
### Version 5.5.35 (2026-01-04)
|
|
391
|
+
## Evidence Guard (Daemon)
|
|
1162
392
|
|
|
1163
|
-
|
|
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
|
|
393
|
+
The evidence guard ensures AI evidence freshness during long work sessions.
|
|
1167
394
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
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
|
|
395
|
+
```bash
|
|
396
|
+
npm run ast:guard:start
|
|
397
|
+
npm run ast:guard:stop
|
|
398
|
+
npm run ast:guard:restart
|
|
399
|
+
npm run ast:guard:status
|
|
400
|
+
npm run ast:guard:logs
|
|
401
|
+
```
|
|
1178
402
|
|
|
1179
403
|
---
|
|
1180
404
|
|
|
1181
|
-
|
|
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
|
|
405
|
+
## Developer Experience: Notifications & Guardrails
|
|
1201
406
|
|
|
1202
|
-
|
|
407
|
+
Pumuki includes a built-in notification and guardrail layer to keep long work sessions safe and predictable.
|
|
1203
408
|
|
|
1204
|
-
###
|
|
409
|
+
### macOS Notifications
|
|
1205
410
|
|
|
1206
|
-
|
|
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
|
|
411
|
+
On macOS, notifications are delivered using:
|
|
1210
412
|
|
|
1211
|
-
|
|
1212
|
-
|
|
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
|
|
413
|
+
* `terminal-notifier` (preferred, if installed)
|
|
414
|
+
* `osascript` fallback (built-in)
|
|
1216
415
|
|
|
1217
|
-
|
|
416
|
+
The notification system includes deduplication, cooldowns, and retry logic to avoid spam during long sessions.
|
|
1218
417
|
|
|
1219
|
-
###
|
|
418
|
+
### Evidence Freshness Alerts (SLA)
|
|
1220
419
|
|
|
1221
|
-
|
|
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
|
|
420
|
+
When `.AI_EVIDENCE.json` becomes stale beyond the configured threshold, the guard will:
|
|
1229
421
|
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
- Added `ast:gitflow` npm script
|
|
1233
|
-
- Updated GitEnvironmentService to install pre-push hook
|
|
1234
|
-
- Updated pre-commit hook to validate protected branches
|
|
422
|
+
* Notify that evidence is stale (including how many seconds)
|
|
423
|
+
* Optionally attempt an auto-refresh depending on guard configuration
|
|
1235
424
|
|
|
1236
|
-
|
|
425
|
+
When evidence returns to a fresh state (back within SLA), the guard can notify that evidence is healthy again.
|
|
1237
426
|
|
|
1238
|
-
###
|
|
427
|
+
### AI Evidence Refresh Notifications
|
|
1239
428
|
|
|
1240
|
-
|
|
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
|
|
429
|
+
When evidence is refreshed, the orchestration layer updates `.AI_EVIDENCE.json` and sends a macOS notification:
|
|
1244
430
|
|
|
1245
|
-
|
|
431
|
+
* If gate is **ALLOWED**: `AI Evidence has been refreshed automatically`
|
|
432
|
+
* If gate is **BLOCKED**: `AI Gate BLOCKED - <N> violations need fixing`
|
|
1246
433
|
|
|
1247
|
-
###
|
|
434
|
+
### Git Tree Guardrails (Atomic Commits)
|
|
1248
435
|
|
|
1249
|
-
|
|
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"
|
|
436
|
+
Pumuki monitors the working tree and staging area and can notify when there are too many changes at once.
|
|
1253
437
|
|
|
1254
|
-
|
|
438
|
+
Typical behavior:
|
|
1255
439
|
|
|
1256
|
-
|
|
440
|
+
* Warn/error when the git tree exceeds configured limits (total/staged/unstaged)
|
|
441
|
+
* Suggest splitting work into smaller, atomic commits
|
|
442
|
+
* Provide grouped commit suggestions when it can infer feature-based groupings
|
|
1257
443
|
|
|
1258
|
-
|
|
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
|
|
444
|
+
Configuration (environment variables):
|
|
1262
445
|
|
|
1263
|
-
|
|
446
|
+
* `HOOK_GUARD_DIRTY_TREE_STAGED_LIMIT` (default: 10)
|
|
447
|
+
* `HOOK_GUARD_DIRTY_TREE_UNSTAGED_LIMIT` (default: 15)
|
|
448
|
+
* `HOOK_GUARD_DIRTY_TREE_TOTAL_LIMIT` (default: 20)
|
|
449
|
+
* `HOOK_GUARD_DIRTY_TREE_INTERVAL` (default: 60000 ms)
|
|
450
|
+
* `HOOK_GUARD_DIRTY_TREE_REMINDER` (default: 300000 ms)
|
|
1264
451
|
|
|
1265
|
-
###
|
|
452
|
+
### Failure Modes (Visibility)
|
|
1266
453
|
|
|
1267
|
-
|
|
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
|
|
454
|
+
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
455
|
|
|
1272
456
|
---
|
|
1273
457
|
|
|
1274
|
-
|
|
458
|
+
## Evidence Maintenance
|
|
1275
459
|
|
|
1276
|
-
|
|
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
|
|
460
|
+
Manually refresh AI evidence:
|
|
1281
461
|
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
- Violations summary now reads from `ast-summary.json` with severity breakdown
|
|
462
|
+
```bash
|
|
463
|
+
npm run ast:refresh
|
|
464
|
+
```
|
|
1286
465
|
|
|
1287
466
|
---
|
|
1288
467
|
|
|
1289
|
-
|
|
468
|
+
## Daily Workflow (High Level)
|
|
1290
469
|
|
|
1291
|
-
|
|
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
|
|
470
|
+
## Maturity & Stability
|
|
1296
471
|
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
-
|
|
1300
|
-
|
|
1301
|
-
- Enhanced documentation structure for better navigation
|
|
472
|
+
* Production usage
|
|
473
|
+
* CI/CD integration
|
|
474
|
+
* Changelog-driven evolution
|
|
475
|
+
* Designed for long-lived codebases
|
|
1302
476
|
|
|
1303
|
-
|
|
1304
|
-
- Fixed evidence staleness detection in RealtimeGuardService
|
|
1305
|
-
- Improved notification error handling with graceful fallbacks
|
|
477
|
+
Frequent updates are expected and encouraged at this stage.
|
|
1306
478
|
|
|
1307
479
|
---
|
|
1308
480
|
|
|
1309
|
-
##
|
|
481
|
+
## Intended Audience
|
|
1310
482
|
|
|
1311
|
-
|
|
483
|
+
Pumuki is intentionally opinionated and designed for:
|
|
1312
484
|
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
485
|
+
* Senior engineers
|
|
486
|
+
* Tech leads
|
|
487
|
+
* Software architects
|
|
488
|
+
* Platform and infrastructure teams
|
|
1317
489
|
|
|
1318
|
-
|
|
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
|
|
1322
|
-
|
|
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
|
|
490
|
+
It is not optimized for casual or experimental AI usage.
|
|
1332
491
|
|
|
1333
492
|
---
|
|
1334
493
|
|
|
1335
494
|
## License
|
|
1336
495
|
|
|
1337
|
-
|
|
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)
|
|
496
|
+
© Pumuki 2025. All rights reserved.
|