@kevinrabun/judges 3.51.0 → 3.53.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/CHANGELOG.md +24 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +112 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/chat-notify.d.ts +9 -0
- package/dist/commands/chat-notify.d.ts.map +1 -0
- package/dist/commands/chat-notify.js +259 -0
- package/dist/commands/chat-notify.js.map +1 -0
- package/dist/commands/code-similarity.d.ts +9 -0
- package/dist/commands/code-similarity.d.ts.map +1 -0
- package/dist/commands/code-similarity.js +232 -0
- package/dist/commands/code-similarity.js.map +1 -0
- package/dist/commands/compliance-weight.d.ts +9 -0
- package/dist/commands/compliance-weight.d.ts.map +1 -0
- package/dist/commands/compliance-weight.js +273 -0
- package/dist/commands/compliance-weight.js.map +1 -0
- package/dist/commands/cross-pr-regression.d.ts +9 -0
- package/dist/commands/cross-pr-regression.d.ts.map +1 -0
- package/dist/commands/cross-pr-regression.js +298 -0
- package/dist/commands/cross-pr-regression.js.map +1 -0
- package/dist/commands/design-audit.d.ts +9 -0
- package/dist/commands/design-audit.d.ts.map +1 -0
- package/dist/commands/design-audit.js +302 -0
- package/dist/commands/design-audit.js.map +1 -0
- package/dist/commands/doc-drift.d.ts +9 -0
- package/dist/commands/doc-drift.d.ts.map +1 -0
- package/dist/commands/doc-drift.js +259 -0
- package/dist/commands/doc-drift.js.map +1 -0
- package/dist/commands/exception-consistency.d.ts +7 -0
- package/dist/commands/exception-consistency.d.ts.map +1 -0
- package/dist/commands/exception-consistency.js +193 -0
- package/dist/commands/exception-consistency.js.map +1 -0
- package/dist/commands/impact-scan.d.ts +9 -0
- package/dist/commands/impact-scan.d.ts.map +1 -0
- package/dist/commands/impact-scan.js +282 -0
- package/dist/commands/impact-scan.js.map +1 -0
- package/dist/commands/judge-learn.d.ts +9 -0
- package/dist/commands/judge-learn.d.ts.map +1 -0
- package/dist/commands/judge-learn.js +218 -0
- package/dist/commands/judge-learn.js.map +1 -0
- package/dist/commands/model-report.d.ts +9 -0
- package/dist/commands/model-report.d.ts.map +1 -0
- package/dist/commands/model-report.js +195 -0
- package/dist/commands/model-report.js.map +1 -0
- package/dist/commands/refactor-safety.d.ts +9 -0
- package/dist/commands/refactor-safety.d.ts.map +1 -0
- package/dist/commands/refactor-safety.js +274 -0
- package/dist/commands/refactor-safety.js.map +1 -0
- package/dist/commands/remediation-lib.d.ts +9 -0
- package/dist/commands/remediation-lib.d.ts.map +1 -0
- package/dist/commands/remediation-lib.js +266 -0
- package/dist/commands/remediation-lib.js.map +1 -0
- package/dist/commands/resource-cleanup.d.ts +7 -0
- package/dist/commands/resource-cleanup.d.ts.map +1 -0
- package/dist/commands/resource-cleanup.js +236 -0
- package/dist/commands/resource-cleanup.js.map +1 -0
- package/dist/commands/team-trust.d.ts +8 -0
- package/dist/commands/team-trust.d.ts.map +1 -0
- package/dist/commands/team-trust.js +175 -0
- package/dist/commands/team-trust.js.map +1 -0
- package/dist/commands/trust-adaptive.d.ts +9 -0
- package/dist/commands/trust-adaptive.d.ts.map +1 -0
- package/dist/commands/trust-adaptive.js +194 -0
- package/dist/commands/trust-adaptive.js.map +1 -0
- package/dist/commands/watch-judge.d.ts +8 -0
- package/dist/commands/watch-judge.d.ts.map +1 -0
- package/dist/commands/watch-judge.js +180 -0
- package/dist/commands/watch-judge.js.map +1 -0
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refactor safety — analyze proposed refactorings for breaking changes,
|
|
3
|
+
* incomplete migrations, orphaned references, and behavioral changes.
|
|
4
|
+
*
|
|
5
|
+
* Compares two directory snapshots or a list of changed files against
|
|
6
|
+
* the broader codebase to detect incomplete refactors.
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync, readdirSync, statSync, existsSync } from "fs";
|
|
9
|
+
import { join, extname, relative } from "path";
|
|
10
|
+
// ─── File Collection ────────────────────────────────────────────────────────
|
|
11
|
+
const CODE_EXTS = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".java", ".cs", ".go", ".rs"]);
|
|
12
|
+
function collectFiles(dir, max = 500) {
|
|
13
|
+
const files = [];
|
|
14
|
+
function walk(d) {
|
|
15
|
+
if (files.length >= max)
|
|
16
|
+
return;
|
|
17
|
+
let entries;
|
|
18
|
+
try {
|
|
19
|
+
entries = readdirSync(d);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
for (const e of entries) {
|
|
25
|
+
if (files.length >= max)
|
|
26
|
+
return;
|
|
27
|
+
if (e.startsWith(".") || e === "node_modules" || e === "dist" || e === "build")
|
|
28
|
+
continue;
|
|
29
|
+
const full = join(d, e);
|
|
30
|
+
try {
|
|
31
|
+
if (statSync(full).isDirectory())
|
|
32
|
+
walk(full);
|
|
33
|
+
else if (CODE_EXTS.has(extname(full)))
|
|
34
|
+
files.push(full);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
/* skip */
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
walk(dir);
|
|
42
|
+
return files;
|
|
43
|
+
}
|
|
44
|
+
// ─── Analysis ───────────────────────────────────────────────────────────────
|
|
45
|
+
function extractExports(content) {
|
|
46
|
+
const exports = [];
|
|
47
|
+
const exportRegex = /\bexport\s+(?:function|class|const|let|type|interface|enum)\s+(\w+)/g;
|
|
48
|
+
let m;
|
|
49
|
+
while ((m = exportRegex.exec(content)) !== null)
|
|
50
|
+
exports.push(m[1]);
|
|
51
|
+
const defaultExport = /\bexport\s+default\s+(?:function|class)?\s*(\w+)?/g;
|
|
52
|
+
while ((m = defaultExport.exec(content)) !== null) {
|
|
53
|
+
if (m[1])
|
|
54
|
+
exports.push(m[1]);
|
|
55
|
+
}
|
|
56
|
+
return exports;
|
|
57
|
+
}
|
|
58
|
+
function extractImports(content) {
|
|
59
|
+
const imports = [];
|
|
60
|
+
const importRegex = /import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g;
|
|
61
|
+
let m;
|
|
62
|
+
while ((m = importRegex.exec(content)) !== null) {
|
|
63
|
+
const names = m[1]
|
|
64
|
+
.split(",")
|
|
65
|
+
.map((n) => n
|
|
66
|
+
.trim()
|
|
67
|
+
.split(/\s+as\s+/)[0]
|
|
68
|
+
.trim())
|
|
69
|
+
.filter(Boolean);
|
|
70
|
+
imports.push({ names, source: m[2] });
|
|
71
|
+
}
|
|
72
|
+
return imports;
|
|
73
|
+
}
|
|
74
|
+
function analyzeRefactorSafety(files, dir) {
|
|
75
|
+
const issues = [];
|
|
76
|
+
// Build export map: symbol → file
|
|
77
|
+
const exportMap = new Map();
|
|
78
|
+
const fileContents = new Map();
|
|
79
|
+
for (const f of files) {
|
|
80
|
+
let content;
|
|
81
|
+
try {
|
|
82
|
+
content = readFileSync(f, "utf-8");
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
fileContents.set(f, content);
|
|
88
|
+
const exports = extractExports(content);
|
|
89
|
+
for (const exp of exports) {
|
|
90
|
+
exportMap.set(exp, f);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Check for orphaned imports (importing symbols that no file exports)
|
|
94
|
+
for (const [filePath, content] of fileContents) {
|
|
95
|
+
const imports = extractImports(content);
|
|
96
|
+
const lines = content.split("\n");
|
|
97
|
+
for (const imp of imports) {
|
|
98
|
+
// Only check local imports (starting with . or ..)
|
|
99
|
+
if (!imp.source.startsWith("."))
|
|
100
|
+
continue;
|
|
101
|
+
for (const name of imp.names) {
|
|
102
|
+
// Check if any file exports this symbol
|
|
103
|
+
if (!exportMap.has(name)) {
|
|
104
|
+
const lineNum = lines.findIndex((l) => l.includes(name) && l.includes("import")) + 1;
|
|
105
|
+
issues.push({
|
|
106
|
+
file: filePath,
|
|
107
|
+
line: lineNum || 1,
|
|
108
|
+
kind: "orphaned-import",
|
|
109
|
+
message: `Import '${name}' from '${imp.source}' — symbol not found in any scanned file exports`,
|
|
110
|
+
severity: "high",
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Detect renamed/removed patterns
|
|
117
|
+
for (const [filePath, content] of fileContents) {
|
|
118
|
+
const lines = content.split("\n");
|
|
119
|
+
// Check for TODO/FIXME indicating incomplete refactor
|
|
120
|
+
for (let i = 0; i < lines.length; i++) {
|
|
121
|
+
const line = lines[i];
|
|
122
|
+
if (/\/\/\s*(TODO|FIXME|HACK|XXX)\s*:?\s*(refactor|rename|migrate|move|deprecated)/i.test(line)) {
|
|
123
|
+
issues.push({
|
|
124
|
+
file: filePath,
|
|
125
|
+
line: i + 1,
|
|
126
|
+
kind: "incomplete-refactor-marker",
|
|
127
|
+
message: `Found refactor marker: ${line.trim().substring(0, 80)}`,
|
|
128
|
+
severity: "medium",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Detect deprecated usage
|
|
133
|
+
for (let i = 0; i < lines.length; i++) {
|
|
134
|
+
if (/@deprecated/i.test(lines[i])) {
|
|
135
|
+
// Find the symbol being deprecated
|
|
136
|
+
const nextLine = lines[i + 1] || "";
|
|
137
|
+
const symbolMatch = nextLine.match(/\b(function|class|const|let|var)\s+(\w+)/);
|
|
138
|
+
if (symbolMatch) {
|
|
139
|
+
const deprecatedName = symbolMatch[2];
|
|
140
|
+
// Count references across codebase
|
|
141
|
+
let refs = 0;
|
|
142
|
+
for (const [otherFile, otherContent] of fileContents) {
|
|
143
|
+
if (otherFile === filePath)
|
|
144
|
+
continue;
|
|
145
|
+
const regex = new RegExp(`\\b${deprecatedName}\\b`, "g");
|
|
146
|
+
const matches = otherContent.match(regex);
|
|
147
|
+
if (matches)
|
|
148
|
+
refs += matches.length;
|
|
149
|
+
}
|
|
150
|
+
if (refs > 0) {
|
|
151
|
+
issues.push({
|
|
152
|
+
file: filePath,
|
|
153
|
+
line: i + 1,
|
|
154
|
+
kind: "deprecated-still-used",
|
|
155
|
+
message: `@deprecated symbol '${deprecatedName}' still referenced ${refs} time(s) across codebase`,
|
|
156
|
+
severity: "high",
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Detect type assertion overuse (potential behavioral change masking)
|
|
163
|
+
const assertionCount = (content.match(/\bas\s+\w/g) || []).length;
|
|
164
|
+
if (assertionCount > 10) {
|
|
165
|
+
issues.push({
|
|
166
|
+
file: filePath,
|
|
167
|
+
line: 1,
|
|
168
|
+
kind: "excessive-type-assertions",
|
|
169
|
+
message: `${assertionCount} type assertions — may mask type incompatibilities from refactoring`,
|
|
170
|
+
severity: "low",
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Detect dead files (files with exports but no imports from other files)
|
|
175
|
+
for (const [filePath, content] of fileContents) {
|
|
176
|
+
const exports = extractExports(content);
|
|
177
|
+
if (exports.length === 0)
|
|
178
|
+
continue;
|
|
179
|
+
// Skip entry points
|
|
180
|
+
const rel = relative(dir, filePath);
|
|
181
|
+
if (rel.includes("index.") || rel.includes("main.") || rel.includes("cli.") || rel.includes("test"))
|
|
182
|
+
continue;
|
|
183
|
+
let referenced = false;
|
|
184
|
+
for (const [otherFile, otherContent] of fileContents) {
|
|
185
|
+
if (otherFile === filePath)
|
|
186
|
+
continue;
|
|
187
|
+
if (exports.some((exp) => otherContent.includes(exp))) {
|
|
188
|
+
referenced = true;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (!referenced) {
|
|
193
|
+
issues.push({
|
|
194
|
+
file: filePath,
|
|
195
|
+
line: 1,
|
|
196
|
+
kind: "potentially-dead-file",
|
|
197
|
+
message: `File exports [${exports.slice(0, 3).join(", ")}${exports.length > 3 ? "..." : ""}] but none appear imported elsewhere`,
|
|
198
|
+
severity: "low",
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return issues.sort((a, b) => {
|
|
203
|
+
const sev = { high: 3, medium: 2, low: 1 };
|
|
204
|
+
return sev[b.severity] - sev[a.severity];
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// ─── CLI ────────────────────────────────────────────────────────────────────
|
|
208
|
+
export function runRefactorSafety(argv) {
|
|
209
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
210
|
+
console.log(`
|
|
211
|
+
judges refactor-safety — Analyze refactoring safety
|
|
212
|
+
|
|
213
|
+
Usage:
|
|
214
|
+
judges refactor-safety [dir]
|
|
215
|
+
judges refactor-safety src/ --severity high
|
|
216
|
+
judges refactor-safety --format json
|
|
217
|
+
|
|
218
|
+
Options:
|
|
219
|
+
[dir] Directory to scan (default: .)
|
|
220
|
+
--severity <level> Filter by minimum severity (high|medium|low)
|
|
221
|
+
--format json JSON output
|
|
222
|
+
--help, -h Show this help
|
|
223
|
+
|
|
224
|
+
Detects:
|
|
225
|
+
• Orphaned imports (importing symbols that don't exist)
|
|
226
|
+
• Deprecated symbols still in use
|
|
227
|
+
• Incomplete refactor markers (TODO/FIXME with refactor keywords)
|
|
228
|
+
• Excessive type assertions masking type changes
|
|
229
|
+
• Potentially dead files (exported but never imported)
|
|
230
|
+
`);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const format = argv.find((_a, i) => argv[i - 1] === "--format") || "text";
|
|
234
|
+
const severityFilter = argv.find((_a, i) => argv[i - 1] === "--severity") || "low";
|
|
235
|
+
const dir = argv.find((a) => !a.startsWith("-") && argv.indexOf(a) > 0) || ".";
|
|
236
|
+
if (!existsSync(dir)) {
|
|
237
|
+
console.error(` Directory not found: ${dir}`);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const severityOrder = { high: 3, medium: 2, low: 1 };
|
|
241
|
+
const minSev = severityOrder[severityFilter] || 1;
|
|
242
|
+
const files = collectFiles(dir);
|
|
243
|
+
const allIssues = analyzeRefactorSafety(files, dir).filter((x) => severityOrder[x.severity] >= minSev);
|
|
244
|
+
if (format === "json") {
|
|
245
|
+
console.log(JSON.stringify({ issues: allIssues, filesScanned: files.length, timestamp: new Date().toISOString() }, null, 2));
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
console.log(`\n Refactor Safety — ${files.length} files scanned, ${allIssues.length} issue(s)\n ──────────────────────────`);
|
|
249
|
+
if (allIssues.length === 0) {
|
|
250
|
+
console.log(" ✅ No refactoring safety issues detected");
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const byKind = new Map();
|
|
254
|
+
for (const issue of allIssues) {
|
|
255
|
+
byKind.set(issue.kind, (byKind.get(issue.kind) || 0) + 1);
|
|
256
|
+
}
|
|
257
|
+
console.log("\n Summary:");
|
|
258
|
+
for (const [kind, count] of byKind) {
|
|
259
|
+
console.log(` ${kind}: ${count}`);
|
|
260
|
+
}
|
|
261
|
+
console.log("\n Details:");
|
|
262
|
+
for (const issue of allIssues.slice(0, 50)) {
|
|
263
|
+
const icon = issue.severity === "high" ? "🔴" : issue.severity === "medium" ? "🟡" : "⚪";
|
|
264
|
+
console.log(` ${icon} [${issue.severity}] ${issue.file}:${issue.line}`);
|
|
265
|
+
console.log(` ${issue.message}`);
|
|
266
|
+
}
|
|
267
|
+
if (allIssues.length > 50) {
|
|
268
|
+
console.log(`\n ... and ${allIssues.length - 50} more`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
console.log("");
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=refactor-safety.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refactor-safety.js","sourceRoot":"","sources":["../../src/commands/refactor-safety.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,E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AM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5D,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;gBACnC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;YACvC,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;gBACzF,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,KAAK,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3E,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1C,CAAC;YAED,IAAI,SAAS,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;gBAC1B,OAAO,CAAC,GAAG,CAAC,iBAAiB,SAAS,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remediation library — stores proven fixes as parameterized
|
|
3
|
+
* templates ranked by effectiveness. Auto-applies top-ranked
|
|
4
|
+
* templates to new instances of the same finding pattern.
|
|
5
|
+
*
|
|
6
|
+
* All data stored locally in `.judges-remediation/`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function runRemediationLib(argv: string[]): void;
|
|
9
|
+
//# sourceMappingURL=remediation-lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remediation-lib.d.ts","sourceRoot":"","sources":["../../src/commands/remediation-lib.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiIH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAmLtD"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remediation library — stores proven fixes as parameterized
|
|
3
|
+
* templates ranked by effectiveness. Auto-applies top-ranked
|
|
4
|
+
* templates to new instances of the same finding pattern.
|
|
5
|
+
*
|
|
6
|
+
* All data stored locally in `.judges-remediation/`.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
// ─── Storage ────────────────────────────────────────────────────────────────
|
|
11
|
+
const DATA_DIR = ".judges-remediation";
|
|
12
|
+
const LIB_FILE = join(DATA_DIR, "library.json");
|
|
13
|
+
function ensureDir() {
|
|
14
|
+
if (!existsSync(DATA_DIR))
|
|
15
|
+
mkdirSync(DATA_DIR, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
function loadLibrary() {
|
|
18
|
+
if (!existsSync(LIB_FILE))
|
|
19
|
+
return { templates: [], totalApplied: 0, lastUpdated: new Date().toISOString() };
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(readFileSync(LIB_FILE, "utf-8"));
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return { templates: [], totalApplied: 0, lastUpdated: new Date().toISOString() };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function saveLibrary(lib) {
|
|
28
|
+
ensureDir();
|
|
29
|
+
lib.lastUpdated = new Date().toISOString();
|
|
30
|
+
writeFileSync(LIB_FILE, JSON.stringify(lib, null, 2));
|
|
31
|
+
}
|
|
32
|
+
// ─── Built-in templates ─────────────────────────────────────────────────────
|
|
33
|
+
const BUILTIN_TEMPLATES = [
|
|
34
|
+
{
|
|
35
|
+
id: "builtin-empty-catch",
|
|
36
|
+
ruleId: "empty-catch",
|
|
37
|
+
name: "Add error logging to empty catch",
|
|
38
|
+
description: "Replace empty catch blocks with console.error or logger",
|
|
39
|
+
language: "typescript",
|
|
40
|
+
before: "catch (err) {}",
|
|
41
|
+
after: 'catch (err) { console.error("Unhandled error:", err); }',
|
|
42
|
+
votes: 10,
|
|
43
|
+
applied: 0,
|
|
44
|
+
successRate: 95,
|
|
45
|
+
createdAt: "2025-01-01T00:00:00Z",
|
|
46
|
+
updatedAt: "2025-01-01T00:00:00Z",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "builtin-sql-injection",
|
|
50
|
+
ruleId: "sql-injection",
|
|
51
|
+
name: "Use parameterized query",
|
|
52
|
+
description: "Replace string concatenation with parameterized queries",
|
|
53
|
+
language: "typescript",
|
|
54
|
+
before: "`SELECT * FROM users WHERE id = ${userId}`",
|
|
55
|
+
after: '"SELECT * FROM users WHERE id = $1", [userId]',
|
|
56
|
+
votes: 15,
|
|
57
|
+
applied: 0,
|
|
58
|
+
successRate: 98,
|
|
59
|
+
createdAt: "2025-01-01T00:00:00Z",
|
|
60
|
+
updatedAt: "2025-01-01T00:00:00Z",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "builtin-xss",
|
|
64
|
+
ruleId: "xss",
|
|
65
|
+
name: "Sanitize HTML output",
|
|
66
|
+
description: "Escape user input before inserting into HTML",
|
|
67
|
+
language: "javascript",
|
|
68
|
+
before: "element.innerHTML = userInput",
|
|
69
|
+
after: "element.textContent = userInput",
|
|
70
|
+
votes: 12,
|
|
71
|
+
applied: 0,
|
|
72
|
+
successRate: 92,
|
|
73
|
+
createdAt: "2025-01-01T00:00:00Z",
|
|
74
|
+
updatedAt: "2025-01-01T00:00:00Z",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "builtin-hardcoded-secret",
|
|
78
|
+
ruleId: "hardcoded-secret",
|
|
79
|
+
name: "Move to environment variable",
|
|
80
|
+
description: "Replace hardcoded secrets with environment variable references",
|
|
81
|
+
language: "any",
|
|
82
|
+
before: 'const API_KEY = "sk-abc123..."',
|
|
83
|
+
after: "const API_KEY = process.env.API_KEY || ''",
|
|
84
|
+
votes: 14,
|
|
85
|
+
applied: 0,
|
|
86
|
+
successRate: 96,
|
|
87
|
+
createdAt: "2025-01-01T00:00:00Z",
|
|
88
|
+
updatedAt: "2025-01-01T00:00:00Z",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "builtin-todo-placeholder",
|
|
92
|
+
ruleId: "todo-placeholder",
|
|
93
|
+
name: "Replace TODO with implementation",
|
|
94
|
+
description: "Flag TODO comments that AI generators leave behind",
|
|
95
|
+
language: "any",
|
|
96
|
+
before: "// TODO: implement this",
|
|
97
|
+
after: "// Implementation required — see ticket #XXX",
|
|
98
|
+
votes: 8,
|
|
99
|
+
applied: 0,
|
|
100
|
+
successRate: 70,
|
|
101
|
+
createdAt: "2025-01-01T00:00:00Z",
|
|
102
|
+
updatedAt: "2025-01-01T00:00:00Z",
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
// ─── CLI ────────────────────────────────────────────────────────────────────
|
|
106
|
+
export function runRemediationLib(argv) {
|
|
107
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
108
|
+
console.log(`
|
|
109
|
+
judges remediation-lib — Proven fix templates for common findings
|
|
110
|
+
|
|
111
|
+
Usage:
|
|
112
|
+
judges remediation-lib --list
|
|
113
|
+
judges remediation-lib --search "empty-catch"
|
|
114
|
+
judges remediation-lib --add --rule "my-rule" --name "Fix name" --before "bad" --after "good" --lang ts
|
|
115
|
+
judges remediation-lib --vote --id "builtin-empty-catch"
|
|
116
|
+
judges remediation-lib --apply --id "builtin-sql-injection" --file src/db.ts
|
|
117
|
+
judges remediation-lib --init (seed with built-in templates)
|
|
118
|
+
|
|
119
|
+
Options:
|
|
120
|
+
--list List all templates (ranked by votes)
|
|
121
|
+
--search <pattern> Search templates by rule or name
|
|
122
|
+
--add Add a new template
|
|
123
|
+
--rule <ruleId> Rule ID for the template
|
|
124
|
+
--name <name> Template name
|
|
125
|
+
--before <code> Code pattern to match
|
|
126
|
+
--after <code> Replacement code
|
|
127
|
+
--lang <language> Language (default: any)
|
|
128
|
+
--vote Upvote a template
|
|
129
|
+
--id <template-id> Template ID (for vote/apply)
|
|
130
|
+
--apply Apply template to file
|
|
131
|
+
--file <path> Target file for apply
|
|
132
|
+
--init Initialize with built-in templates
|
|
133
|
+
--format json JSON output
|
|
134
|
+
--help, -h Show this help
|
|
135
|
+
`);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const format = argv.find((_a, i) => argv[i - 1] === "--format") || "text";
|
|
139
|
+
const _isList = argv.includes("--list");
|
|
140
|
+
const isSearch = argv.includes("--search");
|
|
141
|
+
const isAdd = argv.includes("--add");
|
|
142
|
+
const isVote = argv.includes("--vote");
|
|
143
|
+
const isApply = argv.includes("--apply");
|
|
144
|
+
const isInit = argv.includes("--init");
|
|
145
|
+
const id = argv.find((_a, i) => argv[i - 1] === "--id") || "";
|
|
146
|
+
const ruleId = argv.find((_a, i) => argv[i - 1] === "--rule") || "";
|
|
147
|
+
const name = argv.find((_a, i) => argv[i - 1] === "--name") || "";
|
|
148
|
+
const before = argv.find((_a, i) => argv[i - 1] === "--before") || "";
|
|
149
|
+
const after = argv.find((_a, i) => argv[i - 1] === "--after") || "";
|
|
150
|
+
const lang = argv.find((_a, i) => argv[i - 1] === "--lang") || "any";
|
|
151
|
+
const searchTerm = argv.find((_a, i) => argv[i - 1] === "--search") || "";
|
|
152
|
+
const file = argv.find((_a, i) => argv[i - 1] === "--file") || "";
|
|
153
|
+
if (isInit) {
|
|
154
|
+
const lib = loadLibrary();
|
|
155
|
+
let added = 0;
|
|
156
|
+
for (const bt of BUILTIN_TEMPLATES) {
|
|
157
|
+
if (!lib.templates.some((t) => t.id === bt.id)) {
|
|
158
|
+
lib.templates.push({ ...bt });
|
|
159
|
+
added++;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
saveLibrary(lib);
|
|
163
|
+
console.log(` ✅ Initialized with ${added} built-in templates (${lib.templates.length} total)`);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (isAdd) {
|
|
167
|
+
if (!ruleId || !name || !before || !after) {
|
|
168
|
+
console.error(" --rule, --name, --before, and --after are required");
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const lib = loadLibrary();
|
|
172
|
+
const template = {
|
|
173
|
+
id: `custom-${Date.now()}`,
|
|
174
|
+
ruleId,
|
|
175
|
+
name,
|
|
176
|
+
description: name,
|
|
177
|
+
language: lang,
|
|
178
|
+
before,
|
|
179
|
+
after,
|
|
180
|
+
votes: 0,
|
|
181
|
+
applied: 0,
|
|
182
|
+
successRate: 0,
|
|
183
|
+
createdAt: new Date().toISOString(),
|
|
184
|
+
updatedAt: new Date().toISOString(),
|
|
185
|
+
};
|
|
186
|
+
lib.templates.push(template);
|
|
187
|
+
saveLibrary(lib);
|
|
188
|
+
console.log(` ✅ Added template "${name}" for rule "${ruleId}"`);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (isVote) {
|
|
192
|
+
if (!id) {
|
|
193
|
+
console.error(" --id is required");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const lib = loadLibrary();
|
|
197
|
+
const tmpl = lib.templates.find((t) => t.id === id);
|
|
198
|
+
if (!tmpl) {
|
|
199
|
+
console.error(` Template "${id}" not found`);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
tmpl.votes++;
|
|
203
|
+
tmpl.updatedAt = new Date().toISOString();
|
|
204
|
+
saveLibrary(lib);
|
|
205
|
+
console.log(` ✅ Upvoted "${tmpl.name}" (${tmpl.votes} votes)`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (isApply) {
|
|
209
|
+
if (!id || !file) {
|
|
210
|
+
console.error(" --id and --file are required");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (!existsSync(file)) {
|
|
214
|
+
console.error(` File not found: ${file}`);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const lib = loadLibrary();
|
|
218
|
+
const tmpl = lib.templates.find((t) => t.id === id);
|
|
219
|
+
if (!tmpl) {
|
|
220
|
+
console.error(` Template "${id}" not found`);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const content = readFileSync(file, "utf-8");
|
|
224
|
+
if (!content.includes(tmpl.before)) {
|
|
225
|
+
console.log(` ⚠ Pattern not found in ${file}`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const updated = content.replace(tmpl.before, tmpl.after);
|
|
229
|
+
writeFileSync(file, updated);
|
|
230
|
+
tmpl.applied++;
|
|
231
|
+
lib.totalApplied++;
|
|
232
|
+
saveLibrary(lib);
|
|
233
|
+
console.log(` ✅ Applied "${tmpl.name}" to ${file}`);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// List / Search
|
|
237
|
+
const lib = loadLibrary();
|
|
238
|
+
let templates = lib.templates;
|
|
239
|
+
if (isSearch && searchTerm) {
|
|
240
|
+
const term = searchTerm.toLowerCase();
|
|
241
|
+
templates = templates.filter((t) => t.ruleId.toLowerCase().includes(term) ||
|
|
242
|
+
t.name.toLowerCase().includes(term) ||
|
|
243
|
+
t.description.toLowerCase().includes(term));
|
|
244
|
+
}
|
|
245
|
+
templates.sort((a, b) => b.votes - a.votes);
|
|
246
|
+
if (format === "json") {
|
|
247
|
+
console.log(JSON.stringify({ templates, totalApplied: lib.totalApplied, timestamp: new Date().toISOString() }, null, 2));
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
console.log(`\n Remediation Library — ${templates.length} templates\n ──────────────────────────`);
|
|
251
|
+
if (templates.length === 0) {
|
|
252
|
+
console.log(" No templates found. Use --init to seed built-ins or --add to create.");
|
|
253
|
+
console.log("");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
for (const t of templates) {
|
|
257
|
+
const effIcon = t.successRate >= 90 ? "🟢" : t.successRate >= 70 ? "🟡" : "🔴";
|
|
258
|
+
console.log(`\n ${effIcon} ${t.name} [${t.id}]`);
|
|
259
|
+
console.log(` Rule: ${t.ruleId} | Lang: ${t.language} | Votes: ${t.votes} | Applied: ${t.applied} | Success: ${t.successRate}%`);
|
|
260
|
+
console.log(` Before: ${t.before}`);
|
|
261
|
+
console.log(` After: ${t.after}`);
|
|
262
|
+
}
|
|
263
|
+
console.log(`\n Total applied: ${lib.totalApplied}\n`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=remediation-lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remediation-lib.js","sourceRoot":"","sources":["../../src/commands/remediation-lib.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAyB5B,+EAA+E;AAE/E,MAAM,QAAQ,GAAG,qBAAqB,CAAC;AACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAEhD,SAAS,SAAS;IAChB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,WAAW;IAClB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,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AC,6BAA6B,SAAS,CAAC,MAAM,0CAA0C,CAAC,CAAC;QAErG,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,0EAA0E,CAAC,CAAC;YACxF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAC/E,OAAO,CAAC,GAAG,CAAC,SAAS,OAAO,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACpD,OAAO,CAAC,GAAG,CACT,iBAAiB,CAAC,CAAC,MAAM,YAAY,CAAC,CAAC,QAAQ,aAAa,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,OAAO,eAAe,CAAC,CAAC,WAAW,GAAG,CAC3H,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,wBAAwB,GAAG,CAAC,YAAY,IAAI,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource cleanup — validate that allocated resources are properly
|
|
3
|
+
* freed: file handles, DB connections, timers, event listeners,
|
|
4
|
+
* streams with try-finally or equivalent cleanup mechanisms.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runResourceCleanup(argv: string[]): void;
|
|
7
|
+
//# sourceMappingURL=resource-cleanup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-cleanup.d.ts","sourceRoot":"","sources":["../../src/commands/resource-cleanup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+LH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CA8EvD"}
|