@bacnh85/pi-sub 0.1.4 → 0.1.5

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 +4 -16
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -305,25 +305,10 @@ async function fetchCodexUsage(signal?: AbortSignal): Promise<SubscriptionUsageS
305
305
 
306
306
  async function fetchOpenCodeGoUsage(signal?: AbortSignal): Promise<SubscriptionUsageSnapshot> {
307
307
  try {
308
- const auth = await readOpenCodeGoAuth();
309
- const timeoutSignal = AbortSignal.timeout(7_000);
310
- const combinedSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
311
- const response = await fetch("https://opencode.ai/zen/go/v1/usage", {
312
- headers: {
313
- Accept: "application/json",
314
- Authorization: `Bearer ${auth.key}`,
315
- "User-Agent": "pi-sub/0.1.4",
316
- },
317
- signal: combinedSignal,
318
- });
319
- if (!response.ok) throw new Error(`usage request failed with HTTP ${response.status}`);
320
- const usage = parseOpcodeUsageResponse(await response.json());
308
+ await readOpenCodeGoAuth();
321
309
  const account: SubscriptionAccountSnapshot = {
322
310
  isActive: true,
323
311
  accountLabel: "OpenCode Go",
324
- plan: planLabel(usage?.plan_type),
325
- fiveHour: usageWindowFromApi(usage?.primary),
326
- weekly: usageWindowFromApi(usage?.secondary),
327
312
  lastActivity: "Now",
328
313
  };
329
314
  return {
@@ -427,9 +412,12 @@ function renderSubscriptionLine(ctx: ExtensionContext, state: State): void {
427
412
  const account = snapshot.activeAccount;
428
413
  const segments = windowSegments(account);
429
414
  const cost = snapshot.cost;
415
+ const hasWindows = segments.length > 0;
430
416
  if (cost !== undefined && cost > 0) segments.push(`$${cost.toFixed(2)}`);
431
417
  if (segments.length === 0) {
432
418
  line = `Sub ${state.adapter.displayName}`;
419
+ } else if (!hasWindows) {
420
+ line = `${state.adapter.displayName} ${segments.join(" ")}`;
433
421
  } else {
434
422
  line = segments.join(" ");
435
423
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bacnh85/pi-sub",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Pi extension showing subscription usage for supported model providers.",
5
5
  "type": "module",
6
6
  "license": "MIT",