@llblab/pi-codex-usage 0.3.5 → 0.4.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.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +1 -0
- package/README.md +4 -4
- package/banner.png +0 -0
- package/index.ts +21 -8
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
- Trigger: Updating quota polling or error handling.
|
|
9
9
|
- Action: Do not collapse the bar while a request is in flight; only show `n/a` or `error` after repeated failures or no usable quota.
|
|
10
10
|
|
|
11
|
-
- `Compact dual bar`: Encode the 5-hour and weekly quota windows in the
|
|
11
|
+
- `Compact dual bar`: Encode the 5-hour and weekly quota windows in the ten-character separated-sextant bar.
|
|
12
12
|
- Trigger: Changing statusline formatting.
|
|
13
|
-
- Action: Keep a fixed-width `
|
|
13
|
+
- Action: Keep a fixed-width `xxxxxxxxxx` bar where top sextants represent the 5-hour window and bottom sextants represent the weekly window, with 20 steps per window.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
- `0.4.0` Expanded the dual statusline bar to ten glyphs with 20 steps per quota window, moved its status key near the start of the footer status order, and draws the bar on the themed selected background. Impact: 5-hour and weekly limits now move in 5% increments for 40 total discrete points while empty cells no longer blend into the terminal background.
|
|
3
4
|
- `0.3.5` Refined the compact statusline bar with quadrant glyphs, darker bar coloring, and blink-on-segment-change behavior. Impact: Codex quota changes are easier to notice while routine refreshes stay visually stable.
|
|
4
5
|
- `0.3.4` Added package banner metadata and README hero image. Impact: Pi/package listings can show the Codex Usage banner while npm packages include the image asset.
|
|
5
6
|
- `Fork baseline` Imported `extensions/pi-codex-usage` from `narumiruna/pi-extensions` as a standalone `@llblab/pi-codex-usage` package. Impact: the extension can be installed and maintained independently.
|
package/README.md
CHANGED
|
@@ -15,12 +15,12 @@ This repository is a minimal fork of [`narumiruna/pi-extensions/extensions/pi-co
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
17
17
|
- Shows an empty statusline bar immediately, then refreshes every 30 seconds while the active Pi model uses `openai-codex`
|
|
18
|
-
- Statusline output stays compact, with the `codex` label accented and the
|
|
18
|
+
- Statusline output stays compact, with the `codex` label accented and the quota bar drawn on a themed background
|
|
19
19
|
- Additional returned buckets, including Spark-specific limits, are ignored
|
|
20
20
|
- Pi OpenAI Codex provider auth is used first
|
|
21
21
|
- Codex CLI app-server remains available as a fallback
|
|
22
22
|
- Missing auth, subscription, plan, or quota windows are shown as `n/a`, not as an error
|
|
23
|
-
- Successful updates briefly redraw the bar only when a
|
|
23
|
+
- Successful updates briefly redraw the bar only when a 5% segment changes
|
|
24
24
|
- Network/provider failures keep the last good bar briefly, then show `error`
|
|
25
25
|
- No commands or configuration are required
|
|
26
26
|
|
|
@@ -43,10 +43,10 @@ pi install git:github.com/llblab/pi-codex-usage
|
|
|
43
43
|
Normal usage:
|
|
44
44
|
|
|
45
45
|
```text
|
|
46
|
-
codex
|
|
46
|
+
codex ██████▀▀▀▀
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
The
|
|
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
51
|
Unavailable because Codex auth or subscription quota is not available:
|
|
52
52
|
|
package/banner.png
CHANGED
|
Binary file
|
package/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ const CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
|
|
|
11
11
|
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
12
12
|
const REFRESH_INTERVAL_MS = 30 * 1000;
|
|
13
13
|
const REDRAW_BLINK_MS = 150;
|
|
14
|
-
const STATUS_KEY = "codex-usage";
|
|
14
|
+
const STATUS_KEY = "aa-codex-usage";
|
|
15
15
|
const MAX_ERROR_BODY_CHARS = 600;
|
|
16
16
|
const STATUS_LABEL_TEXT = "codex";
|
|
17
17
|
const DUAL_BAR_CHARS = [
|
|
@@ -688,7 +688,8 @@ export function formatCodexUsageStatusline(
|
|
|
688
688
|
ctx: ExtensionContext,
|
|
689
689
|
_model?: CodexUsageModel,
|
|
690
690
|
): string {
|
|
691
|
-
|
|
691
|
+
const bar = formatReportBar(report);
|
|
692
|
+
return bar ? formatStatuslineBarText(ctx, bar) : formatStatuslineText(ctx, "n/a");
|
|
692
693
|
}
|
|
693
694
|
|
|
694
695
|
function formatReportBar(report: CodexUsageReport): string | undefined {
|
|
@@ -702,8 +703,20 @@ function formatStatuslineText(ctx: ExtensionContext, value: string): string {
|
|
|
702
703
|
return `${label} ${ctx.ui.theme.fg("dim", value)}`;
|
|
703
704
|
}
|
|
704
705
|
|
|
706
|
+
function formatStatuslineBarText(ctx: ExtensionContext, bar: string): string {
|
|
707
|
+
const label = ctx.ui.theme.fg("accent", STATUS_LABEL_TEXT);
|
|
708
|
+
const value = ctx.ui.theme.bg(
|
|
709
|
+
"selectedBg",
|
|
710
|
+
ctx.ui.theme.fg("dim", bar),
|
|
711
|
+
);
|
|
712
|
+
return `${label} ${value}`;
|
|
713
|
+
}
|
|
714
|
+
|
|
705
715
|
function formatEmptyStatuslineBar(ctx: ExtensionContext): string {
|
|
706
|
-
return
|
|
716
|
+
return formatStatuslineBarText(
|
|
717
|
+
ctx,
|
|
718
|
+
"\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0",
|
|
719
|
+
);
|
|
707
720
|
}
|
|
708
721
|
|
|
709
722
|
function formatStatuslineProblem(
|
|
@@ -755,10 +768,10 @@ function formatDualLimitBar(
|
|
|
755
768
|
primary: NormalizedRateLimitWindow | undefined,
|
|
756
769
|
secondary: NormalizedRateLimitWindow | undefined,
|
|
757
770
|
): string {
|
|
758
|
-
const primaryParts =
|
|
759
|
-
const secondaryParts =
|
|
771
|
+
const primaryParts = filledTwentieths(primary);
|
|
772
|
+
const secondaryParts = filledTwentieths(secondary);
|
|
760
773
|
let value = "";
|
|
761
|
-
for (let index = 0; index <
|
|
774
|
+
for (let index = 0; index < 10; index++) {
|
|
762
775
|
const leftPart = index * 2 + 1;
|
|
763
776
|
const rightPart = leftPart + 1;
|
|
764
777
|
let mask = 0;
|
|
@@ -771,9 +784,9 @@ function formatDualLimitBar(
|
|
|
771
784
|
return value;
|
|
772
785
|
}
|
|
773
786
|
|
|
774
|
-
function
|
|
787
|
+
function filledTwentieths(window: NormalizedRateLimitWindow | undefined): number {
|
|
775
788
|
if (!window) return 0;
|
|
776
|
-
return Math.round(remainingPercent(window) /
|
|
789
|
+
return Math.round(remainingPercent(window) / 5);
|
|
777
790
|
}
|
|
778
791
|
|
|
779
792
|
function remainingPercent(window: NormalizedRateLimitWindow): number {
|