pumuki-ast-hooks 5.3.4 → 5.3.6

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
@@ -5,11 +5,27 @@
5
5
  <h1 align="center">@pumuki/ast-intelligence-hooks</h1>
6
6
 
7
7
  <p align="center">
8
- <a href="https://www.npmjs.com/package/@pumuki/ast-intelligence-hooks"><img src="https://img.shields.io/npm/v/@pumuki/ast-intelligence-hooks.svg?label=npm" alt="npm version" /></a>
9
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
10
- <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg" alt="Node.js Version" /></a>
11
- <a href="https://www.npmjs.com/"><img src="https://img.shields.io/badge/npm-%3E%3D9.0.0-red.svg" alt="npm" /></a>
12
- <img src="https://img.shields.io/badge/platforms-iOS%20%7C%20Android%20%7C%20Backend%20%7C%20Frontend-blue.svg" alt="Platforms" />
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
+ <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
+ <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-%3E%3D18.0.0-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-%3E%3D9.0.0-red.svg?style=flat-square&logo=npm" alt="npm" /></a>
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
+ <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
+ <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>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <strong>Enterprise-grade AST Intelligence System for multi-platform code quality enforcement</strong>
20
+ </p>
21
+
22
+ <p align="center">
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>
13
29
  </p>
14
30
 
15
31
  ### Visual Overview
@@ -0,0 +1,121 @@
1
+ # Migration Guide: 5.3.3 → 5.3.4
2
+
3
+ ## Overview
4
+
5
+ Version 5.3.4 is a **patch release** that fixes critical bugs in the audit orchestrator. This release is **fully backward compatible** and requires no code changes.
6
+
7
+ ## What's Fixed
8
+
9
+ ### 1. Audit Option 2 (Strict REPO+STAGING)
10
+
11
+ **Problem**: Option 2 was incorrectly analyzing only staged files instead of the entire repository.
12
+
13
+ **Fix**:
14
+ - Added `unset STAGING_ONLY_MODE` to ensure full repository scan
15
+ - Added `export AUDIT_LIBRARY=true` to include library files in analysis
16
+ - Fixed environment variable propagation to Node.js process
17
+
18
+ **Impact**: You'll now see the correct number of violations for your entire repository.
19
+
20
+ ### 2. Staged File Detection
21
+
22
+ **Problem**: Violations in staged files were not being correctly matched due to path format differences.
23
+
24
+ **Fix**: Enhanced `compute_staged_summary` to use relative paths for more robust matching.
25
+
26
+ **Impact**: Better accuracy in detecting violations in staged files.
27
+
28
+ ## Upgrade Instructions
29
+
30
+ ### Step 1: Update the Package
31
+
32
+ ```bash
33
+ npm install @pumuki/ast-intelligence-hooks@5.3.4
34
+ ```
35
+
36
+ ### Step 2: Reinstall Hooks (Recommended)
37
+
38
+ ```bash
39
+ npm run install-hooks
40
+ ```
41
+
42
+ This ensures you have the latest orchestrator scripts.
43
+
44
+ ### Step 3: Verify Installation
45
+
46
+ ```bash
47
+ npx ast-check-version
48
+ ```
49
+
50
+ Expected output:
51
+ ```
52
+ Installed version: 5.3.4 (npm)
53
+ Latest: 5.3.4
54
+ ✅ You're up to date!
55
+ ```
56
+
57
+ ## Testing the Update
58
+
59
+ ### Test Option 2 (Full Repository Audit)
60
+
61
+ ```bash
62
+ # Run the audit menu
63
+ npm run audit
64
+
65
+ # Select option 2: "Strict REPO+STAGING"
66
+ ```
67
+
68
+ **Expected behavior**:
69
+ - Should scan ALL files in your repository (not just staged)
70
+ - Should report significantly more violations than before (if you had issues with 5.3.3)
71
+ - Should include violations from library files if `AUDIT_LIBRARY=true`
72
+
73
+ ### Test Option 3 (Staging Only)
74
+
75
+ ```bash
76
+ # Stage some files
77
+ git add src/some-file.ts
78
+
79
+ # Run audit and select option 3
80
+ npm run audit
81
+ ```
82
+
83
+ **Expected behavior**:
84
+ - Should only analyze staged files
85
+ - Should show informative message if no AST-compatible files are staged
86
+ - Should correctly detect violations in staged files
87
+
88
+ ## Breaking Changes
89
+
90
+ **None**. This is a patch release with full backward compatibility.
91
+
92
+ ## Known Issues
93
+
94
+ None reported for 5.3.4.
95
+
96
+ ## Rollback Instructions
97
+
98
+ If you need to rollback to 5.3.3:
99
+
100
+ ```bash
101
+ npm install @pumuki/ast-intelligence-hooks@5.3.3
102
+ npm run install-hooks
103
+ ```
104
+
105
+ ## Support
106
+
107
+ - **Issues**: https://github.com/SwiftEnProfundidad/ast-intelligence-hooks/issues
108
+ - **Discussions**: https://github.com/SwiftEnProfundidad/ast-intelligence-hooks/discussions
109
+ - **Email**: freelancemerlos@gmail.com
110
+
111
+ ## Next Steps
112
+
113
+ After upgrading, we recommend:
114
+
115
+ 1. Run a full audit on your repository (Option 2)
116
+ 2. Review and fix any newly detected violations
117
+ 3. Commit your fixes with proper conventional commit messages
118
+
119
+ ---
120
+
121
+ **Thank you for using @pumuki/ast-intelligence-hooks!** 🚀
@@ -0,0 +1,170 @@
1
+ # Release Notes - v5.3.4
2
+
3
+ **Release Date**: December 29, 2025
4
+ **Type**: Patch Release
5
+ **Compatibility**: Fully backward compatible with 5.3.x
6
+
7
+ ---
8
+
9
+ ## 🎯 Overview
10
+
11
+ Version 5.3.4 addresses critical bugs in the audit orchestrator that were preventing correct analysis of repository files. This patch ensures that audit options work as intended and provide accurate violation reports.
12
+
13
+ ---
14
+
15
+ ## 🐛 Bug Fixes
16
+
17
+ ### Fixed: Audit Option 2 Analyzing Only Staged Files
18
+
19
+ **Issue**: Option 2 (Strict REPO+STAGING) was incorrectly configured with `STAGING_ONLY_MODE=1`, causing it to analyze only staged files instead of the entire repository.
20
+
21
+ **Impact**: Users running full repository audits were only seeing violations from staged files, missing thousands of potential issues in the codebase.
22
+
23
+ **Resolution**:
24
+ - Added `unset STAGING_ONLY_MODE` in `full_audit_strict_repo_and_staging()` function
25
+ - Added `export AUDIT_LIBRARY=true` to include library files in analysis
26
+ - Fixed environment variable propagation to Node.js subprocess
27
+
28
+ **Files Changed**:
29
+ - `scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh`
30
+
31
+ **Verification**:
32
+ ```bash
33
+ # Before: Only staged files analyzed
34
+ npm run audit # Option 2 → ~376 files, ~546 violations
35
+
36
+ # After: Full repository analyzed
37
+ npm run audit # Option 2 → All files, correct violation count
38
+ ```
39
+
40
+ ---
41
+
42
+ ### Fixed: AUDIT_LIBRARY Not Passed to Node.js Process
43
+
44
+ **Issue**: The `AUDIT_LIBRARY` environment variable was set in the shell but not exported to the Node.js subprocess executing `ast-intelligence.js`.
45
+
46
+ **Impact**: When auditing the library itself, files in `scripts/hooks-system/` were being incorrectly filtered out.
47
+
48
+ **Resolution**:
49
+ - Modified `run_ast_intelligence()` to explicitly export `AUDIT_LIBRARY` when spawning Node.js process
50
+ - Ensured variable is available in both execution paths (with and without `NODE_PATH`)
51
+
52
+ **Files Changed**:
53
+ - `scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh` (lines 1014, 1016)
54
+
55
+ ---
56
+
57
+ ### Improved: Staged File Path Matching
58
+
59
+ **Issue**: Violations in staged files were not being correctly matched due to differences between absolute and relative path formats.
60
+
61
+ **Impact**: Staged file summary showed incorrect violation counts.
62
+
63
+ **Resolution**:
64
+ - Enhanced `compute_staged_summary()` to use both relative and absolute paths for matching
65
+ - Implemented more robust path comparison using `endswith()` logic
66
+ - Added `staged-rel.txt` for relative path storage
67
+
68
+ **Files Changed**:
69
+ - `scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh` (lines 337-370)
70
+
71
+ ---
72
+
73
+ ## 🔧 Improvements
74
+
75
+ ### Enhanced Error Messages
76
+
77
+ - Improved informative messages when no AST-compatible files are staged (Option 3)
78
+ - Better debug output for troubleshooting audit issues
79
+
80
+ ### Code Quality
81
+
82
+ - Cleaned up debug console.log statements
83
+ - Improved code organization in audit orchestrator
84
+
85
+ ---
86
+
87
+ ## 📦 Installation
88
+
89
+ ### New Installation
90
+
91
+ ```bash
92
+ npm install --save-dev @pumuki/ast-intelligence-hooks@5.3.4
93
+ npm run install-hooks
94
+ ```
95
+
96
+ ### Upgrade from 5.3.3
97
+
98
+ ```bash
99
+ npm install --save-dev @pumuki/ast-intelligence-hooks@5.3.4
100
+ npm run install-hooks # Recommended to update orchestrator scripts
101
+ ```
102
+
103
+ See [Migration Guide](./MIGRATION_5.3.4.md) for detailed upgrade instructions.
104
+
105
+ ---
106
+
107
+ ## ✅ Verification
108
+
109
+ After upgrading, verify the fixes:
110
+
111
+ ### Test 1: Full Repository Audit (Option 2)
112
+
113
+ ```bash
114
+ npm run audit
115
+ # Select option 2: "Strict REPO+STAGING"
116
+ ```
117
+
118
+ **Expected**: Should analyze ALL files in repository, not just staged files.
119
+
120
+ ### Test 2: Staging Only Audit (Option 3)
121
+
122
+ ```bash
123
+ git add src/some-file.ts
124
+ npm run audit
125
+ # Select option 3: "Strict STAGING only"
126
+ ```
127
+
128
+ **Expected**: Should analyze only staged files and show correct violations.
129
+
130
+ ---
131
+
132
+ ## 🔄 Breaking Changes
133
+
134
+ **None**. This is a fully backward-compatible patch release.
135
+
136
+ ---
137
+
138
+ ## 📚 Documentation
139
+
140
+ - [CHANGELOG](../CHANGELOG.md)
141
+ - [Migration Guide](./MIGRATION_5.3.4.md)
142
+ - [Installation Guide](./INSTALLATION.md)
143
+ - [API Reference](./API_REFERENCE.md)
144
+
145
+ ---
146
+
147
+ ## 🙏 Acknowledgments
148
+
149
+ Thanks to all users who reported issues and helped identify these bugs.
150
+
151
+ ---
152
+
153
+ ## 📞 Support
154
+
155
+ - **Issues**: [GitHub Issues](https://github.com/SwiftEnProfundidad/ast-intelligence-hooks/issues)
156
+ - **Discussions**: [GitHub Discussions](https://github.com/SwiftEnProfundidad/ast-intelligence-hooks/discussions)
157
+ - **Email**: freelancemerlos@gmail.com
158
+
159
+ ---
160
+
161
+ ## 🚀 What's Next?
162
+
163
+ Stay tuned for upcoming features in future releases:
164
+ - Enhanced violation reporting
165
+ - Performance optimizations
166
+ - Additional platform support
167
+
168
+ ---
169
+
170
+ **Full Changelog**: [5.3.3...5.3.4](https://github.com/SwiftEnProfundidad/ast-intelligence-hooks/compare/v5.3.3...v5.3.4)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki-ast-hooks",
3
- "version": "5.3.4",
3
+ "version": "5.3.6",
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": {
@@ -2,7 +2,7 @@
2
2
  🔋 TOKEN USAGE - Current Session
3
3
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4
4
 
5
- Status: OK
5
+ Status: OK (stale data)
6
6
  Tokens Used: 0 / 1,000,000 (0%)
7
7
  Remaining: 1,000,000 tokens
8
8
  Source: file
@@ -10,5 +10,7 @@ Source: file
10
10
  ✅ Token usage healthy
11
11
  → Continue working normally
12
12
 
13
- Last updated: 2025-12-29T15:42:43.129Z
13
+ ℹ️ Data is stale. Ensure guards are running and refreshing token usage.
14
+
15
+ Last updated: 2025-12-29T16:15:44.360Z
14
16
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -515,3 +515,14 @@
515
515
  {"timestamp":"2025-12-29T15:36:42.905Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"0a254ce5-ac1b-45da-ae9e-b6dc03c052fe","type":"token_ok"},"context":{}}
516
516
  {"timestamp":"2025-12-29T15:39:43.017Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"930e0daa-10e3-4213-8fa3-097e6115ec6e","type":"token_ok"},"context":{}}
517
517
  {"timestamp":"2025-12-29T15:42:43.130Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"ade4fa8a-38e3-47f3-bffd-de2d6e292a94","type":"token_ok"},"context":{}}
518
+ {"timestamp":"2025-12-29T15:45:43.246Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"15feba45-8624-4af0-9fd9-dcfbc4190068","type":"token_ok"},"context":{}}
519
+ {"timestamp":"2025-12-29T15:48:43.358Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"99a8f294-71f7-4407-9618-3c7778790429","type":"token_ok"},"context":{}}
520
+ {"timestamp":"2025-12-29T15:51:43.469Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"89133e5a-4003-4468-94b0-c67e47ca8db2","type":"token_ok"},"context":{}}
521
+ {"timestamp":"2025-12-29T15:54:43.579Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"6919b6b4-50e3-47ae-8b39-14c558d634fc","type":"token_ok"},"context":{}}
522
+ {"timestamp":"2025-12-29T15:57:43.699Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"f4d95623-a24d-47ee-b344-559f23b23e83","type":"token_ok"},"context":{}}
523
+ {"timestamp":"2025-12-29T16:00:43.813Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"dc99dbf4-5041-4490-950b-fd0b9b19f9a6","type":"token_ok"},"context":{}}
524
+ {"timestamp":"2025-12-29T16:03:43.921Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"8a762550-4bb3-4239-96ce-e7a08838d24b","type":"token_ok"},"context":{}}
525
+ {"timestamp":"2025-12-29T16:06:44.037Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"d6372050-8b4f-4c01-9e26-cf035e9feb05","type":"token_ok"},"context":{}}
526
+ {"timestamp":"2025-12-29T16:09:44.150Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"46322b8d-19ff-4888-8ce9-d901a54191d4","type":"token_ok"},"context":{}}
527
+ {"timestamp":"2025-12-29T16:12:44.258Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"eac1ff0f-5133-41b1-a324-40c38c8b8f02","type":"token_ok"},"context":{}}
528
+ {"timestamp":"2025-12-29T16:15:44.361Z","level":"debug","component":"NotificationCenter","event":"Notification enqueued","data":{"id":"b013b103-7ea4-4f60-aebd-e9c0b4f21438","type":"token_ok"},"context":{}}
@@ -1549,3 +1549,36 @@
1549
1549
  {"timestamp":"2025-12-29T15:42:43.119Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1550
1550
  {"timestamp":"2025-12-29T15:42:43.121Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":false,"untrusted":false},"context":{}}
1551
1551
  {"timestamp":"2025-12-29T15:42:43.130Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":false,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file"}}
1552
+ {"timestamp":"2025-12-29T15:45:43.236Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1553
+ {"timestamp":"2025-12-29T15:45:43.237Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":false,"untrusted":false},"context":{}}
1554
+ {"timestamp":"2025-12-29T15:45:43.247Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":false,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file"}}
1555
+ {"timestamp":"2025-12-29T15:48:43.349Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1556
+ {"timestamp":"2025-12-29T15:48:43.350Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":false,"untrusted":false},"context":{}}
1557
+ {"timestamp":"2025-12-29T15:48:43.359Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":false,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file"}}
1558
+ {"timestamp":"2025-12-29T15:51:43.458Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1559
+ {"timestamp":"2025-12-29T15:51:43.459Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":false,"untrusted":false},"context":{}}
1560
+ {"timestamp":"2025-12-29T15:51:43.469Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":false,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file"}}
1561
+ {"timestamp":"2025-12-29T15:54:43.567Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1562
+ {"timestamp":"2025-12-29T15:54:43.569Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":true,"untrusted":false},"context":{}}
1563
+ {"timestamp":"2025-12-29T15:54:43.579Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":true,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file (stale)"}}
1564
+ {"timestamp":"2025-12-29T15:57:43.688Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1565
+ {"timestamp":"2025-12-29T15:57:43.689Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":true,"untrusted":false},"context":{}}
1566
+ {"timestamp":"2025-12-29T15:57:43.699Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":true,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file (stale)"}}
1567
+ {"timestamp":"2025-12-29T16:00:43.803Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1568
+ {"timestamp":"2025-12-29T16:00:43.804Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":true,"untrusted":false},"context":{}}
1569
+ {"timestamp":"2025-12-29T16:00:43.814Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":true,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file (stale)"}}
1570
+ {"timestamp":"2025-12-29T16:03:43.910Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1571
+ {"timestamp":"2025-12-29T16:03:43.911Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":true,"untrusted":false},"context":{}}
1572
+ {"timestamp":"2025-12-29T16:03:43.921Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":true,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file (stale)"}}
1573
+ {"timestamp":"2025-12-29T16:06:44.028Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1574
+ {"timestamp":"2025-12-29T16:06:44.029Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":true,"untrusted":false},"context":{}}
1575
+ {"timestamp":"2025-12-29T16:06:44.038Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":true,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file (stale)"}}
1576
+ {"timestamp":"2025-12-29T16:09:44.139Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1577
+ {"timestamp":"2025-12-29T16:09:44.140Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":true,"untrusted":false},"context":{}}
1578
+ {"timestamp":"2025-12-29T16:09:44.150Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":true,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file (stale)"}}
1579
+ {"timestamp":"2025-12-29T16:12:44.248Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1580
+ {"timestamp":"2025-12-29T16:12:44.249Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":true,"untrusted":false},"context":{}}
1581
+ {"timestamp":"2025-12-29T16:12:44.258Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":true,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file (stale)"}}
1582
+ {"timestamp":"2025-12-29T16:15:44.350Z","level":"debug","component":"TokenMonitor","event":"CURSOR_SERVICE_USING_FILE","data":{"usage":{"tokensUsed":0,"maxTokens":1000000,"percentUsed":72.36585,"timestamp":"2025-12-29T15:38:11.174Z","source":"file","untrusted":false}},"context":{}}
1583
+ {"timestamp":"2025-12-29T16:15:44.351Z","level":"debug","component":"TokenMonitor","event":"TOKEN_MONITOR_METRICS","data":{"timestamp":"2025-12-29T15:38:11.174Z","tokensUsed":0,"maxTokens":1000000,"percentUsed":0,"remainingTokens":1000000,"level":"ok","source":"file","stale":true,"untrusted":false},"context":{}}
1584
+ {"timestamp":"2025-12-29T16:15:44.362Z","level":"info","component":"TokenMonitor","event":"TOKEN_MONITOR_RESULT","data":{"level":"ok","percentUsed":0,"tokensUsed":0,"maxTokens":1000000,"source":"file","stale":true,"untrusted":false},"context":{"message":"Result level=ok percent=0% used=0/1000000 source=file (stale)"}}
@@ -358,18 +358,29 @@ compute_staged_summary() {
358
358
  local total_findings=$(jq -r '.findings | length' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0")
359
359
 
360
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"
361
+ # Build jq array of staged files for efficient matching in single pass
362
+ local staged_array=$(jq -R -s 'split("\n") | map(select(length > 0))' "$staged_file_rel")
363
+
364
+ # Single jq pass: filter findings by staged files and count by severity
365
+ local counts=$(jq -r --argjson staged "$staged_array" '
366
+ .findings
367
+ | map(select(
368
+ .filePath as $fp
369
+ | any($staged[]; . as $sf | ($fp | endswith($sf)) or ($fp | contains("/" + $sf)))
370
+ ))
371
+ | group_by(.severity | ascii_downcase)
372
+ | map({key: .[0].severity | ascii_downcase, value: length})
373
+ | from_entries
374
+ | {
375
+ critical: ((.critical // 0) + (.error // 0)),
376
+ high: (.high // 0),
377
+ medium: ((.medium // 0) + (.warning // 0)),
378
+ low: ((.low // 0) + (.info // 0))
379
+ }
380
+ | "\(.critical) \(.high) \(.medium) \(.low)"
381
+ ' "$TMP_DIR/ast-summary.json" 2>/dev/null || echo "0 0 0 0")
382
+
383
+ read scrit shigh smed slow <<< "$counts"
373
384
  fi
374
385
  printf " Staged AST → 🔴 CRITICAL:%s 🟠 HIGH:%s 🟡 MEDIUM:%s 🔵 LOW:%s\n" "${scrit:-0}" "${shigh:-0}" "${smed:-0}" "${slow:-0}"
375
386
  export STAGED_CRIT=${scrit:-0}