@ravshansbox/pi-quota 0.8.0 → 0.9.0

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 (3) hide show
  1. package/README.md +3 -3
  2. package/index.ts +6 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,12 +12,12 @@ Add `-l` to install it in project settings.
12
12
 
13
13
  ## Usage
14
14
 
15
- Pi loads the extension from `./index.ts` and shows the remaining quota for the provider backing the active model above the editor.
15
+ Pi loads the extension from `./index.ts` and shows the remaining quota for the provider backing the active model in the footer.
16
16
 
17
17
  - Calls the Anthropic usage endpoint once on session start, then reads the Anthropic quota from the rate limit headers of each Anthropic response
18
18
  - Polls the OpenAI Codex usage endpoint on session start, then at every 10-minute wall-clock mark (`HH:00`, `HH:10`, `HH:20`, `HH:30`, `HH:40`, `HH:50`)
19
- - Shows a widget above the editor for the provider backing the **active model**, and only when quota data for that provider has been polled; switching models re-renders it immediately
20
- - The text stays compact, e.g. `93% 1h29m · 67% 3d13h`, where the 5-hour window comes first and the 7-day window second, and each window shows its remaining percentage followed by time until reset
19
+ - Shows a footer status for the provider backing the **active model**, and only when quota data for that provider has been polled; switching models re-renders it immediately
20
+ - The text stays compact, e.g. `93% 1h29m · 67% 4d`, where the 5-hour window comes first and the 7-day window second, and each window shows its remaining percentage followed by time until reset
21
21
  - Available resets, when present, are appended as `· 2x 5h` (count, then time until the soonest expires)
22
22
  - Both providers are checked on session start whenever their credentials exist, so quota is already known when the active model changes
23
23
  - Refreshes Anthropic and OpenAI Codex OAuth access tokens from `~/.pi/agent/auth.json` when needed, writes updated credentials back (re-reading the file first to avoid clobbering concurrent updates), and notifies on the first successful refresh per provider each session
package/index.ts CHANGED
@@ -6,7 +6,6 @@ import {
6
6
  type ExtensionAPI,
7
7
  type ExtensionContext,
8
8
  } from '@earendil-works/pi-coding-agent';
9
- import { Text } from '@earendil-works/pi-tui';
10
9
 
11
10
  interface QuotaConfig {
12
11
  codexResets?: { autoRedeem?: boolean };
@@ -107,8 +106,10 @@ function formatResetTime(reset: Date): string {
107
106
  const hours = Math.floor((diff % 86400000) / 3600000);
108
107
  const minutes = Math.floor((diff % 3600000) / 60000);
109
108
 
110
- if (days > 0) return `${days}d${hours}h`;
111
- if (hours > 0) return `${hours}h${minutes}m`;
109
+ if (days === 1) return `${days}d${hours}h`;
110
+ if (days > 1) return `${Math.round(diff / 86400000)}d`;
111
+ if (hours === 1) return `${hours}h${minutes}m`;
112
+ if (hours > 1) return `${Math.round(diff / 3600000)}h`;
112
113
  if (minutes > 0) return `${minutes}m`;
113
114
  return 'now';
114
115
  }
@@ -233,11 +234,9 @@ export default function (pi: ExtensionAPI) {
233
234
  if (!ctxRef) return;
234
235
 
235
236
  const text = buildStatusText();
236
- const line = text === undefined ? undefined : ctxRef.ui.theme.fg('muted', text);
237
+ const line = text === undefined ? undefined : ctxRef.ui.theme.fg('dim', text);
237
238
 
238
- ctxRef.ui.setWidget('pi-quota', line === undefined ? undefined : () => new Text(line, 0, 0), {
239
- placement: 'aboveEditor',
240
- });
239
+ ctxRef.ui.setStatus('pi-quota', line);
241
240
  }
242
241
 
243
242
  function windowResetDetected(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ravshansbox/pi-quota",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Anthropic and OpenAI Codex quota status extension for pi",
5
5
  "license": "MIT",
6
6
  "type": "module",