pi-lens 2.0.2 → 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 (2) hide show
  1. package/index.ts +25 -18
  2. package/package.json +1 -1
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.2",
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",