@stupify/cli 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analysis.js +27 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/render.js +21 -8
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/analysis.ts +26 -0
- package/src/constants.ts +1 -1
- package/src/render.ts +23 -8
- package/src/types.ts +1 -0
package/dist/analysis.js
CHANGED
|
@@ -73,6 +73,7 @@ function uncheckedSearchMatches(value, contexts) {
|
|
|
73
73
|
patternId: context.checkId,
|
|
74
74
|
reason: match.reason ?? "",
|
|
75
75
|
proof: sourcePointer(context),
|
|
76
|
+
snapshot: sourceSnapshot(context),
|
|
76
77
|
}];
|
|
77
78
|
});
|
|
78
79
|
}
|
|
@@ -80,6 +81,32 @@ function sourcePointer(context) {
|
|
|
80
81
|
const file = context.filePath ?? "(unknown)";
|
|
81
82
|
return `${file}::${context.entityKind || "entity"}::${context.entityName || context.entityId}`;
|
|
82
83
|
}
|
|
84
|
+
function sourceSnapshot(context) {
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(context.text);
|
|
87
|
+
const snapshot = stringSnapshot(parsed.after) ?? stringSnapshot(parsed.before);
|
|
88
|
+
return snapshot ? limitSnapshot(snapshot) : undefined;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function stringSnapshot(value) {
|
|
95
|
+
if (typeof value !== "string")
|
|
96
|
+
return undefined;
|
|
97
|
+
const trimmed = value.trim();
|
|
98
|
+
if (!trimmed || trimmed === "(none)")
|
|
99
|
+
return undefined;
|
|
100
|
+
return trimmed;
|
|
101
|
+
}
|
|
102
|
+
function limitSnapshot(value) {
|
|
103
|
+
const lines = value.split(/\r?\n/);
|
|
104
|
+
const limit = 24;
|
|
105
|
+
if (lines.length <= limit)
|
|
106
|
+
return value;
|
|
107
|
+
return `${lines.slice(0, limit).join("\n")}
|
|
108
|
+
[stupify: snapshot shortened after ${limit} lines]`;
|
|
109
|
+
}
|
|
83
110
|
async function runJsonPrompt(model, prompt, schema, temperature) {
|
|
84
111
|
return cachedJson("model-json", fingerprint({
|
|
85
112
|
version: 1,
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
package/dist/render.js
CHANGED
|
@@ -24,13 +24,18 @@ ${format.success("No search targets found.")}`;
|
|
|
24
24
|
${format.label("Patterns:")} ${run.patterns.join(", ")}
|
|
25
25
|
${format.success("No judgment-offload signals found.")}`;
|
|
26
26
|
}
|
|
27
|
-
return `${
|
|
28
|
-
${run.matches.map((match, index) => `${index + 1}.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
return `${slopHeading()}
|
|
28
|
+
${run.matches.map((match, index) => `${index + 1}. ${format.label(match.patternId)}
|
|
29
|
+
${committerLabel(run)} (${sourceLabel(command)})
|
|
30
|
+
|
|
31
|
+
${match.reason}
|
|
32
|
+
|
|
33
|
+
\`\`\`
|
|
34
|
+
${match.snapshot ?? match.proof}
|
|
35
|
+
\`\`\`
|
|
36
|
+
${format.muted(match.proof)}
|
|
37
|
+
|
|
38
|
+
${match.checkWhy ?? "This pattern may indicate judgment-offload."}`).join("\n\n")}
|
|
34
39
|
${format.muted("Search mode is warn-only.")}`;
|
|
35
40
|
}
|
|
36
41
|
export function helpText() {
|
|
@@ -103,10 +108,18 @@ function sourceLabel(command) {
|
|
|
103
108
|
return "stdin diff";
|
|
104
109
|
}
|
|
105
110
|
function committerLabel(run) {
|
|
106
|
-
const committers = (run.stats.committers ?? []).filter(Boolean);
|
|
111
|
+
const committers = (run.stats.committers ?? []).filter(Boolean).map(committerDisplayName);
|
|
107
112
|
if (committers.length === 0)
|
|
108
113
|
return "unknown committer";
|
|
109
114
|
if (committers.length <= 3)
|
|
110
115
|
return committers.join(", ");
|
|
111
116
|
return `${committers.slice(0, 3).join(", ")} +${committers.length - 3} more`;
|
|
112
117
|
}
|
|
118
|
+
function committerDisplayName(value) {
|
|
119
|
+
return value.replace(/\s*<[^>]+>\s*$/, "").trim() || value;
|
|
120
|
+
}
|
|
121
|
+
function slopHeading() {
|
|
122
|
+
const heading = "AI SLOP DETECTED";
|
|
123
|
+
return `${format.warn(format.heading(heading))}
|
|
124
|
+
${format.warn("=".repeat(heading.length))}`;
|
|
125
|
+
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
package/src/analysis.ts
CHANGED
|
@@ -106,6 +106,7 @@ function uncheckedSearchMatches(value: unknown, contexts: readonly SemContext[])
|
|
|
106
106
|
patternId: context.checkId,
|
|
107
107
|
reason: match.reason ?? "",
|
|
108
108
|
proof: sourcePointer(context),
|
|
109
|
+
snapshot: sourceSnapshot(context),
|
|
109
110
|
}];
|
|
110
111
|
});
|
|
111
112
|
}
|
|
@@ -115,6 +116,31 @@ function sourcePointer(context: SemContext): string {
|
|
|
115
116
|
return `${file}::${context.entityKind || "entity"}::${context.entityName || context.entityId}`;
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
function sourceSnapshot(context: SemContext): string | undefined {
|
|
120
|
+
try {
|
|
121
|
+
const parsed = JSON.parse(context.text) as { after?: unknown; before?: unknown };
|
|
122
|
+
const snapshot = stringSnapshot(parsed.after) ?? stringSnapshot(parsed.before);
|
|
123
|
+
return snapshot ? limitSnapshot(snapshot) : undefined;
|
|
124
|
+
} catch {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function stringSnapshot(value: unknown): string | undefined {
|
|
130
|
+
if (typeof value !== "string") return undefined;
|
|
131
|
+
const trimmed = value.trim();
|
|
132
|
+
if (!trimmed || trimmed === "(none)") return undefined;
|
|
133
|
+
return trimmed;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function limitSnapshot(value: string): string {
|
|
137
|
+
const lines = value.split(/\r?\n/);
|
|
138
|
+
const limit = 24;
|
|
139
|
+
if (lines.length <= limit) return value;
|
|
140
|
+
return `${lines.slice(0, limit).join("\n")}
|
|
141
|
+
[stupify: snapshot shortened after ${limit} lines]`;
|
|
142
|
+
}
|
|
143
|
+
|
|
118
144
|
async function runJsonPrompt(
|
|
119
145
|
model: LocalModel,
|
|
120
146
|
prompt: string,
|
package/src/constants.ts
CHANGED
package/src/render.ts
CHANGED
|
@@ -29,13 +29,18 @@ ${format.label("Patterns:")} ${run.patterns.join(", ")}
|
|
|
29
29
|
${format.success("No judgment-offload signals found.")}`;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
return `${
|
|
33
|
-
${run.matches.map((match, index) => `${index + 1}.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
return `${slopHeading()}
|
|
33
|
+
${run.matches.map((match, index) => `${index + 1}. ${format.label(match.patternId)}
|
|
34
|
+
${committerLabel(run)} (${sourceLabel(command)})
|
|
35
|
+
|
|
36
|
+
${match.reason}
|
|
37
|
+
|
|
38
|
+
\`\`\`
|
|
39
|
+
${match.snapshot ?? match.proof}
|
|
40
|
+
\`\`\`
|
|
41
|
+
${format.muted(match.proof)}
|
|
42
|
+
|
|
43
|
+
${match.checkWhy ?? "This pattern may indicate judgment-offload."}`).join("\n\n")}
|
|
39
44
|
${format.muted("Search mode is warn-only.")}`;
|
|
40
45
|
}
|
|
41
46
|
|
|
@@ -104,8 +109,18 @@ function sourceLabel(command: SearchCommand): string {
|
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
function committerLabel(run: SearchRunJson): string {
|
|
107
|
-
const committers = (run.stats.committers ?? []).filter(Boolean);
|
|
112
|
+
const committers = (run.stats.committers ?? []).filter(Boolean).map(committerDisplayName);
|
|
108
113
|
if (committers.length === 0) return "unknown committer";
|
|
109
114
|
if (committers.length <= 3) return committers.join(", ");
|
|
110
115
|
return `${committers.slice(0, 3).join(", ")} +${committers.length - 3} more`;
|
|
111
116
|
}
|
|
117
|
+
|
|
118
|
+
function committerDisplayName(value: string): string {
|
|
119
|
+
return value.replace(/\s*<[^>]+>\s*$/, "").trim() || value;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function slopHeading(): string {
|
|
123
|
+
const heading = "AI SLOP DETECTED";
|
|
124
|
+
return `${format.warn(format.heading(heading))}
|
|
125
|
+
${format.warn("=".repeat(heading.length))}`;
|
|
126
|
+
}
|