@llblab/pi-codex-usage 0.5.0 → 0.5.2

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/AGENTS.md CHANGED
@@ -14,4 +14,4 @@
14
14
 
15
15
  - `Weekly reset countdown`: Append the weekly reset countdown only when the secondary window exposes a reset time.
16
16
  - Trigger: Changing reset-time normalization or statusline refresh cadence.
17
- - Action: Keep `d` labels rounded upward in 144-minute day-tenth steps, `h`/`m`/`s` labels floored, and hold `0s` until a successful quota refresh reports the next window.
17
+ - Action: Keep `d` labels rounded upward in 144-minute day-tenth steps above 24h, show 24h..1h labels in upward-rounded 6-minute hour-tenth steps, keep `m`/`s` labels floored, and hold `0s` until a successful quota refresh reports the next window.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.5.2: Sub-Day Reset Countdown And JPEG Banner
6
+
7
+ - Refined the weekly reset countdown below 24 hours to use upward-rounded 6-minute hour-tenth steps (`24h`, `23.7h`, `20.1h`, `20h`, `19.9h`, …, `1h`) instead of coarse whole-hour floors. Impact: the statusline gives more useful sub-day reset timing without growing wider than one decimal place.
8
+ - Replaced the package/banner artwork from PNG to JPEG and updated package metadata plus README image references. Impact: the package ships the new compressed banner asset consistently across npm and Pi extension listings.
9
+
10
+ ## 0.5.1: Non-Codex Bucket Hotfix
11
+
12
+ - Fixed non-Codex app-server quota buckets so Spark-only or unrelated limits are ignored instead of being displayed as Codex quota.
13
+
3
14
  ## 0.5.0: Weekly Reset Countdown
4
15
 
5
16
  - Added refresh request coalescing so repeated statusline events share one quota lookup instead of spawning parallel provider/fallback requests. Impact: transient failures and busy session-tree updates no longer amplify Codex usage polling work.
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  > Minimal zero-configuration Pi extension for showing primary ChatGPT Codex usage limits in the statusline
4
4
 
5
- ![Codex Usage](./banner.png)
5
+ ![Codex Usage](./banner.jpg)
6
6
 
7
- This repository is a minimal fork of [`narumiruna/pi-extensions/extensions/pi-codex-usage`](https://github.com/narumiruna/pi-extensions/tree/main/extensions/pi-codex-usage). It keeps the auth and quota-fetching path, but intentionally narrows the interface to the primary Codex 5-hour and weekly windows.
7
+ This repository is a minimal fork of [`narumiruna/pi-extensions/extensions/pi-codex-usage`](https://github.com/narumiruna/pi-extensions/tree/main/extensions/pi-codex-usage). It keeps the auth and quota-fetching path, but intentionally narrows the interface to the primary Codex 5-hour and weekly limits.
8
8
 
9
9
  ## Start Here
10
10
 
@@ -48,7 +48,7 @@ codex ██████▀▀▀▀ 6d
48
48
 
49
49
  The ten-character bar encodes two twenty-step limits at once: 40 total bits of quota state in 10 terminal cells. Each step is 5%: the top quadrants are the 5-hour limit, and the bottom quadrants are the weekly limit.
50
50
 
51
- When the weekly reset time is available, the bar is followed by a countdown. More than a day remains is shown in 144-minute day-tenth steps such as `7d`, `6.9d`, `6.6d`, `5.1d`, `5d`, `3.7d`, `3d`, `2d`, `1.9d`, `1.5d`, `1.1d`, and `1d`, rounded upward to the next tenth. Under a day it switches to floored hours, under an hour to floored minutes, and under a minute to seconds. After the reset timestamp passes, `0s` is held until the next successful quota refresh reports the new weekly window.
51
+ When the weekly reset time is available, the bar is followed by a countdown. More than a day remains is shown in 144-minute day-tenth steps such as `7d`, `6.9d`, `6.6d`, `5.1d`, `5d`, `3.7d`, `3d`, `2d`, `1.9d`, `1.5d`, and `1.1d`, rounded upward to the next tenth. At 24 hours and below it switches to upward-rounded 6-minute hour-tenth steps such as `24h`, `23.7h`, `20.1h`, `20h`, `19.9h`, `1.4h`, `1.3h`, `1.2h`, `1.1h`, and `1h`. Under an hour it switches to floored minutes, and under a minute to seconds. After the reset timestamp passes, `0s` is held until the next successful quota refresh reports the new weekly window.
52
52
 
53
53
  Unavailable because Codex auth or subscription quota is not available:
54
54
 
package/banner.jpg ADDED
Binary file
package/index.ts CHANGED
@@ -12,6 +12,7 @@ const DEFAULT_TIMEOUT_MS = 15_000;
12
12
  const SECOND_MS = 1000;
13
13
  const MINUTE_MS = 60 * SECOND_MS;
14
14
  const HOUR_MS = 60 * MINUTE_MS;
15
+ const HOUR_TENTH_MS = 6 * MINUTE_MS;
15
16
  const DAY_MS = 24 * HOUR_MS;
16
17
  const DAY_TENTH_MS = 144 * MINUTE_MS;
17
18
  const REFRESH_INTERVAL_MS = 30 * SECOND_MS;
@@ -819,11 +820,14 @@ export function formatResetCountdown(
819
820
  now = Date.now(),
820
821
  ): string {
821
822
  const remainingMs = Math.max(0, resetAt - now);
822
- if (remainingMs >= DAY_MS) {
823
+ if (remainingMs > DAY_MS) {
823
824
  const dayTenths = Math.max(10, Math.ceil(remainingMs / DAY_TENTH_MS));
824
825
  return `${formatTenths(dayTenths)}d`;
825
826
  }
826
- if (remainingMs >= HOUR_MS) return `${Math.floor(remainingMs / HOUR_MS)}h`;
827
+ if (remainingMs >= HOUR_MS) {
828
+ const hourTenths = Math.max(10, Math.ceil(remainingMs / HOUR_TENTH_MS));
829
+ return `${formatTenths(hourTenths)}h`;
830
+ }
827
831
  if (remainingMs >= MINUTE_MS)
828
832
  return `${Math.floor(remainingMs / MINUTE_MS)}m`;
829
833
  return `${Math.floor(remainingMs / SECOND_MS)}s`;
@@ -842,15 +846,14 @@ export function nextResetCountdownDelayForRemainingMs(
842
846
  remainingMs: number,
843
847
  ): number | undefined {
844
848
  if (remainingMs <= 0) return undefined;
845
- if (remainingMs >= DAY_MS) {
849
+ if (remainingMs > DAY_MS) {
846
850
  const dayTenths = Math.max(10, Math.ceil(remainingMs / DAY_TENTH_MS));
847
851
  return Math.max(1, remainingMs - (dayTenths - 1) * DAY_TENTH_MS);
848
852
  }
849
853
  if (remainingMs >= HOUR_MS) {
850
- return Math.max(
851
- 1,
852
- remainingMs - Math.floor(remainingMs / HOUR_MS) * HOUR_MS + 1,
853
- );
854
+ const hourTenths = Math.max(10, Math.ceil(remainingMs / HOUR_TENTH_MS));
855
+ if (hourTenths === 10) return Math.max(1, remainingMs - HOUR_MS + 1);
856
+ return Math.max(1, remainingMs - (hourTenths - 1) * HOUR_TENTH_MS);
854
857
  }
855
858
  if (remainingMs >= MINUTE_MS) {
856
859
  return Math.max(
@@ -925,7 +928,7 @@ function isUnavailableError(error: UsageQueryError): boolean {
925
928
  function selectPrimaryCodexSnapshot(
926
929
  report: CodexUsageReport,
927
930
  ): NormalizedRateLimitSnapshot | undefined {
928
- return report.snapshots.find(isPrimaryCodexSnapshot) ?? report.snapshots[0];
931
+ return report.snapshots.find(isPrimaryCodexSnapshot);
929
932
  }
930
933
 
931
934
  function normalizedUsageKey(value: string | undefined): string | undefined {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-codex-usage",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "private": false,
5
5
  "description": "Minimal Pi extension that shows primary Codex ChatGPT subscription usage limits.",
6
6
  "keywords": [
@@ -38,13 +38,13 @@
38
38
  "BACKLOG.md",
39
39
  "CHANGELOG.md",
40
40
  "LICENSE",
41
- "banner.png"
41
+ "banner.jpg"
42
42
  ],
43
43
  "pi": {
44
44
  "extensions": [
45
45
  "./index.ts"
46
46
  ],
47
- "image": "https://github.com/llblab/pi-codex-usage/raw/main/banner.png"
47
+ "image": "https://github.com/llblab/pi-codex-usage/raw/main/banner.jpg"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@earendil-works/pi-agent-core": "*",
package/banner.png DELETED
Binary file