pi-lens 3.6.3 → 3.6.4

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 (206) hide show
  1. package/package.json +3 -3
  2. package/tsconfig.json +1 -1
  3. package/clients/__tests__/file-time.test.js +0 -216
  4. package/clients/__tests__/file-time.test.ts +0 -276
  5. package/clients/__tests__/format-service.test.js +0 -245
  6. package/clients/__tests__/format-service.test.ts +0 -339
  7. package/clients/__tests__/formatters.test.js +0 -271
  8. package/clients/__tests__/formatters.test.ts +0 -401
  9. package/clients/agent-behavior-client.js +0 -110
  10. package/clients/agent-behavior-client.test.js +0 -94
  11. package/clients/agent-behavior-client.test.ts +0 -116
  12. package/clients/amain-types.js +0 -164
  13. package/clients/architect-client.js +0 -291
  14. package/clients/ast-grep-client.js +0 -253
  15. package/clients/ast-grep-parser.js +0 -84
  16. package/clients/ast-grep-rule-manager.js +0 -89
  17. package/clients/ast-grep-types.js +0 -9
  18. package/clients/auto-loop.js +0 -131
  19. package/clients/biome-client.js +0 -420
  20. package/clients/biome-client.test.js +0 -144
  21. package/clients/biome-client.test.ts +0 -163
  22. package/clients/cache/rule-cache.js +0 -72
  23. package/clients/cache-manager.js +0 -245
  24. package/clients/cache-manager.test.js +0 -197
  25. package/clients/cache-manager.test.ts +0 -299
  26. package/clients/complexity-client.js +0 -675
  27. package/clients/complexity-client.test.js +0 -234
  28. package/clients/complexity-client.test.ts +0 -255
  29. package/clients/config-validator.js +0 -465
  30. package/clients/dependency-checker.js +0 -325
  31. package/clients/dependency-checker.test.js +0 -60
  32. package/clients/dependency-checker.test.ts +0 -71
  33. package/clients/dispatch/__tests__/autofix-integration.test.js +0 -245
  34. package/clients/dispatch/__tests__/autofix-integration.test.ts +0 -300
  35. package/clients/dispatch/__tests__/runner-registration.test.js +0 -234
  36. package/clients/dispatch/__tests__/runner-registration.test.ts +0 -286
  37. package/clients/dispatch/debug.log +0 -1
  38. package/clients/dispatch/dispatcher.edge.test.js +0 -82
  39. package/clients/dispatch/dispatcher.edge.test.ts +0 -100
  40. package/clients/dispatch/dispatcher.format.test.js +0 -46
  41. package/clients/dispatch/dispatcher.format.test.ts +0 -58
  42. package/clients/dispatch/dispatcher.inline.test.js +0 -74
  43. package/clients/dispatch/dispatcher.inline.test.ts +0 -93
  44. package/clients/dispatch/dispatcher.js +0 -381
  45. package/clients/dispatch/dispatcher.test.js +0 -116
  46. package/clients/dispatch/dispatcher.test.ts +0 -149
  47. package/clients/dispatch/integration.js +0 -108
  48. package/clients/dispatch/plan.js +0 -183
  49. package/clients/dispatch/runners/architect.js +0 -83
  50. package/clients/dispatch/runners/architect.test.js +0 -138
  51. package/clients/dispatch/runners/architect.test.ts +0 -162
  52. package/clients/dispatch/runners/ast-grep-napi.js +0 -405
  53. package/clients/dispatch/runners/ast-grep-napi.test.js +0 -107
  54. package/clients/dispatch/runners/ast-grep-napi.test.ts +0 -129
  55. package/clients/dispatch/runners/ast-grep.js +0 -157
  56. package/clients/dispatch/runners/biome.js +0 -55
  57. package/clients/dispatch/runners/config-validation.js +0 -67
  58. package/clients/dispatch/runners/go-vet.js +0 -48
  59. package/clients/dispatch/runners/index.js +0 -47
  60. package/clients/dispatch/runners/lsp.js +0 -102
  61. package/clients/dispatch/runners/oxlint.js +0 -67
  62. package/clients/dispatch/runners/oxlint.test.js +0 -230
  63. package/clients/dispatch/runners/oxlint.test.ts +0 -303
  64. package/clients/dispatch/runners/pyright.js +0 -100
  65. package/clients/dispatch/runners/pyright.test.js +0 -98
  66. package/clients/dispatch/runners/pyright.test.ts +0 -121
  67. package/clients/dispatch/runners/python-slop.js +0 -97
  68. package/clients/dispatch/runners/python-slop.test.js +0 -203
  69. package/clients/dispatch/runners/python-slop.test.ts +0 -298
  70. package/clients/dispatch/runners/ruff.js +0 -48
  71. package/clients/dispatch/runners/rust-clippy.js +0 -102
  72. package/clients/dispatch/runners/scan_codebase.test.js +0 -89
  73. package/clients/dispatch/runners/scan_codebase.test.ts +0 -105
  74. package/clients/dispatch/runners/shellcheck.js +0 -147
  75. package/clients/dispatch/runners/shellcheck.test.js +0 -98
  76. package/clients/dispatch/runners/shellcheck.test.ts +0 -129
  77. package/clients/dispatch/runners/similarity.js +0 -230
  78. package/clients/dispatch/runners/spellcheck.js +0 -106
  79. package/clients/dispatch/runners/spellcheck.test.js +0 -158
  80. package/clients/dispatch/runners/spellcheck.test.ts +0 -214
  81. package/clients/dispatch/runners/tree-sitter.js +0 -246
  82. package/clients/dispatch/runners/ts-lsp.js +0 -125
  83. package/clients/dispatch/runners/ts-slop.js +0 -113
  84. package/clients/dispatch/runners/type-safety.js +0 -142
  85. package/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -134
  86. package/clients/dispatch/runners/utils/runner-helpers.js +0 -115
  87. package/clients/dispatch/runners/utils.js +0 -51
  88. package/clients/dispatch/runners/yaml-rule-parser.js +0 -360
  89. package/clients/dispatch/types.js +0 -16
  90. package/clients/dispatch/utils/format-utils.js +0 -44
  91. package/clients/dogfood.test.js +0 -201
  92. package/clients/dogfood.test.ts +0 -269
  93. package/clients/file-kinds.js +0 -177
  94. package/clients/file-kinds.test.js +0 -169
  95. package/clients/file-kinds.test.ts +0 -210
  96. package/clients/file-time.js +0 -152
  97. package/clients/file-utils.js +0 -40
  98. package/clients/fix-scanners.js +0 -204
  99. package/clients/format-service.js +0 -184
  100. package/clients/formatters.js +0 -488
  101. package/clients/go-client.js +0 -203
  102. package/clients/go-client.test.js +0 -127
  103. package/clients/go-client.test.ts +0 -143
  104. package/clients/installer/index.js +0 -403
  105. package/clients/interviewer-templates.js +0 -75
  106. package/clients/interviewer.js +0 -173
  107. package/clients/jscpd-client.js +0 -196
  108. package/clients/jscpd-client.test.js +0 -127
  109. package/clients/jscpd-client.test.ts +0 -145
  110. package/clients/knip-client.js +0 -239
  111. package/clients/knip-client.test.js +0 -112
  112. package/clients/knip-client.test.ts +0 -128
  113. package/clients/latency-logger.js +0 -40
  114. package/clients/lsp/__tests__/client.test.js +0 -310
  115. package/clients/lsp/__tests__/client.test.ts +0 -412
  116. package/clients/lsp/__tests__/config.test.js +0 -167
  117. package/clients/lsp/__tests__/config.test.ts +0 -217
  118. package/clients/lsp/__tests__/error-recovery.test.js +0 -213
  119. package/clients/lsp/__tests__/error-recovery.test.ts +0 -279
  120. package/clients/lsp/__tests__/integration.test.js +0 -127
  121. package/clients/lsp/__tests__/integration.test.ts +0 -160
  122. package/clients/lsp/__tests__/launch.test.js +0 -313
  123. package/clients/lsp/__tests__/launch.test.ts +0 -394
  124. package/clients/lsp/__tests__/server.test.js +0 -259
  125. package/clients/lsp/__tests__/server.test.ts +0 -332
  126. package/clients/lsp/__tests__/service.test.js +0 -438
  127. package/clients/lsp/__tests__/service.test.ts +0 -530
  128. package/clients/lsp/client.js +0 -350
  129. package/clients/lsp/config.js +0 -112
  130. package/clients/lsp/index.js +0 -318
  131. package/clients/lsp/installer/index.js +0 -391
  132. package/clients/lsp/interactive-install.js +0 -221
  133. package/clients/lsp/language.js +0 -170
  134. package/clients/lsp/launch.js +0 -329
  135. package/clients/lsp/lsp/launch.js +0 -116
  136. package/clients/lsp/lsp/server.js +0 -532
  137. package/clients/lsp/lsp-index.js +0 -10
  138. package/clients/lsp/path-utils.js +0 -5
  139. package/clients/lsp/server.js +0 -725
  140. package/clients/lsp/test-py-spawn/requirements.txt +0 -1
  141. package/clients/lsp/test-py-spawn/test.py +0 -3
  142. package/clients/lsp/test-py-svc/requirements.txt +0 -1
  143. package/clients/lsp/test-py-svc/test.py +0 -3
  144. package/clients/lsp/test-python-project/requirements.txt +0 -1
  145. package/clients/lsp/test-python-project/test.py +0 -5
  146. package/clients/metrics-client.js +0 -107
  147. package/clients/metrics-client.test.js +0 -128
  148. package/clients/metrics-client.test.ts +0 -163
  149. package/clients/metrics-history.js +0 -367
  150. package/clients/path-utils.js +0 -142
  151. package/clients/pipeline.js +0 -272
  152. package/clients/production-readiness.js +0 -522
  153. package/clients/project-index.js +0 -255
  154. package/clients/project-metadata.js +0 -531
  155. package/clients/ruff-client.js +0 -325
  156. package/clients/ruff-client.test.js +0 -132
  157. package/clients/ruff-client.test.ts +0 -153
  158. package/clients/rules-scanner.js +0 -97
  159. package/clients/runner-tracker.js +0 -152
  160. package/clients/rust-client.js +0 -205
  161. package/clients/rust-client.test.js +0 -108
  162. package/clients/rust-client.test.ts +0 -130
  163. package/clients/safe-spawn-async.js +0 -163
  164. package/clients/safe-spawn.js +0 -241
  165. package/clients/sanitize.js +0 -291
  166. package/clients/sanitize.test.js +0 -177
  167. package/clients/sanitize.test.ts +0 -223
  168. package/clients/scan-architectural-debt.js +0 -167
  169. package/clients/scan-utils.js +0 -83
  170. package/clients/secrets-scanner.js +0 -119
  171. package/clients/secrets-scanner.test.js +0 -100
  172. package/clients/secrets-scanner.test.ts +0 -113
  173. package/clients/sg-runner.js +0 -292
  174. package/clients/state-matrix.js +0 -160
  175. package/clients/subprocess-client.js +0 -65
  176. package/clients/symbol-types.js +0 -5
  177. package/clients/test-runner-client.js +0 -523
  178. package/clients/test-runner-client.test.js +0 -192
  179. package/clients/test-runner-client.test.ts +0 -253
  180. package/clients/test-utils.js +0 -27
  181. package/clients/test-utils.ts +0 -36
  182. package/clients/todo-scanner.js +0 -200
  183. package/clients/todo-scanner.test.js +0 -301
  184. package/clients/todo-scanner.test.ts +0 -352
  185. package/clients/tool-availability.js +0 -207
  186. package/clients/tree-sitter-client.js +0 -601
  187. package/clients/tree-sitter-query-loader.js +0 -355
  188. package/clients/tree-sitter-symbol-extractor.js +0 -289
  189. package/clients/ts-service.js +0 -129
  190. package/clients/type-coverage-client.js +0 -127
  191. package/clients/type-coverage-client.test.js +0 -105
  192. package/clients/type-coverage-client.test.ts +0 -125
  193. package/clients/type-safety-client.js +0 -138
  194. package/clients/types.js +0 -11
  195. package/clients/typescript-client.codefix.test.js +0 -157
  196. package/clients/typescript-client.codefix.test.ts +0 -186
  197. package/clients/typescript-client.js +0 -509
  198. package/clients/typescript-client.test.js +0 -105
  199. package/clients/typescript-client.test.ts +0 -126
  200. package/commands/booboo.js +0 -1007
  201. package/commands/fix-from-booboo.js +0 -398
  202. package/commands/fix-simplified.js +0 -618
  203. package/commands/rate.js +0 -281
  204. package/commands/rate.test.js +0 -119
  205. package/commands/rate.test.ts +0 -131
  206. package/commands/refactor.js +0 -130
@@ -1,398 +0,0 @@
1
- /**
2
- * /lens-booboo-fix command - Sequential fixing from booboo results
3
- *
4
- * Reads the latest /lens-booboo review and applies automated fixes
5
- * for the issues found. Works sequentially through fixable issues.
6
- */
7
- import * as nodeFs from "node:fs";
8
- import * as path from "node:path";
9
- import { getSourceFiles } from "../clients/scan-utils.js";
10
- import { isTestFile } from "../clients/file-utils.js";
11
- export async function handleFixFromBooboo(args, ctx, clients, pi) {
12
- const targetPath = args.trim() || ctx.cwd || process.cwd();
13
- // Find latest booboo review
14
- const reviewDir = path.join(targetPath, ".pi-lens", "reviews");
15
- let latestReview = null;
16
- // Check if reviews directory exists
17
- if (!nodeFs.existsSync(reviewDir)) {
18
- ctx.ui.notify("❌ No /lens-booboo review found (no .pi-lens/reviews directory). Run `/lens-booboo` first.", "error");
19
- return;
20
- }
21
- let jsonFiles = [];
22
- let detailedReport = "";
23
- let reportRelPath = ""; // Will hold relative path to markdown report
24
- try {
25
- const files = nodeFs.readdirSync(reviewDir);
26
- jsonFiles = files
27
- .filter((f) => f.startsWith("booboo-") && f.endsWith(".json"))
28
- .sort()
29
- .reverse();
30
- if (jsonFiles.length === 0) {
31
- ctx.ui.notify("❌ No /lens-booboo review found. Run `/lens-booboo` first to scan for issues.", "error");
32
- return;
33
- }
34
- const latestReviewPath = path.join(reviewDir, jsonFiles[0]);
35
- const fileContent = nodeFs.readFileSync(latestReviewPath, "utf-8");
36
- latestReview = JSON.parse(fileContent);
37
- // Load detailed markdown report for specific findings
38
- const mdFile = jsonFiles[0].replace(".json", ".md");
39
- const mdPath = path.join(reviewDir, mdFile);
40
- reportRelPath = path.relative(targetPath, mdPath).replace(/\\/g, "/");
41
- try {
42
- detailedReport = nodeFs.readFileSync(mdPath, "utf-8");
43
- }
44
- catch {
45
- // Ignore - we'll work without details
46
- }
47
- }
48
- catch (err) {
49
- console.error("[fix-from-booboo] Error reading review:", err);
50
- ctx.ui.notify(`❌ Error reading booboo review: ${err instanceof Error ? err.message : String(err)}`, "error");
51
- return;
52
- }
53
- if (!latestReview) {
54
- ctx.ui.notify("❌ Failed to parse booboo review. Run `/lens-booboo` again.", "error");
55
- return;
56
- }
57
- // Check if meta exists
58
- if (!latestReview.meta) {
59
- ctx.ui.notify("❌ Invalid booboo review format (missing meta). Run `/lens-booboo` again.", "error");
60
- return;
61
- }
62
- // Use meta properties directly (summary object doesn't exist in JSON)
63
- const totalIssues = latestReview.meta.totalIssues ?? 0;
64
- const fixableCount = latestReview.meta.fixableCount ?? 0;
65
- const refactorNeeded = latestReview.meta.refactorNeeded ?? 0;
66
- const timestamp = latestReview.meta.timestamp ?? "unknown";
67
- const runners = latestReview.meta.runners ?? [];
68
- ctx.ui.notify(`🔧 Fixing from review: ${timestamp} (${fixableCount} fixable issues)`, "info");
69
- const results = [];
70
- let fixedCount = 0;
71
- const isTsProject = nodeFs.existsSync(path.join(targetPath, "tsconfig.json"));
72
- // Get source files with SAME exclusions as booboo uses
73
- // 1. Start with scan-utils getSourceFiles (excludes EXCLUDED_DIRS)
74
- // 2. Filter out test files (matches booboo's shouldIncludeFile)
75
- // 3. Filter out compiled .js in TS projects (same as booboo)
76
- const sourceFiles = getSourceFiles(targetPath, isTsProject).filter(file => {
77
- // Match booboo's shouldIncludeFile: exclude test files
78
- if (isTestFile(file))
79
- return false;
80
- // Match booboo's TS project compiled JS exclusion
81
- if (isTsProject && file.endsWith(".js") && nodeFs.existsSync(file.replace(/\.js$/, ".ts"))) {
82
- return false;
83
- }
84
- return true;
85
- });
86
- ctx.ui.notify(`🔧 Found ${sourceFiles.length} source file(s) to check (tests/excluded dirs skipped)`, "info");
87
- // 1. Biome auto-fixes for TS/JS files - run once on all files for efficiency
88
- if (clients.biome.isAvailable()) {
89
- const biomeFiles = sourceFiles.filter(f => clients.biome.isSupportedFile(f));
90
- if (biomeFiles.length > 0) {
91
- ctx.ui.notify(`🔧 Running Biome on ${biomeFiles.length} file(s)...`, "info");
92
- const biomeResult = clients.biome.fixFiles(biomeFiles);
93
- if (biomeResult.success && biomeResult.fixed > 0) {
94
- fixedCount += biomeResult.fixed;
95
- results.push(`✅ Biome: Fixed ${biomeResult.fixed} issue(s) in ${biomeFiles.length} file(s)`);
96
- }
97
- else if (biomeResult.success) {
98
- results.push(`✅ Biome: No issues found in ${biomeFiles.length} file(s)`);
99
- }
100
- else {
101
- results.push(`⚠️ Biome: ${biomeResult.error || "Failed to run"}`);
102
- }
103
- }
104
- }
105
- // 2. Ruff auto-fixes for Python files - run once on all files for efficiency
106
- if (clients.ruff.isAvailable()) {
107
- const pythonFiles = sourceFiles.filter(f => f.endsWith(".py"));
108
- if (pythonFiles.length > 0) {
109
- ctx.ui.notify(`🔧 Running Ruff on ${pythonFiles.length} Python file(s)...`, "info");
110
- const ruffResult = clients.ruff.fixFiles(pythonFiles);
111
- if (ruffResult.success && ruffResult.fixed > 0) {
112
- fixedCount += ruffResult.fixed;
113
- results.push(`✅ Ruff: Fixed ${ruffResult.fixed} issue(s) in ${pythonFiles.length} file(s)`);
114
- }
115
- else if (ruffResult.success) {
116
- results.push(`✅ Ruff: No issues found in ${pythonFiles.length} file(s)`);
117
- }
118
- else {
119
- results.push(`⚠️ Ruff: ${ruffResult.error || "Failed to run"}`);
120
- }
121
- }
122
- }
123
- // 3. Categorize findings for agent dispatch
124
- const agentTasks = [];
125
- const deferredToRefactor = [];
126
- const informational = [];
127
- // Parse detailed report sections to build specific tasks
128
- const reportSections = parseReportSections(detailedReport);
129
- // Check for issues from booboo review runners and dispatch appropriately
130
- for (const runner of runners) {
131
- if (runner.findings === 0)
132
- continue;
133
- switch (runner.name) {
134
- case "ast-grep (design smells)": {
135
- // AST-grep issues can often be fixed immediately by agent
136
- const section = reportSections["ast-grep"];
137
- if (section) {
138
- const files = extractFilesFromSection(section);
139
- agentTasks.push({
140
- type: "ast-grep",
141
- priority: 1,
142
- prompt: `**AST Structural Issues** (${runner.findings} found)\n\nFix design smell issues in:\n${files.map(f => `- ${f}`).join("\n")}\n\nReview the /lens-booboo report for specific rule violations and apply fixes. Focus on: extracting nested logic, reducing parameter lists, converting callbacks to async/await, and removing redundant code.`,
143
- });
144
- }
145
- break;
146
- }
147
- case "ast-grep (similar functions)": {
148
- // Similar functions need major refactoring - defer
149
- deferredToRefactor.push(`${runner.findings} groups of similar functions - use "/lens-booboo-refactor --mode=extract-helpers"`);
150
- break;
151
- }
152
- case "semantic similarity (Amain)": {
153
- // Semantic duplicates need major refactoring - defer
154
- deferredToRefactor.push(`${runner.findings} semantic duplicate pairs - use "/lens-booboo-refactor --mode=consolidate"`);
155
- break;
156
- }
157
- case "complexity metrics": {
158
- // High complexity can sometimes be reduced immediately
159
- const section = reportSections["Complexity Metrics"];
160
- if (section) {
161
- const highCogFiles = extractComplexityFiles(section);
162
- if (highCogFiles.length > 0) {
163
- agentTasks.push({
164
- type: "complexity",
165
- priority: 2,
166
- prompt: `**Complexity Reduction** (${highCogFiles.length} high-complexity files)\n\nReduce cognitive complexity in:\n${highCogFiles.slice(0, 5).map(f => `- ${f.file} (cognitive: ${f.cognitive})`).join("\n")}${highCogFiles.length > 5 ? `\n- ... and ${highCogFiles.length - 5} more` : ""}\n\nApply these techniques:\n1. Extract nested logic into named functions\n2. Use early returns to reduce nesting\n3. Replace nested if/else with switch or lookup tables\n4. Simplify boolean expressions\n\nRun "/lens-booboo-refactor --mode=reduce-complexity" for major cases.`,
167
- });
168
- }
169
- }
170
- break;
171
- }
172
- case "duplicate code (jscpd)": {
173
- // Duplicates need extraction - defer to refactor
174
- deferredToRefactor.push(`${runner.findings} duplicate code blocks - use "/lens-booboo-refactor --mode=extract-helpers"`);
175
- break;
176
- }
177
- case "dead code (Knip)": {
178
- // Dead code can be removed immediately
179
- const section = reportSections["Dead Code"];
180
- if (section) {
181
- const deadItems = extractDeadCodeItems(section);
182
- if (deadItems.length > 0) {
183
- agentTasks.push({
184
- type: "dead-code",
185
- priority: 1, // High priority - safe to remove
186
- prompt: `**Dead Code Removal** (${runner.findings} items)\n\nRemove unused code:\n${deadItems.slice(0, 10).map(i => `- [${i.type}] ${i.name} in ${i.file || "unknown"}`).join("\n")}${deadItems.length > 10 ? `\n- ... and ${deadItems.length - 10} more` : ""}\n\nCheck each item is truly unused (not dynamically imported or called via reflection), then safely remove.`,
187
- });
188
- }
189
- }
190
- break;
191
- }
192
- case "type coverage": {
193
- // Type coverage issues - agent can add types
194
- const section = reportSections["Type Coverage"];
195
- if (section) {
196
- const untypedFiles = extractUntypedFiles(section);
197
- if (untypedFiles.length > 0) {
198
- agentTasks.push({
199
- type: "types",
200
- priority: 3,
201
- prompt: `**Add Type Annotations** (${untypedFiles.length} files with untyped identifiers)\n\nAdd explicit types to improve type coverage in:\n${untypedFiles.slice(0, 5).map(f => `- ${f.file} (${f.count} untyped)`).join("\n")}${untypedFiles.length > 5 ? `\n- ... and ${untypedFiles.length - 5} more` : ""}\n\nFocus on:\n1. Function parameters and return types\n2. Variable declarations with 'any'\n3. Object literal types\n4. Event handler signatures`,
202
- });
203
- }
204
- }
205
- break;
206
- }
207
- case "circular deps (Madge)": {
208
- // Circular deps need architectural refactoring - defer
209
- deferredToRefactor.push(`${runner.findings} circular dependency chains - use "/lens-booboo-refactor --mode=break-circular"`);
210
- break;
211
- }
212
- case "architectural rules": {
213
- // Some architectural issues can be fixed immediately
214
- const section = reportSections["Architectural Rules"];
215
- if (section) {
216
- const archIssues = extractArchitecturalIssues(section);
217
- if (archIssues.length > 0) {
218
- agentTasks.push({
219
- type: "architectural",
220
- priority: 2,
221
- prompt: `**Fix Architectural Violations** (${runner.findings} violations)\n\nFix these architectural issues:\n${archIssues.slice(0, 10).map(i => `- ${i.file}: ${i.message}`).join("\n")}${archIssues.length > 10 ? `\n- ... and ${archIssues.length - 10} more` : ""}\n\nFocus on:\n1. Replace 'any' types with proper types or 'unknown'\n2. Fix absolute paths to use path.join()\n3. Extract deeply nested functions\n4. Reduce long parameter lists with options objects`,
222
- });
223
- }
224
- }
225
- break;
226
- }
227
- case "TODO scanner": {
228
- informational.push(`${runner.findings} TODOs/annotations - informational only`);
229
- break;
230
- }
231
- }
232
- }
233
- // Build summary report
234
- const outputParts = [
235
- `🔧 /lens-booboo-fix from ${timestamp}`,
236
- `Found ${totalIssues} total issues, ${fixableCount} fixable`,
237
- "",
238
- "=== Automatic Fixes (Biome/Ruff) ===",
239
- ...(results.length > 0 ? results : ["ℹ️ No automatic fixes applied"]),
240
- "",
241
- ];
242
- // Add agent tasks
243
- if (agentTasks.length > 0) {
244
- outputParts.push(`=== Agent Work Queue (${agentTasks.length} task groups) ===`);
245
- agentTasks.sort((a, b) => a.priority - b.priority);
246
- for (const task of agentTasks) {
247
- outputParts.push(`\n🎯 **${task.type.toUpperCase()}** (Priority: ${task.priority})`);
248
- }
249
- outputParts.push("");
250
- }
251
- // Add deferred items
252
- if (deferredToRefactor.length > 0) {
253
- outputParts.push("=== Deferred to /lens-booboo-refactor ===");
254
- for (const item of deferredToRefactor) {
255
- outputParts.push(`⏭️ ${item}`);
256
- }
257
- outputParts.push("");
258
- }
259
- // Add informational
260
- if (informational.length > 0) {
261
- outputParts.push("=== Informational ===");
262
- for (const item of informational) {
263
- outputParts.push(`ℹ️ ${item}`);
264
- }
265
- outputParts.push("");
266
- }
267
- // Add completion status
268
- if (fixedCount > 0) {
269
- outputParts.push(`✅ Fixed ${fixedCount} issue(s) automatically with Biome/Ruff`);
270
- outputParts.push("");
271
- }
272
- outputParts.push("Next steps:");
273
- if (agentTasks.length > 0) {
274
- outputParts.push("- Agent will work through the tasks above (priority order)");
275
- }
276
- if (deferredToRefactor.length > 0) {
277
- outputParts.push('- Run "/lens-booboo-refactor" for major structural changes');
278
- }
279
- outputParts.push('- Run "/lens-booboo" again to verify fixes');
280
- const message = outputParts.join("\n");
281
- // Always show summary to user in UI first
282
- ctx.ui.notify(message, "info");
283
- // If there are agent tasks, also send a compact prompt to the agent
284
- if (agentTasks.length > 0) {
285
- // Sort by priority
286
- agentTasks.sort((a, b) => a.priority - b.priority);
287
- // Compact task list - just type and brief description
288
- const compactTasks = agentTasks.map((t, i) => {
289
- const briefDesc = t.type === "complexity" ? "reduce cognitive complexity" :
290
- t.type === "architectural" ? "fix architectural violations" :
291
- t.type === "dead-code" ? "remove unused code" :
292
- t.type === "types" ? "add type annotations" :
293
- t.type === "ast-grep" ? "fix design smells" : "fix issues";
294
- return `${i + 1}. [P${t.priority}] ${t.type}: ${briefDesc}`;
295
- }).join("\n");
296
- // Context-optimized prompt (~500 chars vs 4000+ before)
297
- const agentPrompt = `🔧 /lens-booboo-fix: ${totalIssues} issues, ${fixableCount} fixable
298
-
299
- Auto-fixes: ${fixedCount > 0 ? `${fixedCount} issues fixed` : "none applied"}
300
-
301
- ${agentTasks.length} tasks queued (priority order):
302
- ${compactTasks}
303
-
304
- ${deferredToRefactor.length > 0 ? `\nDeferred (${deferredToRefactor.length}): Use /lens-booboo-refactor for major structural changes\n` : ""}
305
- 📄 Read ${reportRelPath} for detailed findings and file locations.
306
-
307
- Work through tasks in priority order (P1 highest). Read specific sections of the report as needed.`;
308
- try {
309
- if (ctx.isIdle()) {
310
- pi.sendUserMessage(agentPrompt);
311
- }
312
- else {
313
- pi.sendUserMessage(agentPrompt, { deliverAs: "steer" });
314
- }
315
- }
316
- catch (err) {
317
- console.error("[fix-from-booboo] sendUserMessage failed:", err);
318
- // Error already logged, UI already notified with summary
319
- }
320
- }
321
- }
322
- function parseReportSections(report) {
323
- const sections = {};
324
- if (!report)
325
- return sections;
326
- // Split on ## headers
327
- const parts = report.split(/^## /m);
328
- for (const part of parts) {
329
- if (!part.trim())
330
- continue;
331
- const lines = part.split("\n");
332
- const title = lines[0].trim();
333
- const content = lines.slice(1).join("\n");
334
- sections[title] = content;
335
- }
336
- return sections;
337
- }
338
- function extractFilesFromSection(section) {
339
- const files = [];
340
- // Match file paths in table rows
341
- const regex = /\|\s*([^|\n]+\.ts|[^|\n]+\.js|[^|\n]+\.tsx|[^|\n]+\.jsx)\s*\|/g;
342
- let match;
343
- while ((match = regex.exec(section)) !== null) {
344
- const file = match[1].trim();
345
- if (!files.includes(file))
346
- files.push(file);
347
- }
348
- return files.slice(0, 10); // Limit to first 10
349
- }
350
- function extractComplexityFiles(section) {
351
- const files = [];
352
- // Match complexity table rows: | file | cognitive |
353
- const lines = section.split("\n");
354
- for (const line of lines) {
355
- const match = line.match(/\|\s*([^|]+\.ts|[^|]+\.js)\s*\|\s*(\d+)\s*\|/);
356
- if (match) {
357
- files.push({ file: match[1].trim(), cognitive: parseInt(match[2]) });
358
- }
359
- }
360
- // Match report threshold: Very High Cognitive Complexity (> 30)
361
- return files.filter(f => f.cognitive > 30).sort((a, b) => b.cognitive - a.cognitive);
362
- }
363
- function extractDeadCodeItems(section) {
364
- const items = [];
365
- // Match dead code table rows: | type | name | file |
366
- const lines = section.split("\n");
367
- for (const line of lines) {
368
- const match = line.match(/\|\s*(\w+)\s*\|\s*([^|]+)\s*\|\s*([^|]*)\s*\|/);
369
- if (match) {
370
- items.push({ type: match[1].trim(), name: match[2].trim(), file: match[3]?.trim() || undefined });
371
- }
372
- }
373
- return items;
374
- }
375
- function extractUntypedFiles(section) {
376
- const files = [];
377
- // Match file count table rows: | file | count |
378
- const lines = section.split("\n");
379
- for (const line of lines) {
380
- const match = line.match(/\|\s*([^|]+\.ts|[^|]+\.js)\s*\|\s*(\d+)\s*\|/);
381
- if (match) {
382
- files.push({ file: match[1].trim(), count: parseInt(match[2]) });
383
- }
384
- }
385
- return files;
386
- }
387
- function extractArchitecturalIssues(section) {
388
- const issues = [];
389
- // Match bullet points: - **file**: message
390
- const lines = section.split("\n");
391
- for (const line of lines) {
392
- const match = line.match(/-\s*\*\*([^*]+)\*\*:\s*(.+)/);
393
- if (match) {
394
- issues.push({ file: match[1].trim(), message: match[2].trim() });
395
- }
396
- }
397
- return issues;
398
- }