pumuki-ast-hooks 5.5.21 → 5.5.23

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 CHANGED
@@ -1065,6 +1065,24 @@ For coding standards, see [CODE_STANDARDS.md](./docs/CODE_STANDARDS.md).
1065
1065
 
1066
1066
  ## 📝 Recent Changes
1067
1067
 
1068
+ ### Version 5.5.22 (2026-01-04)
1069
+
1070
+ **🔴 CRITICAL Fix:**
1071
+ - Replaced self-referential wrapper with complete session-loader implementation
1072
+ - Root cause: wrapper called itself causing infinite recursion
1073
+ - Session loader now works correctly in all consuming projects
1074
+
1075
+ ---
1076
+
1077
+ ### Version 5.5.21 (2026-01-04)
1078
+
1079
+ **🐛 Bug Fixes:**
1080
+ - Fixed fork bomb caused by wrapper scripts being copied to incorrect location
1081
+ - Excluded wrapper scripts from bin/ copy to prevent recursive calls
1082
+ - Session loader now works correctly without causing resource exhaustion
1083
+
1084
+ ---
1085
+
1068
1086
  ### Version 5.5.20 (2026-01-04)
1069
1087
 
1070
1088
  **🐛 Bug Fixes:**
@@ -1,5 +1,5 @@
1
1
  #!/bin/bash
2
- # AST Session Loader v5.5.20
2
+ # AST Session Loader v5.5.22
3
3
  # Runs on IDE startup to initialize AST hooks, show context and check tokens
4
4
  REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo ".")
5
5
 
@@ -26,7 +26,7 @@ fi
26
26
  # Banner
27
27
  echo ""
28
28
  echo -e "${BLUE}╔══════════════════════════════════════════════════════════╗${NC}"
29
- echo -e "${BLUE}║ 🤖 AST Intelligence Hooks v5.5.20 ║${NC}"
29
+ echo -e "${BLUE}║ 🤖 AST Intelligence Hooks v5.5.22 ║${NC}"
30
30
  echo -e "${BLUE}║ Workspace Opened - Loading Context... ║${NC}"
31
31
  echo -e "${BLUE}╚══════════════════════════════════════════════════════════╝${NC}"
32
32
  echo ""
@@ -1,3 +1,79 @@
1
+ # Release Notes - v5.5.22
2
+
3
+ **Release Date**: January 4, 2026
4
+ **Type**: Critical Patch Release
5
+ **Compatibility**: Fully backward compatible with 5.5.x
6
+
7
+ ---
8
+
9
+ ## 🔴 CRITICAL Fix
10
+
11
+ ### Root Cause Analysis
12
+
13
+ The session-loader fork bomb was caused by an **architectural flaw** in the wrapper pattern:
14
+
15
+ ```
16
+ scripts/hooks-system/bin/session-loader.sh (WRAPPER)
17
+ → calls: bash "$REPO_ROOT/scripts/hooks-system/bin/session-loader.sh"
18
+ → which is THE SAME FILE
19
+ → INFINITE RECURSION → FORK BOMB
20
+ ```
21
+
22
+ ### Solution
23
+
24
+ Replaced the 6-line self-referential wrapper with the **complete 108-line implementation** directly in `scripts/hooks-system/bin/session-loader.sh`.
25
+
26
+ ### Impact
27
+
28
+ - **Before**: Any project installing the library would get the broken wrapper, causing fork bombs on IDE startup
29
+ - **After**: Projects get a fully working session-loader that displays context correctly
30
+
31
+ ---
32
+
33
+ ## 📦 Installation / Upgrade
34
+ ```bash
35
+ npm install --save-dev pumuki-ast-hooks@5.5.22
36
+ npm run install-hooks
37
+ ```
38
+
39
+ ---
40
+
41
+ # Release Notes - v5.5.21
42
+
43
+ **Release Date**: January 4, 2026
44
+ **Type**: Patch Release
45
+ **Compatibility**: Fully backward compatible with 5.5.x
46
+
47
+ ---
48
+
49
+ ## 🎯 Overview
50
+
51
+ This release fixes a critical fork bomb issue in the installer caused by wrapper scripts being copied to incorrect locations, preventing recursive calls that would exhaust system resources.
52
+
53
+ ---
54
+
55
+ ## 🐛 Bug Fixes
56
+
57
+ ### Fixed: Fork bomb in session-loader
58
+ - **Issue**: Wrapper scripts (`session-loader.sh`, `cli.js`, `install.js`) were copied from `/bin/` to `scripts/hooks-system/bin/`, causing them to call themselves recursively
59
+ - **Resolution**: Modified `FileSystemInstallerService` to exclude wrapper scripts when copying the `bin/` directory
60
+ - **Impact**: Session loader now works correctly without causing fork resource exhaustion or infinite loops
61
+
62
+ ### Technical Details
63
+ - Wrapper scripts in the library's `/bin/` directory are now excluded during installation
64
+ - This prevents the wrapper from being copied to the location where it would call itself
65
+ - Installation process is now safe and doesn't cause resource exhaustion
66
+
67
+ ---
68
+
69
+ ## 📦 Installation / Upgrade
70
+ ```bash
71
+ npm install --save-dev pumuki-ast-hooks@5.5.21
72
+ npm run install-hooks
73
+ ```
74
+
75
+ ---
76
+
1
77
  # Release Notes - v5.5.20
2
78
 
3
79
  **Release Date**: January 4, 2026
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki-ast-hooks",
3
- "version": "5.5.21",
3
+ "version": "5.5.23",
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": {
@@ -1,5 +1,107 @@
1
1
  #!/bin/bash
2
- # Script Wrapper
3
- # Redirects to the centralized implementation in scripts/hooks-system
2
+ # AST Session Loader v5.5.22
3
+ # Runs on IDE startup to initialize AST hooks, show context and check tokens
4
4
  REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo ".")
5
- bash "$REPO_ROOT/scripts/hooks-system/bin/session-loader.sh" "$@"
5
+
6
+ BLUE='\033[0;34m'
7
+ CYAN='\033[0;36m'
8
+ GREEN='\033[0;32m'
9
+ YELLOW='\033[1;33m'
10
+ MAGENTA='\033[0;35m'
11
+ NC='\033[0m'
12
+
13
+ EVIDENCE_FILE="$REPO_ROOT/.AI_EVIDENCE.json"
14
+ SESSION_FILE="$REPO_ROOT/.AI_SESSION_START.md"
15
+ TOKEN_STATUS="$REPO_ROOT/.audit_tmp/token-status.txt"
16
+ VIOLATIONS_REPORT="$REPO_ROOT/.audit_tmp/intelligent-report.txt"
17
+
18
+ TOKEN_TRACKER="$REPO_ROOT/scripts/hooks-system/infrastructure/watchdog/token-tracker.sh"
19
+ if [ -f "$TOKEN_TRACKER" ]; then
20
+ bash "$TOKEN_TRACKER"
21
+ fi
22
+
23
+ echo ""
24
+ echo -e "${BLUE}╔══════════════════════════════════════════════════════════╗${NC}"
25
+ echo -e "${BLUE}║ 🤖 AST Intelligence Hooks v5.5.22 ║${NC}"
26
+ echo -e "${BLUE}║ Workspace Opened - Loading Context... ║${NC}"
27
+ echo -e "${BLUE}╚══════════════════════════════════════════════════════════╝${NC}"
28
+ echo ""
29
+
30
+ CURRENT_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
31
+ echo -e "${CYAN}📍 Current Branch: ${MAGENTA}$CURRENT_BRANCH${NC}"
32
+ echo ""
33
+
34
+ echo -e "${CYAN}📝 Recent Commits:${NC}"
35
+ git log --oneline -3 2>/dev/null | sed 's/^/ /' || echo " No commits yet"
36
+ echo ""
37
+
38
+ if [[ -f "$EVIDENCE_FILE" ]]; then
39
+ CURRENT_SESSION_ID=$(jq -r '.session_id // empty' "$EVIDENCE_FILE" 2>/dev/null || echo "")
40
+ CURRENT_ACTION=$(jq -r '.action // empty' "$EVIDENCE_FILE" 2>/dev/null || echo "")
41
+ if [[ -n "$CURRENT_SESSION_ID" && "$CURRENT_SESSION_ID" != "null" ]]; then
42
+ echo -e "${CYAN}📖 Session Context:${NC}"
43
+ if [[ -n "$CURRENT_ACTION" && "$CURRENT_ACTION" != "null" ]]; then
44
+ echo " Session: $CURRENT_SESSION_ID - $CURRENT_ACTION"
45
+ else
46
+ echo " Session: $CURRENT_SESSION_ID"
47
+ fi
48
+ echo ""
49
+ fi
50
+ fi
51
+
52
+ if [[ -f "$VIOLATIONS_REPORT" ]]; then
53
+ echo -e "${CYAN}🎯 Top Violations (last audit):${NC}"
54
+ grep -E "CRITICAL|HIGH|MEDIUM|LOW" "$VIOLATIONS_REPORT" 2>/dev/null | head -5 | sed 's/^/ /' || echo " No violations found"
55
+ echo ""
56
+ elif [[ -f "$REPO_ROOT/.audit_tmp/ast-summary.json" ]]; then
57
+ echo -e "${CYAN}🎯 Violations Summary:${NC}"
58
+ CRITICAL=$(jq -r '.levels.CRITICAL // 0' "$REPO_ROOT/.audit_tmp/ast-summary.json" 2>/dev/null || echo "0")
59
+ HIGH=$(jq -r '.levels.HIGH // 0' "$REPO_ROOT/.audit_tmp/ast-summary.json" 2>/dev/null || echo "0")
60
+ MEDIUM=$(jq -r '.levels.MEDIUM // 0' "$REPO_ROOT/.audit_tmp/ast-summary.json" 2>/dev/null || echo "0")
61
+ LOW=$(jq -r '.levels.LOW // 0' "$REPO_ROOT/.audit_tmp/ast-summary.json" 2>/dev/null || echo "0")
62
+ echo " 🔴 CRITICAL: $CRITICAL 🟠 HIGH: $HIGH 🟡 MEDIUM: $MEDIUM 🔵 LOW: $LOW"
63
+ echo ""
64
+ fi
65
+
66
+ AGE=0
67
+ if [[ -f "$EVIDENCE_FILE" ]]; then
68
+ EVIDENCE_TS=$(jq -r '.timestamp' "$EVIDENCE_FILE" 2>/dev/null || echo "")
69
+ if [[ -n "$EVIDENCE_TS" ]] && [[ "$EVIDENCE_TS" != "null" ]]; then
70
+ CLEAN_TS=$(echo "$EVIDENCE_TS" | sed -E 's/\.[0-9]+([+-][0-9]{2}:[0-9]{2}|Z)$/\1/')
71
+
72
+ if [[ "$CLEAN_TS" =~ \+[0-9]{2}:[0-9]{2}$ ]] || [[ "$CLEAN_TS" =~ -[0-9]{2}:[0-9]{2}$ ]]; then
73
+ EVIDENCE_EPOCH=$(python3 -c "from datetime import datetime; import sys; dt = datetime.fromisoformat('$CLEAN_TS'); print(int(dt.timestamp()))" 2>/dev/null || echo "0")
74
+ elif [[ "$CLEAN_TS" =~ Z$ ]]; then
75
+ EVIDENCE_EPOCH=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$CLEAN_TS" +%s 2>/dev/null || echo "0")
76
+ else
77
+ EVIDENCE_EPOCH=0
78
+ fi
79
+
80
+ if [[ "$EVIDENCE_EPOCH" != "0" ]]; then
81
+ NOW_EPOCH=$(date +%s)
82
+ AGE=$((NOW_EPOCH - EVIDENCE_EPOCH))
83
+
84
+ if [[ $AGE -gt 180 ]]; then
85
+ echo -e "${YELLOW}⚠️ Evidence is stale (${AGE}s old, max 3min)${NC}"
86
+ echo -e "${YELLOW} Run: ai-start${NC}"
87
+ else
88
+ echo -e "${GREEN}✅ Evidence fresh (${AGE}s old)${NC}"
89
+ fi
90
+ echo ""
91
+ fi
92
+ fi
93
+ fi
94
+
95
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
96
+ echo -e "${CYAN}🚀 Quick Commands:${NC}"
97
+ echo " ai-start → Update evidence & start work"
98
+ echo " bash scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh → Full audit"
99
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
100
+ echo ""
101
+
102
+ if [[ $AGE -gt 180 ]]; then
103
+ echo -e "${YELLOW}⚠️ Run 'ai-start' to refresh evidence before working${NC}"
104
+ else
105
+ echo -e "${GREEN}✅ Session loaded - Ready to work!${NC}"
106
+ fi
107
+ echo ""
@@ -391,6 +391,16 @@ function updateAIEvidence(violations, gateResult, tokenUsage) {
391
391
  fs.writeFileSync(evidencePath, JSON.stringify(evidence, null, 2));
392
392
  console.log('[Intelligent Audit] ✅ .AI_EVIDENCE.json updated with complete format (ai_gate, severity_metrics, token_usage, git_flow, watchers)');
393
393
 
394
+ try {
395
+ const gateStatus = evidence.ai_gate.status;
396
+ const violationCount = evidence.severity_metrics.total_violations;
397
+ const notifTitle = gateStatus === 'BLOCKED' ? '🚨 AI Gate BLOCKED' : '✅ Evidence Updated';
398
+ const notifMsg = `Gate: ${gateStatus} | Violations: ${violationCount} | Tokens: ${tokenPercent}%`;
399
+ execSync(`osascript -e 'display notification "${notifMsg}" with title "${notifTitle}" sound name "Glass"'`, { stdio: 'ignore' });
400
+ } catch (notifErr) {
401
+ // Silent fail for non-macOS
402
+ }
403
+
394
404
  } catch (evidenceFileUpdateError) {
395
405
  process.stderr.write(`[Intelligent Audit] ⚠️ Evidence update failed: ${toErrorMessage(evidenceFileUpdateError)}\n`);
396
406
  }