@narumitw/pi-biome-lsp 0.1.10 → 0.1.12

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/README.md CHANGED
@@ -13,6 +13,7 @@ Use it to give Pi Biome diagnostics, formatting, import organization, and safe s
13
13
  - Computes or writes Biome source actions such as `source.fixAll.biome` and `source.organizeImports.biome`.
14
14
  - Supports workspace roots, file limits, and recursive file discovery.
15
15
  - Starts the language server only for tool calls, then shuts it down.
16
+ - Shows statusline activity only while Biome LSP tools are running.
16
17
  - Provides clear setup errors when Biome is missing.
17
18
 
18
19
  ## 📦 Install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-biome-lsp",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Pi extension that exposes Biome language-server tools for diagnostics, formatting, and fixes.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/biome-lsp.ts CHANGED
@@ -46,6 +46,10 @@ interface ServerCommand {
46
46
  args: string[];
47
47
  }
48
48
 
49
+ interface StatusContext {
50
+ ui: { setStatus: (key: string, value: string | undefined) => void };
51
+ }
52
+
49
53
  interface LspPosition {
50
54
  line: number;
51
55
  character: number;
@@ -124,8 +128,8 @@ const biomeDiagnosticsTool = defineTool({
124
128
  "If Biome is missing, report the configuration error and suggest installing @biomejs/biome or setting PI_BIOME_LSP_COMMAND.",
125
129
  ],
126
130
  parameters: Type.Object(PathsParameters),
127
- async execute(_toolCallId, params, signal) {
128
- return runDiagnostics(params, signal);
131
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
132
+ return runDiagnostics(params, signal, ctx);
129
133
  },
130
134
  });
131
135
 
@@ -143,12 +147,13 @@ const biomeFormatTool = defineTool({
143
147
  Type.Boolean({ description: "Write formatted text back to the file. Defaults to false." }),
144
148
  ),
145
149
  }),
146
- async execute(_toolCallId, params, signal) {
150
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
147
151
  const root = resolveRoot(params.root);
148
152
  const file = resolveBiomeFile(root, params.path);
149
153
  const client = new LspClient(getServerCommand(), root, getTimeoutMs());
150
154
  const abort = () => client.close();
151
155
  signal?.addEventListener("abort", abort, { once: true });
156
+ ctx.ui.setStatus(STATUS_KEY, "biome-lsp: format");
152
157
 
153
158
  try {
154
159
  await client.start();
@@ -171,6 +176,7 @@ const biomeFormatTool = defineTool({
171
176
  text: params.write ? undefined : newText,
172
177
  });
173
178
  } finally {
179
+ ctx.ui.setStatus(STATUS_KEY, undefined);
174
180
  signal?.removeEventListener("abort", abort);
175
181
  await client.shutdown();
176
182
  }
@@ -197,13 +203,14 @@ const biomeFixTool = defineTool({
197
203
  Type.Boolean({ description: "Write fixed text back to the file. Defaults to false." }),
198
204
  ),
199
205
  }),
200
- async execute(_toolCallId, params, signal) {
206
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
201
207
  const root = resolveRoot(params.root);
202
208
  const file = resolveBiomeFile(root, params.path);
203
209
  const actionKind = params.kind?.trim() || "source.fixAll.biome";
204
210
  const client = new LspClient(getServerCommand(), root, getTimeoutMs());
205
211
  const abort = () => client.close();
206
212
  signal?.addEventListener("abort", abort, { once: true });
213
+ ctx.ui.setStatus(STATUS_KEY, "biome-lsp: fix");
207
214
 
208
215
  try {
209
216
  await client.start();
@@ -231,6 +238,7 @@ const biomeFixTool = defineTool({
231
238
  text: params.write ? undefined : newText,
232
239
  });
233
240
  } finally {
241
+ ctx.ui.setStatus(STATUS_KEY, undefined);
234
242
  signal?.removeEventListener("abort", abort);
235
243
  await client.shutdown();
236
244
  }
@@ -246,12 +254,11 @@ export default function biomeLsp(pi: ExtensionAPI) {
246
254
  description: "Show Biome LSP extension configuration",
247
255
  handler: async (_args, ctx) => {
248
256
  ctx.ui.notify(buildStatusMessage(), statusLevel());
249
- updateStatus(ctx);
250
257
  },
251
258
  });
252
259
 
253
260
  pi.on("session_start", (_event, ctx) => {
254
- updateStatus(ctx);
261
+ ctx.ui.setStatus(STATUS_KEY, undefined);
255
262
  });
256
263
 
257
264
  pi.on("session_shutdown", (_event, ctx) => {
@@ -262,6 +269,7 @@ export default function biomeLsp(pi: ExtensionAPI) {
262
269
  async function runDiagnostics(
263
270
  params: { root?: string; paths?: string[]; limit?: number },
264
271
  signal: AbortSignal | undefined,
272
+ ctx: StatusContext,
265
273
  ) {
266
274
  const root = resolveRoot(params.root);
267
275
  const files = collectBiomeFiles(root, params.paths, params.limit ?? DEFAULT_FILE_LIMIT);
@@ -272,6 +280,7 @@ async function runDiagnostics(
272
280
  const client = new LspClient(getServerCommand(), root, getTimeoutMs());
273
281
  const abort = () => client.close();
274
282
  signal?.addEventListener("abort", abort, { once: true });
283
+ ctx.ui.setStatus(STATUS_KEY, "biome-lsp: diagnostics");
275
284
 
276
285
  try {
277
286
  await client.start();
@@ -293,6 +302,7 @@ async function runDiagnostics(
293
302
  summary: summarize(entries),
294
303
  });
295
304
  } finally {
305
+ ctx.ui.setStatus(STATUS_KEY, undefined);
296
306
  signal?.removeEventListener("abort", abort);
297
307
  await client.shutdown();
298
308
  }
@@ -313,13 +323,6 @@ function getTimeoutMs() {
313
323
  return Number.isFinite(rawValue) && rawValue > 0 ? rawValue : DEFAULT_TIMEOUT_MS;
314
324
  }
315
325
 
316
- function updateStatus(ctx: {
317
- ui: { setStatus: (key: string, value: string | undefined) => void };
318
- }) {
319
- const command = getServerCommand();
320
- ctx.ui.setStatus(STATUS_KEY, `biome-lsp: ${commandExists(command.command) ? "ready" : "missing"}`);
321
- }
322
-
323
326
  function buildStatusMessage() {
324
327
  const command = getServerCommand();
325
328
  return [