pi-lens 2.2.6 ā 2.2.7
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/commands/fix.js +39 -23
- package/commands/fix.ts +45 -33
- package/commands/refactor.js +7 -5
- package/commands/refactor.ts +7 -5
- package/package.json +1 -1
package/commands/fix.js
CHANGED
|
@@ -112,41 +112,57 @@ function generatePlan(results, session, _isTsProject, prevCounts) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
nodeFs.writeFileSync(reportPath, tsvRows.join("\n"), "utf-8");
|
|
115
|
-
// --- Build
|
|
115
|
+
// --- Build actionable list for terminal (no TSV reading needed) ---
|
|
116
116
|
const lines = [];
|
|
117
|
-
lines.push(`š FIX PLAN ā Iteration ${session.iteration}/${MAX_ITERATIONS} ā ${totalFixable} issues`);
|
|
118
|
-
|
|
119
|
-
// Summary by category with counts
|
|
117
|
+
lines.push(`š FIX PLAN ā Iteration ${session.iteration}/${MAX_ITERATIONS} ā ${totalFixable} issues:\n`);
|
|
118
|
+
// Duplicates
|
|
120
119
|
if (filteredDups.length > 0) {
|
|
121
|
-
|
|
120
|
+
for (const clone of filteredDups.slice(0, 10)) {
|
|
121
|
+
lines.push(`š ${clone.fileA}:${clone.startA} ā ${clone.lines} dup from ${clone.fileB}:${clone.startB}`);
|
|
122
|
+
}
|
|
123
|
+
if (filteredDups.length > 10)
|
|
124
|
+
lines.push(` ... +${filteredDups.length - 10} more`);
|
|
125
|
+
lines.push("");
|
|
122
126
|
}
|
|
127
|
+
// Dead code
|
|
123
128
|
if (filteredDeadCode.length > 0) {
|
|
124
|
-
|
|
129
|
+
for (const issue of filteredDeadCode.slice(0, 10)) {
|
|
130
|
+
lines.push(`šļø ${issue.file || issue.name} ā ${issue.name} unused`);
|
|
131
|
+
}
|
|
132
|
+
if (filteredDeadCode.length > 10)
|
|
133
|
+
lines.push(` ... +${filteredDeadCode.length - 10} more`);
|
|
134
|
+
lines.push("");
|
|
125
135
|
}
|
|
136
|
+
// AST lint
|
|
126
137
|
if (agentTasks.length > 0) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
for (const t of agentTasks) {
|
|
130
|
-
grouped.set(t.rule, (grouped.get(t.rule) ?? 0) + 1);
|
|
138
|
+
for (const issue of agentTasks.slice(0, 15)) {
|
|
139
|
+
lines.push(`šØ ${issue.file}:${issue.line} ā ${issue.rule}`);
|
|
131
140
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
lines.push(` ${rule}: ${count}`);
|
|
136
|
-
}
|
|
137
|
-
if (sorted.length > 5)
|
|
138
|
-
lines.push(` ... and ${sorted.length - 5} more rules`);
|
|
141
|
+
if (agentTasks.length > 15)
|
|
142
|
+
lines.push(` ... +${agentTasks.length - 15} more`);
|
|
143
|
+
lines.push("");
|
|
139
144
|
}
|
|
145
|
+
// Biome
|
|
140
146
|
if (filteredBiome.length > 0) {
|
|
141
|
-
|
|
147
|
+
for (const issue of filteredBiome.slice(0, 10)) {
|
|
148
|
+
lines.push(`š ${issue.file}:${issue.line} ā ${issue.rule}`);
|
|
149
|
+
}
|
|
150
|
+
if (filteredBiome.length > 10)
|
|
151
|
+
lines.push(` ... +${filteredBiome.length - 10} more`);
|
|
152
|
+
lines.push("");
|
|
142
153
|
}
|
|
154
|
+
// AI Slop
|
|
143
155
|
if (filteredSlop.length > 0) {
|
|
144
|
-
|
|
156
|
+
for (const { file, warnings } of filteredSlop.slice(0, 5)) {
|
|
157
|
+
lines.push(`š¤ ${file} ā ${warnings[0]}`);
|
|
158
|
+
}
|
|
159
|
+
if (filteredSlop.length > 5)
|
|
160
|
+
lines.push(` ... +${filteredSlop.length - 5} more`);
|
|
161
|
+
lines.push("");
|
|
145
162
|
}
|
|
146
|
-
lines.push("
|
|
147
|
-
lines.push("
|
|
148
|
-
lines.push(
|
|
149
|
-
lines.push('š« **False positive**: `/lens-booboo-fix --false-positive "type:file:line"`');
|
|
163
|
+
lines.push("---");
|
|
164
|
+
lines.push("š Fix items above, then run `/lens-booboo-fix --loop`");
|
|
165
|
+
lines.push('š« False positive: `/lens-booboo-fix --false-positive "type:file:line"`');
|
|
150
166
|
return lines.join("\n");
|
|
151
167
|
}
|
|
152
168
|
// --- Main handler ---
|
package/commands/fix.ts
CHANGED
|
@@ -183,56 +183,68 @@ function generatePlan(
|
|
|
183
183
|
|
|
184
184
|
nodeFs.writeFileSync(reportPath, tsvRows.join("\n"), "utf-8");
|
|
185
185
|
|
|
186
|
-
// --- Build
|
|
186
|
+
// --- Build actionable list for terminal (no TSV reading needed) ---
|
|
187
187
|
const lines: string[] = [];
|
|
188
188
|
lines.push(
|
|
189
|
-
`š FIX PLAN ā Iteration ${session.iteration}/${MAX_ITERATIONS} ā ${totalFixable} issues`,
|
|
189
|
+
`š FIX PLAN ā Iteration ${session.iteration}/${MAX_ITERATIONS} ā ${totalFixable} issues:\n`,
|
|
190
190
|
);
|
|
191
|
-
lines.push(`š Full plan: .pi-lens/reports/fix-plan.tsv\n`);
|
|
192
191
|
|
|
193
|
-
//
|
|
192
|
+
// Duplicates
|
|
194
193
|
if (filteredDups.length > 0) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
for (const clone of filteredDups.slice(0, 10)) {
|
|
195
|
+
lines.push(
|
|
196
|
+
`š ${clone.fileA}:${clone.startA} ā ${clone.lines} dup from ${clone.fileB}:${clone.startB}`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
if (filteredDups.length > 10)
|
|
200
|
+
lines.push(` ... +${filteredDups.length - 10} more`);
|
|
201
|
+
lines.push("");
|
|
198
202
|
}
|
|
203
|
+
|
|
204
|
+
// Dead code
|
|
199
205
|
if (filteredDeadCode.length > 0) {
|
|
200
|
-
|
|
201
|
-
`šļø
|
|
202
|
-
|
|
206
|
+
for (const issue of filteredDeadCode.slice(0, 10)) {
|
|
207
|
+
lines.push(`šļø ${issue.file || issue.name} ā ${issue.name} unused`);
|
|
208
|
+
}
|
|
209
|
+
if (filteredDeadCode.length > 10)
|
|
210
|
+
lines.push(` ... +${filteredDeadCode.length - 10} more`);
|
|
211
|
+
lines.push("");
|
|
203
212
|
}
|
|
213
|
+
|
|
214
|
+
// AST lint
|
|
204
215
|
if (agentTasks.length > 0) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
for (const t of agentTasks) {
|
|
208
|
-
grouped.set(t.rule, (grouped.get(t.rule) ?? 0) + 1);
|
|
209
|
-
}
|
|
210
|
-
const sorted = [...grouped.entries()].sort((a, b) => b[1] - a[1]);
|
|
211
|
-
lines.push(`šØ Lint: ${agentTasks.length} item(s)`);
|
|
212
|
-
for (const [rule, count] of sorted.slice(0, 5)) {
|
|
213
|
-
lines.push(` ${rule}: ${count}`);
|
|
216
|
+
for (const issue of agentTasks.slice(0, 15)) {
|
|
217
|
+
lines.push(`šØ ${issue.file}:${issue.line} ā ${issue.rule}`);
|
|
214
218
|
}
|
|
215
|
-
if (
|
|
216
|
-
lines.push(` ...
|
|
219
|
+
if (agentTasks.length > 15)
|
|
220
|
+
lines.push(` ... +${agentTasks.length - 15} more`);
|
|
221
|
+
lines.push("");
|
|
217
222
|
}
|
|
223
|
+
|
|
224
|
+
// Biome
|
|
218
225
|
if (filteredBiome.length > 0) {
|
|
219
|
-
|
|
226
|
+
for (const issue of filteredBiome.slice(0, 10)) {
|
|
227
|
+
lines.push(`š ${issue.file}:${issue.line} ā ${issue.rule}`);
|
|
228
|
+
}
|
|
229
|
+
if (filteredBiome.length > 10)
|
|
230
|
+
lines.push(` ... +${filteredBiome.length - 10} more`);
|
|
231
|
+
lines.push("");
|
|
220
232
|
}
|
|
233
|
+
|
|
234
|
+
// AI Slop
|
|
221
235
|
if (filteredSlop.length > 0) {
|
|
222
|
-
|
|
223
|
-
`š¤
|
|
224
|
-
|
|
236
|
+
for (const { file, warnings } of filteredSlop.slice(0, 5)) {
|
|
237
|
+
lines.push(`š¤ ${file} ā ${warnings[0]}`);
|
|
238
|
+
}
|
|
239
|
+
if (filteredSlop.length > 5)
|
|
240
|
+
lines.push(` ... +${filteredSlop.length - 5} more`);
|
|
241
|
+
lines.push("");
|
|
225
242
|
}
|
|
226
243
|
|
|
227
|
-
lines.push("
|
|
228
|
-
lines.push(
|
|
229
|
-
"š **Read plan**: `read .pi-lens/reports/fix-plan.tsv` for full details",
|
|
230
|
-
);
|
|
231
|
-
lines.push(
|
|
232
|
-
"š **Fix & loop**: Fix items, then run `/lens-booboo-fix --loop`",
|
|
233
|
-
);
|
|
244
|
+
lines.push("---");
|
|
245
|
+
lines.push("š Fix items above, then run `/lens-booboo-fix --loop`");
|
|
234
246
|
lines.push(
|
|
235
|
-
'š«
|
|
247
|
+
'š« False positive: `/lens-booboo-fix --false-positive "type:file:line"`',
|
|
236
248
|
);
|
|
237
249
|
|
|
238
250
|
return lines.join("\n");
|
package/commands/refactor.js
CHANGED
|
@@ -83,16 +83,18 @@ export async function handleRefactor(args, ctx, clients, pi, skipRules, ruleActi
|
|
|
83
83
|
: "";
|
|
84
84
|
// First violation line for quick reference
|
|
85
85
|
const firstViolationLine = issues.length > 0 ? issues[0].line : null;
|
|
86
|
-
// ---
|
|
86
|
+
// --- Full ranked list in terminal (agent won't read TSV) ---
|
|
87
87
|
const topFiles = scored
|
|
88
|
-
.slice(0,
|
|
88
|
+
.slice(0, 15)
|
|
89
89
|
.map((f, i) => {
|
|
90
90
|
const name = path.relative(targetPath, f.file).replace(/\\/g, "/");
|
|
91
|
-
|
|
91
|
+
const m = metricsByFile.get(f.file);
|
|
92
|
+
const mi = m ? `MI:${m.mi.toFixed(0)}` : "";
|
|
93
|
+
return ` ${i + 1}. ${name} (${f.score} pts${mi ? `, ${mi}` : ""})`;
|
|
92
94
|
})
|
|
93
95
|
.join("\n");
|
|
94
96
|
ctx.ui.notify(`šļø Worst: ${relFile} (score: ${score}) ā ${scored.length} files with debt`, "info");
|
|
95
|
-
console.log(`\nš
|
|
97
|
+
console.log(`\nš Ranked by debt score:\n${topFiles}${scored.length > 15 ? `\n ... and ${scored.length - 15} more` : ""}\n`);
|
|
96
98
|
// --- Steer message for agent ---
|
|
97
99
|
const steer = [
|
|
98
100
|
`šļø BOOBOO REFACTOR ā worst offender identified`,
|
|
@@ -107,7 +109,7 @@ export async function handleRefactor(args, ctx, clients, pi, skipRules, ruleActi
|
|
|
107
109
|
: "",
|
|
108
110
|
firstViolationLine ? `First violation at line ${firstViolationLine}` : "",
|
|
109
111
|
"",
|
|
110
|
-
`š
|
|
112
|
+
`š Read \`${relFile}\` when ready to implement`,
|
|
111
113
|
"",
|
|
112
114
|
"**Your job**:",
|
|
113
115
|
"1. Analyze this code ā what's the most impactful refactoring for this file?",
|
package/commands/refactor.ts
CHANGED
|
@@ -148,12 +148,14 @@ export async function handleRefactor(
|
|
|
148
148
|
// First violation line for quick reference
|
|
149
149
|
const firstViolationLine = issues.length > 0 ? issues[0].line : null;
|
|
150
150
|
|
|
151
|
-
// ---
|
|
151
|
+
// --- Full ranked list in terminal (agent won't read TSV) ---
|
|
152
152
|
const topFiles = scored
|
|
153
|
-
.slice(0,
|
|
153
|
+
.slice(0, 15)
|
|
154
154
|
.map((f, i) => {
|
|
155
155
|
const name = path.relative(targetPath, f.file).replace(/\\/g, "/");
|
|
156
|
-
|
|
156
|
+
const m = metricsByFile.get(f.file);
|
|
157
|
+
const mi = m ? `MI:${m.mi.toFixed(0)}` : "";
|
|
158
|
+
return ` ${i + 1}. ${name} (${f.score} pts${mi ? `, ${mi}` : ""})`;
|
|
157
159
|
})
|
|
158
160
|
.join("\n");
|
|
159
161
|
|
|
@@ -162,7 +164,7 @@ export async function handleRefactor(
|
|
|
162
164
|
"info",
|
|
163
165
|
);
|
|
164
166
|
console.log(
|
|
165
|
-
`\nš
|
|
167
|
+
`\nš Ranked by debt score:\n${topFiles}${scored.length > 15 ? `\n ... and ${scored.length - 15} more` : ""}\n`,
|
|
166
168
|
);
|
|
167
169
|
|
|
168
170
|
// --- Steer message for agent ---
|
|
@@ -179,7 +181,7 @@ export async function handleRefactor(
|
|
|
179
181
|
: "",
|
|
180
182
|
firstViolationLine ? `First violation at line ${firstViolationLine}` : "",
|
|
181
183
|
"",
|
|
182
|
-
`š
|
|
184
|
+
`š Read \`${relFile}\` when ready to implement`,
|
|
183
185
|
"",
|
|
184
186
|
"**Your job**:",
|
|
185
187
|
"1. Analyze this code ā what's the most impactful refactoring for this file?",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-lens",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Real-time code quality feedback for pi ā TypeScript LSP, Biome, ast-grep, Ruff, complexity metrics, duplicate detection. Includes automated fix loop (/lens-booboo-fix) and interactive architectural refactoring (/lens-booboo-refactor) with browser-based interviews.",
|
|
6
6
|
"repository": {
|