avana-cli 2.11.0

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.
Files changed (100) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE +21 -0
  3. package/README.md +584 -0
  4. package/dist/cli.d.ts +7 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +153 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/commands/install.d.ts +6 -0
  9. package/dist/commands/install.d.ts.map +1 -0
  10. package/dist/commands/install.js +101 -0
  11. package/dist/commands/install.js.map +1 -0
  12. package/dist/commands/scan.d.ts +19 -0
  13. package/dist/commands/scan.d.ts.map +1 -0
  14. package/dist/commands/scan.js +383 -0
  15. package/dist/commands/scan.js.map +1 -0
  16. package/dist/commands/uninstall.d.ts +6 -0
  17. package/dist/commands/uninstall.d.ts.map +1 -0
  18. package/dist/commands/uninstall.js +80 -0
  19. package/dist/commands/uninstall.js.map +1 -0
  20. package/dist/index.d.ts +97 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +475 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/rules/additional-patterns.d.ts +12 -0
  25. package/dist/rules/additional-patterns.d.ts.map +1 -0
  26. package/dist/rules/additional-patterns.js +170 -0
  27. package/dist/rules/additional-patterns.js.map +1 -0
  28. package/dist/rules/code-patterns.d.ts +26 -0
  29. package/dist/rules/code-patterns.d.ts.map +1 -0
  30. package/dist/rules/code-patterns.js +220 -0
  31. package/dist/rules/code-patterns.js.map +1 -0
  32. package/dist/rules/secret-patterns.d.ts +28 -0
  33. package/dist/rules/secret-patterns.d.ts.map +1 -0
  34. package/dist/rules/secret-patterns.js +1729 -0
  35. package/dist/rules/secret-patterns.js.map +1 -0
  36. package/dist/scanners/secret-scanner.d.ts +34 -0
  37. package/dist/scanners/secret-scanner.d.ts.map +1 -0
  38. package/dist/scanners/secret-scanner.js +281 -0
  39. package/dist/scanners/secret-scanner.js.map +1 -0
  40. package/dist/types/index.d.ts +116 -0
  41. package/dist/types/index.d.ts.map +1 -0
  42. package/dist/types/index.js +7 -0
  43. package/dist/types/index.js.map +1 -0
  44. package/dist/utils/error-handler.d.ts +126 -0
  45. package/dist/utils/error-handler.d.ts.map +1 -0
  46. package/dist/utils/error-handler.js +222 -0
  47. package/dist/utils/error-handler.js.map +1 -0
  48. package/dist/utils/exit-codes.d.ts +52 -0
  49. package/dist/utils/exit-codes.d.ts.map +1 -0
  50. package/dist/utils/exit-codes.js +89 -0
  51. package/dist/utils/exit-codes.js.map +1 -0
  52. package/dist/utils/file-stream-scanner.d.ts +31 -0
  53. package/dist/utils/file-stream-scanner.d.ts.map +1 -0
  54. package/dist/utils/file-stream-scanner.js +159 -0
  55. package/dist/utils/file-stream-scanner.js.map +1 -0
  56. package/dist/utils/file-type-detector.d.ts +45 -0
  57. package/dist/utils/file-type-detector.d.ts.map +1 -0
  58. package/dist/utils/file-type-detector.js +237 -0
  59. package/dist/utils/file-type-detector.js.map +1 -0
  60. package/dist/utils/ignore-pattern-manager.d.ts +61 -0
  61. package/dist/utils/ignore-pattern-manager.d.ts.map +1 -0
  62. package/dist/utils/ignore-pattern-manager.js +204 -0
  63. package/dist/utils/ignore-pattern-manager.js.map +1 -0
  64. package/dist/utils/json-output-formatter.d.ts +232 -0
  65. package/dist/utils/json-output-formatter.d.ts.map +1 -0
  66. package/dist/utils/json-output-formatter.js +367 -0
  67. package/dist/utils/json-output-formatter.js.map +1 -0
  68. package/dist/utils/logger.d.ts +181 -0
  69. package/dist/utils/logger.d.ts.map +1 -0
  70. package/dist/utils/logger.js +414 -0
  71. package/dist/utils/logger.js.map +1 -0
  72. package/dist/utils/markdown-output-formatter.d.ts +65 -0
  73. package/dist/utils/markdown-output-formatter.d.ts.map +1 -0
  74. package/dist/utils/markdown-output-formatter.js +316 -0
  75. package/dist/utils/markdown-output-formatter.js.map +1 -0
  76. package/dist/utils/memory-manager.d.ts +77 -0
  77. package/dist/utils/memory-manager.d.ts.map +1 -0
  78. package/dist/utils/memory-manager.js +157 -0
  79. package/dist/utils/memory-manager.js.map +1 -0
  80. package/dist/utils/parallel-scanner-worker.d.ts +19 -0
  81. package/dist/utils/parallel-scanner-worker.d.ts.map +1 -0
  82. package/dist/utils/parallel-scanner-worker.js +51 -0
  83. package/dist/utils/parallel-scanner-worker.js.map +1 -0
  84. package/dist/utils/parallel-scanner.d.ts +82 -0
  85. package/dist/utils/parallel-scanner.d.ts.map +1 -0
  86. package/dist/utils/parallel-scanner.js +229 -0
  87. package/dist/utils/parallel-scanner.js.map +1 -0
  88. package/dist/utils/pattern-validator.d.ts +108 -0
  89. package/dist/utils/pattern-validator.d.ts.map +1 -0
  90. package/dist/utils/pattern-validator.js +315 -0
  91. package/dist/utils/pattern-validator.js.map +1 -0
  92. package/dist/utils/progress-reporter.d.ts +68 -0
  93. package/dist/utils/progress-reporter.d.ts.map +1 -0
  94. package/dist/utils/progress-reporter.js +194 -0
  95. package/dist/utils/progress-reporter.js.map +1 -0
  96. package/dist/utils/result-cache.d.ts +99 -0
  97. package/dist/utils/result-cache.d.ts.map +1 -0
  98. package/dist/utils/result-cache.js +335 -0
  99. package/dist/utils/result-cache.js.map +1 -0
  100. package/package.json +80 -0
@@ -0,0 +1,315 @@
1
+ "use strict";
2
+ /**
3
+ * Pattern Validator
4
+ * Validates and tests all detection patterns for correctness and performance
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.PatternValidator = void 0;
8
+ /**
9
+ * Pattern Validator class
10
+ * Validates regex patterns for correctness, performance, and security
11
+ */
12
+ class PatternValidator {
13
+ debugMode = false;
14
+ backtrackingTimeout = 1000; // 1 second timeout
15
+ constructor(debugMode = false, backtrackingTimeout = 1000) {
16
+ this.debugMode = debugMode;
17
+ this.backtrackingTimeout = backtrackingTimeout;
18
+ }
19
+ /**
20
+ * Validate a pattern for correctness and compilation
21
+ */
22
+ validatePattern(pattern) {
23
+ const result = {
24
+ isValid: true,
25
+ errors: [],
26
+ warnings: [],
27
+ };
28
+ try {
29
+ // Measure compilation time
30
+ const startTime = Date.now();
31
+ const regex = this.compilePattern(pattern);
32
+ const compilationTime = Date.now() - startTime;
33
+ result.compilationTime = compilationTime;
34
+ // Warn about slow compilation
35
+ if (compilationTime > 100) {
36
+ result.warnings.push(`Pattern compilation took ${compilationTime}ms (slow)`);
37
+ }
38
+ // Check for catastrophic backtracking
39
+ const backtrackingResult = this.checkBacktracking(regex);
40
+ if (backtrackingResult.hasBacktracking) {
41
+ result.errors.push(`Pattern has catastrophic backtracking (execution time: ${backtrackingResult.executionTime}ms)`);
42
+ result.isValid = false;
43
+ }
44
+ // Run test cases if provided
45
+ if (pattern.testCases && pattern.testCases.length > 0) {
46
+ const testResults = this.testPattern(pattern, pattern.testCases);
47
+ result.testResults = testResults.results;
48
+ if (!testResults.allPassed) {
49
+ result.errors.push(`${testResults.failedCount} test cases failed`);
50
+ result.isValid = false;
51
+ }
52
+ }
53
+ // Validate pattern structure
54
+ this.validatePatternStructure(pattern, regex, result);
55
+ }
56
+ catch (error) {
57
+ result.isValid = false;
58
+ result.errors.push(`Pattern compilation failed: ${error instanceof Error ? error.message : String(error)}`);
59
+ }
60
+ return result;
61
+ }
62
+ /**
63
+ * Test a pattern against positive and negative test cases
64
+ */
65
+ testPattern(pattern, testCases) {
66
+ const results = [];
67
+ let passedCount = 0;
68
+ let failedCount = 0;
69
+ try {
70
+ const regex = this.compilePattern(pattern);
71
+ for (const testCase of testCases) {
72
+ const result = this.runTestCase(regex, testCase);
73
+ results.push(result);
74
+ if (result.passed) {
75
+ passedCount++;
76
+ }
77
+ else {
78
+ failedCount++;
79
+ }
80
+ }
81
+ }
82
+ catch (error) {
83
+ // If pattern doesn't compile, all tests fail
84
+ for (const testCase of testCases) {
85
+ results.push({
86
+ testCase,
87
+ passed: false,
88
+ actualMatch: null,
89
+ error: `Pattern compilation failed: ${error instanceof Error ? error.message : String(error)}`,
90
+ });
91
+ failedCount++;
92
+ }
93
+ }
94
+ return {
95
+ results,
96
+ allPassed: failedCount === 0,
97
+ passedCount,
98
+ failedCount,
99
+ };
100
+ }
101
+ /**
102
+ * Check if a pattern has catastrophic backtracking
103
+ */
104
+ checkBacktracking(pattern) {
105
+ // Test inputs that commonly cause backtracking
106
+ const problematicInputs = [
107
+ 'a'.repeat(100) + 'X', // Long string that doesn't match
108
+ 'a'.repeat(50) + 'b'.repeat(50) + 'X',
109
+ '1'.repeat(100) + 'X',
110
+ 'x'.repeat(30) + 'y'.repeat(30) + 'z'.repeat(30) + 'X',
111
+ // Nested quantifiers test
112
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaX',
113
+ // Alternation test
114
+ 'abcdefghijklmnopqrstuvwxyzX',
115
+ ];
116
+ for (const testInput of problematicInputs) {
117
+ const result = this.testPatternPerformance(pattern, testInput);
118
+ if (result.hasBacktracking) {
119
+ return {
120
+ ...result,
121
+ testInput,
122
+ };
123
+ }
124
+ }
125
+ return {
126
+ hasBacktracking: false,
127
+ executionTime: 0,
128
+ timedOut: false,
129
+ };
130
+ }
131
+ /**
132
+ * Compile a pattern from string or RegExp
133
+ */
134
+ compilePattern(pattern) {
135
+ if (pattern.pattern instanceof RegExp) {
136
+ return pattern.pattern;
137
+ }
138
+ if (typeof pattern.pattern === 'string') {
139
+ try {
140
+ // Try to create regex with global and case-insensitive flags
141
+ return new RegExp(pattern.pattern, 'gi');
142
+ }
143
+ catch (error) {
144
+ throw new Error(`Invalid regex pattern: ${pattern.pattern}`);
145
+ }
146
+ }
147
+ throw new Error('Pattern must be a string or RegExp');
148
+ }
149
+ /**
150
+ * Run a single test case against a regex
151
+ */
152
+ runTestCase(regex, testCase) {
153
+ try {
154
+ // Reset regex state
155
+ regex.lastIndex = 0;
156
+ const match = regex.exec(testCase.input);
157
+ const actualMatch = match ? match[0] : null;
158
+ let passed = false;
159
+ if (testCase.shouldMatch) {
160
+ // Should match - check if we got a match
161
+ passed = actualMatch !== null;
162
+ // If expected match is specified, check it matches
163
+ if (passed && testCase.expectedMatch) {
164
+ passed = actualMatch === testCase.expectedMatch;
165
+ }
166
+ }
167
+ else {
168
+ // Should not match - check if we got no match
169
+ passed = actualMatch === null;
170
+ }
171
+ return {
172
+ testCase,
173
+ passed,
174
+ actualMatch,
175
+ };
176
+ }
177
+ catch (error) {
178
+ return {
179
+ testCase,
180
+ passed: false,
181
+ actualMatch: null,
182
+ error: error instanceof Error ? error.message : String(error),
183
+ };
184
+ }
185
+ }
186
+ /**
187
+ * Test pattern performance to detect backtracking
188
+ */
189
+ testPatternPerformance(pattern, testInput) {
190
+ const startTime = Date.now();
191
+ let timedOut = false;
192
+ let executionTime = 0;
193
+ try {
194
+ // Set up timeout
195
+ const timeoutId = setTimeout(() => {
196
+ timedOut = true;
197
+ }, this.backtrackingTimeout);
198
+ // Reset regex state
199
+ pattern.lastIndex = 0;
200
+ // Test the pattern
201
+ pattern.test(testInput);
202
+ clearTimeout(timeoutId);
203
+ executionTime = Date.now() - startTime;
204
+ // Consider it backtracking if it took more than 100ms
205
+ const hasBacktracking = timedOut || executionTime > 100;
206
+ return {
207
+ hasBacktracking,
208
+ executionTime,
209
+ timedOut,
210
+ };
211
+ }
212
+ catch (error) {
213
+ executionTime = Date.now() - startTime;
214
+ return {
215
+ hasBacktracking: timedOut || executionTime > 100,
216
+ executionTime,
217
+ timedOut,
218
+ };
219
+ }
220
+ }
221
+ /**
222
+ * Validate pattern structure and provide warnings
223
+ */
224
+ validatePatternStructure(pattern, regex, result) {
225
+ const patternStr = pattern.pattern.toString();
226
+ // Check for common issues
227
+ if (patternStr.includes('.*.*')) {
228
+ result.warnings.push('Pattern contains nested .* quantifiers which may cause performance issues');
229
+ }
230
+ if (patternStr.includes('(.+)+') || patternStr.includes('(.*)+')) {
231
+ result.warnings.push('Pattern contains nested quantifiers which may cause catastrophic backtracking');
232
+ }
233
+ if (patternStr.includes('(.*|.*)')) {
234
+ result.warnings.push('Pattern contains alternation with overlapping branches');
235
+ }
236
+ // Check for overly broad patterns
237
+ if (patternStr === '.*' || patternStr === '.+') {
238
+ result.warnings.push('Pattern is overly broad and may cause false positives');
239
+ }
240
+ // Check for missing anchors in patterns that should be anchored
241
+ if (pattern.id.includes('line') && !patternStr.includes('^') && !patternStr.includes('$')) {
242
+ result.warnings.push('Line-based pattern should consider using anchors (^ or $)');
243
+ }
244
+ // Check for case sensitivity issues
245
+ if (!regex.ignoreCase && patternStr.includes('[a-z]') && !patternStr.includes('[A-Z]')) {
246
+ result.warnings.push('Pattern may miss uppercase variants - consider case-insensitive flag');
247
+ }
248
+ // Check for missing word boundaries
249
+ if (pattern.id.includes('key') || pattern.id.includes('token')) {
250
+ if (!patternStr.includes('\\b') && !patternStr.includes('(?:^|\\W)')) {
251
+ result.warnings.push('Key/token pattern should consider word boundaries to avoid false positives');
252
+ }
253
+ }
254
+ }
255
+ /**
256
+ * Validate all patterns in a collection
257
+ */
258
+ validateAllPatterns(patterns) {
259
+ const results = new Map();
260
+ let validCount = 0;
261
+ let invalidCount = 0;
262
+ let warningCount = 0;
263
+ for (const pattern of patterns) {
264
+ const result = this.validatePattern(pattern);
265
+ results.set(pattern.id, result);
266
+ if (result.isValid) {
267
+ validCount++;
268
+ }
269
+ else {
270
+ invalidCount++;
271
+ }
272
+ if (result.warnings.length > 0) {
273
+ warningCount++;
274
+ }
275
+ if (this.debugMode) {
276
+ console.log(`Validated pattern ${pattern.id}: ${result.isValid ? 'VALID' : 'INVALID'}`);
277
+ if (result.errors.length > 0) {
278
+ console.log(` Errors: ${result.errors.join(', ')}`);
279
+ }
280
+ if (result.warnings.length > 0) {
281
+ console.log(` Warnings: ${result.warnings.join(', ')}`);
282
+ }
283
+ }
284
+ }
285
+ return {
286
+ results,
287
+ validCount,
288
+ invalidCount,
289
+ warningCount,
290
+ };
291
+ }
292
+ /**
293
+ * Generate test cases for common secret patterns
294
+ */
295
+ generateTestCases(patternType) {
296
+ const testCases = [];
297
+ switch (patternType.toLowerCase()) {
298
+ case 'api-key':
299
+ testCases.push({ input: 'api_key=abc123def456', shouldMatch: true, description: 'Basic API key' }, { input: 'API_KEY="xyz789"', shouldMatch: true, description: 'Quoted API key' }, { input: 'apikey: sk_test_123456789', shouldMatch: true, description: 'Stripe-style key' }, { input: 'const message = "api key is secret"', shouldMatch: false, description: 'False positive text' }, { input: 'api_key_length = 32', shouldMatch: false, description: 'Variable name only' });
300
+ break;
301
+ case 'password':
302
+ testCases.push({ input: 'password=secret123', shouldMatch: true, description: 'Basic password' }, { input: 'PASSWORD: "mypassword"', shouldMatch: true, description: 'Quoted password' }, { input: 'pwd=admin', shouldMatch: true, description: 'Short password' }, { input: 'password_field = input', shouldMatch: false, description: 'Field reference' }, { input: 'password validation failed', shouldMatch: false, description: 'Error message' });
303
+ break;
304
+ case 'token':
305
+ testCases.push({ input: 'token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9', shouldMatch: true, description: 'JWT token' }, { input: 'access_token: "ghp_1234567890abcdef"', shouldMatch: true, description: 'GitHub token' }, { input: 'bearer_token = "sk_live_123"', shouldMatch: true, description: 'Bearer token' }, { input: 'token_type = "bearer"', shouldMatch: false, description: 'Token type only' }, { input: 'tokenize the string', shouldMatch: false, description: 'Verb usage' });
306
+ break;
307
+ default:
308
+ // Generic test cases
309
+ testCases.push({ input: 'test_string_123', shouldMatch: false, description: 'Generic test string' }, { input: '', shouldMatch: false, description: 'Empty string' }, { input: 'a'.repeat(1000), shouldMatch: false, description: 'Very long string' });
310
+ }
311
+ return testCases;
312
+ }
313
+ }
314
+ exports.PatternValidator = PatternValidator;
315
+ //# sourceMappingURL=pattern-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern-validator.js","sourceRoot":"","sources":["../../src/utils/pattern-validator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAuDH;;;GAGG;AACH,MAAa,gBAAgB;IACnB,SAAS,GAAY,KAAK,CAAC;IAC3B,mBAAmB,GAAW,IAAI,CAAC,CAAC,mBAAmB;IAE/D,YA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AAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnYD,4CAmYC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Progress Reporter
3
+ * Provides progress reporting functionality for file scanning operations
4
+ */
5
+ export interface ProgressOptions {
6
+ total: number;
7
+ noProgress?: boolean;
8
+ }
9
+ export interface ProgressStats {
10
+ current: number;
11
+ total: number;
12
+ percentage: number;
13
+ eta: number;
14
+ elapsedTime: number;
15
+ rate: number;
16
+ }
17
+ export declare class ProgressReporter {
18
+ private progressBar;
19
+ private startTime;
20
+ private lastUpdateTime;
21
+ private current;
22
+ private total;
23
+ private noProgress;
24
+ private readonly updateThreshold;
25
+ constructor(options: ProgressOptions);
26
+ /**
27
+ * Start the progress reporting
28
+ */
29
+ start(): void;
30
+ /**
31
+ * Update progress (throttled to updateThreshold)
32
+ */
33
+ update(current?: number): void;
34
+ /**
35
+ * Increment progress by 1
36
+ */
37
+ increment(): void;
38
+ /**
39
+ * Complete the progress reporting
40
+ */
41
+ complete(): void;
42
+ /**
43
+ * Stop and clear the progress bar without completing
44
+ */
45
+ stop(): void;
46
+ /**
47
+ * Get current progress statistics
48
+ */
49
+ getStats(): ProgressStats;
50
+ /**
51
+ * Check if progress reporting is enabled
52
+ */
53
+ isEnabled(): boolean;
54
+ /**
55
+ * Update the total number of items
56
+ */
57
+ setTotal(total: number): void;
58
+ }
59
+ export declare let progressReporter: ProgressReporter | null;
60
+ /**
61
+ * Initialize global progress reporter
62
+ */
63
+ export declare function initializeProgressReporter(options: ProgressOptions): ProgressReporter;
64
+ /**
65
+ * Get the global progress reporter instance
66
+ */
67
+ export declare function getProgressReporter(): ProgressReporter | null;
68
+ //# sourceMappingURL=progress-reporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-reporter.d.ts","sourceRoot":"","sources":["../../src/utils/progress-reporter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAe;gBAEnC,OAAO,EAAE,eAAe;IAKpC;;OAEG;IACI,KAAK,IAAI,IAAI;IA0BpB;;OAEG;IACI,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IA8BrC;;OAEG;IACI,SAAS,IAAI,IAAI;IAIxB;;OAEG;IACI,QAAQ,IAAI,IAAI;IAiBvB;;OAEG;IACI,IAAI,IAAI,IAAI;IAenB;;OAEG;IACI,QAAQ,IAAI,aAAa;IAiBhC;;OAEG;IACI,SAAS,IAAI,OAAO;IAI3B;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAMrC;AAGD,eAAO,IAAI,gBAAgB,EAAE,gBAAgB,GAAG,IAAW,CAAC;AAE5D;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB,CAGrF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,GAAG,IAAI,CAE7D"}
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ /**
3
+ * Progress Reporter
4
+ * Provides progress reporting functionality for file scanning operations
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.progressReporter = exports.ProgressReporter = void 0;
41
+ exports.initializeProgressReporter = initializeProgressReporter;
42
+ exports.getProgressReporter = getProgressReporter;
43
+ const cliProgress = __importStar(require("cli-progress"));
44
+ class ProgressReporter {
45
+ progressBar = null;
46
+ startTime = 0;
47
+ lastUpdateTime = 0;
48
+ current = 0;
49
+ total = 0;
50
+ noProgress = false;
51
+ updateThreshold = 100; // Update at most once per 100ms
52
+ constructor(options) {
53
+ this.total = options.total;
54
+ this.noProgress = options.noProgress || false;
55
+ }
56
+ /**
57
+ * Start the progress reporting
58
+ */
59
+ start() {
60
+ if (this.noProgress) {
61
+ return;
62
+ }
63
+ this.startTime = Date.now();
64
+ this.lastUpdateTime = this.startTime;
65
+ this.current = 0;
66
+ // Create progress bar with custom format
67
+ this.progressBar = new cliProgress.SingleBar({
68
+ format: 'Scanning |{bar}| {percentage}% | {value}/{total} files | ETA: {eta}s | {rate} files/s',
69
+ barCompleteChar: '\u2588',
70
+ barIncompleteChar: '\u2591',
71
+ hideCursor: true,
72
+ clearOnComplete: true,
73
+ stopOnComplete: true,
74
+ etaBuffer: 50, // Use last 50 updates for ETA calculation
75
+ }, cliProgress.Presets.shades_classic);
76
+ this.progressBar.start(this.total, 0, {
77
+ rate: 0,
78
+ eta: 0
79
+ });
80
+ }
81
+ /**
82
+ * Update progress (throttled to updateThreshold)
83
+ */
84
+ update(current) {
85
+ const now = Date.now();
86
+ if (current !== undefined) {
87
+ this.current = current;
88
+ }
89
+ else {
90
+ this.current++;
91
+ }
92
+ if (this.noProgress || !this.progressBar) {
93
+ return;
94
+ }
95
+ // Throttle updates to avoid performance issues
96
+ if (now - this.lastUpdateTime < this.updateThreshold && current !== this.total) {
97
+ return;
98
+ }
99
+ const elapsedTime = (now - this.startTime) / 1000; // in seconds
100
+ const rate = elapsedTime > 0 ? this.current / elapsedTime : 0;
101
+ const eta = rate > 0 ? Math.ceil((this.total - this.current) / rate) : 0;
102
+ this.progressBar.update(this.current, {
103
+ rate: rate.toFixed(1),
104
+ eta: eta
105
+ });
106
+ this.lastUpdateTime = now;
107
+ }
108
+ /**
109
+ * Increment progress by 1
110
+ */
111
+ increment() {
112
+ this.update(this.current + 1);
113
+ }
114
+ /**
115
+ * Complete the progress reporting
116
+ */
117
+ complete() {
118
+ if (this.noProgress || !this.progressBar) {
119
+ return;
120
+ }
121
+ // Ensure we're at 100%
122
+ this.progressBar.update(this.total);
123
+ this.progressBar.stop();
124
+ // Clear the progress bar from terminal
125
+ if (process.stdout.isTTY) {
126
+ process.stdout.write('\r\x1b[K'); // Clear current line
127
+ }
128
+ this.progressBar = null;
129
+ }
130
+ /**
131
+ * Stop and clear the progress bar without completing
132
+ */
133
+ stop() {
134
+ if (this.noProgress || !this.progressBar) {
135
+ return;
136
+ }
137
+ this.progressBar.stop();
138
+ // Clear the progress bar from terminal
139
+ if (process.stdout.isTTY) {
140
+ process.stdout.write('\r\x1b[K'); // Clear current line
141
+ }
142
+ this.progressBar = null;
143
+ }
144
+ /**
145
+ * Get current progress statistics
146
+ */
147
+ getStats() {
148
+ const now = Date.now();
149
+ const elapsedTime = (now - this.startTime) / 1000; // in seconds
150
+ const rate = elapsedTime > 0 ? this.current / elapsedTime : 0;
151
+ const eta = rate > 0 ? Math.ceil((this.total - this.current) / rate) : 0;
152
+ const percentage = this.total > 0 ? Math.round((this.current / this.total) * 100) : 0;
153
+ return {
154
+ current: this.current,
155
+ total: this.total,
156
+ percentage,
157
+ eta,
158
+ elapsedTime,
159
+ rate
160
+ };
161
+ }
162
+ /**
163
+ * Check if progress reporting is enabled
164
+ */
165
+ isEnabled() {
166
+ return !this.noProgress;
167
+ }
168
+ /**
169
+ * Update the total number of items
170
+ */
171
+ setTotal(total) {
172
+ this.total = total;
173
+ if (this.progressBar && !this.noProgress) {
174
+ this.progressBar.setTotal(total);
175
+ }
176
+ }
177
+ }
178
+ exports.ProgressReporter = ProgressReporter;
179
+ // Global progress reporter instance
180
+ exports.progressReporter = null;
181
+ /**
182
+ * Initialize global progress reporter
183
+ */
184
+ function initializeProgressReporter(options) {
185
+ exports.progressReporter = new ProgressReporter(options);
186
+ return exports.progressReporter;
187
+ }
188
+ /**
189
+ * Get the global progress reporter instance
190
+ */
191
+ function getProgressReporter() {
192
+ return exports.progressReporter;
193
+ }
194
+ //# sourceMappingURL=progress-reporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-reporter.js","sourceRoot":"","sources":["../../src/utils/progress-reporter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuLH,gEAGC;AAKD,kDAEC;AA/LD,0DAA4C;AAgB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