pi-lens 1.3.11 → 1.3.13
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
CHANGED
|
@@ -2,6 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to pi-lens will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.3.11] - 2026-03-25
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Actionable feedback messages**: All real-time warnings now include specific guidance on what to do.
|
|
9
|
+
- **Code entropy metric**: Shannon entropy in bits (threshold: >3.5 indicates risky AI-induced complexity).
|
|
10
|
+
- **Advanced pattern matching**: `/lens-booboo` now finds structurally similar functions (e.g., `formatDate` and `formatTimestamp`).
|
|
11
|
+
- **Duplicate export detection**: Warns when redefining a function that already exists in the codebase.
|
|
12
|
+
- **Biome formatting noise removed**: Only lint issues shown in real-time; use `/lens-format` for formatting.
|
|
13
|
+
|
|
14
|
+
## [1.3.10] - 2026-03-25
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- **Actionable complexity warnings**: Real-time feedback when metrics break limits with specific fix guidance.
|
|
18
|
+
|
|
19
|
+
## [1.3.9] - 2026-03-25
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- **Entropy calculation**: Corrected to use bits with 3.5-bit threshold for AI-induced complexity.
|
|
23
|
+
|
|
24
|
+
## [1.3.8] - 2026-03-25
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- **Code entropy metric**: Shannon entropy to detect repetitive or unpredictable code patterns.
|
|
28
|
+
|
|
29
|
+
## [1.3.7] - 2026-03-25
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
- **Advanced pattern matching in `/lens-booboo`**: Finds structurally similar functions across the codebase.
|
|
33
|
+
|
|
34
|
+
## [1.3.6] - 2026-03-25
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
- **Duplicate export detection on write**: Warns when defining a function that already exists elsewhere.
|
|
38
|
+
|
|
39
|
+
## [1.3.5] - 2026-03-25
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
- **Consistent command prefix**: All commands now start with `lens-`.
|
|
43
|
+
- `/find-todos` → `/lens-todos`
|
|
44
|
+
- `/dead-code` → `/lens-dead-code`
|
|
45
|
+
- `/check-deps` → `/lens-deps`
|
|
46
|
+
- `/format` → `/lens-format`
|
|
47
|
+
- `/design-review` + `/lens-metrics` → `/lens-booboo`
|
|
48
|
+
|
|
5
49
|
## [1.5.0] - 2026-03-23
|
|
6
50
|
|
|
7
51
|
### Added
|
package/README.md
CHANGED
|
@@ -15,8 +15,38 @@ Real-time code quality feedback for [pi](https://github.com/mariozechner/pi-codi
|
|
|
15
15
|
| **Biome** | Lint + format for JS/TS/JSX/TSX/CSS/JSON. Auto-fix disabled by default, use `/lens-format` to apply |
|
|
16
16
|
| **Ruff** | Lint + format for Python. Auto-fixes on every write by default |
|
|
17
17
|
| **Test Runner** | Runs corresponding test file when you edit source code (vitest, jest, pytest). Silent if no test file exists. |
|
|
18
|
-
| **Complexity Metrics** | AST-based analysis: Maintainability Index, Cyclomatic/Cognitive Complexity, Halstead Volume, nesting depth, function length. |
|
|
18
|
+
| **Complexity Metrics** | AST-based analysis: Maintainability Index, Cyclomatic/Cognitive Complexity, Halstead Volume, nesting depth, function length, code entropy. |
|
|
19
19
|
| **jscpd** | Code duplication detection. Warns when editing a file that has duplicates with other files in the project. |
|
|
20
|
+
| **Duplicate Exports** | Detects when you redefine a function that already exists elsewhere in the codebase. |
|
|
21
|
+
|
|
22
|
+
### Actionable feedback
|
|
23
|
+
|
|
24
|
+
All warnings include actionable guidance — the agent sees what to do, not just what's wrong:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
[TypeScript] 2 issue(s):
|
|
28
|
+
[error] L10: Type 'string' is not assignable to type 'number'
|
|
29
|
+
|
|
30
|
+
[ast-grep] 1 structural issue(s) — 1 warning(s):
|
|
31
|
+
no-console-log: console.log found (L15)
|
|
32
|
+
→ Use a proper logging framework or remove before committing.
|
|
33
|
+
|
|
34
|
+
[jscpd] 1 duplicate block(s) involving utils.ts:
|
|
35
|
+
15 lines — helpers.ts:20
|
|
36
|
+
→ Extract duplicated code to a shared utility function
|
|
37
|
+
|
|
38
|
+
[Duplicate Exports] 1 function(s) already exist:
|
|
39
|
+
formatDate (already in helpers.ts)
|
|
40
|
+
→ Import the existing function instead of redefining it
|
|
41
|
+
|
|
42
|
+
[Complexity Warnings]
|
|
43
|
+
⚠ Maintainability dropped to 55 — extract logic into helper functions
|
|
44
|
+
⚠ High entropy (4.2 bits) — follow project conventions
|
|
45
|
+
|
|
46
|
+
[Tests] ✗ 1/3 failed, 2 passed
|
|
47
|
+
✗ should format date
|
|
48
|
+
→ Fix failing tests before proceeding
|
|
49
|
+
```
|
|
20
50
|
|
|
21
51
|
### Pre-write hints
|
|
22
52
|
|
|
@@ -291,6 +291,17 @@ export class ComplexityClient {
|
|
|
291
291
|
warnings.push(`High entropy (${metrics.codeEntropy.toFixed(1)} bits) — follow project conventions`);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
// Comments ratio (>30% = excessive comments, AI slop signal)
|
|
295
|
+
const totalLines = metrics.linesOfCode + metrics.commentLines;
|
|
296
|
+
if (totalLines > 10 && metrics.commentLines / totalLines > 0.3) {
|
|
297
|
+
warnings.push(`Excessive comments (${Math.round(metrics.commentLines / totalLines * 100)}%) — remove obvious comments`);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Verbose code (long functions with low complexity = overly verbose)
|
|
301
|
+
if (metrics.avgFunctionLength > 30 && metrics.cyclomaticComplexity < 3) {
|
|
302
|
+
warnings.push(`Verbose code (avg ${Math.round(metrics.avgFunctionLength)} lines, low complexity) — simplify or extract`);
|
|
303
|
+
}
|
|
304
|
+
|
|
294
305
|
return warnings;
|
|
295
306
|
}
|
|
296
307
|
|
package/index.ts
CHANGED
|
@@ -711,10 +711,24 @@ export default function (pi: ExtensionAPI) {
|
|
|
711
711
|
|
|
712
712
|
const diags = tsClient.getDiagnostics(filePath);
|
|
713
713
|
if (diags.length > 0) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
714
|
+
// Separate unused imports (TS6133, TS6196) from other diagnostics
|
|
715
|
+
const unusedImports = diags.filter(d => d.code === 6133 || d.code === 6196);
|
|
716
|
+
const otherDiags = diags.filter(d => d.code !== 6133 && d.code !== 6196);
|
|
717
|
+
|
|
718
|
+
if (unusedImports.length > 0) {
|
|
719
|
+
lspOutput += `\n\n[Unused Imports] ${unusedImports.length} imported but never used:\n`;
|
|
720
|
+
for (const d of unusedImports.slice(0, 10)) {
|
|
721
|
+
lspOutput += ` L${d.range.start.line + 1}: ${d.message}\n`;
|
|
722
|
+
}
|
|
723
|
+
lspOutput += ` → Remove unused imports to reduce noise\n`;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (otherDiags.length > 0) {
|
|
727
|
+
lspOutput += `\n\n[TypeScript] ${otherDiags.length} issue(s):\n`;
|
|
728
|
+
for (const d of otherDiags.slice(0, 10)) {
|
|
729
|
+
const label = d.severity === 2 ? "Warning" : "Error";
|
|
730
|
+
lspOutput += ` [${label}] L${d.range.start.line + 1}: ${d.message}\n`;
|
|
731
|
+
}
|
|
718
732
|
}
|
|
719
733
|
}
|
|
720
734
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
id: magic-numbers
|
|
2
|
+
language: TypeScript
|
|
3
|
+
message: "Magic number detected — use a named constant"
|
|
4
|
+
severity: hint
|
|
5
|
+
note: |
|
|
6
|
+
Hardcoded numbers make code harder to understand and maintain.
|
|
7
|
+
Extract to a named constant with a descriptive name.
|
|
8
|
+
rule:
|
|
9
|
+
kind: number
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
id: silent-failure
|
|
2
|
+
language: TypeScript
|
|
3
|
+
message: "Silent failure detected — log or rethrow the error"
|
|
4
|
+
severity: warning
|
|
5
|
+
note: |
|
|
6
|
+
Empty catch blocks swallow errors silently.
|
|
7
|
+
Always log the error or rethrow it to aid debugging.
|
|
8
|
+
rule:
|
|
9
|
+
kind: catch_clause
|
|
10
|
+
has:
|
|
11
|
+
kind: statement_block
|
|
12
|
+
not:
|
|
13
|
+
has:
|
|
14
|
+
kind: throw_statement
|