@vibecheckai/cli 2.5.7 → 2.7.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/LICENSE +1 -1
- package/dist/bundles/vibecheck-core.js +20 -20
- package/dist/commands/secrets-allowlist.js +4 -4
- package/dist/commands/secrets-allowlist.js.map +1 -1
- package/dist/commands/ship-consolidated.js +193 -193
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/init/ci-generator.d.ts +2 -2
- package/dist/init/hooks-installer.d.ts +2 -2
- package/dist/init/index.d.ts +1 -1
- package/dist/init/index.d.ts.map +1 -1
- package/dist/init/index.js +2 -2
- package/dist/init/index.js.map +1 -1
- package/dist/init/templates.d.ts +6 -285
- package/dist/init/templates.d.ts.map +1 -1
- package/dist/init/templates.js +2 -3
- package/dist/init/templates.js.map +1 -1
- package/dist/runtime/json-output.d.ts +2 -2
- package/package.json +11 -3
- package/dist/bundles/guardrail-core.js +0 -25799
- package/dist/bundles/guardrail-security.js +0 -208687
- package/dist/bundles/guardrail-ship.js +0 -2318
- package/dist/commands/autopilot-decision.d.ts +0 -24
- package/dist/commands/autopilot-decision.d.ts.map +0 -1
- package/dist/commands/autopilot-decision.js +0 -304
- package/dist/commands/autopilot-decision.js.map +0 -1
- package/dist/commands/autopilot.d.ts +0 -33
- package/dist/commands/autopilot.d.ts.map +0 -1
- package/dist/commands/autopilot.js +0 -1539
- package/dist/commands/autopilot.js.map +0 -1
- package/dist/commands/context.d.ts +0 -8
- package/dist/commands/context.d.ts.map +0 -1
- package/dist/commands/context.js +0 -340
- package/dist/commands/context.js.map +0 -1
- package/dist/commands/debug.d.ts +0 -78
- package/dist/commands/debug.d.ts.map +0 -1
- package/dist/commands/debug.js +0 -381
- package/dist/commands/debug.js.map +0 -1
- package/dist/commands/preview.d.ts +0 -54
- package/dist/commands/preview.d.ts.map +0 -1
- package/dist/commands/preview.js +0 -352
- package/dist/commands/preview.js.map +0 -1
- package/dist/commands/quality/check.d.ts +0 -31
- package/dist/commands/quality/check.d.ts.map +0 -1
- package/dist/commands/quality/check.js +0 -242
- package/dist/commands/quality/check.js.map +0 -1
- package/dist/commands/quality/index.d.ts +0 -8
- package/dist/commands/quality/index.d.ts.map +0 -1
- package/dist/commands/quality/index.js +0 -14
- package/dist/commands/quality/index.js.map +0 -1
- package/dist/commands/quality/setup-quality.d.ts +0 -23
- package/dist/commands/quality/setup-quality.d.ts.map +0 -1
- package/dist/commands/quality/setup-quality.js +0 -452
- package/dist/commands/quality/setup-quality.js.map +0 -1
- package/dist/commands/quality/tidy.d.ts +0 -41
- package/dist/commands/quality/tidy.d.ts.map +0 -1
- package/dist/commands/quality/tidy.js +0 -466
- package/dist/commands/quality/tidy.js.map +0 -1
- package/dist/commands/quality/utils.d.ts +0 -73
- package/dist/commands/quality/utils.d.ts.map +0 -1
- package/dist/commands/quality/utils.js +0 -158
- package/dist/commands/quality/utils.js.map +0 -1
- package/dist/fix/analytics.d.ts +0 -121
- package/dist/fix/analytics.d.ts.map +0 -1
- package/dist/fix/analytics.js +0 -289
- package/dist/fix/analytics.js.map +0 -1
- package/dist/fix/audit.d.ts +0 -61
- package/dist/fix/audit.d.ts.map +0 -1
- package/dist/fix/audit.js +0 -149
- package/dist/fix/audit.js.map +0 -1
- package/dist/fix/config.d.ts +0 -78
- package/dist/fix/config.d.ts.map +0 -1
- package/dist/fix/config.js +0 -200
- package/dist/fix/config.js.map +0 -1
- package/dist/fix/impact.d.ts +0 -74
- package/dist/fix/impact.d.ts.map +0 -1
- package/dist/fix/impact.js +0 -281
- package/dist/fix/impact.js.map +0 -1
- package/dist/fix/learning.d.ts +0 -109
- package/dist/fix/learning.d.ts.map +0 -1
- package/dist/fix/learning.js +0 -296
- package/dist/fix/learning.js.map +0 -1
- package/dist/fix/metrics.d.ts +0 -106
- package/dist/fix/metrics.d.ts.map +0 -1
- package/dist/fix/metrics.js +0 -138
- package/dist/fix/metrics.js.map +0 -1
- package/dist/fix/parallel.d.ts +0 -69
- package/dist/fix/parallel.d.ts.map +0 -1
- package/dist/fix/parallel.js +0 -203
- package/dist/fix/parallel.js.map +0 -1
- package/dist/fix/report.d.ts +0 -40
- package/dist/fix/report.d.ts.map +0 -1
- package/dist/fix/report.js +0 -212
- package/dist/fix/report.js.map +0 -1
- package/dist/fix/strategy.d.ts +0 -53
- package/dist/fix/strategy.d.ts.map +0 -1
- package/dist/fix/strategy.js +0 -143
- package/dist/fix/strategy.js.map +0 -1
- package/dist/fix/templates.d.ts +0 -58
- package/dist/fix/templates.d.ts.map +0 -1
- package/dist/fix/templates.js +0 -259
- package/dist/fix/templates.js.map +0 -1
- package/dist/fix/testing.d.ts +0 -68
- package/dist/fix/testing.d.ts.map +0 -1
- package/dist/fix/testing.js +0 -245
- package/dist/fix/testing.js.map +0 -1
- package/dist/fix/validation.d.ts +0 -71
- package/dist/fix/validation.d.ts.map +0 -1
- package/dist/fix/validation.js +0 -267
- package/dist/fix/validation.js.map +0 -1
- package/dist/fix/visualization.d.ts +0 -73
- package/dist/fix/visualization.d.ts.map +0 -1
- package/dist/fix/visualization.js +0 -243
- package/dist/fix/visualization.js.map +0 -1
- package/dist/runtime/cli-errors.d.ts +0 -38
- package/dist/runtime/cli-errors.d.ts.map +0 -1
- package/dist/runtime/cli-errors.js +0 -354
- package/dist/runtime/cli-errors.js.map +0 -1
- package/dist/runtime/owner-mode.d.ts +0 -48
- package/dist/runtime/owner-mode.d.ts.map +0 -1
- package/dist/runtime/owner-mode.js +0 -284
- package/dist/runtime/owner-mode.js.map +0 -1
- package/dist/scanner/index.d.ts +0 -8
- package/dist/scanner/index.d.ts.map +0 -1
- package/dist/scanner/index.js +0 -15
- package/dist/scanner/index.js.map +0 -1
- package/dist/scanner/placeholder-detector.d.ts +0 -56
- package/dist/scanner/placeholder-detector.d.ts.map +0 -1
- package/dist/scanner/placeholder-detector.js +0 -220
- package/dist/scanner/placeholder-detector.js.map +0 -1
- package/dist/scanner/route-detector.d.ts +0 -100
- package/dist/scanner/route-detector.d.ts.map +0 -1
- package/dist/scanner/route-detector.js +0 -455
- package/dist/scanner/route-detector.js.map +0 -1
- package/dist/scanner/scoring.d.ts +0 -67
- package/dist/scanner/scoring.d.ts.map +0 -1
- package/dist/scanner/scoring.js +0 -284
- package/dist/scanner/scoring.js.map +0 -1
- package/dist/ship-baseline.d.ts +0 -56
- package/dist/ship-baseline.d.ts.map +0 -1
- package/dist/ship-baseline.js +0 -194
- package/dist/ship-baseline.js.map +0 -1
- package/dist/ship-config.d.ts +0 -91
- package/dist/ship-config.d.ts.map +0 -1
- package/dist/ship-config.js +0 -133
- package/dist/ship-config.js.map +0 -1
- package/dist/ship-data-loader.d.ts +0 -70
- package/dist/ship-data-loader.d.ts.map +0 -1
- package/dist/ship-data-loader.js +0 -301
- package/dist/ship-data-loader.js.map +0 -1
- package/dist/utils/ai-helpers.d.ts +0 -72
- package/dist/utils/ai-helpers.d.ts.map +0 -1
- package/dist/utils/ai-helpers.js +0 -339
- package/dist/utils/ai-helpers.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -34
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -160
- package/dist/utils/validation.js.map +0 -1
package/dist/fix/strategy.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Fix Strategies and Profiles
|
|
4
|
-
*
|
|
5
|
-
* Provides different fixing strategies (conservative, balanced, aggressive)
|
|
6
|
-
* to control how fixes are applied based on risk tolerance and confidence levels.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.FixStrategyFilter = exports.STRATEGY_PRESETS = void 0;
|
|
10
|
-
exports.STRATEGY_PRESETS = {
|
|
11
|
-
conservative: {
|
|
12
|
-
strategy: 'conservative',
|
|
13
|
-
minConfidence: 0.9,
|
|
14
|
-
maxRisk: 'low',
|
|
15
|
-
allowHighRisk: false,
|
|
16
|
-
requireVerification: true,
|
|
17
|
-
maxConcurrentFixes: 1,
|
|
18
|
-
batchSize: 5,
|
|
19
|
-
retryOnFailure: false,
|
|
20
|
-
autoRollback: true,
|
|
21
|
-
},
|
|
22
|
-
balanced: {
|
|
23
|
-
strategy: 'balanced',
|
|
24
|
-
minConfidence: 0.7,
|
|
25
|
-
maxRisk: 'medium',
|
|
26
|
-
allowHighRisk: false,
|
|
27
|
-
requireVerification: true,
|
|
28
|
-
maxConcurrentFixes: 3,
|
|
29
|
-
batchSize: 10,
|
|
30
|
-
retryOnFailure: true,
|
|
31
|
-
autoRollback: true,
|
|
32
|
-
},
|
|
33
|
-
aggressive: {
|
|
34
|
-
strategy: 'aggressive',
|
|
35
|
-
minConfidence: 0.5,
|
|
36
|
-
maxRisk: 'high',
|
|
37
|
-
allowHighRisk: true,
|
|
38
|
-
requireVerification: false,
|
|
39
|
-
maxConcurrentFixes: 10,
|
|
40
|
-
batchSize: 50,
|
|
41
|
-
retryOnFailure: true,
|
|
42
|
-
autoRollback: false,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
class FixStrategyFilter {
|
|
46
|
-
constructor(config) {
|
|
47
|
-
if (typeof config === 'string') {
|
|
48
|
-
this.config = exports.STRATEGY_PRESETS[config];
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
this.config = config;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Filter fix packs based on strategy
|
|
56
|
-
*/
|
|
57
|
-
filterPacks(packs) {
|
|
58
|
-
return packs
|
|
59
|
-
.map((pack) => this.filterPack(pack))
|
|
60
|
-
.filter((pack) => pack !== null && pack.fixes.length > 0);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Filter a single pack based on strategy
|
|
64
|
-
*/
|
|
65
|
-
filterPack(pack) {
|
|
66
|
-
const filteredFixes = pack.fixes.filter((fix) => this.shouldApplyFix(fix));
|
|
67
|
-
if (filteredFixes.length === 0) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
const avgConfidence = filteredFixes.length > 0
|
|
71
|
-
? filteredFixes.reduce((sum, f) => sum + f.confidence, 0) /
|
|
72
|
-
filteredFixes.length
|
|
73
|
-
: 0;
|
|
74
|
-
return {
|
|
75
|
-
...pack,
|
|
76
|
-
fixes: filteredFixes,
|
|
77
|
-
confidence: avgConfidence,
|
|
78
|
-
estimatedRisk: this.calculatePackRisk(filteredFixes),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Determine if a fix should be applied based on strategy
|
|
83
|
-
*/
|
|
84
|
-
shouldApplyFix(fix) {
|
|
85
|
-
// Check confidence threshold
|
|
86
|
-
if (fix.confidence < this.config.minConfidence) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
// Check risk level
|
|
90
|
-
if (fix.risk === 'high' && !this.config.allowHighRisk) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
// Check max risk
|
|
94
|
-
const riskLevels = { low: 1, medium: 2, high: 3 };
|
|
95
|
-
if (riskLevels[fix.risk] > riskLevels[this.config.maxRisk]) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Calculate pack risk based on filtered fixes
|
|
102
|
-
*/
|
|
103
|
-
calculatePackRisk(fixes) {
|
|
104
|
-
if (fixes.length === 0)
|
|
105
|
-
return 'low';
|
|
106
|
-
const highRiskCount = fixes.filter((f) => f.risk === 'high').length;
|
|
107
|
-
const mediumRiskCount = fixes.filter((f) => f.risk === 'medium').length;
|
|
108
|
-
if (highRiskCount > fixes.length * 0.3)
|
|
109
|
-
return 'high';
|
|
110
|
-
if (mediumRiskCount > fixes.length * 0.5)
|
|
111
|
-
return 'medium';
|
|
112
|
-
return 'low';
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Batch fixes according to strategy
|
|
116
|
-
*/
|
|
117
|
-
batchFixes(packs) {
|
|
118
|
-
const batches = [];
|
|
119
|
-
const batchSize = this.config.batchSize;
|
|
120
|
-
for (let i = 0; i < packs.length; i += batchSize) {
|
|
121
|
-
batches.push(packs.slice(i, i + batchSize));
|
|
122
|
-
}
|
|
123
|
-
return batches;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get configuration
|
|
127
|
-
*/
|
|
128
|
-
getConfig() {
|
|
129
|
-
return { ...this.config };
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Merge custom config with strategy preset
|
|
133
|
-
*/
|
|
134
|
-
static mergeConfig(strategy, overrides) {
|
|
135
|
-
return {
|
|
136
|
-
...exports.STRATEGY_PRESETS[strategy],
|
|
137
|
-
...overrides,
|
|
138
|
-
strategy, // Ensure strategy is not overridden
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.FixStrategyFilter = FixStrategyFilter;
|
|
143
|
-
//# sourceMappingURL=strategy.js.map
|
package/dist/fix/strategy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../src/fix/strategy.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAkBU,QAAA,gBAAgB,GAAwC;IACnE,YAAY,EAAE;QACZ,QAAQ,EAAE,cAAc;QACxB,aAAa,EAAE,GAAG;QAClB,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,KAAK;QACpB,mBAAmB,EAAE,IAAI;QACzB,kBAAkB,EAAE,CAAC;QACrB,SAAS,EAAE,CAAC;QACZ,cAAc,EAAE,KAAK;QACrB,YAAY,EAAE,IAAI;KACnB;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,GAAG;QAClB,OAAO,EAAE,QAAQ;QACjB,aAAa,EAAE,KAAK;QACpB,mBAAmB,EAAE,IAAI;QACzB,kBAAkB,EAA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AAC,IAAI,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAC;QAExE,IAAI,aAAa,GAAG,KAAK,CAAC,MAAM,GAAG,GAAG;YAAE,OAAO,MAAM,CAAC;QACtD,IAAI,eAAe,GAAG,KAAK,CAAC,MAAM,GAAG,GAAG;YAAE,OAAO,QAAQ,CAAC;QAC1D,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,KAAgB;QACzB,MAAM,OAAO,GAAgB,EAAE,CAAC;QAChC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAExC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAChB,QAAqB,EACrB,SAAkC;QAElC,OAAO;YACL,GAAG,wBAAgB,CAAC,QAAQ,CAAC;YAC7B,GAAG,SAAS;YACZ,QAAQ,EAAE,oCAAoC;SAC/C,CAAC;IACJ,CAAC;CACF;AArHD,8CAqHC"}
|
package/dist/fix/templates.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fix Templates and Pattern Library
|
|
3
|
-
*
|
|
4
|
-
* Provides reusable fix templates and patterns for common issues.
|
|
5
|
-
* Templates can be customized and extended for specific use cases.
|
|
6
|
-
*/
|
|
7
|
-
import { Finding, Fix } from './engine';
|
|
8
|
-
export interface FixTemplate {
|
|
9
|
-
id: string;
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
category: string;
|
|
13
|
-
pattern: string;
|
|
14
|
-
confidence: number;
|
|
15
|
-
risk: 'low' | 'medium' | 'high';
|
|
16
|
-
apply: (finding: Finding, context: TemplateContext) => Fix | null;
|
|
17
|
-
validate?: (fix: Fix, context: TemplateContext) => boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface TemplateContext {
|
|
20
|
-
filePath: string;
|
|
21
|
-
fileContent: string;
|
|
22
|
-
lineNumber: number;
|
|
23
|
-
lineContent: string;
|
|
24
|
-
projectPath: string;
|
|
25
|
-
}
|
|
26
|
-
export declare class FixTemplateLibrary {
|
|
27
|
-
private templates;
|
|
28
|
-
constructor();
|
|
29
|
-
/**
|
|
30
|
-
* Register a fix template
|
|
31
|
-
*/
|
|
32
|
-
register(template: FixTemplate): void;
|
|
33
|
-
/**
|
|
34
|
-
* Find matching templates for a finding
|
|
35
|
-
*/
|
|
36
|
-
findMatching(finding: Finding, context: TemplateContext): FixTemplate[];
|
|
37
|
-
/**
|
|
38
|
-
* Apply best matching template
|
|
39
|
-
*/
|
|
40
|
-
applyBestMatch(finding: Finding, context: TemplateContext): Fix | null;
|
|
41
|
-
/**
|
|
42
|
-
* Register default templates
|
|
43
|
-
*/
|
|
44
|
-
private registerDefaultTemplates;
|
|
45
|
-
/**
|
|
46
|
-
* Infer environment variable name from key name
|
|
47
|
-
*/
|
|
48
|
-
private inferEnvVarName;
|
|
49
|
-
/**
|
|
50
|
-
* Get all registered templates
|
|
51
|
-
*/
|
|
52
|
-
getAllTemplates(): FixTemplate[];
|
|
53
|
-
/**
|
|
54
|
-
* Get template by ID
|
|
55
|
-
*/
|
|
56
|
-
getTemplate(id: string): FixTemplate | undefined;
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/fix/templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH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
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Fix Templates and Pattern Library
|
|
4
|
-
*
|
|
5
|
-
* Provides reusable fix templates and patterns for common issues.
|
|
6
|
-
* Templates can be customized and extended for specific use cases.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.FixTemplateLibrary = void 0;
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
class FixTemplateLibrary {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.templates = new Map();
|
|
15
|
-
this.registerDefaultTemplates();
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Register a fix template
|
|
19
|
-
*/
|
|
20
|
-
register(template) {
|
|
21
|
-
this.templates.set(template.id, template);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Find matching templates for a finding
|
|
25
|
-
*/
|
|
26
|
-
findMatching(finding, context) {
|
|
27
|
-
const matches = [];
|
|
28
|
-
for (const template of this.templates.values()) {
|
|
29
|
-
// Check category match
|
|
30
|
-
if (template.category.toLowerCase() !== finding.category.toLowerCase() &&
|
|
31
|
-
!finding.category
|
|
32
|
-
.toLowerCase()
|
|
33
|
-
.includes(template.category.toLowerCase())) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
// Check pattern match
|
|
37
|
-
try {
|
|
38
|
-
const regex = new RegExp(template.pattern, 'i');
|
|
39
|
-
if (regex.test(context.lineContent) ||
|
|
40
|
-
regex.test(finding.description)) {
|
|
41
|
-
matches.push(template);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// Invalid regex, skip
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Sort by confidence (highest first)
|
|
49
|
-
return matches.sort((a, b) => b.confidence - a.confidence);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Apply best matching template
|
|
53
|
-
*/
|
|
54
|
-
applyBestMatch(finding, context) {
|
|
55
|
-
const matches = this.findMatching(finding, context);
|
|
56
|
-
if (matches.length === 0) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
// Try templates in order of confidence
|
|
60
|
-
for (const template of matches) {
|
|
61
|
-
const fix = template.apply(finding, context);
|
|
62
|
-
if (fix && template.validate && !template.validate(fix, context)) {
|
|
63
|
-
continue; // Validation failed, try next
|
|
64
|
-
}
|
|
65
|
-
if (fix) {
|
|
66
|
-
return fix;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Register default templates
|
|
73
|
-
*/
|
|
74
|
-
registerDefaultTemplates() {
|
|
75
|
-
// Secret/API Key Template
|
|
76
|
-
this.register({
|
|
77
|
-
id: 'secret-env-var',
|
|
78
|
-
name: 'Move Secret to Environment Variable',
|
|
79
|
-
description: 'Replace hardcoded secrets with environment variables',
|
|
80
|
-
category: 'security',
|
|
81
|
-
pattern: '(api[_-]?key|secret|token|password)\\s*[:=]\\s*[\'"`][^\'"`]+[\'"`]',
|
|
82
|
-
confidence: 0.9,
|
|
83
|
-
risk: 'low',
|
|
84
|
-
apply: (finding, context) => {
|
|
85
|
-
const line = context.lineContent;
|
|
86
|
-
const match = line.match(/(\w+)\s*[:=]\s*[\'"`]([^\'"`]+)[\'"`]/i);
|
|
87
|
-
if (!match)
|
|
88
|
-
return null;
|
|
89
|
-
const [, keyName, value] = match;
|
|
90
|
-
const envVarName = this.inferEnvVarName(keyName);
|
|
91
|
-
const newLine = line.replace(/[\'"`][^\'"`]+[\'"`]/, `process.env.${envVarName}`);
|
|
92
|
-
return {
|
|
93
|
-
findingId: finding.id,
|
|
94
|
-
file: finding.file,
|
|
95
|
-
line: finding.line,
|
|
96
|
-
oldCode: line,
|
|
97
|
-
newCode: newLine,
|
|
98
|
-
confidence: 0.9,
|
|
99
|
-
risk: 'low',
|
|
100
|
-
explanation: `Replace hardcoded ${keyName} with environment variable ${envVarName}`,
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
// Console.log Template
|
|
105
|
-
this.register({
|
|
106
|
-
id: 'console-log-to-logger',
|
|
107
|
-
name: 'Replace console.log with Logger',
|
|
108
|
-
description: 'Replace console.log statements with proper logger',
|
|
109
|
-
category: 'quality',
|
|
110
|
-
pattern: 'console\\.(log|warn|error|info|debug)',
|
|
111
|
-
confidence: 0.85,
|
|
112
|
-
risk: 'low',
|
|
113
|
-
apply: (finding, context) => {
|
|
114
|
-
const line = context.lineContent;
|
|
115
|
-
const match = line.match(/console\.(log|warn|error|info|debug)/);
|
|
116
|
-
if (!match)
|
|
117
|
-
return null;
|
|
118
|
-
const [, method] = match;
|
|
119
|
-
const loggerMethod = method === 'log' ? 'debug' : method;
|
|
120
|
-
const newLine = line.replace(/console\.(log|warn|error|info|debug)/, `logger.${loggerMethod}`);
|
|
121
|
-
return {
|
|
122
|
-
findingId: finding.id,
|
|
123
|
-
file: finding.file,
|
|
124
|
-
line: finding.line,
|
|
125
|
-
oldCode: line,
|
|
126
|
-
newCode: newLine,
|
|
127
|
-
confidence: 0.85,
|
|
128
|
-
risk: 'low',
|
|
129
|
-
explanation: `Replace console.${method} with logger.${loggerMethod}`,
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
// Var to Const Template
|
|
134
|
-
this.register({
|
|
135
|
-
id: 'var-to-const',
|
|
136
|
-
name: 'Replace var with const/let',
|
|
137
|
-
description: 'Replace var declarations with const or let',
|
|
138
|
-
category: 'quality',
|
|
139
|
-
pattern: '\\bvar\\s+',
|
|
140
|
-
confidence: 0.9,
|
|
141
|
-
risk: 'low',
|
|
142
|
-
apply: (finding, context) => {
|
|
143
|
-
const line = context.lineContent;
|
|
144
|
-
if (!/\bvar\s+/.test(line))
|
|
145
|
-
return null;
|
|
146
|
-
// Heuristic: use const if no reassignment detected
|
|
147
|
-
const isReassigned = /=\s*\w+.*=/.test(line);
|
|
148
|
-
const replacement = isReassigned ? 'let' : 'const';
|
|
149
|
-
const newLine = line.replace(/\bvar\b/, replacement);
|
|
150
|
-
return {
|
|
151
|
-
findingId: finding.id,
|
|
152
|
-
file: finding.file,
|
|
153
|
-
line: finding.line,
|
|
154
|
-
oldCode: line,
|
|
155
|
-
newCode: newLine,
|
|
156
|
-
confidence: 0.85,
|
|
157
|
-
risk: 'low',
|
|
158
|
-
explanation: `Replace var with ${replacement} for better scoping`,
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
// Dependency Upgrade Template
|
|
163
|
-
this.register({
|
|
164
|
-
id: 'dependency-upgrade',
|
|
165
|
-
name: 'Upgrade Dependency Version',
|
|
166
|
-
description: 'Upgrade vulnerable dependency to safe version',
|
|
167
|
-
category: 'security',
|
|
168
|
-
pattern: 'upgrade.*to.*@?[\\d.]+',
|
|
169
|
-
confidence: 0.95,
|
|
170
|
-
risk: 'low',
|
|
171
|
-
apply: (finding, context) => {
|
|
172
|
-
const match = finding.recommendation.match(/Upgrade to ([^@\s]+)@?([^\s]+)?/i);
|
|
173
|
-
if (!match)
|
|
174
|
-
return null;
|
|
175
|
-
const [, pkgName, version] = match;
|
|
176
|
-
try {
|
|
177
|
-
const packageJsonPath = (0, path_1.join)(context.projectPath, 'package.json');
|
|
178
|
-
const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
|
|
179
|
-
const oldVersion = packageJson.dependencies?.[pkgName] ||
|
|
180
|
-
packageJson.devDependencies?.[pkgName];
|
|
181
|
-
if (!oldVersion)
|
|
182
|
-
return null;
|
|
183
|
-
const newVersion = version || 'latest';
|
|
184
|
-
const oldLine = `"${pkgName}": "${oldVersion}"`;
|
|
185
|
-
const newLine = `"${pkgName}": "^${newVersion}"`;
|
|
186
|
-
return {
|
|
187
|
-
findingId: finding.id,
|
|
188
|
-
file: 'package.json',
|
|
189
|
-
line: finding.line,
|
|
190
|
-
oldCode: oldLine,
|
|
191
|
-
newCode: newLine,
|
|
192
|
-
confidence: 0.95,
|
|
193
|
-
risk: 'low',
|
|
194
|
-
explanation: `Upgrade ${pkgName} from ${oldVersion} to ${newVersion}`,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
catch {
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
// TODO Comment Template
|
|
203
|
-
this.register({
|
|
204
|
-
id: 'add-todo-comment',
|
|
205
|
-
name: 'Add TODO Comment',
|
|
206
|
-
description: 'Add TODO comment for manual review',
|
|
207
|
-
category: 'quality',
|
|
208
|
-
pattern: '.*', // Catch-all for low confidence fixes
|
|
209
|
-
confidence: 0.5,
|
|
210
|
-
risk: 'low',
|
|
211
|
-
apply: (finding, context) => {
|
|
212
|
-
const line = context.lineContent;
|
|
213
|
-
const newLine = `// TODO: ${finding.recommendation}\n${line}`;
|
|
214
|
-
return {
|
|
215
|
-
findingId: finding.id,
|
|
216
|
-
file: finding.file,
|
|
217
|
-
line: finding.line,
|
|
218
|
-
oldCode: line,
|
|
219
|
-
newCode: newLine,
|
|
220
|
-
confidence: 0.5,
|
|
221
|
-
risk: 'low',
|
|
222
|
-
explanation: `Add TODO comment: ${finding.recommendation}`,
|
|
223
|
-
};
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Infer environment variable name from key name
|
|
229
|
-
*/
|
|
230
|
-
inferEnvVarName(keyName) {
|
|
231
|
-
const normalized = keyName
|
|
232
|
-
.toUpperCase()
|
|
233
|
-
.replace(/[^A-Z0-9]+/g, '_')
|
|
234
|
-
.replace(/^_+|_+$/g, '');
|
|
235
|
-
if (normalized.includes('API_KEY'))
|
|
236
|
-
return 'API_KEY';
|
|
237
|
-
if (normalized.includes('TOKEN'))
|
|
238
|
-
return 'AUTH_TOKEN';
|
|
239
|
-
if (normalized.includes('SECRET'))
|
|
240
|
-
return 'SECRET_KEY';
|
|
241
|
-
if (normalized.includes('PASSWORD'))
|
|
242
|
-
return 'DB_PASSWORD';
|
|
243
|
-
return normalized || 'SECRET_VALUE';
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Get all registered templates
|
|
247
|
-
*/
|
|
248
|
-
getAllTemplates() {
|
|
249
|
-
return Array.from(this.templates.values());
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Get template by ID
|
|
253
|
-
*/
|
|
254
|
-
getTemplate(id) {
|
|
255
|
-
return this.templates.get(id);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
exports.FixTemplateLibrary = FixTemplateLibrary;
|
|
259
|
-
//# sourceMappingURL=templates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/fix/templates.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,2BAAkC;AAClC,+BAA4B;AAsB5B,MAAa,kBAAkB;IAG7B;QAFQ,cAAS,GAA6B,IAAI,GAAG,EAAE,CAAC;QAGtD,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,QAAqB;QAC5B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,OAAgB,EAAE,OAAwB;QACrD,MAAM,OAAO,GAAkB,EAAE,CAAC;QAElC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/C,uBAAuB;YACvB,IACE,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE;gBAClE,CAAC,OAAO,CAAC,QAAQ;qBACd,WAAW,EAAE;qBACb,QAAQ,CAAC,QAAQ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;oBAClB,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,OAAO;oBAChB,UAAU,EAAE,GAAG;oBACf,IAAI,EAAE,KAAK;oBACX,WAAW,EAAE,qBAAqB,OAAO,CAAC,cAAc,EAAE;iBAC3D,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,OAAe;QACrC,MAAM,UAAU,GAAG,OAAO;aACvB,WAAW,EAAE;aACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;aAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAE3B,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QACrD,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO,YAAY,CAAC;QACtD,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO,YAAY,CAAC;QACvD,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC;YAAE,OAAO,aAAa,CAAC;QAE1D,OAAO,UAAU,IAAI,cAAc,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,EAAU;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;CACF;AAzRD,gDAyRC"}
|
package/dist/fix/testing.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fix Testing Framework
|
|
3
|
-
*
|
|
4
|
-
* Tests fixes before application using sandbox environments,
|
|
5
|
-
* unit tests, and validation checks.
|
|
6
|
-
*/
|
|
7
|
-
import { Fix, FixPack } from './engine';
|
|
8
|
-
export interface TestResult {
|
|
9
|
-
passed: boolean;
|
|
10
|
-
testsRun: number;
|
|
11
|
-
testsPassed: number;
|
|
12
|
-
testsFailed: number;
|
|
13
|
-
errors: string[];
|
|
14
|
-
warnings: string[];
|
|
15
|
-
duration: number;
|
|
16
|
-
}
|
|
17
|
-
export interface FixTestResult {
|
|
18
|
-
fix: Fix;
|
|
19
|
-
testResult: TestResult;
|
|
20
|
-
safeToApply: boolean;
|
|
21
|
-
reason?: string;
|
|
22
|
-
}
|
|
23
|
-
export interface TestConfiguration {
|
|
24
|
-
runTests: boolean;
|
|
25
|
-
testCommand?: string;
|
|
26
|
-
testTimeout: number;
|
|
27
|
-
requireAllTestsPass: boolean;
|
|
28
|
-
sandboxEnabled: boolean;
|
|
29
|
-
}
|
|
30
|
-
export declare class FixTester {
|
|
31
|
-
private projectPath;
|
|
32
|
-
private sandboxPath;
|
|
33
|
-
private config;
|
|
34
|
-
constructor(projectPath: string, config?: Partial<TestConfiguration>);
|
|
35
|
-
/**
|
|
36
|
-
* Test a fix before application
|
|
37
|
-
*/
|
|
38
|
-
testFix(fix: Fix): Promise<FixTestResult>;
|
|
39
|
-
/**
|
|
40
|
-
* Test a pack of fixes
|
|
41
|
-
*/
|
|
42
|
-
testPack(pack: FixPack): Promise<FixTestResult[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Run tests in the project
|
|
45
|
-
*/
|
|
46
|
-
private runTests;
|
|
47
|
-
/**
|
|
48
|
-
* Detect test command from package.json
|
|
49
|
-
*/
|
|
50
|
-
private detectTestCommand;
|
|
51
|
-
/**
|
|
52
|
-
* Extract test count from output
|
|
53
|
-
*/
|
|
54
|
-
private extractTestCount;
|
|
55
|
-
/**
|
|
56
|
-
* Validate fix before testing
|
|
57
|
-
*/
|
|
58
|
-
private validateFix;
|
|
59
|
-
/**
|
|
60
|
-
* Create sandbox environment (future enhancement)
|
|
61
|
-
*/
|
|
62
|
-
private createSandbox;
|
|
63
|
-
/**
|
|
64
|
-
* Cleanup sandbox (future enhancement)
|
|
65
|
-
*/
|
|
66
|
-
private cleanupSandbox;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/fix/testing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAoB;gBAGhC,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,OAAO,CAAC,iBAAiB,CAAM;IAazC;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC;IAqE/C;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,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