pumuki-ast-hooks 5.5.29 → 5.5.31

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.29",
3
+ "version": "5.5.31",
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": {
@@ -79,12 +79,19 @@ class GitEnvironmentService {
79
79
  return;
80
80
  }
81
81
 
82
+ // Install pre-commit hook
82
83
  const preCommitHook = this.getPreCommitHookContent();
83
84
  const preCommitPath = path.join(gitHooksDir, 'pre-commit');
84
-
85
85
  fs.writeFileSync(preCommitPath, preCommitHook);
86
86
  fs.chmodSync(preCommitPath, '755');
87
87
  this.logSuccess(' ✅ Installed pre-commit hook');
88
+
89
+ // Install pre-push hook (Git Flow enforcement)
90
+ const prePushHook = this.getPrePushHookContent();
91
+ const prePushPath = path.join(gitHooksDir, 'pre-push');
92
+ fs.writeFileSync(prePushPath, prePushHook);
93
+ fs.chmodSync(prePushPath, '755');
94
+ this.logSuccess(' ✅ Installed pre-push hook (Git Flow enforcement)');
88
95
  }
89
96
 
90
97
  getPreCommitHookContent() {
@@ -146,6 +153,107 @@ fi
146
153
 
147
154
  # Fallback: direct execution logic here...
148
155
  echo "⚠️ ast-intelligence-hooks not found"
156
+ exit 0
157
+ `;
158
+ }
159
+
160
+ getPrePushHookContent() {
161
+ return `#!/bin/bash
162
+ # AST Intelligence Hooks - Pre-push (Git Flow Enforcement)
163
+ # Auto-generated by pumuki-ast-hooks v${this.version}
164
+
165
+ # Check for bypass
166
+ if [[ -n "\${GIT_BYPASS_HOOK}" ]]; then
167
+ echo "⚠️ Bypassing Git Flow enforcement (GIT_BYPASS_HOOK=1)"
168
+ exit 0
169
+ fi
170
+
171
+ # Change to project root
172
+ cd "$(git rev-parse --show-toplevel)" || exit 1
173
+
174
+ # Check if we're pushing only tags (read from stdin)
175
+ while read local_ref local_sha remote_ref remote_sha; do
176
+ # If pushing a tag (refs/tags/*), allow it
177
+ if [[ "$local_ref" =~ ^refs/tags/ ]]; then
178
+ echo ""
179
+ echo "✅ Tag push detected - allowing release workflow"
180
+ echo ""
181
+ exit 0
182
+ fi
183
+ done
184
+
185
+ echo ""
186
+ echo "🔍 Validating Git Flow compliance before push..."
187
+ echo ""
188
+
189
+ # Get current branch
190
+ CURRENT_BRANCH=$(git branch --show-current 2>/dev/null || echo "")
191
+
192
+ if [[ -z "$CURRENT_BRANCH" ]]; then
193
+ echo "❌ Detached HEAD - cannot validate Git Flow"
194
+ exit 1
195
+ fi
196
+
197
+ # Protected branches - cannot push directly
198
+ PROTECTED_BRANCHES=("main" "master" "develop")
199
+ for protected in "\${PROTECTED_BRANCHES[@]}"; do
200
+ if [[ "$CURRENT_BRANCH" == "$protected" ]]; then
201
+ echo "❌ Cannot push directly to protected branch: $CURRENT_BRANCH"
202
+ echo ""
203
+ echo "Create a feature branch instead:"
204
+ echo " git checkout -b feature/my-feature"
205
+ echo ""
206
+ exit 1
207
+ fi
208
+ done
209
+
210
+ # Validate branch naming convention
211
+ if [[ ! "$CURRENT_BRANCH" =~ ^(feature|fix|hotfix|chore|docs|refactor|test|ci)/ ]]; then
212
+ echo "⚠️ Branch name '$CURRENT_BRANCH' doesn't follow Git Flow convention"
213
+ echo ""
214
+ echo "Expected patterns:"
215
+ echo " feature/description"
216
+ echo " fix/description"
217
+ echo " hotfix/description"
218
+ echo " chore/description"
219
+ echo ""
220
+ echo "This is a WARNING - push will continue"
221
+ echo ""
222
+ fi
223
+
224
+ # Check evidence freshness (optional - warn only)
225
+ EVIDENCE_FILE=".AI_EVIDENCE.json"
226
+ if [[ -f "$EVIDENCE_FILE" ]]; then
227
+ EVIDENCE_TS=$(jq -r '.timestamp // .severity_metrics.last_updated // empty' "$EVIDENCE_FILE" 2>/dev/null || echo "")
228
+ if [[ -n "$EVIDENCE_TS" ]]; then
229
+ # Parse timestamp and check age
230
+ CLEAN_TS=$(echo "$EVIDENCE_TS" | sed 's/\\.[0-9]*Z$/Z/')
231
+ EVIDENCE_EPOCH=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$CLEAN_TS" +%s 2>/dev/null || echo "0")
232
+ NOW_EPOCH=$(date +%s)
233
+ AGE=$((NOW_EPOCH - EVIDENCE_EPOCH))
234
+
235
+ if [[ $AGE -gt 300 ]]; then
236
+ echo "⚠️ Evidence is stale (\${AGE}s old, recommended <5min)"
237
+ echo " Consider running: npm run ast:refresh"
238
+ echo ""
239
+ fi
240
+ fi
241
+ fi
242
+
243
+ # Run gitflow-enforcer if available (optional validation)
244
+ ENFORCER_SCRIPT="scripts/hooks-system/infrastructure/shell/gitflow/gitflow-enforcer.sh"
245
+ if [[ -f "$ENFORCER_SCRIPT" ]]; then
246
+ if ! bash "$ENFORCER_SCRIPT" check 2>/dev/null; then
247
+ echo ""
248
+ echo "⚠️ Git Flow check completed with warnings (non-blocking)"
249
+ echo ""
250
+ fi
251
+ fi
252
+
253
+ echo ""
254
+ echo "✅ Git Flow validation passed. Proceeding with push..."
255
+ echo ""
256
+
149
257
  exit 0
150
258
  `;
151
259
  }
@@ -43,6 +43,10 @@ function getInstalledVersion() {
43
43
  return { version: pkg.version, type: 'npm', path: packageRoot, packageName };
44
44
  } catch (err) {
45
45
  // Try next package name
46
+ const error = err && err.message ? err.message : String(err);
47
+ if (process.env.DEBUG) {
48
+ console.warn(`[check-version] Failed to resolve ${packageName}: ${error}`);
49
+ }
46
50
  }
47
51
  }
48
52
 
@@ -44,6 +44,10 @@ class KotlinParser {
44
44
  { encoding: 'utf-8', stdio: 'pipe' }
45
45
  );
46
46
  } catch (error) {
47
+ const errorMsg = error && error.message ? error.message : String(error);
48
+ if (process.env.DEBUG) {
49
+ console.warn(`[kotlin-parser] Detekt execution failed for ${filePath}: ${errorMsg}`);
50
+ }
47
51
  }
48
52
 
49
53
  if (!fs.existsSync(tmpXml)) {
@@ -570,7 +570,10 @@ function sendAuditNotification(totalViolations, levelTotals) {
570
570
  level
571
571
  });
572
572
  } catch (error) {
573
- // Silent fail - notifications are optional
573
+ const errorMsg = error && error.message ? error.message : String(error);
574
+ if (process.env.DEBUG) {
575
+ console.warn(`[ast-intelligence] Notification failed (optional): ${errorMsg}`);
576
+ }
574
577
  }
575
578
  }
576
579
 
@@ -157,7 +157,10 @@ function getBranchStateSafe(gitQuery, repoRoot, branch) {
157
157
  try {
158
158
  return gitQuery.getBranchState(branch);
159
159
  } catch (error) {
160
- // Fall through to CLI-based state
160
+ const errorMsg = error && error.message ? error.message : String(error);
161
+ if (process.env.DEBUG) {
162
+ console.warn(`[ast-intelligence-automation] gitQuery.getBranchState failed, falling through to CLI: ${errorMsg}`);
163
+ }
161
164
  }
162
165
  }
163
166