@marckrenn/pi-sub-bar 1.0.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/CHANGELOG.md +12 -0
- package/README.md +194 -0
- package/index.ts +655 -0
- package/package.json +36 -0
- package/src/core-settings.ts +25 -0
- package/src/dividers.ts +48 -0
- package/src/errors.ts +71 -0
- package/src/formatting.ts +824 -0
- package/src/paths.ts +14 -0
- package/src/providers/extras.ts +21 -0
- package/src/providers/metadata.ts +137 -0
- package/src/providers/settings.ts +328 -0
- package/src/providers/windows.ts +18 -0
- package/src/settings/display.ts +695 -0
- package/src/settings/menu.ts +163 -0
- package/src/settings/themes.ts +318 -0
- package/src/settings/ui.ts +1064 -0
- package/src/settings-types.ts +542 -0
- package/src/settings-ui.ts +5 -0
- package/src/settings.ts +159 -0
- package/src/share.ts +56 -0
- package/src/status.ts +84 -0
- package/src/storage.ts +61 -0
- package/src/types.ts +19 -0
- package/src/ui/settings-list.ts +304 -0
- package/src/usage/types.ts +5 -0
- package/src/utils.ts +42 -0
- package/test/all.test.ts +4 -0
- package/test/dividers.test.ts +34 -0
- package/test/formatting.test.ts +329 -0
- package/test/providers.test.ts +42 -0
- package/test/settings.test.ts +211 -0
- package/tsconfig.json +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @marckrenn/pi-sub-bar
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`9bedd80`](https://github.com/marckrenn/pi-sub/commit/9bedd80b0037b723e70f0376019fff59a617e7cb) Thanks [@marckrenn](https://github.com/marckrenn)! - Initial 1.0.0 release.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`9bedd80`](https://github.com/marckrenn/pi-sub/commit/9bedd80b0037b723e70f0376019fff59a617e7cb)]:
|
|
12
|
+
- @marckrenn/pi-sub-shared@1.0.0
|
package/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# sub-bar
|
|
2
|
+
|
|
3
|
+
Usage widget extension for [pi-coding-agent](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent).
|
|
4
|
+
|
|
5
|
+
Displays current provider usage in a widget below the editor. Fetching and caching are handled by `sub-core`.
|
|
6
|
+
|
|
7
|
+
### Impressions
|
|
8
|
+
|
|
9
|
+
https://github.com/user-attachments/assets/d61d82f6-afd0-45fc-82f3-69910543aa7a
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- Displays realtime usage quotas for multiple AI providers
|
|
20
|
+
- Auto-detects provider from current model (via sub-core)
|
|
21
|
+
- Shows rate limit windows with visual progress bars
|
|
22
|
+
- Status indicators from provider status pages
|
|
23
|
+
- Theme save/share/import and `sub-bar:import` preview flow
|
|
24
|
+
- Provider Shown selector to pin the displayed provider
|
|
25
|
+
- **Extensive settings UI** via `sub-bar:settings`
|
|
26
|
+
- Cycle through providers with `Ctrl+Alt+P`
|
|
27
|
+
|
|
28
|
+
### Supported Providers
|
|
29
|
+
|
|
30
|
+
| Provider | Usage Data | Status Page |
|
|
31
|
+
|----------|-----------|-------------|
|
|
32
|
+
| Anthropic (Claude) | 5h/7d windows, extra usage | ✅ |
|
|
33
|
+
| GitHub Copilot | Monthly quota, requests | ✅ |
|
|
34
|
+
| Google Gemini | Pro/Flash quotas | ✅ |
|
|
35
|
+
| Antigravity | Claude/Pro/Flash quotas | ✅ |
|
|
36
|
+
| OpenAI Codex | Primary/secondary windows | ✅ |
|
|
37
|
+
| AWS Kiro | Credits | - |
|
|
38
|
+
| z.ai | Tokens/monthly limits | - |
|
|
39
|
+
|
|
40
|
+
### Provider Feature Matrix
|
|
41
|
+
|
|
42
|
+
| Provider | Usage Windows | Extra Info | Status Indicator | Tested | Notes |
|
|
43
|
+
|----------|--------------|------------|------------------|--------|-------|
|
|
44
|
+
| Anthropic (Claude) | 5h, 7d, Extra | Extra usage label | ✅ | ✅ | Extra usage can show on/off state |
|
|
45
|
+
| GitHub Copilot | Month | Model multiplier + requests left | ✅ | ✅ | Requests left uses model multiplier |
|
|
46
|
+
| Google Gemini | Pro, Flash | - | ✅ | - | Quotas aggregated per model family |
|
|
47
|
+
| Antigravity | Claude, Pro, Flash | - | ✅ | - | Sandbox Cloud Code Assist quotas |
|
|
48
|
+
| OpenAI Codex | Primary, Secondary | - | ✅ | ✅ | Credits not yet supported (PRs welcome!) |
|
|
49
|
+
| AWS Kiro | Credits | - | - | - | - |
|
|
50
|
+
| z.ai | Tokens, Monthly | - | - | - | API quota limits |
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Install via the pi package manager (recommended). `sub-bar` depends on `sub-core` for data (it will not render without it):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pi install npm:@marckrenn/pi-sub-core
|
|
58
|
+
pi install npm:@marckrenn/pi-sub-bar
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use `-l` to install into project settings instead of global:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pi install -l npm:@marckrenn/pi-sub-core
|
|
65
|
+
pi install -l npm:@marckrenn/pi-sub-bar
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Manual install (local development):
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/marckrenn/pi-sub.git
|
|
72
|
+
|
|
73
|
+
ln -s /path/to/pi-sub/packages/sub-core ~/.pi/agent/extensions/sub-core
|
|
74
|
+
ln -s /path/to/pi-sub/packages/sub-bar ~/.pi/agent/extensions/sub-bar
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Alternative (no symlink): add both to `~/.pi/agent/settings.json`:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"extensions": [
|
|
82
|
+
"/path/to/pi-sub/packages/sub-core/index.ts",
|
|
83
|
+
"/path/to/pi-sub/packages/sub-bar/index.ts"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
The extension loads automatically. Use:
|
|
91
|
+
|
|
92
|
+
- `sub-bar:settings` - Open display + provider UI settings (includes Provider Shown)
|
|
93
|
+
- `sub-bar:import <share string>` - Preview a shared theme and choose to save/apply
|
|
94
|
+
- `sub-core:settings` - Configure provider enablement/order + usage/status refresh settings
|
|
95
|
+
- `Ctrl+Alt+P` - Cycle through available providers
|
|
96
|
+
- `Ctrl+Alt+R` - Toggle reset timer format (relative vs datetime)
|
|
97
|
+
|
|
98
|
+
**Caching:**
|
|
99
|
+
- Handled by sub-core at `cache.json` next to the sub-core extension entry
|
|
100
|
+
- Cache TTL matches your auto-refresh interval setting
|
|
101
|
+
- Lock file prevents race conditions between multiple pi windows
|
|
102
|
+
|
|
103
|
+
## Communication with sub-core
|
|
104
|
+
|
|
105
|
+
`sub-bar` is a display client. It listens for `sub-core:update-current`/`sub-core:ready` events and renders the widget. On startup it requests the current state via `sub-core:request`.
|
|
106
|
+
|
|
107
|
+
`sub-bar` manages display settings and UI-only provider options (window visibility, labels, status indicator). Provider enablement lives in sub-core, but the sub-bar settings UI can toggle Enabled (auto/on/off) and forwards changes to `sub-core:settings:patch`. Ordering and refresh behavior are configured in `sub-core:settings`, and sub-core broadcasts updates that sub-bar consumes. The cycle command forwards to `sub-core:action` so core updates provider selection and then broadcasts the new state.
|
|
108
|
+
|
|
109
|
+
## Settings
|
|
110
|
+
|
|
111
|
+
Display and provider UI settings are persisted next to the extension entry (`settings.json` in the same folder as `index.ts`). Core settings are managed by sub-core, and the sub-bar settings menu includes a shortcut that points you to `sub-core:settings` for additional options.
|
|
112
|
+
|
|
113
|
+
**Settings migrations:** settings are merged with defaults on load, but renames/removals are not migrated automatically. When adding new settings or changing schema, update the defaults/merge logic and provide a migration (or instruct users to reset `settings.json`).
|
|
114
|
+
|
|
115
|
+
### Provider UI Settings
|
|
116
|
+
|
|
117
|
+
Use `sub-bar:settings` → Provider Settings to control enabled state (auto/on/off), status indicators, and per-provider window visibility.
|
|
118
|
+
|
|
119
|
+
### Core Settings
|
|
120
|
+
|
|
121
|
+
Use `sub-core:settings` to configure provider enablement (auto/on/off), fetch status, usage refresh settings, status refresh settings, and provider order.
|
|
122
|
+
|
|
123
|
+
### Display Settings
|
|
124
|
+
|
|
125
|
+
Use Display Settings → Theme to save, load, import, and randomize display themes.
|
|
126
|
+
|
|
127
|
+
Display Settings cover layout, bars, labels/text, reset timers, status indicators, dividers, and color tuning. Open `sub-bar:settings` → Display Settings to explore the full list in the UI.
|
|
128
|
+
|
|
129
|
+
## Credentials
|
|
130
|
+
|
|
131
|
+
Credentials are loaded by sub-core from:
|
|
132
|
+
|
|
133
|
+
- `~/.pi/agent/auth.json` - pi's auth file
|
|
134
|
+
- Provider-specific locations (e.g., `~/.codex/auth.json`, `~/.gemini/oauth_creds.json`)
|
|
135
|
+
- macOS Keychain for Claude Code credentials
|
|
136
|
+
- Environment variables (e.g., `Z_AI_API_KEY`)
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
### Packaging notes (pi install compatibility)
|
|
141
|
+
|
|
142
|
+
Pi packages use a `pi` field in `package.json` plus the `pi-package` keyword for discoverability. This repo already declares `pi.extensions`, so you can install via:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pi install npm:@marckrenn/pi-sub-core
|
|
146
|
+
pi install npm:@marckrenn/pi-sub-bar
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Manual paths/symlinks still work for local development as documented above.
|
|
150
|
+
|
|
151
|
+
### Architecture
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
sub-bar/
|
|
155
|
+
├── index.ts # Extension entry point (display client)
|
|
156
|
+
├── src/
|
|
157
|
+
│ ├── formatting.ts # UI formatting
|
|
158
|
+
│ ├── status.ts # Status indicator helpers
|
|
159
|
+
│ ├── utils.ts # Display helpers
|
|
160
|
+
│ ├── providers/ # Display metadata + visibility rules
|
|
161
|
+
│ ├── settings/ # Settings UI helpers
|
|
162
|
+
│ ├── settings-types.ts # Settings type definitions
|
|
163
|
+
│ ├── settings.ts # Settings persistence
|
|
164
|
+
│ └── usage/types.ts # Shared usage types
|
|
165
|
+
├── package.json
|
|
166
|
+
└── tsconfig.json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Adding a New Provider
|
|
170
|
+
|
|
171
|
+
Update both sub-core (fetch) and sub-bar (display). See `sub-core/README.md` for the full checklist.
|
|
172
|
+
|
|
173
|
+
### Feature placement (UI vs core)
|
|
174
|
+
|
|
175
|
+
- **sub-bar** owns presentation (formatting, layout, status indicators, UI settings).
|
|
176
|
+
- **sub-core** owns data fetching, caching, provider selection, and shared settings/events.
|
|
177
|
+
- Add shared types to **sub-shared** when both layers reference them.
|
|
178
|
+
|
|
179
|
+
See the root README “Developer guide” for the full decision checklist and examples.
|
|
180
|
+
|
|
181
|
+
### Commands
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm run check
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Credits
|
|
188
|
+
|
|
189
|
+
- Hannes Januschka ([barts](https://github.com/hjanuschka/shitty-extensions?tab=readme-ov-file#usage-barts), [@hjanuschka](https://x.com/hjanuschka))
|
|
190
|
+
- Peter Steinberger ([CodexBar](https://github.com/steipete/CodexBar), [@steipete](https://x.com/steipete))
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
MIT
|