pumuki-ast-hooks 5.3.2 → 5.3.4

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.
@@ -1 +1,7 @@
1
1
  {"timestamp":"2025-12-25T22:29:39.634Z","commit":"cce11ed7eb1e70da937d1443853ccb86f718fe95","branch":"feature/meta-audit-insights","summary":{"total":556,"CRITICAL":257,"HIGH":0,"MEDIUM":99,"LOW":200},"averageScore":50,"gatePassed":false,"blockedBy":"CRITICAL"}
2
+ {"timestamp":"2025-12-29T15:17:57.510Z","commit":"61b9945cfda1764f08f359ffed6228f4af1d7d92","branch":"fix/audit-staged-severity-case-insensitive","summary":{"total":546,"CRITICAL":0,"HIGH":0,"MEDIUM":0,"LOW":546},"averageScore":4,"gatePassed":true,"blockedBy":null}
3
+ {"timestamp":"2025-12-29T15:24:55.686Z","commit":"61b9945cfda1764f08f359ffed6228f4af1d7d92","branch":"fix/audit-staged-severity-case-insensitive","summary":{"total":546,"CRITICAL":0,"HIGH":0,"MEDIUM":0,"LOW":546},"averageScore":4,"gatePassed":true,"blockedBy":null}
4
+ {"timestamp":"2025-12-29T15:29:28.676Z","commit":"61b9945cfda1764f08f359ffed6228f4af1d7d92","branch":"fix/audit-staged-severity-case-insensitive","summary":{"total":546,"CRITICAL":0,"HIGH":0,"MEDIUM":0,"LOW":546},"averageScore":4,"gatePassed":true,"blockedBy":null}
5
+ {"timestamp":"2025-12-29T15:33:41.996Z","commit":"61b9945cfda1764f08f359ffed6228f4af1d7d92","branch":"fix/audit-staged-severity-case-insensitive","summary":{"total":546,"CRITICAL":0,"HIGH":0,"MEDIUM":0,"LOW":546},"averageScore":4,"gatePassed":true,"blockedBy":null}
6
+ {"timestamp":"2025-12-29T15:35:31.277Z","commit":"61b9945cfda1764f08f359ffed6228f4af1d7d92","branch":"fix/audit-staged-severity-case-insensitive","summary":{"total":546,"CRITICAL":0,"HIGH":0,"MEDIUM":0,"LOW":546},"averageScore":4,"gatePassed":true,"blockedBy":null}
7
+ {"timestamp":"2025-12-29T15:38:11.144Z","commit":"61b9945cfda1764f08f359ffed6228f4af1d7d92","branch":"fix/audit-staged-severity-case-insensitive","summary":{"total":546,"CRITICAL":0,"HIGH":0,"MEDIUM":0,"LOW":546},"averageScore":4,"gatePassed":true,"blockedBy":null}
@@ -1 +1,7 @@
1
1
  {"timestamp":"2025-12-25T22:29:39.685Z","estimated":555199.75,"percentUsed":55.519975,"remaining":444800.25}
2
+ {"timestamp":"2025-12-29T15:17:57.538Z","estimated":723658.5,"percentUsed":72.36585,"remaining":276341.5}
3
+ {"timestamp":"2025-12-29T15:24:55.714Z","estimated":723658.5,"percentUsed":72.36585,"remaining":276341.5}
4
+ {"timestamp":"2025-12-29T15:29:28.704Z","estimated":723658.5,"percentUsed":72.36585,"remaining":276341.5}
5
+ {"timestamp":"2025-12-29T15:33:42.024Z","estimated":723658.5,"percentUsed":72.36585,"remaining":276341.5}
6
+ {"timestamp":"2025-12-29T15:35:31.306Z","estimated":723658.5,"percentUsed":72.36585,"remaining":276341.5}
7
+ {"timestamp":"2025-12-29T15:38:11.174Z","estimated":723658.5,"percentUsed":72.36585,"remaining":276341.5}
@@ -28,6 +28,7 @@ async function runASTIntelligence() {
28
28
  const root = getRepoRoot();
29
29
 
30
30
  const isLibraryAudit = process.env.AUDIT_LIBRARY === 'true';
31
+
31
32
  const allFiles = listSourceFiles(root).filter(f => {
32
33
  const p = String(f || '').replace(/\\/g, '/');
33
34
  if (!isLibraryAudit && p.includes('/infrastructure/ast/')) return false;
@@ -534,19 +535,34 @@ function listSourceFiles(root) {
534
535
  if (process.env.STAGING_ONLY_MODE === "1") {
535
536
  const { execSync } = require("child_process");
536
537
  try {
537
- const stagedFiles = execSync("git diff --cached --name-only --diff-filter=ACM", {
538
+ const allStaged = execSync("git diff --cached --name-only --diff-filter=ACM", {
538
539
  encoding: "utf8",
539
540
  cwd: root
540
541
  })
541
542
  .trim()
542
543
  .split("\n")
543
- .filter(f => f.trim())
544
+ .filter(f => f.trim());
545
+
546
+ if (allStaged.length === 0) {
547
+ return [];
548
+ }
549
+
550
+ const stagedFiles = allStaged
544
551
  .map(f => path.resolve(root, f.trim()))
545
552
  .filter(f => {
546
553
  const ext = path.extname(f);
547
554
  return [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".swift", ".kt", ".kts"].includes(ext);
548
555
  })
549
556
  .filter(f => fs.existsSync(f) && !shouldIgnore(f.replace(/\\/g, "/")));
557
+
558
+ // Si hay staged files pero ninguno es compatible con AST
559
+ if (stagedFiles.length === 0 && allStaged.length > 0) {
560
+ console.error('\n⚠️ No AST-compatible files in staging area');
561
+ console.error(' Staged files found:', allStaged.length);
562
+ console.error(' AST analyzes: .ts, .tsx, .js, .jsx, .mjs, .cjs, .swift, .kt, .kts');
563
+ console.error(' Consider staging source code files or use option 2 for full repository analysis\n');
564
+ }
565
+
550
566
  return stagedFiles;
551
567
  } catch (error) {
552
568
  return [];
@@ -584,7 +600,9 @@ function listSourceFiles(root) {
584
600
  function shouldIgnore(file) {
585
601
  const p = file.replace(/\\/g, "/");
586
602
  if (p.includes("node_modules/")) return true;
603
+
587
604
  const isLibraryAudit = process.env.AUDIT_LIBRARY === 'true';
605
+
588
606
  if (!isLibraryAudit && p.includes("scripts/hooks-system/")) return true;
589
607
  if (!isLibraryAudit && p.includes("/infrastructure/ast/")) return true;
590
608
  if (p.includes("/.cursor/")) return true;
@@ -27,11 +27,18 @@ const { execSync } = require('child_process');
27
27
 
28
28
  const MCP_VERSION = '2024-11-05';
29
29
 
30
- // Configuration
31
- const CompositionRoot = require('../../application/CompositionRoot');
32
-
30
+ // Configuration - LAZY LOADING to avoid blocking MCP initialization
33
31
  const REPO_ROOT = process.env.REPO_ROOT || process.cwd();
34
- const compositionRoot = CompositionRoot.createForProduction(REPO_ROOT);
32
+
33
+ // Lazy-loaded CompositionRoot - only initialized when first needed
34
+ let _compositionRoot = null;
35
+ function getCompositionRoot() {
36
+ if (!_compositionRoot) {
37
+ const CompositionRoot = require('../../application/CompositionRoot');
38
+ _compositionRoot = CompositionRoot.createForProduction(REPO_ROOT);
39
+ }
40
+ return _compositionRoot;
41
+ }
35
42
 
36
43
  const EVIDENCE_FILE = path.join(REPO_ROOT, '.AI_EVIDENCE.json');
37
44
  const GITFLOW_STATE_FILE = path.join(REPO_ROOT, '.git', 'gitflow-state.json');
@@ -154,15 +161,15 @@ function resolveUpdateEvidenceScript() {
154
161
 
155
162
  // Lazy Loading Services
156
163
  function getContextEngine() {
157
- return compositionRoot.getContextDetectionEngine();
164
+ return getCompositionRoot().getContextDetectionEngine();
158
165
  }
159
166
 
160
167
  function getOrchestrator() {
161
- return compositionRoot.getOrchestrator();
168
+ return getCompositionRoot().getOrchestrator();
162
169
  }
163
170
 
164
171
  function getNotificationAdapter() {
165
- return compositionRoot.getNotificationService();
172
+ return getCompositionRoot().getNotificationService();
166
173
  }
167
174
 
168
175
  // Polling state
@@ -183,7 +190,7 @@ const AUTO_PR_ENABLED = process.env.AUTO_PR_ENABLED === 'true';
183
190
  * Helper: Send macOS notification via centralized adapter
184
191
  */
185
192
  function sendNotification(title, message, sound = 'Hero') {
186
- compositionRoot.getNotificationService().notify({
193
+ getCompositionRoot().getNotificationService().notify({
187
194
  type: 'mcp_automation',
188
195
  level: 'info',
189
196
  title,
@@ -196,9 +203,9 @@ function sendNotification(title, message, sound = 'Hero') {
196
203
  * Check evidence status
197
204
  */
198
205
  function checkEvidence() {
199
- const monitor = compositionRoot.getEvidenceMonitor();
206
+ const monitor = getCompositionRoot().getEvidenceMonitor();
200
207
  const isStale = monitor.isStale();
201
- const gitFlow = compositionRoot.getGitFlowService();
208
+ const gitFlow = getCompositionRoot().getGitFlowService();
202
209
  const currentBranch = gitFlow.getCurrentBranch();
203
210
 
204
211
  if (isStale) {
@@ -217,7 +224,7 @@ function checkEvidence() {
217
224
  * Auto-complete Git Flow cycle
218
225
  */
219
226
  async function autoCompleteGitFlow(params) {
220
- const gitFlowService = compositionRoot.getGitFlowService();
227
+ const gitFlowService = getCompositionRoot().getGitFlowService();
221
228
  const results = [];
222
229
  const currentBranch = gitFlowService.getCurrentBranch();
223
230
  const baseBranch = process.env.AST_BASE_BRANCH || 'develop';
@@ -235,7 +242,7 @@ async function autoCompleteGitFlow(params) {
235
242
 
236
243
  if (!gitFlowService.isClean()) {
237
244
  results.push('⚠️ Uncommitted changes detected, committing...');
238
- const gitCommand = compositionRoot.getGitCommandAdapter();
245
+ const gitCommand = getCompositionRoot().getGitCommandAdapter();
239
246
  gitCommand.addAll();
240
247
  const message = params.commitMessage || `chore: auto-commit changes on ${currentBranch}`;
241
248
  gitCommand.commit(message);
@@ -245,7 +252,7 @@ async function autoCompleteGitFlow(params) {
245
252
  }
246
253
 
247
254
  results.push('Pushing to origin...');
248
- const gitCommand = compositionRoot.getGitCommandAdapter();
255
+ const gitCommand = getCompositionRoot().getGitCommandAdapter();
249
256
  gitCommand.push('origin', currentBranch, { setUpstream: true });
250
257
  results.push('✅ Pushed to origin');
251
258
 
@@ -260,7 +267,7 @@ async function autoCompleteGitFlow(params) {
260
267
 
261
268
  if (params.autoMerge) {
262
269
  results.push('Auto-merging PR...');
263
- const github = compositionRoot.getGitHubAdapter();
270
+ const github = getCompositionRoot().getGitHubAdapter();
264
271
  github.mergePullRequest(prUrl);
265
272
  results.push(`✅ PR merged and branch deleted`);
266
273
 
@@ -295,7 +302,7 @@ async function autoCompleteGitFlow(params) {
295
302
  * Sync branches (develop ↔ main)
296
303
  */
297
304
  function syncBranches(params) {
298
- const gitFlowService = compositionRoot.getGitFlowService();
305
+ const gitFlowService = getCompositionRoot().getGitFlowService();
299
306
  const result = gitFlowService.syncBranches();
300
307
 
301
308
  return {
@@ -309,11 +316,11 @@ function syncBranches(params) {
309
316
  * Cleanup stale branches (local + remote)
310
317
  */
311
318
  function cleanupStaleBranches(params) {
312
- const gitFlowService = compositionRoot.getGitFlowService();
319
+ const gitFlowService = getCompositionRoot().getGitFlowService();
313
320
  const baseBranch = process.env.AST_BASE_BRANCH || 'develop';
314
- const gitQuery = compositionRoot.getGitQueryAdapter();
315
- const gitCommand = compositionRoot.getGitCommandAdapter();
316
- const github = compositionRoot.getGitHubAdapter();
321
+ const gitQuery = getCompositionRoot().getGitQueryAdapter();
322
+ const gitCommand = getCompositionRoot().getGitCommandAdapter();
323
+ const github = getCompositionRoot().getGitHubAdapter();
317
324
 
318
325
  const results = [];
319
326
 
@@ -367,7 +374,7 @@ function cleanupStaleBranches(params) {
367
374
  * Auto-execute ai-start when code files detected
368
375
  */
369
376
  async function autoExecuteAIStart(params) {
370
- const useCase = compositionRoot.getAutoExecuteAIStartUseCase();
377
+ const useCase = getCompositionRoot().getAutoExecuteAIStartUseCase();
371
378
 
372
379
  try {
373
380
  const result = await useCase.execute({
@@ -503,8 +510,8 @@ function checkBranchChangesCoherence(branchName, uncommittedChanges) {
503
510
  * Returns BLOCKED or ALLOWED status with auto-fixes applied
504
511
  */
505
512
  async function aiGateCheck() {
506
- const gitFlowService = compositionRoot.getGitFlowService();
507
- const gitQuery = compositionRoot.getGitQueryAdapter();
513
+ const gitFlowService = getCompositionRoot().getGitFlowService();
514
+ const gitQuery = getCompositionRoot().getGitQueryAdapter();
508
515
  const currentBranch = getCurrentGitBranch(REPO_ROOT);
509
516
  const isProtectedBranch = ['main', 'master', 'develop'].includes(currentBranch);
510
517
 
@@ -516,7 +523,7 @@ async function aiGateCheck() {
516
523
  const autoFixes = [];
517
524
 
518
525
  // 1. Evidence Freshness Check (Auto-fix included)
519
- const evidenceMonitor = compositionRoot.getEvidenceMonitor();
526
+ const evidenceMonitor = getCompositionRoot().getEvidenceMonitor();
520
527
  if (evidenceMonitor.isStale()) {
521
528
  try {
522
529
  await evidenceMonitor.refresh();
@@ -541,8 +548,8 @@ async function aiGateCheck() {
541
548
  }
542
549
 
543
550
  // 3. Block Commit Use Case Integration
544
- const blockCommitUseCase = compositionRoot.getBlockCommitUseCase();
545
- const astAdapter = compositionRoot.getAstAdapter();
551
+ const blockCommitUseCase = getCompositionRoot().getBlockCommitUseCase();
552
+ const astAdapter = getCompositionRoot().getAstAdapter();
546
553
 
547
554
  try {
548
555
  const auditResult = await astAdapter.analyzeStagedFiles();
@@ -581,10 +588,10 @@ async function aiGateCheck() {
581
588
  async function validateAndFix(params) {
582
589
  const results = [];
583
590
  const issues = [];
584
- const gitFlowService = compositionRoot.getGitFlowService();
585
- const gitQuery = compositionRoot.getGitQueryAdapter();
586
- const gitCommand = compositionRoot.getGitCommandAdapter();
587
- const evidenceMonitor = compositionRoot.getEvidenceMonitor();
591
+ const gitFlowService = getCompositionRoot().getGitFlowService();
592
+ const gitQuery = getCompositionRoot().getGitQueryAdapter();
593
+ const gitCommand = getCompositionRoot().getGitCommandAdapter();
594
+ const evidenceMonitor = getCompositionRoot().getEvidenceMonitor();
588
595
 
589
596
  try {
590
597
  if (evidenceMonitor.isStale()) {
@@ -633,9 +640,10 @@ async function validateAndFix(params) {
633
640
  }
634
641
 
635
642
  /**
636
- * MCP Protocol Handler
643
+ * MCP Protocol Handler - Direct instantiation to avoid blocking on CompositionRoot
637
644
  */
638
- const protocolHandler = compositionRoot.getMcpProtocolHandler(process.stdin, process.stdout);
645
+ const McpProtocolHandler = require('./services/McpProtocolHandler');
646
+ const protocolHandler = new McpProtocolHandler(process.stdin, process.stdout);
639
647
 
640
648
  async function handleMcpMessage(message) {
641
649
  try {
@@ -749,8 +757,8 @@ async function handleMcpMessage(message) {
749
757
  }
750
758
 
751
759
  if (uri === 'gitflow://state') {
752
- const gitFlow = compositionRoot.getGitFlowService();
753
- const gitQuery = compositionRoot.getGitQueryAdapter();
760
+ const gitFlow = getCompositionRoot().getGitFlowService();
761
+ const gitQuery = getCompositionRoot().getGitQueryAdapter();
754
762
  const currentBranch = getCurrentGitBranch(REPO_ROOT);
755
763
  const branchState = getBranchStateSafe(gitQuery, REPO_ROOT, currentBranch);
756
764
 
@@ -776,7 +784,7 @@ async function handleMcpMessage(message) {
776
784
  }
777
785
 
778
786
  if (uri === 'context://active') {
779
- const orchestrator = compositionRoot.getOrchestrator();
787
+ const orchestrator = getCompositionRoot().getOrchestrator();
780
788
  try {
781
789
  const decision = await orchestrator.analyzeContext();
782
790
  return {
@@ -938,10 +946,10 @@ protocolHandler.start(handleMcpMessage);
938
946
  setInterval(async () => {
939
947
  try {
940
948
  const now = Date.now();
941
- const gitFlowService = compositionRoot.getGitFlowService();
942
- const gitQuery = compositionRoot.getGitQueryAdapter();
943
- const evidenceMonitor = compositionRoot.getEvidenceMonitor();
944
- const orchestrator = compositionRoot.getOrchestrator();
949
+ const gitFlowService = getCompositionRoot().getGitFlowService();
950
+ const gitQuery = getCompositionRoot().getGitQueryAdapter();
951
+ const evidenceMonitor = getCompositionRoot().getEvidenceMonitor();
952
+ const orchestrator = getCompositionRoot().getOrchestrator();
945
953
 
946
954
  const currentBranch = gitFlowService.getCurrentBranch();
947
955
  const baseBranch = process.env.AST_BASE_BRANCH || 'develop';
@@ -1002,9 +1010,9 @@ setInterval(async () => {
1002
1010
  if (now - lastAutoCommitTime < AUTO_COMMIT_INTERVAL) return;
1003
1011
 
1004
1012
  try {
1005
- const gitFlowService = compositionRoot.getGitFlowService();
1006
- const gitQuery = compositionRoot.getGitQueryAdapter();
1007
- const gitCommand = compositionRoot.getGitCommandAdapter();
1013
+ const gitFlowService = getCompositionRoot().getGitFlowService();
1014
+ const gitQuery = getCompositionRoot().getGitQueryAdapter();
1015
+ const gitCommand = getCompositionRoot().getGitCommandAdapter();
1008
1016
 
1009
1017
  const currentBranch = gitFlowService.getCurrentBranch();
1010
1018
  const isFeatureBranch = currentBranch.match(/^(feature|fix|hotfix)\//);
@@ -218,6 +218,8 @@ full_audit_strict_repo_and_staging() {
218
218
  export AUDIT_STRICT=1
219
219
  export BLOCK_ALL_SEVERITIES=1
220
220
  export BLOCK_ON_REPO_VIOLATIONS=1
221
+ export AUDIT_LIBRARY=true
222
+ unset STAGING_ONLY_MODE
221
223
  full_audit
222
224
  }
223
225
 
@@ -335,6 +337,9 @@ full_audit_standard() {
335
337
  compute_staged_summary() {
336
338
  if ! command -v git >/dev/null 2>&1; then return; fi
337
339
  local staged_file="$TMP_DIR/staged.txt"
340
+ local staged_file_rel="$TMP_DIR/staged-rel.txt"
341
+ # Store both absolute and relative paths for different matching needs
342
+ git diff --cached --name-only --diff-filter=ACM > "$staged_file_rel" || true
338
343
  git diff --cached --name-only --diff-filter=ACM | sed "s|^|$ROOT_DIR/|" > "$staged_file" || true
339
344
  if [[ ! -s "$staged_file" ]]; then return; fi
340
345
  printf "\n%bStaging Area%b\n" "$YELLOW" "$NC"
@@ -350,15 +355,22 @@ compute_staged_summary() {
350
355
 
351
356
  if [[ -f "$TMP_DIR/ast-summary.json" ]] && command -v jq >/dev/null 2>&1; then
352
357
  local scrit=0 shigh=0 smed=0 slow=0
353
- while IFS= read -r fpath; do
354
- [[ -z "$fpath" ]] && continue
355
- local ccrit chigh cmed clow
356
- ccrit=$(jq -r --arg p "$fpath" '[ .findings[] | select(.filePath == $p) | .severity | ascii_downcase | if .=="critical" or .=="error" then 1 else 0 end ] | add // 0' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
357
- chigh=$(jq -r --arg p "$fpath" '[ .findings[] | select(.filePath == $p) | .severity | ascii_downcase | if .=="high" then 1 else 0 end ] | add // 0' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
358
- cmed=$(jq -r --arg p "$fpath" '[ .findings[] | select(.filePath == $p) | .severity | ascii_downcase | if .=="warning" or .=="medium" then 1 else 0 end ] | add // 0' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
359
- clow=$(jq -r --arg p "$fpath" '[ .findings[] | select(.filePath == $p) | .severity | ascii_downcase | if .=="info" or .=="low" then 1 else 0 end ] | add // 0' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
360
- scrit=$((scrit + ccrit)); shigh=$((shigh + chigh)); smed=$((smed + cmed)); slow=$((slow + clow))
361
- done < "$staged_file"
358
+ local total_findings=$(jq -r '.findings | length' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
359
+
360
+ if [[ "$total_findings" -gt 0 ]] && [[ -s "$staged_file_rel" ]]; then
361
+ # Use relative paths for matching - more reliable across different path formats
362
+ while IFS= read -r relpath; do
363
+ [[ -z "$relpath" ]] && continue
364
+ local ccrit chigh cmed clow
365
+ # Match using 'endswith' with relative path OR exact match with absolute path
366
+ local abs_path="$ROOT_DIR/$relpath"
367
+ ccrit=$(jq -r --arg rel "$relpath" --arg abs "$abs_path" '[ .findings[] | select((.filePath | endswith($rel)) or .filePath == $abs) | .severity | ascii_downcase | if .=="critical" or .=="error" then 1 else 0 end ] | add // 0' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
368
+ chigh=$(jq -r --arg rel "$relpath" --arg abs "$abs_path" '[ .findings[] | select((.filePath | endswith($rel)) or .filePath == $abs) | .severity | ascii_downcase | if .=="high" then 1 else 0 end ] | add // 0' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
369
+ cmed=$(jq -r --arg rel "$relpath" --arg abs "$abs_path" '[ .findings[] | select((.filePath | endswith($rel)) or .filePath == $abs) | .severity | ascii_downcase | if .=="warning" or .=="medium" then 1 else 0 end ] | add // 0' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
370
+ clow=$(jq -r --arg rel "$relpath" --arg abs "$abs_path" '[ .findings[] | select((.filePath | endswith($rel)) or .filePath == $abs) | .severity | ascii_downcase | if .=="info" or .=="low" then 1 else 0 end ] | add // 0' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
371
+ scrit=$((scrit + ccrit)); shigh=$((shigh + chigh)); smed=$((smed + cmed)); slow=$((slow + clow))
372
+ done < "$staged_file_rel"
373
+ fi
362
374
  printf " Staged AST → 🔴 CRITICAL:%s 🟠 HIGH:%s 🟡 MEDIUM:%s 🔵 LOW:%s\n" "${scrit:-0}" "${shigh:-0}" "${smed:-0}" "${slow:-0}"
363
375
  export STAGED_CRIT=${scrit:-0}
364
376
  export STAGED_HIGH=${shigh:-0}
@@ -999,9 +1011,9 @@ run_ast_intelligence() {
999
1011
  # Execute AST with proper error handling and NODE_PATH
1000
1012
  # Change to HOOKS_SYSTEM_DIR so Node.js resolves modules correctly
1001
1013
  if [[ -n "$node_path_value" ]]; then
1002
- ast_output=$(cd "$HOOKS_SYSTEM_DIR" && export NODE_PATH="$node_path_value" && export AUDIT_TMP="$TMP_DIR" && "$node_bin" "${AST_DIR}/ast-intelligence.js" 2>&1) || ast_exit_code=$?
1014
+ ast_output=$(cd "$HOOKS_SYSTEM_DIR" && export NODE_PATH="$node_path_value" && export AUDIT_TMP="$TMP_DIR" && export AUDIT_LIBRARY="${AUDIT_LIBRARY:-false}" && "$node_bin" "${AST_DIR}/ast-intelligence.js" 2>&1) || ast_exit_code=$?
1003
1015
  else
1004
- ast_output=$(cd "$HOOKS_SYSTEM_DIR" && export AUDIT_TMP="$TMP_DIR" && "$node_bin" "${AST_DIR}/ast-intelligence.js" 2>&1) || ast_exit_code=$?
1016
+ ast_output=$(cd "$HOOKS_SYSTEM_DIR" && export AUDIT_TMP="$TMP_DIR" && export AUDIT_LIBRARY="${AUDIT_LIBRARY:-false}" && "$node_bin" "${AST_DIR}/ast-intelligence.js" 2>&1) || ast_exit_code=$?
1005
1017
  fi
1006
1018
 
1007
1019
  # Check if AST script failed