@paths.design/caws-cli 3.5.0 → 4.1.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.
- package/dist/budget-derivation.d.ts +41 -2
- package/dist/budget-derivation.d.ts.map +1 -1
- package/dist/budget-derivation.js +417 -30
- package/dist/commands/archive.d.ts +50 -0
- package/dist/commands/archive.d.ts.map +1 -0
- package/dist/commands/archive.js +353 -0
- package/dist/commands/iterate.d.ts.map +1 -1
- package/dist/commands/iterate.js +12 -13
- package/dist/commands/mode.d.ts +24 -0
- package/dist/commands/mode.d.ts.map +1 -0
- package/dist/commands/mode.js +259 -0
- package/dist/commands/plan.d.ts +49 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +448 -0
- package/dist/commands/quality-gates.d.ts +52 -0
- package/dist/commands/quality-gates.d.ts.map +1 -0
- package/dist/commands/quality-gates.js +490 -0
- package/dist/commands/specs.d.ts +71 -0
- package/dist/commands/specs.d.ts.map +1 -0
- package/dist/commands/specs.js +735 -0
- package/dist/commands/status.d.ts +4 -3
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +552 -22
- package/dist/commands/tutorial.d.ts +55 -0
- package/dist/commands/tutorial.d.ts.map +1 -0
- package/dist/commands/tutorial.js +481 -0
- package/dist/commands/validate.d.ts +10 -2
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +199 -39
- package/dist/config/modes.d.ts +225 -0
- package/dist/config/modes.d.ts.map +1 -0
- package/dist/config/modes.js +321 -0
- package/dist/constants/spec-types.d.ts +41 -0
- package/dist/constants/spec-types.d.ts.map +1 -0
- package/dist/constants/spec-types.js +42 -0
- package/dist/index-new.d.ts +5 -0
- package/dist/index-new.d.ts.map +1 -0
- package/dist/index-new.js +317 -0
- package/dist/index.js +227 -10
- package/dist/index.js.backup +4711 -0
- package/dist/policy/PolicyManager.d.ts +104 -0
- package/dist/policy/PolicyManager.d.ts.map +1 -0
- package/dist/policy/PolicyManager.js +399 -0
- package/dist/scaffold/cursor-hooks.d.ts.map +1 -1
- package/dist/scaffold/cursor-hooks.js +15 -0
- package/dist/scaffold/git-hooks.d.ts.map +1 -1
- package/dist/scaffold/git-hooks.js +32 -44
- package/dist/scaffold/index.d.ts.map +1 -1
- package/dist/scaffold/index.js +19 -0
- package/dist/spec/SpecFileManager.d.ts +146 -0
- package/dist/spec/SpecFileManager.d.ts.map +1 -0
- package/dist/spec/SpecFileManager.js +419 -0
- package/dist/utils/quality-gates-errors.js +520 -0
- package/dist/utils/quality-gates.d.ts +49 -0
- package/dist/utils/quality-gates.d.ts.map +1 -0
- package/dist/utils/quality-gates.js +361 -0
- package/dist/utils/spec-resolver.d.ts +88 -0
- package/dist/utils/spec-resolver.d.ts.map +1 -0
- package/dist/utils/spec-resolver.js +602 -0
- package/dist/validation/spec-validation.d.ts +14 -0
- package/dist/validation/spec-validation.d.ts.map +1 -1
- package/dist/validation/spec-validation.js +225 -13
- package/package.json +6 -5
- package/templates/.cursor/hooks/caws-scope-guard.sh +64 -8
- package/templates/.cursor/hooks/validate-spec.sh +22 -12
- package/templates/.cursor/rules/00-claims-verification.mdc +144 -0
- package/templates/.cursor/rules/01-working-style.mdc +50 -0
- package/templates/.cursor/rules/02-quality-gates.mdc +370 -0
- package/templates/.cursor/rules/03-naming-and-refactor.mdc +33 -0
- package/templates/.cursor/rules/04-logging-language-style.mdc +23 -0
- package/templates/.cursor/rules/05-safe-defaults-guards.mdc +23 -0
- package/templates/.cursor/rules/06-typescript-conventions.mdc +36 -0
- package/templates/.cursor/rules/07-process-ops.mdc +20 -0
- package/templates/.cursor/rules/08-solid-and-architecture.mdc +16 -0
- package/templates/.cursor/rules/09-docstrings.mdc +89 -0
- package/templates/.cursor/rules/10-authorship-and-attribution.mdc +15 -0
- package/templates/.cursor/rules/11-documentation-quality-standards.mdc +390 -0
- package/templates/.cursor/rules/12-scope-management-waivers.mdc +385 -0
- package/templates/.cursor/rules/13-implementation-completeness.mdc +516 -0
- package/templates/.cursor/rules/14-language-agnostic-standards.mdc +588 -0
- package/templates/.cursor/rules/15-sophisticated-todo-detection.mdc +425 -0
- package/templates/.cursor/rules/README.md +150 -0
- package/templates/apps/tools/caws/prompt-lint.js.backup +274 -0
- package/templates/apps/tools/caws/provenance.js.backup +73 -0
- package/templates/scripts/quality-gates/check-god-objects.js +146 -0
- package/templates/scripts/quality-gates/run-quality-gates.js +50 -0
- package/templates/scripts/v3/analysis/todo_analyzer.py +1950 -0
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Quality Gates Error Taxonomy
|
|
3
|
+
* Comprehensive error handling for CAWS quality gates with structured error types,
|
|
4
|
+
* recovery strategies, and audit trails.
|
|
5
|
+
*
|
|
6
|
+
* @author @darianrosebrook
|
|
7
|
+
* @ts-nocheck
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const crypto = require('crypto');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Quality Gates Error Categories
|
|
14
|
+
*/
|
|
15
|
+
const ERROR_CATEGORIES = {
|
|
16
|
+
VALIDATION: 'validation',
|
|
17
|
+
CONFIGURATION: 'configuration',
|
|
18
|
+
EXECUTION: 'execution',
|
|
19
|
+
NETWORK: 'network',
|
|
20
|
+
SECURITY: 'security',
|
|
21
|
+
PERFORMANCE: 'performance',
|
|
22
|
+
BUSINESS_LOGIC: 'business_logic',
|
|
23
|
+
INFRASTRUCTURE: 'infrastructure',
|
|
24
|
+
DATA: 'data',
|
|
25
|
+
TIMEOUT: 'timeout',
|
|
26
|
+
INTERNAL: 'internal',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Error Severity Levels
|
|
31
|
+
*/
|
|
32
|
+
const ERROR_SEVERITY = {
|
|
33
|
+
DEBUG: 'debug',
|
|
34
|
+
INFO: 'info',
|
|
35
|
+
WARNING: 'warning',
|
|
36
|
+
ERROR: 'error',
|
|
37
|
+
CRITICAL: 'critical',
|
|
38
|
+
FATAL: 'fatal',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Recovery Strategies
|
|
43
|
+
*/
|
|
44
|
+
const RECOVERY_STRATEGIES = {
|
|
45
|
+
RETRY: 'retry',
|
|
46
|
+
FALLBACK: 'fallback',
|
|
47
|
+
SKIP: 'skip',
|
|
48
|
+
ESCALATE: 'escalate',
|
|
49
|
+
MANUAL_INTERVENTION: 'manual_intervention',
|
|
50
|
+
AUTO_FIX: 'auto_fix',
|
|
51
|
+
WAIVER: 'waiver',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Quality Gates Error Class
|
|
56
|
+
* @typedef {Object} QualityGatesErrorOptions
|
|
57
|
+
* @property {string} category
|
|
58
|
+
* @property {string} code
|
|
59
|
+
* @property {string} message
|
|
60
|
+
* @property {string} [severity]
|
|
61
|
+
* @property {string} [component]
|
|
62
|
+
* @property {string} [operation]
|
|
63
|
+
* @property {Object} [context]
|
|
64
|
+
* @property {string[]} [recoveryStrategies]
|
|
65
|
+
* @property {boolean} [retryable]
|
|
66
|
+
* @property {string|null} [correlationId]
|
|
67
|
+
* @property {string[]} [errorChain]
|
|
68
|
+
*/
|
|
69
|
+
class QualityGatesError extends Error {
|
|
70
|
+
/**
|
|
71
|
+
* @param {QualityGatesErrorOptions} options
|
|
72
|
+
*/
|
|
73
|
+
constructor(options) {
|
|
74
|
+
const {
|
|
75
|
+
category,
|
|
76
|
+
code,
|
|
77
|
+
message,
|
|
78
|
+
severity = ERROR_SEVERITY.ERROR,
|
|
79
|
+
component = 'quality-gates',
|
|
80
|
+
operation = 'unknown',
|
|
81
|
+
context = {},
|
|
82
|
+
recoveryStrategies = [],
|
|
83
|
+
retryable = false,
|
|
84
|
+
correlationId = null,
|
|
85
|
+
errorChain = [],
|
|
86
|
+
} = options;
|
|
87
|
+
|
|
88
|
+
super(message);
|
|
89
|
+
|
|
90
|
+
this.name = 'QualityGatesError';
|
|
91
|
+
this.errorId = `qg-err-${Date.now()}-${crypto.randomBytes(4).toString('hex')}`;
|
|
92
|
+
this.category = category;
|
|
93
|
+
this.code = code;
|
|
94
|
+
this.severity = severity;
|
|
95
|
+
this.component = component;
|
|
96
|
+
this.operation = operation;
|
|
97
|
+
this.context = context;
|
|
98
|
+
this.recoveryStrategies = recoveryStrategies;
|
|
99
|
+
this.retryable = retryable;
|
|
100
|
+
this.correlationId = correlationId;
|
|
101
|
+
this.errorChain = errorChain;
|
|
102
|
+
this.timestamp = new Date().toISOString();
|
|
103
|
+
this.stack = this.stack || new Error().stack;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Add context to the error
|
|
108
|
+
*/
|
|
109
|
+
withContext(key, value) {
|
|
110
|
+
this.context[key] = value;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Add a recovery strategy
|
|
116
|
+
*/
|
|
117
|
+
withRecoveryStrategy(strategy) {
|
|
118
|
+
this.recoveryStrategies.push(strategy);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Mark as retryable
|
|
124
|
+
*/
|
|
125
|
+
retryable(retryable) {
|
|
126
|
+
this.retryable = retryable;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Set correlation ID for tracing
|
|
132
|
+
*/
|
|
133
|
+
withCorrelationId(correlationId) {
|
|
134
|
+
this.correlationId = correlationId;
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Add to error chain
|
|
140
|
+
*/
|
|
141
|
+
withErrorChain(previousError) {
|
|
142
|
+
this.errorChain.push(previousError);
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Convert to JSON for logging
|
|
148
|
+
*/
|
|
149
|
+
toJSON() {
|
|
150
|
+
return {
|
|
151
|
+
errorId: this.errorId,
|
|
152
|
+
name: this.name,
|
|
153
|
+
category: this.category,
|
|
154
|
+
code: this.code,
|
|
155
|
+
message: this.message,
|
|
156
|
+
severity: this.severity,
|
|
157
|
+
component: this.component,
|
|
158
|
+
operation: this.operation,
|
|
159
|
+
context: this.context,
|
|
160
|
+
recoveryStrategies: this.recoveryStrategies,
|
|
161
|
+
retryable: this.retryable,
|
|
162
|
+
correlationId: this.correlationId,
|
|
163
|
+
errorChain: this.errorChain,
|
|
164
|
+
timestamp: this.timestamp,
|
|
165
|
+
stack: this.stack,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Get human-readable error summary
|
|
171
|
+
*/
|
|
172
|
+
getSummary() {
|
|
173
|
+
return `[${this.category.toUpperCase()}] ${this.code}: ${this.message}`;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Check if error requires human intervention
|
|
178
|
+
*/
|
|
179
|
+
requiresHumanIntervention() {
|
|
180
|
+
return (
|
|
181
|
+
this.recoveryStrategies.includes(RECOVERY_STRATEGIES.MANUAL_INTERVENTION) ||
|
|
182
|
+
this.recoveryStrategies.includes(RECOVERY_STRATEGIES.ESCALATE) ||
|
|
183
|
+
this.severity === ERROR_SEVERITY.FATAL
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Check if error can be auto-recovered
|
|
189
|
+
*/
|
|
190
|
+
canAutoRecover() {
|
|
191
|
+
return (
|
|
192
|
+
this.recoveryStrategies.includes(RECOVERY_STRATEGIES.AUTO_FIX) ||
|
|
193
|
+
this.recoveryStrategies.includes(RECOVERY_STRATEGIES.RETRY) ||
|
|
194
|
+
this.recoveryStrategies.includes(RECOVERY_STRATEGIES.FALLBACK)
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Specific Error Types for Quality Gates
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* God Object Detection Errors
|
|
205
|
+
*/
|
|
206
|
+
class GodObjectError extends QualityGatesError {
|
|
207
|
+
constructor(file, lineCount, threshold, options = {}) {
|
|
208
|
+
super({
|
|
209
|
+
category: ERROR_CATEGORIES.BUSINESS_LOGIC,
|
|
210
|
+
code: 'GOD_OBJECT_DETECTED',
|
|
211
|
+
message: `God object detected: ${file} has ${lineCount} lines (threshold: ${threshold})`,
|
|
212
|
+
severity: lineCount > threshold * 1.5 ? ERROR_SEVERITY.CRITICAL : ERROR_SEVERITY.ERROR,
|
|
213
|
+
component: 'god-object-detector',
|
|
214
|
+
operation: 'analyze_file_size',
|
|
215
|
+
context: {
|
|
216
|
+
file,
|
|
217
|
+
lineCount,
|
|
218
|
+
threshold,
|
|
219
|
+
fileSizeKB: options.fileSizeKB,
|
|
220
|
+
relativePath: options.relativePath,
|
|
221
|
+
},
|
|
222
|
+
recoveryStrategies: [RECOVERY_STRATEGIES.MANUAL_INTERVENTION, RECOVERY_STRATEGIES.WAIVER],
|
|
223
|
+
retryable: false,
|
|
224
|
+
...options,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Hidden TODO Detection Errors
|
|
231
|
+
*/
|
|
232
|
+
class HiddenTodoError extends QualityGatesError {
|
|
233
|
+
constructor(file, todoCount, confidence, options = {}) {
|
|
234
|
+
super({
|
|
235
|
+
category: ERROR_CATEGORIES.BUSINESS_LOGIC,
|
|
236
|
+
code: 'HIDDEN_TODOS_DETECTED',
|
|
237
|
+
message: `Hidden TODOs detected: ${file} has ${todoCount} TODOs (confidence: ${confidence})`,
|
|
238
|
+
severity: confidence > 0.9 ? ERROR_SEVERITY.CRITICAL : ERROR_SEVERITY.ERROR,
|
|
239
|
+
component: 'todo-analyzer',
|
|
240
|
+
operation: 'analyze_hidden_todos',
|
|
241
|
+
context: {
|
|
242
|
+
file,
|
|
243
|
+
todoCount,
|
|
244
|
+
confidence,
|
|
245
|
+
blockingTodos: options.blockingTodos || 0,
|
|
246
|
+
nonBlockingTodos: options.nonBlockingTodos || 0,
|
|
247
|
+
},
|
|
248
|
+
recoveryStrategies: [
|
|
249
|
+
RECOVERY_STRATEGIES.MANUAL_INTERVENTION,
|
|
250
|
+
RECOVERY_STRATEGIES.WAIVER,
|
|
251
|
+
RECOVERY_STRATEGIES.AUTO_FIX,
|
|
252
|
+
],
|
|
253
|
+
retryable: false,
|
|
254
|
+
...options,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Configuration Errors
|
|
261
|
+
*/
|
|
262
|
+
class ConfigurationError extends QualityGatesError {
|
|
263
|
+
constructor(configKey, expectedType, actualValue, options = {}) {
|
|
264
|
+
super({
|
|
265
|
+
category: ERROR_CATEGORIES.CONFIGURATION,
|
|
266
|
+
code: 'INVALID_CONFIGURATION',
|
|
267
|
+
message: `Invalid configuration: ${configKey} expected ${expectedType}, got ${typeof actualValue}`,
|
|
268
|
+
severity: ERROR_SEVERITY.ERROR,
|
|
269
|
+
component: 'config-manager',
|
|
270
|
+
operation: 'validate_config',
|
|
271
|
+
context: {
|
|
272
|
+
configKey,
|
|
273
|
+
expectedType,
|
|
274
|
+
actualValue,
|
|
275
|
+
configFile: options.configFile,
|
|
276
|
+
},
|
|
277
|
+
recoveryStrategies: [RECOVERY_STRATEGIES.MANUAL_INTERVENTION, RECOVERY_STRATEGIES.FALLBACK],
|
|
278
|
+
retryable: false,
|
|
279
|
+
...options,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Waiver Validation Errors
|
|
286
|
+
*/
|
|
287
|
+
class WaiverError extends QualityGatesError {
|
|
288
|
+
constructor(waiverId, reason, options = {}) {
|
|
289
|
+
super({
|
|
290
|
+
category: ERROR_CATEGORIES.VALIDATION,
|
|
291
|
+
code: 'INVALID_WAIVER',
|
|
292
|
+
message: `Invalid waiver: ${waiverId} - ${reason}`,
|
|
293
|
+
severity: ERROR_SEVERITY.WARNING,
|
|
294
|
+
component: 'waiver-manager',
|
|
295
|
+
operation: 'validate_waiver',
|
|
296
|
+
context: {
|
|
297
|
+
waiverId,
|
|
298
|
+
reason,
|
|
299
|
+
expiresAt: options.expiresAt,
|
|
300
|
+
gates: options.gates,
|
|
301
|
+
},
|
|
302
|
+
recoveryStrategies: [RECOVERY_STRATEGIES.MANUAL_INTERVENTION, RECOVERY_STRATEGIES.SKIP],
|
|
303
|
+
retryable: false,
|
|
304
|
+
...options,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Execution Errors
|
|
311
|
+
*/
|
|
312
|
+
class ExecutionError extends QualityGatesError {
|
|
313
|
+
constructor(command, exitCode, stderr, options = {}) {
|
|
314
|
+
super({
|
|
315
|
+
category: ERROR_CATEGORIES.EXECUTION,
|
|
316
|
+
code: 'COMMAND_FAILED',
|
|
317
|
+
message: `Command failed: ${command} (exit code: ${exitCode})`,
|
|
318
|
+
severity: ERROR_SEVERITY.ERROR,
|
|
319
|
+
component: 'command-executor',
|
|
320
|
+
operation: 'execute_command',
|
|
321
|
+
context: {
|
|
322
|
+
command,
|
|
323
|
+
exitCode,
|
|
324
|
+
stderr,
|
|
325
|
+
stdout: options.stdout,
|
|
326
|
+
workingDirectory: options.workingDirectory,
|
|
327
|
+
},
|
|
328
|
+
recoveryStrategies: [RECOVERY_STRATEGIES.RETRY, RECOVERY_STRATEGIES.MANUAL_INTERVENTION],
|
|
329
|
+
retryable: true,
|
|
330
|
+
...options,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Network/External Service Errors
|
|
337
|
+
*/
|
|
338
|
+
class NetworkError extends QualityGatesError {
|
|
339
|
+
constructor(url, statusCode, response, options = {}) {
|
|
340
|
+
super({
|
|
341
|
+
category: ERROR_CATEGORIES.NETWORK,
|
|
342
|
+
code: 'NETWORK_REQUEST_FAILED',
|
|
343
|
+
message: `Network request failed: ${url} (status: ${statusCode})`,
|
|
344
|
+
severity: statusCode >= 500 ? ERROR_SEVERITY.ERROR : ERROR_SEVERITY.WARNING,
|
|
345
|
+
component: 'network-client',
|
|
346
|
+
operation: 'make_request',
|
|
347
|
+
context: {
|
|
348
|
+
url,
|
|
349
|
+
statusCode,
|
|
350
|
+
response,
|
|
351
|
+
method: options.method,
|
|
352
|
+
headers: options.headers,
|
|
353
|
+
},
|
|
354
|
+
recoveryStrategies: [RECOVERY_STRATEGIES.RETRY, RECOVERY_STRATEGIES.FALLBACK],
|
|
355
|
+
retryable: true,
|
|
356
|
+
...options,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* File System Errors
|
|
363
|
+
*/
|
|
364
|
+
class FileSystemError extends QualityGatesError {
|
|
365
|
+
constructor(operation, filePath, originalError, options = {}) {
|
|
366
|
+
super({
|
|
367
|
+
category: ERROR_CATEGORIES.INFRASTRUCTURE,
|
|
368
|
+
code: 'FILE_SYSTEM_ERROR',
|
|
369
|
+
message: `File system error: ${operation} failed for ${filePath}`,
|
|
370
|
+
severity: ERROR_SEVERITY.ERROR,
|
|
371
|
+
component: 'file-system',
|
|
372
|
+
operation,
|
|
373
|
+
context: {
|
|
374
|
+
filePath,
|
|
375
|
+
originalError: originalError.message,
|
|
376
|
+
errorCode: originalError.code,
|
|
377
|
+
permissions: options.permissions,
|
|
378
|
+
},
|
|
379
|
+
recoveryStrategies: [RECOVERY_STRATEGIES.RETRY, RECOVERY_STRATEGIES.MANUAL_INTERVENTION],
|
|
380
|
+
retryable: true,
|
|
381
|
+
...options,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Error Factory Functions
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Create a god object error
|
|
392
|
+
*/
|
|
393
|
+
function createGodObjectError(file, lineCount, threshold, options = {}) {
|
|
394
|
+
return new GodObjectError(file, lineCount, threshold, options);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Create a hidden TODO error
|
|
399
|
+
*/
|
|
400
|
+
function createHiddenTodoError(file, todoCount, confidence, options = {}) {
|
|
401
|
+
return new HiddenTodoError(file, todoCount, confidence, options);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Create a configuration error
|
|
406
|
+
*/
|
|
407
|
+
function createConfigurationError(configKey, expectedType, actualValue, options = {}) {
|
|
408
|
+
return new ConfigurationError(configKey, expectedType, actualValue, options);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Create a waiver error
|
|
413
|
+
*/
|
|
414
|
+
function createWaiverError(waiverId, reason, options = {}) {
|
|
415
|
+
return new WaiverError(waiverId, reason, options);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Create an execution error
|
|
420
|
+
*/
|
|
421
|
+
function createExecutionError(command, exitCode, stderr, options = {}) {
|
|
422
|
+
return new ExecutionError(command, exitCode, stderr, options);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Create a network error
|
|
427
|
+
*/
|
|
428
|
+
function createNetworkError(url, statusCode, response, options = {}) {
|
|
429
|
+
return new NetworkError(url, statusCode, response, options);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Create a file system error
|
|
434
|
+
*/
|
|
435
|
+
function createFileSystemError(operation, filePath, originalError, options = {}) {
|
|
436
|
+
return new FileSystemError(operation, filePath, originalError, options);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Error Classification Utilities
|
|
441
|
+
*/
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Classify an error by its properties
|
|
445
|
+
*/
|
|
446
|
+
function classifyError(error) {
|
|
447
|
+
const classification = {
|
|
448
|
+
category: ERROR_CATEGORIES.INTERNAL,
|
|
449
|
+
severity: ERROR_SEVERITY.ERROR,
|
|
450
|
+
retryable: false,
|
|
451
|
+
requiresHumanIntervention: false,
|
|
452
|
+
canAutoRecover: false,
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
if (error instanceof QualityGatesError) {
|
|
456
|
+
classification.category = error.category;
|
|
457
|
+
classification.severity = error.severity;
|
|
458
|
+
classification.retryable = error.retryable;
|
|
459
|
+
classification.requiresHumanIntervention = error.requiresHumanIntervention();
|
|
460
|
+
classification.canAutoRecover = error.canAutoRecover();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return classification;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Get error statistics from a collection of errors
|
|
468
|
+
*/
|
|
469
|
+
function getErrorStatistics(errors) {
|
|
470
|
+
const stats = {
|
|
471
|
+
total: errors.length,
|
|
472
|
+
byCategory: {},
|
|
473
|
+
bySeverity: {},
|
|
474
|
+
retryable: 0,
|
|
475
|
+
requiresHumanIntervention: 0,
|
|
476
|
+
canAutoRecover: 0,
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
errors.forEach((error) => {
|
|
480
|
+
const classification = classifyError(error);
|
|
481
|
+
|
|
482
|
+
// Count by category
|
|
483
|
+
stats.byCategory[classification.category] =
|
|
484
|
+
(stats.byCategory[classification.category] || 0) + 1;
|
|
485
|
+
|
|
486
|
+
// Count by severity
|
|
487
|
+
stats.bySeverity[classification.severity] =
|
|
488
|
+
(stats.bySeverity[classification.severity] || 0) + 1;
|
|
489
|
+
|
|
490
|
+
// Count flags
|
|
491
|
+
if (classification.retryable) stats.retryable++;
|
|
492
|
+
if (classification.requiresHumanIntervention) stats.requiresHumanIntervention++;
|
|
493
|
+
if (classification.canAutoRecover) stats.canAutoRecover++;
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
return stats;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
module.exports = {
|
|
500
|
+
QualityGatesError,
|
|
501
|
+
GodObjectError,
|
|
502
|
+
HiddenTodoError,
|
|
503
|
+
ConfigurationError,
|
|
504
|
+
WaiverError,
|
|
505
|
+
ExecutionError,
|
|
506
|
+
NetworkError,
|
|
507
|
+
FileSystemError,
|
|
508
|
+
ERROR_CATEGORIES,
|
|
509
|
+
ERROR_SEVERITY,
|
|
510
|
+
RECOVERY_STRATEGIES,
|
|
511
|
+
createGodObjectError,
|
|
512
|
+
createHiddenTodoError,
|
|
513
|
+
createConfigurationError,
|
|
514
|
+
createWaiverError,
|
|
515
|
+
createExecutionError,
|
|
516
|
+
createNetworkError,
|
|
517
|
+
createFileSystemError,
|
|
518
|
+
classifyError,
|
|
519
|
+
getErrorStatistics,
|
|
520
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get staged files from git
|
|
3
|
+
* @returns {string[]} Array of staged file paths
|
|
4
|
+
*/
|
|
5
|
+
export function getStagedFiles(): string[];
|
|
6
|
+
/**
|
|
7
|
+
* Check for god objects in staged files
|
|
8
|
+
* @param {string[]} stagedFiles - Array of staged file paths
|
|
9
|
+
* @param {string} language - Language to check ('rust', 'typescript', etc.)
|
|
10
|
+
* @returns {Object} God object analysis results
|
|
11
|
+
*/
|
|
12
|
+
export function checkGodObjects(stagedFiles: string[], language?: string): any;
|
|
13
|
+
/**
|
|
14
|
+
* Check for hidden TODOs in staged files
|
|
15
|
+
* @param {string[]} stagedFiles - Array of staged file paths
|
|
16
|
+
* @returns {Object} TODO analysis results
|
|
17
|
+
*/
|
|
18
|
+
export function checkHiddenTodos(stagedFiles: string[]): any;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a waiver applies to the given gate
|
|
21
|
+
* @param {string} gate - Gate name to check
|
|
22
|
+
* @returns {Object} Waiver check result
|
|
23
|
+
*/
|
|
24
|
+
export function checkWaiver(gate: string): any;
|
|
25
|
+
/**
|
|
26
|
+
* Detect if project is in crisis response mode
|
|
27
|
+
* @returns {boolean} True if in crisis mode
|
|
28
|
+
*/
|
|
29
|
+
export function detectCrisisMode(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Run comprehensive quality gates on staged files
|
|
32
|
+
* @param {Object} options - Options for quality gates
|
|
33
|
+
* @returns {Object} Quality gate results
|
|
34
|
+
*/
|
|
35
|
+
export function runQualityGates(options?: any): any;
|
|
36
|
+
export namespace CONFIG {
|
|
37
|
+
namespace godObjectThresholds {
|
|
38
|
+
let warning: number;
|
|
39
|
+
let critical: number;
|
|
40
|
+
}
|
|
41
|
+
let todoConfidenceThreshold: number;
|
|
42
|
+
let supportedExtensions: string[];
|
|
43
|
+
namespace crisisResponseThresholds {
|
|
44
|
+
export let godObjectCritical: number;
|
|
45
|
+
let todoConfidenceThreshold_1: number;
|
|
46
|
+
export { todoConfidenceThreshold_1 as todoConfidenceThreshold };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=quality-gates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-gates.d.ts","sourceRoot":"","sources":["../../src/utils/quality-gates.js"],"names":[],"mappings":"AAyGA;;;GAGG;AACH,kCAFa,MAAM,EAAE,CAcpB;AAED;;;;;GAKG;AACH,6CAJW,MAAM,EAAE,aACR,MAAM,OAqDhB;AAED;;;;GAIG;AACH,8CAHW,MAAM,EAAE,OA2ClB;AApMD;;;;GAIG;AACH,kCAHW,MAAM,OAiChB;AAED;;;GAGG;AACH,oCAFa,OAAO,CAkCnB;AA6HD;;;;GAIG;AACH,oDAqHC"}
|