pumuki-ast-hooks 5.5.25 → 5.5.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki-ast-hooks",
3
- "version": "5.5.25",
3
+ "version": "5.5.27",
4
4
  "description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -10,6 +10,20 @@ const { toErrorMessage } = require('../utils/error-utils');
10
10
  const fs = require('fs');
11
11
  const path = require('path');
12
12
 
13
+ function deriveCategoryFromRuleId(ruleId) {
14
+ if (!ruleId || typeof ruleId !== 'string') return 'unknown';
15
+ const parts = ruleId.split('.');
16
+ if (parts.length >= 2) {
17
+ const platform = parts[0].toLowerCase();
18
+ const domain = parts[1].toLowerCase();
19
+ if (['ios', 'android', 'backend', 'frontend'].includes(platform)) {
20
+ return `${platform}.${domain}`;
21
+ }
22
+ return domain;
23
+ }
24
+ return parts[0] || 'unknown';
25
+ }
26
+
13
27
  function formatLocalTimestamp(date = new Date()) {
14
28
  const year = date.getFullYear();
15
29
  const month = String(date.getMonth() + 1).padStart(2, '0');
@@ -251,7 +265,14 @@ function updateAIEvidence(violations, gateResult, tokenUsage) {
251
265
  const isProtected = ['main', 'master', baseBranch].includes(currentBranch);
252
266
  const criticalViolations = violations.filter(v => v.severity === 'CRITICAL');
253
267
  const highViolations = violations.filter(v => v.severity === 'HIGH');
254
- const blockingViolations = [...criticalViolations, ...highViolations].slice(0, 50);
268
+ const mediumViolations = violations.filter(v => v.severity === 'MEDIUM');
269
+ const lowViolations = violations.filter(v => v.severity === 'LOW');
270
+
271
+ let gateViolations = [...criticalViolations, ...highViolations];
272
+ if (gateViolations.length === 0) {
273
+ gateViolations = [...mediumViolations, ...lowViolations];
274
+ }
275
+ const blockingViolations = gateViolations.slice(0, 50);
255
276
 
256
277
  const gateScope = String(env.get('AI_GATE_SCOPE', 'staging') || 'staging').trim().toLowerCase();
257
278
 
@@ -272,16 +293,19 @@ function updateAIEvidence(violations, gateResult, tokenUsage) {
272
293
  status: gateResult.passed ? 'ALLOWED' : 'BLOCKED',
273
294
  scope: gateScope === 'repo' || gateScope === 'repository' ? 'repo' : 'staging',
274
295
  last_check: formatLocalTimestamp(),
275
- violations: blockingViolations.map(v => ({
276
- file: v.filePath || v.file || 'unknown',
277
- line: v.line || null,
278
- severity: v.severity,
279
- rule: v.ruleId || v.rule || 'unknown',
280
- message: v.message || v.description || '',
281
- category: v.category || 'unknown',
282
- intelligent_evaluation: v.intelligentEvaluation || false,
283
- severity_score: v.severityScore || 0
284
- })),
296
+ violations: blockingViolations.map(v => {
297
+ const ruleId = v.ruleId || v.rule || 'unknown';
298
+ return {
299
+ file: v.filePath || v.file || 'unknown',
300
+ line: v.line || null,
301
+ severity: v.severity,
302
+ rule: ruleId,
303
+ message: v.message || v.description || '',
304
+ category: v.category || deriveCategoryFromRuleId(ruleId),
305
+ intelligent_evaluation: v.intelligentEvaluation || false,
306
+ severity_score: v.severityScore || 0
307
+ };
308
+ }),
285
309
  instruction: '🚨 AI MUST call mcp_ast-intelligence-automation_ai_gate_check BEFORE any action. If BLOCKED, fix violations first!',
286
310
  mandatory: true
287
311
  };
@@ -114,6 +114,52 @@ print_header() {
114
114
  printf "%b%s%b\n\n" "$BLUE" "$MSG_TITLE" "$NC"
115
115
  }
116
116
 
117
+ print_blocking_violations() {
118
+ if [[ ! -f "$TMP_DIR/ast-summary.json" ]]; then
119
+ return
120
+ fi
121
+ if ! command -v jq >/dev/null 2>&1; then
122
+ return
123
+ fi
124
+
125
+ local max_show=${1:-20}
126
+
127
+ local critical_violations
128
+ critical_violations=$(jq -r '
129
+ [.findings[] | select(.severity == "CRITICAL" or .severity == "critical" or .severity == "error")]
130
+ | .[0:'"$max_show"']
131
+ | .[] | "🔴 CRITICAL: \(.ruleId) - File: \(.filePath):\(.line // 1)"
132
+ ' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "")
133
+
134
+ local high_violations
135
+ high_violations=$(jq -r '
136
+ [.findings[] | select(.severity == "HIGH" or .severity == "high")]
137
+ | .[0:'"$max_show"']
138
+ | .[] | "🟠 HIGH: \(.ruleId) - File: \(.filePath):\(.line // 1)"
139
+ ' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "")
140
+
141
+ if [[ -n "$critical_violations" || -n "$high_violations" ]]; then
142
+ printf "\n%b📋 BLOCKING VIOLATIONS DETAIL:%b\n" "$YELLOW" "$NC"
143
+ printf "─────────────────────────────────────────────────────────────\n"
144
+ fi
145
+
146
+ if [[ -n "$critical_violations" ]]; then
147
+ printf "%b%s%b\n" "$RED" "$critical_violations" "$NC"
148
+ fi
149
+
150
+ if [[ -n "$high_violations" ]]; then
151
+ printf "%b%s%b\n" "$YELLOW" "$high_violations" "$NC"
152
+ fi
153
+
154
+ local total_crit total_high
155
+ total_crit=$(jq '[.findings[] | select(.severity == "CRITICAL" or .severity == "critical" or .severity == "error")] | length' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
156
+ total_high=$(jq '[.findings[] | select(.severity == "HIGH" or .severity == "high")] | length' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
157
+
158
+ if (( total_crit > max_show )) || (( total_high > max_show )); then
159
+ printf "\n %b(Showing first %d of each severity. Run full audit for complete list)%b\n" "$BLUE" "$max_show" "$NC"
160
+ fi
161
+ }
162
+
117
163
  ignored_globs() {
118
164
  cat <<'EOF'
119
165
  node_modules
@@ -268,6 +314,7 @@ full_audit_strict_staging_only() {
268
314
  printf " 🟠 HIGH: %s\n" "$gate_high"
269
315
  printf " 🟡 MEDIUM: %s\n" "$gate_med"
270
316
  printf " 🔵 LOW: %s\n" "$gate_low"
317
+ print_blocking_violations
271
318
  printf "\n Action: Fix ALL violations in staged files.\n"
272
319
  printf "\n"
273
320
  print_final_signature
@@ -324,6 +371,7 @@ full_audit_standard() {
324
371
  printf " 🟠 HIGH: %s\n" "$gate_high"
325
372
  printf " 🟡 MEDIUM: %s (allowed)\n" "$gate_med"
326
373
  printf " 🔵 LOW: %s (allowed)\n" "$gate_low"
374
+ print_blocking_violations
327
375
  printf "\n Action: Fix CRITICAL/HIGH violations in staged files.\n"
328
376
  printf "\n"
329
377
  print_final_signature
@@ -802,6 +850,7 @@ summarize_all() {
802
850
  printf " MEDIUM violations (repository): %s\n" "$gate_med"
803
851
  printf " LOW violations (repository): %s\n" "$gate_low"
804
852
  printf " ESLint errors (repository): %s\n" "$gate_es"
853
+ print_blocking_violations
805
854
  printf " Action: Clean entire repository before committing.\n"
806
855
  else
807
856
  printf "%b[COMMIT BLOCKED - STRICT STAGING]%b\n" "$RED" "$NC"
@@ -809,6 +858,7 @@ summarize_all() {
809
858
  printf " HIGH violations in staging: %s\n" "$gate_high"
810
859
  printf " MEDIUM violations in staging: %s\n" "$gate_med"
811
860
  printf " LOW violations in staging: %s\n" "$gate_low"
861
+ print_blocking_violations
812
862
  printf " Action: Fix violations in staged files before committing.\n"
813
863
  fi
814
864
  printf "\n"
@@ -822,6 +872,7 @@ summarize_all() {
822
872
  printf "%b[COMMIT BLOCKED - CRITICAL/HIGH]%b\n" "$RED" "$NC"
823
873
  printf " CRITICAL violations in staging: %s\n" "$gate_crit"
824
874
  printf " HIGH violations in staging: %s\n" "$gate_high"
875
+ print_blocking_violations
825
876
  printf " Action: Fix critical/high violations in staged files before committing.\n"
826
877
  printf "\n"
827
878
  print_final_signature