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.
Files changed (4) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +14 -15
  3. package/index.ts +25 -18
  4. 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
- [TypeScript] 2 issue(s):
28
- [error] L10: Type 'string' is not assignable to type 'number'
27
+ 🔴 Fix 2 TypeScript error(s) — these must be resolved:
28
+ L10: Type 'string' is not assignable to type 'number'
29
29
 
30
- [ast-grep] +1 new issue(s) introduced:
31
- no-var: Use 'const' or 'let' instead of 'var' (L23) [fixable]
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
- [ast-grep] Fixed: no-console-log (-1)
35
+ ast-grep: fixed no-console-log (-1)
36
36
 
37
- [Biome] +1 new issue(s) introduced:
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
- 1 fixable run /lens-format
40
- (4 total)
39
+ Auto-fixable: `npx @biomejs/biome check --write utils.ts`
40
+ (4 total remaining)
41
41
 
42
- [jscpd] 1 duplicate block(s) involving utils.ts:
43
- 15 lines helpers.ts:20
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
- [Duplicate Exports] 1 function(s) already exist:
45
+ 🔴 Do not redefine — 1 function(s) already exist elsewhere:
47
46
  formatDate (already in helpers.ts)
48
- → Import the existing function instead of redefining it
47
+ → Import the existing function instead
49
48
 
50
- [Complexity Warnings]
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
- const lines = output.split("\n").filter((l: string) => l.trim());
260
-
261
- for (const line of lines) {
262
- try {
263
- const item = JSON.parse(line);
264
- const ruleId = item.ruleId || item.name || "unknown";
265
- const ruleDesc = astGrepClient.getRuleDescription?.(ruleId);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-lens",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Real-time code feedback for pi — TypeScript LSP, Biome, ast-grep, Ruff, TODO scanner, dead code, duplicate detection, type coverage",
5
5
  "repository": {
6
6
  "type": "git",