pi-lens 3.8.39 → 3.8.41

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 (65) hide show
  1. package/CHANGELOG.md +84 -5
  2. package/README.md +37 -1
  3. package/clients/biome-client.ts +5 -4
  4. package/clients/cache/rule-cache.ts +1 -1
  5. package/clients/complexity-client.ts +1 -1
  6. package/clients/dependency-checker.ts +1 -1
  7. package/clients/dispatch/diagnostic-taxonomy.ts +13 -1
  8. package/clients/dispatch/dispatcher.ts +9 -0
  9. package/clients/dispatch/fact-scheduler.ts +1 -1
  10. package/clients/dispatch/integration.ts +58 -3
  11. package/clients/dispatch/runners/index.ts +2 -0
  12. package/clients/dispatch/runners/semgrep.ts +269 -0
  13. package/clients/dispatch/runners/shellcheck.ts +2 -8
  14. package/clients/dispatch/runners/tree-sitter.ts +32 -11
  15. package/clients/dispatch/tool-profile.ts +1 -0
  16. package/clients/format-service.ts +10 -0
  17. package/clients/formatters.ts +22 -8
  18. package/clients/installer/index.ts +3 -3
  19. package/clients/knip-client.ts +360 -362
  20. package/clients/lsp/aggregation.ts +91 -0
  21. package/clients/lsp/client.ts +91 -38
  22. package/clients/lsp/index.ts +88 -72
  23. package/clients/lsp/launch.ts +107 -34
  24. package/clients/lsp/server-strategies.ts +71 -0
  25. package/clients/lsp/server.ts +76 -57
  26. package/clients/path-utils.ts +17 -0
  27. package/clients/pipeline.ts +23 -5
  28. package/clients/production-readiness.ts +2 -2
  29. package/clients/read-guard-logger.ts +41 -1
  30. package/clients/read-guard-tool-lines.ts +17 -4
  31. package/clients/read-guard.ts +95 -46
  32. package/clients/runtime-agent-end.ts +3 -0
  33. package/clients/runtime-session.ts +5 -0
  34. package/clients/runtime-tool-result.ts +48 -1
  35. package/clients/runtime-turn.ts +48 -4
  36. package/clients/sanitize.ts +1 -1
  37. package/clients/semgrep-config.ts +213 -0
  38. package/clients/tool-policy.ts +1982 -1936
  39. package/clients/tree-sitter-client.ts +1 -1
  40. package/clients/widget-state.ts +283 -0
  41. package/commands/booboo.ts +34 -2
  42. package/index.ts +231 -17
  43. package/package.json +3 -2
  44. package/rules/rule-catalog.json +25 -1
  45. package/rules/tree-sitter-queries/cobol/lock-table-cobol.yml +35 -0
  46. package/rules/tree-sitter-queries/cpp/unnecessary-bit-ops.yml +58 -0
  47. package/rules/tree-sitter-queries/java/infinite-loop.yml +58 -0
  48. package/rules/tree-sitter-queries/java/infinite-recursion.yml +58 -0
  49. package/rules/tree-sitter-queries/java/mockito-initialized.yml +66 -0
  50. package/rules/tree-sitter-queries/java/name-capitalization-conflict.yml +54 -0
  51. package/rules/tree-sitter-queries/java/no-octal-values.yml +48 -0
  52. package/rules/tree-sitter-queries/java/resources-closed.yml +57 -0
  53. package/rules/tree-sitter-queries/java/short-circuit-logic.yml +57 -0
  54. package/rules/tree-sitter-queries/java/tests-include-assertions.yml +60 -0
  55. package/rules/tree-sitter-queries/java/unnecessary-bit-ops-java.yml +57 -0
  56. package/rules/tree-sitter-queries/javascript/switch-case-termination-js.yml +64 -0
  57. package/rules/tree-sitter-queries/plsql/lock-table.yml +42 -0
  58. package/rules/tree-sitter-queries/plsql/nchar-nvarchar2-bytes.yml +54 -0
  59. package/rules/tree-sitter-queries/python/no-super-torchscript.yml +52 -0
  60. package/rules/tree-sitter-queries/typescript/default-not-last.yml +54 -0
  61. package/rules/tree-sitter-queries/typescript/duplicate-function-arg.yml +51 -0
  62. package/rules/tree-sitter-queries/typescript/empty-switch-case.yml +54 -0
  63. package/rules/tree-sitter-queries/typescript/infinite-loop.yml +55 -0
  64. package/rules/tree-sitter-queries/typescript/self-assignment.yml +46 -0
  65. package/rules/tree-sitter-queries/typescript/switch-case-termination.yml +64 -0
@@ -0,0 +1,54 @@
1
+ # Default Not Last
2
+ # Detects default clauses that are not last
3
+ id: default-not-last
4
+ name: Default Clauses Should Be Last
5
+ severity: error
6
+ category: maintainability
7
+ defect_class: correctness
8
+ inline_tier: blocking
9
+ language: typescript
10
+
11
+ message: "default clause should be the last case"
12
+
13
+ description: |
14
+ The default clause should always be the last case in a switch.
15
+ Having it before other cases is confusing and may cause bugs.
16
+
17
+ ✅ FIX: Move default to the end
18
+
19
+ ```typescript
20
+ switch (x) {
21
+ case 1: ...
22
+ default: ... // GOOD - last
23
+ }
24
+ ```
25
+
26
+ query: |
27
+ (switch_statement
28
+ body: (switch_body
29
+ (switch_default) @DEFAULT
30
+ (switch_case) @AFTER_CASE))
31
+
32
+ metavars:
33
+ - DEFAULT
34
+ - AFTER_CASE
35
+
36
+ tags:
37
+ - maintainability
38
+ - typescript
39
+ - confusing
40
+
41
+ examples:
42
+ bad: |
43
+ switch (x) {
44
+ default: ... // BAD - not last
45
+ case 1: ...
46
+ }
47
+
48
+ good: |
49
+ switch (x) {
50
+ case 1: ...
51
+ default: ... // GOOD - last
52
+ }
53
+
54
+ has_fix: false
@@ -0,0 +1,51 @@
1
+ # Duplicate Function Argument
2
+ # Detects duplicate parameter names
3
+ id: duplicate-function-arg
4
+ name: Function Argument Names Should Be Unique
5
+ severity: error
6
+ category: reliability
7
+ defect_class: correctness
8
+ inline_tier: blocking
9
+ language: typescript
10
+
11
+ message: "Duplicate parameter name '{{NAME}}'"
12
+
13
+ description: |
14
+ Duplicate parameter names cause the last one to shadow earlier
15
+ ones, leading to confusing behavior. Use unique names.
16
+
17
+ ✅ FIX: Use unique parameter names
18
+
19
+ ```typescript
20
+ function add(a: number, b: number) { } // GOOD
21
+ ```
22
+
23
+ query: |
24
+ (function_declaration
25
+ parameters: (formal_parameters
26
+ (identifier) @PARAM1
27
+ (identifier) @PARAM2))
28
+ (arrow_function
29
+ parameters: (formal_parameters
30
+ (identifier) @PARAM1
31
+ (identifier) @PARAM2))
32
+
33
+ metavars:
34
+ - PARAM1
35
+ - PARAM2
36
+
37
+ post_filter: same_param_name
38
+
39
+ tags:
40
+ - reliability
41
+ - typescript
42
+ - bugs
43
+
44
+ examples:
45
+ bad: |
46
+ function add(a, a) { } // BAD - duplicate
47
+
48
+ good: |
49
+ function add(a, b) { } // GOOD - unique
50
+
51
+ has_fix: false
@@ -0,0 +1,54 @@
1
+ # Empty Switch Case
2
+ # Detects empty switch cases
3
+ id: empty-switch-case
4
+ name: Switch Cases Should Not Be Empty
5
+ severity: error
6
+ category: reliability
7
+ defect_class: correctness
8
+ inline_tier: blocking
9
+ language: typescript
10
+
11
+ message: "Switch case should not be empty"
12
+
13
+ description: |
14
+ Empty switch cases are confusing and likely indicate incomplete
15
+ code. Add handling or remove the case.
16
+
17
+ ✅ FIX: Add case body or remove
18
+
19
+ ```typescript
20
+ switch (x) {
21
+ case 1:
22
+ handleOne(); // GOOD
23
+ break;
24
+ }
25
+ ```
26
+
27
+ query: |
28
+ (switch_statement
29
+ body: (switch_body
30
+ (switch_case
31
+ consequence: (statement_block) @BLOCK)))
32
+
33
+ metavars:
34
+ - BLOCK
35
+
36
+ post_filter: is_empty_block
37
+
38
+ tags:
39
+ - reliability
40
+ - typescript
41
+ - bugs
42
+
43
+ examples:
44
+ bad: |
45
+ case 1: // BAD - empty
46
+ case 2:
47
+ doWork();
48
+
49
+ good: |
50
+ case 1:
51
+ handleOne(); // GOOD
52
+ break;
53
+
54
+ has_fix: false
@@ -0,0 +1,55 @@
1
+ # Infinite Loop TypeScript
2
+ # Detects potentially infinite loops
3
+ id: infinite-loop
4
+ name: Loops Should Not Be Infinite
5
+ severity: error
6
+ category: reliability
7
+ defect_class: correctness
8
+ inline_tier: blocking
9
+ language: typescript
10
+
11
+ message: "Loop appears to be infinite with no termination condition"
12
+
13
+ description: |
14
+ while(true) or for(;;) without break/return creates infinite loops.
15
+ Ensure there's an exit condition.
16
+
17
+ ✅ FIX: Add break condition
18
+
19
+ ```typescript
20
+ while (running) { // control flag
21
+ if (shouldStop()) break;
22
+ }
23
+ ```
24
+
25
+ query: |
26
+ (while_statement
27
+ condition: (true)
28
+ body: (statement_block) @BODY)
29
+ (for_statement
30
+ condition: (null)
31
+ body: (statement_block) @BODY)
32
+
33
+ metavars:
34
+ - BODY
35
+
36
+ post_filter: no_break_or_return_in_body
37
+
38
+ tags:
39
+ - reliability
40
+ - typescript
41
+ - bugs
42
+
43
+ examples:
44
+ bad: |
45
+ while (true) { // BAD
46
+ doWork();
47
+ }
48
+
49
+ good: |
50
+ while (true) { // GOOD - has exit
51
+ if (done) break;
52
+ doWork();
53
+ }
54
+
55
+ has_fix: false
@@ -0,0 +1,46 @@
1
+ # Self Assignment
2
+ # Detects variables assigned to themselves
3
+ id: self-assignment
4
+ name: Variables Should Not Be Self-Assigned
5
+ severity: error
6
+ category: reliability
7
+ defect_class: correctness
8
+ inline_tier: blocking
9
+ language: typescript
10
+
11
+ message: "'{{VAR}}' is assigned to itself"
12
+
13
+ description: |
14
+ Self-assignment (x = x) has no effect and indicates a bug,
15
+ usually from typo or incomplete refactoring.
16
+
17
+ ✅ FIX: Fix the assignment or remove it
18
+
19
+ ```typescript
20
+ x = y; // GOOD - actual intent
21
+ ```
22
+
23
+ query: |
24
+ (assignment_expression
25
+ left: (identifier) @VAR
26
+ right: (identifier) @SAME
27
+ (#eq? @VAR @SAME))
28
+
29
+ metavars:
30
+ - VAR
31
+ - SAME
32
+
33
+ tags:
34
+ - reliability
35
+ - typescript
36
+ - bugs
37
+ - suspicious
38
+
39
+ examples:
40
+ bad: |
41
+ x = x; // BAD - no effect
42
+
43
+ good: |
44
+ x = y; // GOOD - actual assignment
45
+
46
+ has_fix: false
@@ -0,0 +1,64 @@
1
+ # Switch Case Termination
2
+ # Detects switch cases that don't properly terminate
3
+ id: switch-case-termination
4
+ name: Switch Cases Should End With Terminating Statement
5
+ severity: error
6
+ category: reliability
7
+ defect_class: correctness
8
+ inline_tier: blocking
9
+ language: typescript
10
+
11
+ message: "Switch case should end with break, return, throw, or continue"
12
+
13
+ description: |
14
+ Switch cases that fall through to the next case cause bugs.
15
+ Each case should end with break, return, throw, or continue.
16
+ If fall-through is intentional, add a // fallthrough comment.
17
+
18
+ ✅ FIX: Add terminating statement
19
+
20
+ ```typescript
21
+ switch (x) {
22
+ case 1:
23
+ doSomething();
24
+ break; // GOOD
25
+ }
26
+ ```
27
+
28
+ query: |
29
+ (switch_statement
30
+ body: (switch_body
31
+ (switch_case
32
+ consequence: (statement_block
33
+ (expression_statement) @LAST))
34
+ (switch_case) @NEXT))
35
+
36
+ metavars:
37
+ - LAST
38
+ - NEXT
39
+
40
+ post_filter: no_terminating_statement
41
+
42
+ tags:
43
+ - reliability
44
+ - typescript
45
+ - bugs
46
+
47
+ examples:
48
+ bad: |
49
+ switch (x) {
50
+ case 1:
51
+ doSomething(); // BAD - falls through
52
+ case 2:
53
+ break;
54
+ }
55
+
56
+ good: |
57
+ switch (x) {
58
+ case 1:
59
+ return "one"; // GOOD - return terminates
60
+ case 2:
61
+ break;
62
+ }
63
+
64
+ has_fix: false