pi-lens 2.0.2 → 2.0.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 (2) hide show
  1. package/index.ts +26 -18
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -251,30 +251,38 @@ export default function (pi: ExtensionAPI) {
251
251
  encoding: "utf-8",
252
252
  timeout: 30000,
253
253
  shell: true,
254
+ maxBuffer: 32 * 1024 * 1024, // 32MB
254
255
  });
255
256
 
256
257
  const output = result.stdout || result.stderr || "";
257
258
  if (output.trim() && result.status !== undefined) {
258
259
  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
260
+
261
+ // ast-grep outputs either a JSON array or NDJSON (one object per line)
262
+ // biome-ignore lint/suspicious/noExplicitAny: ast-grep JSON output is untyped
263
+ const parseItems = (raw: string): Record<string, any>[] => {
264
+ const trimmed = raw.trim();
265
+ if (trimmed.startsWith("[")) {
266
+ try { return JSON.parse(trimmed); } catch { return []; }
277
267
  }
268
+ return raw.split("\n").flatMap((l: string) => {
269
+ try { return [JSON.parse(l)]; } catch { return []; }
270
+ });
271
+ };
272
+
273
+ for (const item of parseItems(output)) {
274
+ const ruleId = item.ruleId || item.rule?.title || item.name || "unknown";
275
+ const ruleDesc = astGrepClient.getRuleDescription?.(ruleId);
276
+ const message = ruleDesc?.message || item.message || ruleId;
277
+ const lineNum = item.labels?.[0]?.range?.start?.line ||
278
+ item.spans?.[0]?.range?.start?.line ||
279
+ item.range?.start?.line || 0;
280
+
281
+ issues.push({
282
+ line: lineNum + 1,
283
+ rule: ruleId,
284
+ message: message,
285
+ });
278
286
  }
279
287
 
280
288
  if (issues.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-lens",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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",