@kevinrabun/judges 3.22.0 → 3.23.1
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 +52 -0
- package/dist/api.d.ts +18 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +15 -3
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +54 -36
- package/dist/cli.js.map +1 -1
- package/dist/commands/auto-detect.d.ts +62 -0
- package/dist/commands/auto-detect.d.ts.map +1 -0
- package/dist/commands/auto-detect.js +329 -0
- package/dist/commands/auto-detect.js.map +1 -0
- package/dist/commands/baseline.d.ts +46 -0
- package/dist/commands/baseline.d.ts.map +1 -1
- package/dist/commands/baseline.js +290 -27
- package/dist/commands/baseline.js.map +1 -1
- package/dist/commands/benchmark.d.ts +21 -3
- package/dist/commands/benchmark.d.ts.map +1 -1
- package/dist/commands/benchmark.js +365 -6
- package/dist/commands/benchmark.js.map +1 -1
- package/dist/commands/coverage.d.ts +41 -0
- package/dist/commands/coverage.d.ts.map +1 -0
- package/dist/commands/coverage.js +184 -0
- package/dist/commands/coverage.js.map +1 -0
- package/dist/commands/doctor.d.ts +56 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +363 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/feedback.d.ts +42 -0
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +129 -0
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/rule-metrics.d.ts +44 -0
- package/dist/commands/rule-metrics.d.ts.map +1 -0
- package/dist/commands/rule-metrics.js +114 -0
- package/dist/commands/rule-metrics.js.map +1 -0
- package/dist/commands/rule.d.ts +65 -0
- package/dist/commands/rule.d.ts.map +1 -1
- package/dist/commands/rule.js +94 -0
- package/dist/commands/rule.js.map +1 -1
- package/dist/commands/snapshot.d.ts +81 -0
- package/dist/commands/snapshot.d.ts.map +1 -0
- package/dist/commands/snapshot.js +189 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/config.d.ts +35 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +187 -2
- package/dist/config.js.map +1 -1
- package/dist/dedup.d.ts +35 -0
- package/dist/dedup.d.ts.map +1 -1
- package/dist/dedup.js +96 -0
- package/dist/dedup.js.map +1 -1
- package/dist/evaluators/index.d.ts +22 -2
- package/dist/evaluators/index.d.ts.map +1 -1
- package/dist/evaluators/index.js +144 -52
- package/dist/evaluators/index.js.map +1 -1
- package/dist/patches/index.d.ts.map +1 -1
- package/dist/patches/index.js +426 -0
- package/dist/patches/index.js.map +1 -1
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -1
- package/judgesrc.schema.json +5 -0
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface ProjectSignals {
|
|
2
|
+
/** Primary language(s) detected */
|
|
3
|
+
languages: string[];
|
|
4
|
+
/** Frameworks detected (e.g. "express", "react", "django") */
|
|
5
|
+
frameworks: string[];
|
|
6
|
+
/** Project type classification */
|
|
7
|
+
projectType: ProjectType;
|
|
8
|
+
/** Whether the project has CI configured */
|
|
9
|
+
hasCI: boolean;
|
|
10
|
+
/** Whether the project has Docker/container support */
|
|
11
|
+
hasDocker: boolean;
|
|
12
|
+
/** Whether the project uses a monorepo structure */
|
|
13
|
+
isMonorepo: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type ProjectType = "web-api" | "web-frontend" | "full-stack" | "cli-tool" | "library" | "infrastructure" | "data-science" | "mobile" | "unknown";
|
|
16
|
+
export interface PresetRecommendation {
|
|
17
|
+
/** The preset name to use */
|
|
18
|
+
preset: string;
|
|
19
|
+
/** Why this preset was recommended */
|
|
20
|
+
reason: string;
|
|
21
|
+
/** Confidence: how well the signals match */
|
|
22
|
+
confidence: "high" | "medium" | "low";
|
|
23
|
+
/** Additional configuration suggestions */
|
|
24
|
+
suggestions: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Detect primary languages from a list of file paths.
|
|
28
|
+
*/
|
|
29
|
+
export declare function detectLanguages(files: string[]): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Detect frameworks from file paths and optional package.json dependencies.
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectFrameworksFromFiles(files: string[], packageJsonDeps?: Record<string, string>, requirementsTxt?: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Classify the project type from detected signals.
|
|
36
|
+
*/
|
|
37
|
+
export declare function classifyProjectType(languages: string[], frameworks: string[], files: string[]): ProjectType;
|
|
38
|
+
/**
|
|
39
|
+
* Detect CI configuration from file list.
|
|
40
|
+
*/
|
|
41
|
+
export declare function detectCI(files: string[]): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Detect monorepo structure from file list.
|
|
44
|
+
*/
|
|
45
|
+
export declare function detectMonorepo(files: string[]): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Gather all project signals from detected data.
|
|
48
|
+
*/
|
|
49
|
+
export declare function detectProjectSignals(files: string[], packageJsonDeps?: Record<string, string>, requirementsTxt?: string): ProjectSignals;
|
|
50
|
+
/**
|
|
51
|
+
* Recommend a preset based on detected project signals.
|
|
52
|
+
*/
|
|
53
|
+
export declare function recommendPreset(signals: ProjectSignals): PresetRecommendation;
|
|
54
|
+
/**
|
|
55
|
+
* Format project signals as a readable summary for the init wizard.
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatProjectSummary(signals: ProjectSignals): string;
|
|
58
|
+
/**
|
|
59
|
+
* Format a preset recommendation for display.
|
|
60
|
+
*/
|
|
61
|
+
export declare function formatRecommendation(rec: PresetRecommendation): string;
|
|
62
|
+
//# sourceMappingURL=auto-detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-detect.d.ts","sourceRoot":"","sources":["../../src/commands/auto-detect.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,cAAc;I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vD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EAAE,EACf,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACxC,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAShB;AAID;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,oBAAoB,CAoF7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAmBpE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,GAAG,MAAM,CAmBtE"}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
// ─── Project Auto-Detection for Init Wizard ──────────────────────────────────
|
|
2
|
+
// Detects project type, languages, and frameworks from file system signals,
|
|
3
|
+
// then recommends appropriate presets and configuration for `judges init`.
|
|
4
|
+
//
|
|
5
|
+
// All detection functions are pure and testable — they operate on arrays of
|
|
6
|
+
// file paths and/or package.json content, not direct filesystem access.
|
|
7
|
+
// ──────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
import { PRESETS } from "../presets.js";
|
|
9
|
+
// ─── Language & Framework Detection ─────────────────────────────────────────
|
|
10
|
+
const LANG_INDICATORS = {
|
|
11
|
+
typescript: [".ts", ".tsx"],
|
|
12
|
+
javascript: [".js", ".jsx", ".mjs", ".cjs"],
|
|
13
|
+
python: [".py"],
|
|
14
|
+
rust: [".rs"],
|
|
15
|
+
go: [".go"],
|
|
16
|
+
java: [".java"],
|
|
17
|
+
csharp: [".cs"],
|
|
18
|
+
cpp: [".cpp", ".cc", ".cxx", ".h", ".hpp"],
|
|
19
|
+
ruby: [".rb"],
|
|
20
|
+
php: [".php"],
|
|
21
|
+
kotlin: [".kt", ".kts"],
|
|
22
|
+
swift: [".swift"],
|
|
23
|
+
};
|
|
24
|
+
const FRAMEWORK_FILES = {
|
|
25
|
+
react: ["src/App.tsx", "src/App.jsx", "src/app.tsx", "src/app.jsx"],
|
|
26
|
+
nextjs: ["next.config.js", "next.config.ts", "next.config.mjs"],
|
|
27
|
+
express: [], // detected from package.json
|
|
28
|
+
fastapi: [], // detected from requirements
|
|
29
|
+
django: ["manage.py"],
|
|
30
|
+
flask: [], // detected from requirements
|
|
31
|
+
angular: ["angular.json"],
|
|
32
|
+
vue: ["vue.config.js", "vue.config.ts"],
|
|
33
|
+
svelte: ["svelte.config.js", "svelte.config.ts"],
|
|
34
|
+
terraform: ["main.tf", "variables.tf"],
|
|
35
|
+
docker: ["Dockerfile", "docker-compose.yml", "docker-compose.yaml"],
|
|
36
|
+
};
|
|
37
|
+
const PKG_FRAMEWORK_MAP = {
|
|
38
|
+
express: "express",
|
|
39
|
+
fastify: "fastify",
|
|
40
|
+
koa: "koa",
|
|
41
|
+
hapi: "hapi",
|
|
42
|
+
nestjs: "@nestjs/core",
|
|
43
|
+
react: "react",
|
|
44
|
+
"react-native": "react-native",
|
|
45
|
+
vue: "vue",
|
|
46
|
+
angular: "@angular/core",
|
|
47
|
+
svelte: "svelte",
|
|
48
|
+
nextjs: "next",
|
|
49
|
+
nuxt: "nuxt",
|
|
50
|
+
gatsby: "gatsby",
|
|
51
|
+
electron: "electron",
|
|
52
|
+
};
|
|
53
|
+
const PY_FRAMEWORK_MAP = {
|
|
54
|
+
django: "django",
|
|
55
|
+
flask: "flask",
|
|
56
|
+
fastapi: "fastapi",
|
|
57
|
+
tornado: "tornado",
|
|
58
|
+
starlette: "starlette",
|
|
59
|
+
pyramid: "pyramid",
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Detect primary languages from a list of file paths.
|
|
63
|
+
*/
|
|
64
|
+
export function detectLanguages(files) {
|
|
65
|
+
const counts = new Map();
|
|
66
|
+
for (const file of files) {
|
|
67
|
+
const lower = file.toLowerCase();
|
|
68
|
+
for (const [lang, exts] of Object.entries(LANG_INDICATORS)) {
|
|
69
|
+
if (exts.some((ext) => lower.endsWith(ext))) {
|
|
70
|
+
counts.set(lang, (counts.get(lang) ?? 0) + 1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [...counts.entries()].sort((a, b) => b[1] - a[1]).map(([lang]) => lang);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Detect frameworks from file paths and optional package.json dependencies.
|
|
78
|
+
*/
|
|
79
|
+
export function detectFrameworksFromFiles(files, packageJsonDeps, requirementsTxt) {
|
|
80
|
+
const found = new Set();
|
|
81
|
+
// Check file-based indicators
|
|
82
|
+
const fileSet = new Set(files.map((f) => f.replace(/\\/g, "/")));
|
|
83
|
+
for (const [framework, indicators] of Object.entries(FRAMEWORK_FILES)) {
|
|
84
|
+
if (indicators.length > 0 && indicators.some((ind) => fileSet.has(ind))) {
|
|
85
|
+
found.add(framework);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Check package.json dependencies
|
|
89
|
+
if (packageJsonDeps) {
|
|
90
|
+
for (const [framework, pkg] of Object.entries(PKG_FRAMEWORK_MAP)) {
|
|
91
|
+
if (packageJsonDeps[pkg]) {
|
|
92
|
+
found.add(framework);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Check Python requirements
|
|
97
|
+
if (requirementsTxt) {
|
|
98
|
+
const lower = requirementsTxt.toLowerCase();
|
|
99
|
+
for (const [framework, pkg] of Object.entries(PY_FRAMEWORK_MAP)) {
|
|
100
|
+
if (lower.includes(pkg)) {
|
|
101
|
+
found.add(framework);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Docker detection from file names
|
|
106
|
+
if (files.some((f) => {
|
|
107
|
+
const base = f.replace(/\\/g, "/").split("/").pop() ?? "";
|
|
108
|
+
return base === "Dockerfile" || base.startsWith("docker-compose");
|
|
109
|
+
})) {
|
|
110
|
+
found.add("docker");
|
|
111
|
+
}
|
|
112
|
+
return [...found].sort();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Classify the project type from detected signals.
|
|
116
|
+
*/
|
|
117
|
+
export function classifyProjectType(languages, frameworks, files) {
|
|
118
|
+
const frameworkSet = new Set(frameworks);
|
|
119
|
+
const fileSet = new Set(files.map((f) => f.replace(/\\/g, "/").split("/").pop() ?? ""));
|
|
120
|
+
// Infrastructure
|
|
121
|
+
if (frameworkSet.has("terraform") || files.some((f) => f.endsWith(".tf") || f.endsWith(".bicep"))) {
|
|
122
|
+
return "infrastructure";
|
|
123
|
+
}
|
|
124
|
+
// Mobile
|
|
125
|
+
if (frameworkSet.has("react-native") ||
|
|
126
|
+
frameworkSet.has("flutter") ||
|
|
127
|
+
languages.includes("swift") ||
|
|
128
|
+
languages.includes("kotlin")) {
|
|
129
|
+
// Only mobile if no strong web signals
|
|
130
|
+
if (!frameworkSet.has("express") && !frameworkSet.has("fastapi") && !frameworkSet.has("django")) {
|
|
131
|
+
return "mobile";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Data science
|
|
135
|
+
if (files.some((f) => f.endsWith(".ipynb")) ||
|
|
136
|
+
files.some((f) => f.endsWith(".py") && (f.includes("notebook") || f.includes("analysis")))) {
|
|
137
|
+
return "data-science";
|
|
138
|
+
}
|
|
139
|
+
const hasWebFrontend = frameworkSet.has("react") || frameworkSet.has("vue") || frameworkSet.has("angular") || frameworkSet.has("svelte");
|
|
140
|
+
const hasWebBackend = frameworkSet.has("express") ||
|
|
141
|
+
frameworkSet.has("fastify") ||
|
|
142
|
+
frameworkSet.has("koa") ||
|
|
143
|
+
frameworkSet.has("django") ||
|
|
144
|
+
frameworkSet.has("flask") ||
|
|
145
|
+
frameworkSet.has("fastapi") ||
|
|
146
|
+
frameworkSet.has("nestjs");
|
|
147
|
+
if (hasWebFrontend && hasWebBackend)
|
|
148
|
+
return "full-stack";
|
|
149
|
+
if (hasWebBackend)
|
|
150
|
+
return "web-api";
|
|
151
|
+
if (hasWebFrontend)
|
|
152
|
+
return "web-frontend";
|
|
153
|
+
// CLI tool
|
|
154
|
+
if (fileSet.has("cli.ts") ||
|
|
155
|
+
fileSet.has("cli.js") ||
|
|
156
|
+
fileSet.has("cli.py") ||
|
|
157
|
+
files.some((f) => f.includes("bin/") || f.includes("commands/"))) {
|
|
158
|
+
return "cli-tool";
|
|
159
|
+
}
|
|
160
|
+
// Library — has index/lib but no web framework
|
|
161
|
+
if (files.some((f) => f.includes("lib/") || f.includes("src/index."))) {
|
|
162
|
+
return "library";
|
|
163
|
+
}
|
|
164
|
+
return "unknown";
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Detect CI configuration from file list.
|
|
168
|
+
*/
|
|
169
|
+
export function detectCI(files) {
|
|
170
|
+
return files.some((f) => {
|
|
171
|
+
const norm = f.replace(/\\/g, "/");
|
|
172
|
+
return (norm.includes(".github/workflows/") ||
|
|
173
|
+
norm.includes(".gitlab-ci") ||
|
|
174
|
+
norm.includes("azure-pipelines") ||
|
|
175
|
+
norm.includes("Jenkinsfile") ||
|
|
176
|
+
norm.includes(".circleci/"));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Detect monorepo structure from file list.
|
|
181
|
+
*/
|
|
182
|
+
export function detectMonorepo(files) {
|
|
183
|
+
return files.some((f) => {
|
|
184
|
+
const norm = f.replace(/\\/g, "/");
|
|
185
|
+
return (norm.includes("packages/") ||
|
|
186
|
+
norm.includes("apps/") ||
|
|
187
|
+
norm.includes("lerna.json") ||
|
|
188
|
+
norm.includes("pnpm-workspace.yaml") ||
|
|
189
|
+
norm.includes("turbo.json"));
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Gather all project signals from detected data.
|
|
194
|
+
*/
|
|
195
|
+
export function detectProjectSignals(files, packageJsonDeps, requirementsTxt) {
|
|
196
|
+
const languages = detectLanguages(files);
|
|
197
|
+
const frameworks = detectFrameworksFromFiles(files, packageJsonDeps, requirementsTxt);
|
|
198
|
+
const projectType = classifyProjectType(languages, frameworks, files);
|
|
199
|
+
const hasCI = detectCI(files);
|
|
200
|
+
const hasDocker = frameworks.includes("docker");
|
|
201
|
+
const isMonorepo = detectMonorepo(files);
|
|
202
|
+
return { languages, frameworks, projectType, hasCI, hasDocker, isMonorepo };
|
|
203
|
+
}
|
|
204
|
+
// ─── Preset Recommendation ─────────────────────────────────────────────────
|
|
205
|
+
/**
|
|
206
|
+
* Recommend a preset based on detected project signals.
|
|
207
|
+
*/
|
|
208
|
+
export function recommendPreset(signals) {
|
|
209
|
+
const suggestions = [];
|
|
210
|
+
// Infrastructure projects → strict + compliance
|
|
211
|
+
if (signals.projectType === "infrastructure") {
|
|
212
|
+
suggestions.push("Consider enabling the IaC security judge");
|
|
213
|
+
return {
|
|
214
|
+
preset: "strict",
|
|
215
|
+
reason: "Infrastructure-as-code projects benefit from thorough security and compliance review",
|
|
216
|
+
confidence: "high",
|
|
217
|
+
suggestions,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
// Data science → lenient (exploratory code)
|
|
221
|
+
if (signals.projectType === "data-science") {
|
|
222
|
+
return {
|
|
223
|
+
preset: "lenient",
|
|
224
|
+
reason: "Data science projects typically prioritize exploratory flexibility over strict compliance",
|
|
225
|
+
confidence: "medium",
|
|
226
|
+
suggestions: ["Focus on security for any data pipeline code shipping to production"],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
// Web API → security focus + strict
|
|
230
|
+
if (signals.projectType === "web-api") {
|
|
231
|
+
if (!signals.hasCI)
|
|
232
|
+
suggestions.push("Add CI integration to catch issues in PRs");
|
|
233
|
+
return {
|
|
234
|
+
preset: "security-only",
|
|
235
|
+
reason: "API services are externally accessible — security review is the highest priority",
|
|
236
|
+
confidence: "high",
|
|
237
|
+
suggestions,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
// Full-stack → default (needs both security and quality)
|
|
241
|
+
if (signals.projectType === "full-stack") {
|
|
242
|
+
if (!signals.hasCI)
|
|
243
|
+
suggestions.push("Add CI integration for automated code review");
|
|
244
|
+
if (signals.isMonorepo)
|
|
245
|
+
suggestions.push("Consider per-package .judgesrc configs for large monorepos");
|
|
246
|
+
return {
|
|
247
|
+
preset: "strict",
|
|
248
|
+
reason: "Full-stack applications need comprehensive review across frontend and backend",
|
|
249
|
+
confidence: "high",
|
|
250
|
+
suggestions,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
// Web frontend → lenient (less security surface)
|
|
254
|
+
if (signals.projectType === "web-frontend") {
|
|
255
|
+
return {
|
|
256
|
+
preset: "lenient",
|
|
257
|
+
reason: "Frontend projects have less direct security surface; focus on critical issues",
|
|
258
|
+
confidence: "medium",
|
|
259
|
+
suggestions: ["Enable the accessibility judge for public-facing applications"],
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
// CLI tool → default
|
|
263
|
+
if (signals.projectType === "cli-tool") {
|
|
264
|
+
return {
|
|
265
|
+
preset: "strict",
|
|
266
|
+
reason: "CLI tools benefit from comprehensive quality and security review",
|
|
267
|
+
confidence: "medium",
|
|
268
|
+
suggestions: [],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
// Library → strict (shared code must be solid)
|
|
272
|
+
if (signals.projectType === "library") {
|
|
273
|
+
return {
|
|
274
|
+
preset: "strict",
|
|
275
|
+
reason: "Libraries are consumed by many projects — high quality standards are important",
|
|
276
|
+
confidence: "high",
|
|
277
|
+
suggestions: ["Enable backwards-compatibility judge to catch API breakage"],
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
// Default fallback
|
|
281
|
+
return {
|
|
282
|
+
preset: "strict",
|
|
283
|
+
reason: "General-purpose review covers all quality dimensions",
|
|
284
|
+
confidence: "low",
|
|
285
|
+
suggestions: ["Once your project is established, consider narrowing to a focused preset"],
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Format project signals as a readable summary for the init wizard.
|
|
290
|
+
*/
|
|
291
|
+
export function formatProjectSummary(signals) {
|
|
292
|
+
const lines = [];
|
|
293
|
+
lines.push(" 📦 Detected Project Signals:");
|
|
294
|
+
lines.push(" " + "─".repeat(50));
|
|
295
|
+
if (signals.languages.length > 0) {
|
|
296
|
+
lines.push(` Languages : ${signals.languages.join(", ")}`);
|
|
297
|
+
}
|
|
298
|
+
if (signals.frameworks.length > 0) {
|
|
299
|
+
lines.push(` Frameworks : ${signals.frameworks.join(", ")}`);
|
|
300
|
+
}
|
|
301
|
+
lines.push(` Project type: ${signals.projectType}`);
|
|
302
|
+
lines.push(` CI detected : ${signals.hasCI ? "yes" : "no"}`);
|
|
303
|
+
lines.push(` Docker : ${signals.hasDocker ? "yes" : "no"}`);
|
|
304
|
+
lines.push(` Monorepo : ${signals.isMonorepo ? "yes" : "no"}`);
|
|
305
|
+
lines.push("");
|
|
306
|
+
return lines.join("\n");
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Format a preset recommendation for display.
|
|
310
|
+
*/
|
|
311
|
+
export function formatRecommendation(rec) {
|
|
312
|
+
const lines = [];
|
|
313
|
+
const preset = PRESETS[rec.preset];
|
|
314
|
+
const presetDesc = preset ? preset.description : "";
|
|
315
|
+
lines.push(` 💡 Recommended preset: "${rec.preset}" (confidence: ${rec.confidence})`);
|
|
316
|
+
if (presetDesc)
|
|
317
|
+
lines.push(` ${presetDesc}`);
|
|
318
|
+
lines.push(` Reason: ${rec.reason}`);
|
|
319
|
+
if (rec.suggestions.length > 0) {
|
|
320
|
+
lines.push("");
|
|
321
|
+
lines.push(" 📌 Suggestions:");
|
|
322
|
+
for (const s of rec.suggestions) {
|
|
323
|
+
lines.push(` • ${s}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
lines.push("");
|
|
327
|
+
return lines.join("\n");
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=auto-detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-detect.js","sourceRoot":"","sources":["../../src/commands/auto-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CAAC;IAEzC,IAAI,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAChC,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,2 +1,48 @@
|
|
|
1
|
+
export declare function computeFindingFingerprint(ruleId: string, title: string, sourceCode: string, lineNumber: number, contextRadius?: number): string;
|
|
2
|
+
/** V2 baseline finding stored per-file */
|
|
3
|
+
export interface BaselineFinding {
|
|
4
|
+
ruleId: string;
|
|
5
|
+
title: string;
|
|
6
|
+
fingerprint: string;
|
|
7
|
+
severity: string;
|
|
8
|
+
lineNumbers: number[];
|
|
9
|
+
status: "active" | "resolved";
|
|
10
|
+
}
|
|
11
|
+
/** V2 baseline format — project-wide, fingerprint-based matching */
|
|
12
|
+
export interface BaselineV2 {
|
|
13
|
+
version: 2;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
files: Record<string, BaselineFinding[]>;
|
|
17
|
+
totalFindings: number;
|
|
18
|
+
resolvedFindings: number;
|
|
19
|
+
}
|
|
20
|
+
/** Loaded baseline ready for matching */
|
|
21
|
+
export interface LoadedBaseline {
|
|
22
|
+
version: number;
|
|
23
|
+
/** v1 legacy keys: ruleId::line::title */
|
|
24
|
+
keys: Set<string>;
|
|
25
|
+
/** v2 fingerprints */
|
|
26
|
+
fingerprints: Set<string>;
|
|
27
|
+
/** v2 per-file fingerprint map for faster lookups */
|
|
28
|
+
fileFingerprints: Map<string, Set<string>>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load a baseline file (v1 or v2) into a unified lookup structure.
|
|
32
|
+
*/
|
|
33
|
+
export declare function loadBaselineData(baselinePath: string): LoadedBaseline;
|
|
34
|
+
/**
|
|
35
|
+
* Check whether a finding is suppressed by the loaded baseline.
|
|
36
|
+
*
|
|
37
|
+
* For v1 baselines, uses exact ruleId::line::title matching.
|
|
38
|
+
* For v2 baselines, uses fingerprint matching against source code context.
|
|
39
|
+
*
|
|
40
|
+
* @param filePath - Relative path of the file being evaluated (for v2 per-file lookup)
|
|
41
|
+
*/
|
|
42
|
+
export declare function isBaselined(finding: {
|
|
43
|
+
ruleId: string;
|
|
44
|
+
title: string;
|
|
45
|
+
lineNumbers?: number[];
|
|
46
|
+
}, baseline: LoadedBaseline, sourceCode: string, filePath?: string): boolean;
|
|
1
47
|
export declare function runBaseline(argv: string[]): void;
|
|
2
48
|
//# sourceMappingURL=baseline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../src/commands/baseline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"baseline.d.ts","sourceRoot":"","sources":["../../src/commands/baseline.ts"],"names":[],"mappings":"AA+DA,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,aAAa,GAAE,MAA+B,GAC7C,MAAM,CAYR;AAmBD,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC/B;AAED,oEAAoE;AACpE,MAAM,WA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