deep-slop 1.4.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/.deep-slop/.deep-slop-ignore +13 -0
- package/LICENSE +21 -0
- package/README.md +1170 -0
- package/dist/arch-constraints-C7s1E_bc.js +450 -0
- package/dist/arch-rules-DI1SYPqu.js +358 -0
- package/dist/ast-slop-BGdr58wZ.js +1839 -0
- package/dist/config-lint-ph3vMUbg.js +371 -0
- package/dist/dead-flow-DHRkyxZT.js +1422 -0
- package/dist/deep-slop-bundled.js +33140 -0
- package/dist/discover-B_S_Fy2S.js +164 -0
- package/dist/dup-detect-DKRXM04q.js +709 -0
- package/dist/file-utils-B_HFXhCs.js +93 -0
- package/dist/format-lint-DeElllNm.js +445 -0
- package/dist/framework-lint-CqdlF9hX.js +782 -0
- package/dist/i18n-lint-CPzx7V8Q.js +605 -0
- package/dist/import-intelligence-SK4F7XpL.js +966 -0
- package/dist/index.d.ts +233 -0
- package/dist/index.js +1030 -0
- package/dist/knip-CgxnnTBZ.js +93 -0
- package/dist/lint-external-ZbW3jGvB.js +326 -0
- package/dist/markup-lint-DKVEDz9M.js +805 -0
- package/dist/mcp.js +35939 -0
- package/dist/meta-quality-Dai1W5iC.js +224 -0
- package/dist/perf-hints-BnWFMFff.js +500 -0
- package/dist/security-deep-DJRINs10.js +1198 -0
- package/dist/syntax-deep-ZQYMutky.js +624 -0
- package/dist/tree-sitter-CM-cP0nl.js +661 -0
- package/dist/type-safety-Dboj2C1t.js +519 -0
- package/package.json +92 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { r as readFileContent } from "./file-utils-B_HFXhCs.js";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { writeFile } from "node:fs/promises";
|
|
4
|
+
|
|
5
|
+
//#region src/engines/meta-quality/index.ts
|
|
6
|
+
const HISTORY_DIR = ".deep-slop";
|
|
7
|
+
const HISTORY_FILE = "history.json";
|
|
8
|
+
async function readHistory(rootDir) {
|
|
9
|
+
try {
|
|
10
|
+
const content = await readFileContent(join(rootDir, HISTORY_DIR, HISTORY_FILE));
|
|
11
|
+
return JSON.parse(content);
|
|
12
|
+
} catch {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function scoreReport(filePath, score, totalDiags, bySeverity) {
|
|
17
|
+
const diagnostics = [];
|
|
18
|
+
if (score < 50) diagnostics.push({
|
|
19
|
+
filePath,
|
|
20
|
+
engine: "meta-quality",
|
|
21
|
+
rule: "meta-quality/critical-score",
|
|
22
|
+
severity: "error",
|
|
23
|
+
message: `Project quality score is critically low: ${score}/100`,
|
|
24
|
+
help: "Address the highest-impact issues first: errors, then security, then warnings. Focus on one engine at a time.",
|
|
25
|
+
line: 1,
|
|
26
|
+
column: 1,
|
|
27
|
+
category: "style",
|
|
28
|
+
fixable: false,
|
|
29
|
+
suggestion: {
|
|
30
|
+
type: "refactor",
|
|
31
|
+
text: `Start with: npx deep-slop fix --engine ${score < 30 ? "security-deep" : "ast-slop"}`,
|
|
32
|
+
confidence: .9,
|
|
33
|
+
reason: "Critical scores indicate systemic issues. Fix the most severe category first for maximum score improvement per effort."
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
else if (score < 70) diagnostics.push({
|
|
37
|
+
filePath,
|
|
38
|
+
engine: "meta-quality",
|
|
39
|
+
rule: "meta-quality/low-score",
|
|
40
|
+
severity: "warning",
|
|
41
|
+
message: `Project quality score is below recommended: ${score}/100 (target: 70+)`,
|
|
42
|
+
help: "Review warnings and suggestions. A score of 70+ is recommended for production code.",
|
|
43
|
+
line: 1,
|
|
44
|
+
column: 1,
|
|
45
|
+
category: "style",
|
|
46
|
+
fixable: false
|
|
47
|
+
});
|
|
48
|
+
return diagnostics;
|
|
49
|
+
}
|
|
50
|
+
function trendAnalysis(filePath, current, history) {
|
|
51
|
+
const diagnostics = [];
|
|
52
|
+
if (history.length < 2) return diagnostics;
|
|
53
|
+
const previous = history[history.length - 2];
|
|
54
|
+
const scoreDiff = current.score - previous.score;
|
|
55
|
+
if (scoreDiff < -10) diagnostics.push({
|
|
56
|
+
filePath,
|
|
57
|
+
engine: "meta-quality",
|
|
58
|
+
rule: "meta-quality/severe-regression",
|
|
59
|
+
severity: "error",
|
|
60
|
+
message: `Quality score dropped by ${Math.abs(scoreDiff)} points (${previous.score} → ${current.score})`,
|
|
61
|
+
help: "Review recent changes for quality regressions. Compare diagnostics between runs.",
|
|
62
|
+
line: 1,
|
|
63
|
+
column: 1,
|
|
64
|
+
category: "style",
|
|
65
|
+
fixable: false,
|
|
66
|
+
detail: {
|
|
67
|
+
previousScore: previous.score,
|
|
68
|
+
currentScore: current.score,
|
|
69
|
+
diff: scoreDiff,
|
|
70
|
+
previousTimestamp: previous.timestamp
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
else if (scoreDiff < -3) diagnostics.push({
|
|
74
|
+
filePath,
|
|
75
|
+
engine: "meta-quality",
|
|
76
|
+
rule: "meta-quality/degrading-trend",
|
|
77
|
+
severity: "warning",
|
|
78
|
+
message: `Quality score is degrading: ${previous.score} → ${current.score} (${scoreDiff})`,
|
|
79
|
+
help: "Recent changes introduced quality issues. Review new warnings and errors.",
|
|
80
|
+
line: 1,
|
|
81
|
+
column: 1,
|
|
82
|
+
category: "style",
|
|
83
|
+
fixable: false,
|
|
84
|
+
detail: { diff: scoreDiff }
|
|
85
|
+
});
|
|
86
|
+
else if (scoreDiff > 5) diagnostics.push({
|
|
87
|
+
filePath,
|
|
88
|
+
engine: "meta-quality",
|
|
89
|
+
rule: "meta-quality/improving-trend",
|
|
90
|
+
severity: "info",
|
|
91
|
+
message: `Quality score improved by ${scoreDiff} points (${previous.score} → ${current.score})`,
|
|
92
|
+
help: "Keep up the good work! Maintain quality discipline.",
|
|
93
|
+
line: 1,
|
|
94
|
+
column: 1,
|
|
95
|
+
category: "style",
|
|
96
|
+
fixable: false
|
|
97
|
+
});
|
|
98
|
+
for (const [engine, count] of Object.entries(current.byEngine)) {
|
|
99
|
+
const prevCount = previous.byEngine[engine] ?? 0;
|
|
100
|
+
const diff = count - prevCount;
|
|
101
|
+
if (diff > 10) diagnostics.push({
|
|
102
|
+
filePath,
|
|
103
|
+
engine: "meta-quality",
|
|
104
|
+
rule: "meta-quality/engine-spike",
|
|
105
|
+
severity: "warning",
|
|
106
|
+
message: `${engine} issues spiked: ${prevCount} → ${count} (+${diff})`,
|
|
107
|
+
help: `Focus on ${engine} issues in recent changes. This engine had the largest regression.`,
|
|
108
|
+
line: 1,
|
|
109
|
+
column: 1,
|
|
110
|
+
category: "style",
|
|
111
|
+
fixable: false,
|
|
112
|
+
detail: {
|
|
113
|
+
engine,
|
|
114
|
+
previousCount: prevCount,
|
|
115
|
+
currentCount: count,
|
|
116
|
+
diff
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return diagnostics;
|
|
121
|
+
}
|
|
122
|
+
function qualityGate(filePath, score, failBelow) {
|
|
123
|
+
if (!failBelow) return [];
|
|
124
|
+
const diagnostics = [];
|
|
125
|
+
if (score < failBelow) diagnostics.push({
|
|
126
|
+
filePath,
|
|
127
|
+
engine: "meta-quality",
|
|
128
|
+
rule: "meta-quality/quality-gate-failed",
|
|
129
|
+
severity: "error",
|
|
130
|
+
message: `Quality gate FAILED: score ${score} is below threshold ${failBelow}`,
|
|
131
|
+
help: `Fix issues until score reaches ${failBelow}. CI will fail until then.`,
|
|
132
|
+
line: 1,
|
|
133
|
+
column: 1,
|
|
134
|
+
category: "style",
|
|
135
|
+
fixable: false,
|
|
136
|
+
detail: {
|
|
137
|
+
score,
|
|
138
|
+
threshold: failBelow,
|
|
139
|
+
gap: failBelow - score
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
else diagnostics.push({
|
|
143
|
+
filePath,
|
|
144
|
+
engine: "meta-quality",
|
|
145
|
+
rule: "meta-quality/quality-gate-passed",
|
|
146
|
+
severity: "info",
|
|
147
|
+
message: `Quality gate PASSED: score ${score} ≥ threshold ${failBelow}`,
|
|
148
|
+
help: "Quality gate is satisfied. Keep maintaining code quality.",
|
|
149
|
+
line: 1,
|
|
150
|
+
column: 1,
|
|
151
|
+
category: "style",
|
|
152
|
+
fixable: false,
|
|
153
|
+
detail: {
|
|
154
|
+
score,
|
|
155
|
+
threshold: failBelow
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return diagnostics;
|
|
159
|
+
}
|
|
160
|
+
const metaQualityEngine = {
|
|
161
|
+
name: "meta-quality",
|
|
162
|
+
description: "Meta quality scoring: weighted scoring, trend analysis, diff scoring, quality gate",
|
|
163
|
+
supportedLanguages: [
|
|
164
|
+
"typescript",
|
|
165
|
+
"javascript",
|
|
166
|
+
"python",
|
|
167
|
+
"go",
|
|
168
|
+
"rust",
|
|
169
|
+
"ruby",
|
|
170
|
+
"php",
|
|
171
|
+
"java"
|
|
172
|
+
],
|
|
173
|
+
async run(context) {
|
|
174
|
+
const diagnostics = [];
|
|
175
|
+
const start = Date.now();
|
|
176
|
+
const rootDir = context.rootDirectory;
|
|
177
|
+
const history = await readHistory(rootDir);
|
|
178
|
+
const gateDiags = qualityGate(join(rootDir, "package.json"), 100, context.config.ci.failBelow);
|
|
179
|
+
diagnostics.push(...gateDiags);
|
|
180
|
+
if (history.length >= 2) {
|
|
181
|
+
const currentEntry = history[history.length - 1];
|
|
182
|
+
const trendDiags = trendAnalysis(join(rootDir, "package.json"), currentEntry, history);
|
|
183
|
+
diagnostics.push(...trendDiags);
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
await readFileContent(join(rootDir, ".deep-slop", "config.yml"));
|
|
187
|
+
} catch {
|
|
188
|
+
diagnostics.push({
|
|
189
|
+
filePath: join(rootDir, ".deep-slop"),
|
|
190
|
+
engine: "meta-quality",
|
|
191
|
+
rule: "meta-quality/missing-config",
|
|
192
|
+
severity: "info",
|
|
193
|
+
message: "No .deep-slop/config.yml found — using defaults",
|
|
194
|
+
help: "Run `npx deep-slop init` to create a configuration file with project-specific settings.",
|
|
195
|
+
line: 1,
|
|
196
|
+
column: 1,
|
|
197
|
+
category: "style",
|
|
198
|
+
fixable: true,
|
|
199
|
+
suggestion: {
|
|
200
|
+
type: "insert",
|
|
201
|
+
text: "Run: npx deep-slop init",
|
|
202
|
+
confidence: .7,
|
|
203
|
+
reason: "A config file lets you customize thresholds, exclude patterns, and engine settings for your project."
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const scoreDiags = scoreReport(join(rootDir, "package.json"), 100, 0, {
|
|
208
|
+
error: 0,
|
|
209
|
+
warning: 0,
|
|
210
|
+
info: 0,
|
|
211
|
+
suggestion: 0
|
|
212
|
+
});
|
|
213
|
+
diagnostics.push(...scoreDiags);
|
|
214
|
+
return {
|
|
215
|
+
engine: this.name,
|
|
216
|
+
diagnostics,
|
|
217
|
+
elapsed: Date.now() - start,
|
|
218
|
+
skipped: false
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
export { metaQualityEngine };
|