pi-lens 2.0.1 → 2.0.3
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 +18 -0
- package/README.md +14 -15
- package/index.ts +25 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to pi-lens will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.0.1] - 2026-03-25
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **ast-grep in `/lens-booboo` was silently dropping all results** — newer ast-grep versions exit `0` with `--json` even when issues are found; fixed the exit code check.
|
|
9
|
+
- **Renamed "Design Smells" to "ast-grep"** in booboo report — the scan runs all 65 rules (security, correctness, style, design), not just design smells.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- **Stronger real-time feedback messages** — all messages now use severity emoji and imperative language:
|
|
13
|
+
- `🔴 Fix N TypeScript error(s) — these must be resolved`
|
|
14
|
+
- `🧹 Remove N unused import(s) — they are dead code`
|
|
15
|
+
- `🔴 You introduced N new structural violation(s) — fix before moving on`
|
|
16
|
+
- `🟠 You introduced N new Biome violation(s) — fix before moving on`
|
|
17
|
+
- `🟡 Complexity issues — refactor when you get a chance`
|
|
18
|
+
- `🟠 This file has N duplicate block(s) — extract to shared utilities`
|
|
19
|
+
- `🔴 Do not redefine — N function(s) already exist elsewhere`
|
|
20
|
+
- **Biome fix command is now a real bash command** — `npx @biomejs/biome check --write <file>` instead of `/lens-format` (which is a pi UI command, not runnable from agent tools).
|
|
21
|
+
- **Complexity warnings skip test files in real-time** — same exclusion as lens-booboo.
|
|
22
|
+
|
|
5
23
|
## [2.0.0] - 2026-03-25
|
|
6
24
|
|
|
7
25
|
### Added
|
package/README.md
CHANGED
|
@@ -24,30 +24,29 @@ Real-time code quality feedback for [pi](https://github.com/mariozechner/pi-codi
|
|
|
24
24
|
ast-grep and Biome run in **delta mode** — only violations *introduced by the current edit* are shown. Pre-existing issues are silent. Fixed violations are acknowledged.
|
|
25
25
|
|
|
26
26
|
```
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
🔴 Fix 2 TypeScript error(s) — these must be resolved:
|
|
28
|
+
L10: Type 'string' is not assignable to type 'number'
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
no-var: Use 'const' or 'let' instead of 'var' (L23)
|
|
30
|
+
🔴 You introduced 1 new structural violation(s) — fix before moving on:
|
|
31
|
+
no-var: Use 'const' or 'let' instead of 'var' (L23)
|
|
32
32
|
→ var has function scope and can lead to unexpected hoisting behavior.
|
|
33
|
-
(18 total)
|
|
33
|
+
(18 total remaining)
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
✅ ast-grep: fixed no-console-log (-1)
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
🟠 You introduced 1 new Biome violation(s) — fix before moving on:
|
|
38
38
|
L23:5 [style/useConst] This let declares a variable that is only assigned once.
|
|
39
|
-
|
|
40
|
-
(4 total)
|
|
39
|
+
→ Auto-fixable: `npx @biomejs/biome check --write utils.ts`
|
|
40
|
+
(4 total remaining)
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
15 lines
|
|
44
|
-
→ Extract duplicated code to a shared utility function
|
|
42
|
+
🟠 This file has 1 duplicate block(s) — extract to shared utilities:
|
|
43
|
+
15 lines duplicated with helpers.ts:20
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
🔴 Do not redefine — 1 function(s) already exist elsewhere:
|
|
47
46
|
formatDate (already in helpers.ts)
|
|
48
|
-
→ Import the existing function instead
|
|
47
|
+
→ Import the existing function instead
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
🟡 Complexity issues — refactor when you get a chance:
|
|
51
50
|
⚠ Maintainability dropped to 55 — extract logic into helper functions
|
|
52
51
|
⚠ AI-style comments (6) — remove hand-holding comments
|
|
53
52
|
⚠ Many try/catch blocks (7) — consolidate error handling
|
package/index.ts
CHANGED
|
@@ -256,25 +256,32 @@ export default function (pi: ExtensionAPI) {
|
|
|
256
256
|
const output = result.stdout || result.stderr || "";
|
|
257
257
|
if (output.trim() && result.status !== undefined) {
|
|
258
258
|
let issues: Array<{line: number; rule: string; message: string}> = [];
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const message = ruleDesc?.message || item.message || ruleId;
|
|
267
|
-
const lineNum = item.labels?.[0]?.range?.start?.line ||
|
|
268
|
-
item.spans?.[0]?.range?.start?.line || 0;
|
|
269
|
-
|
|
270
|
-
issues.push({
|
|
271
|
-
line: lineNum + 1,
|
|
272
|
-
rule: ruleId,
|
|
273
|
-
message: message,
|
|
274
|
-
});
|
|
275
|
-
} catch {
|
|
276
|
-
// Skip unparseable lines
|
|
259
|
+
|
|
260
|
+
// ast-grep outputs either a JSON array or NDJSON (one object per line)
|
|
261
|
+
// biome-ignore lint/suspicious/noExplicitAny: ast-grep JSON output is untyped
|
|
262
|
+
const parseItems = (raw: string): Record<string, any>[] => {
|
|
263
|
+
const trimmed = raw.trim();
|
|
264
|
+
if (trimmed.startsWith("[")) {
|
|
265
|
+
try { return JSON.parse(trimmed); } catch { return []; }
|
|
277
266
|
}
|
|
267
|
+
return raw.split("\n").flatMap((l: string) => {
|
|
268
|
+
try { return [JSON.parse(l)]; } catch { return []; }
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
for (const item of parseItems(output)) {
|
|
273
|
+
const ruleId = item.ruleId || item.rule?.title || item.name || "unknown";
|
|
274
|
+
const ruleDesc = astGrepClient.getRuleDescription?.(ruleId);
|
|
275
|
+
const message = ruleDesc?.message || item.message || ruleId;
|
|
276
|
+
const lineNum = item.labels?.[0]?.range?.start?.line ||
|
|
277
|
+
item.spans?.[0]?.range?.start?.line ||
|
|
278
|
+
item.range?.start?.line || 0;
|
|
279
|
+
|
|
280
|
+
issues.push({
|
|
281
|
+
line: lineNum + 1,
|
|
282
|
+
rule: ruleId,
|
|
283
|
+
message: message,
|
|
284
|
+
});
|
|
278
285
|
}
|
|
279
286
|
|
|
280
287
|
if (issues.length > 0) {
|
package/package.json
CHANGED