@hk_net/pi-usage-bars 0.5.0 → 0.6.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 +10 -0
- package/LICENSE +21 -21
- package/README.md +145 -139
- package/docs/provider-research.md +4 -4
- package/docs/releasing.md +104 -104
- package/extensions/usage-bars/core.ts +1341 -1274
- package/extensions/usage-bars/index.ts +781 -768
- package/package.json +75 -74
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## [0.6.0] - 2026-08-29
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added Baseten current calendar-month credits-used reporting through its documented key-authenticated billing usage API. Baseten has no documented remaining-credit or quota percentage in this API, so the extension renders only the reported usage.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Updated the development and test baseline to Pi SDK 0.84.4.
|
|
14
|
+
|
|
5
15
|
## [0.5.0] - 2026-08-22
|
|
6
16
|
|
|
7
17
|
### Added
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 ajarellanod and hknet
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ajarellanod and hknet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,139 +1,145 @@
|
|
|
1
|
-
# pi-usage-bars
|
|
2
|
-
|
|
3
|
-
Quota, balance, and spend indicators for [Pi](https://github.com/earendil-works/pi).
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
It adds:
|
|
8
|
-
|
|
9
|
-
- a footer status bar for the active supported provider
|
|
10
|
-
- a `/usage` command showing configured quota, balance, and spend data
|
|
11
|
-
|
|
12
|
-
## Supported providers
|
|
13
|
-
|
|
14
|
-
| Provider | Pi provider ID | Authentication |
|
|
15
|
-
| --- | --- | --- |
|
|
16
|
-
| OpenAI Codex | `openai-codex` | ChatGPT subscription OAuth |
|
|
17
|
-
| Anthropic Claude | `anthropic` | Claude Pro/Max OAuth |
|
|
18
|
-
| ZAI Coding Plan (Global) | `zai` | ZAI API key |
|
|
19
|
-
| ZAI Coding Plan (China) | `zai-coding-cn` | ZAI China API key |
|
|
20
|
-
| Kimi For Coding | `kimi-coding` | Kimi Coding Plan OAuth or API key |
|
|
21
|
-
| MiniMax Coding Plan (Global) | `minimax` | MiniMax Global API key |
|
|
22
|
-
| MiniMax Coding Plan (China) | `minimax-cn` | MiniMax China API key |
|
|
23
|
-
| OpenRouter | `openrouter` | OpenRouter API key |
|
|
24
|
-
| DeepSeek | `deepseek` | DeepSeek API key |
|
|
25
|
-
| Moonshot/Kimi API (Global) | `moonshotai` | Moonshot Global API key |
|
|
26
|
-
| Moonshot/Kimi API (China) | `moonshotai-cn` | Moonshot China API key |
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
1
|
+
# pi-usage-bars
|
|
2
|
+
|
|
3
|
+
Quota, balance, and spend indicators for [Pi](https://github.com/earendil-works/pi).
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
It adds:
|
|
8
|
+
|
|
9
|
+
- a footer status bar for the active supported provider
|
|
10
|
+
- a `/usage` command showing configured quota, balance, and spend data
|
|
11
|
+
|
|
12
|
+
## Supported providers
|
|
13
|
+
|
|
14
|
+
| Provider | Pi provider ID | Authentication |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| OpenAI Codex | `openai-codex` | ChatGPT subscription OAuth |
|
|
17
|
+
| Anthropic Claude | `anthropic` | Claude Pro/Max OAuth |
|
|
18
|
+
| ZAI Coding Plan (Global) | `zai` | ZAI API key |
|
|
19
|
+
| ZAI Coding Plan (China) | `zai-coding-cn` | ZAI China API key |
|
|
20
|
+
| Kimi For Coding | `kimi-coding` | Kimi Coding Plan OAuth or API key |
|
|
21
|
+
| MiniMax Coding Plan (Global) | `minimax` | MiniMax Global API key |
|
|
22
|
+
| MiniMax Coding Plan (China) | `minimax-cn` | MiniMax China API key |
|
|
23
|
+
| OpenRouter | `openrouter` | OpenRouter API key |
|
|
24
|
+
| DeepSeek | `deepseek` | DeepSeek API key |
|
|
25
|
+
| Moonshot/Kimi API (Global) | `moonshotai` | Moonshot Global API key |
|
|
26
|
+
| Moonshot/Kimi API (China) | `moonshotai-cn` | Moonshot China API key |
|
|
27
|
+
| Baseten | `baseten` | Baseten API key |
|
|
28
|
+
|
|
29
|
+
DeepSeek shows total, topped-up, and granted balances in the currency returned by the API. Moonshot shows available, cash, and voucher balances; this is separate from the Kimi For Coding subscription provider. Pi uses `MOONSHOT_API_KEY` for both Moonshot regions, so `/usage` automatically hides the expected authentication failure from the region where a shared environment key is not valid.
|
|
30
|
+
|
|
31
|
+
OpenRouter shows the account credit balance and current daily, weekly, and monthly key spend. If the API key has a configured credit limit, that limit is also rendered as a usage bar. Baseten shows current calendar-month credits used, aggregated across its documented dedicated, training, and Model APIs billing categories; it does not invent a remaining-balance or quota percentage.
|
|
32
|
+
|
|
33
|
+
MiniMax Subscription Keys can represent an active Token Plan, purchased Credits, or both. The extension shows quota windows when present and a neutral credit-balance line if a first-party key-authenticated response exposes `points_balance`/`credits_balance`. MiniMax currently exposes Credits-only balances through a console endpoint requiring browser-cookie authentication, so a key-only Credits account is shown as “No active Token Plan” with a direction to check the console rather than a fabricated percentage. The extension does not import browser cookies.
|
|
34
|
+
|
|
35
|
+
Google Gemini CLI and Google Antigravity are not supported because Pi removed those built-in providers in version 0.71.0.
|
|
36
|
+
|
|
37
|
+
## Requirements
|
|
38
|
+
|
|
39
|
+
- Pi 0.84.2 or newer (tested with the current Pi 0.84.4 release)
|
|
40
|
+
- Node.js 22.19 or newer when using the npm-distributed Pi CLI
|
|
41
|
+
|
|
42
|
+
Authenticate providers through Pi's `/login` command. The extension resolves credentials through Pi's provider API; it does not read or write `auth.json` itself.
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
Install the npm package:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pi install npm:@hk_net/pi-usage-bars
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or install the latest source directly from GitHub:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pi install https://github.com/hknet/pi-usage-bars
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Restart Pi after installation, or use `/reload` when the package is already installed.
|
|
59
|
+
|
|
60
|
+
Update an existing npm installation with:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pi update npm:@hk_net/pi-usage-bars
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Use
|
|
67
|
+
|
|
68
|
+
### Footer usage bars
|
|
69
|
+
|
|
70
|
+
When the active model belongs to a configured supported provider, the footer shows its available quota windows with reset countdowns when provided by the service.
|
|
71
|
+
|
|
72
|
+

|
|
73
|
+
|
|
74
|
+
Usage refresh runs in interactive TUI sessions every two minutes. It does not run in print, JSON, or RPC mode.
|
|
75
|
+
|
|
76
|
+
### `/usage`
|
|
77
|
+
|
|
78
|
+
Run `/usage` to open a searchable list of configured supported providers. The selected provider's details are expanded; use the configured selection and page-navigation keybindings to browse the bounded list.
|
|
79
|
+
|
|
80
|
+
![/usage command]
|
|
81
|
+
|
|
82
|
+
### `--usage`
|
|
83
|
+
|
|
84
|
+
Pass `--usage` to print one JSON line for the active model provider and exit without opening the usage UI. This is also useful as a loader and credential smoke test:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
pi --no-extensions -e C:\hk\code\pi-usage-bars\extensions\usage-bars\index.ts --usage
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The result has `status` set to `ok`, `unconfigured`, `unsupported`, or `error`. No credential is included in the output.(https://raw.githubusercontent.com/hknet/pi-usage-bars/main/assets/usage-command.png)
|
|
91
|
+
|
|
92
|
+
## Endpoint configuration
|
|
93
|
+
|
|
94
|
+
First-party monitoring endpoints can be overridden:
|
|
95
|
+
|
|
96
|
+
| Variable | Default |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `PI_ZAI_USAGE_ENDPOINT` | `https://api.z.ai/api/monitor/usage/quota/limit` |
|
|
99
|
+
| `PI_ZAI_CODING_CN_USAGE_ENDPOINT` | `https://open.bigmodel.cn/api/monitor/usage/quota/limit` |
|
|
100
|
+
| `PI_KIMI_USAGE_ENDPOINT` | `https://api.kimi.com/coding/v1/usages` |
|
|
101
|
+
| `PI_MINIMAX_USAGE_ENDPOINT` | `https://api.minimax.io/v1/token_plan/remains` |
|
|
102
|
+
| `PI_MINIMAX_LEGACY_USAGE_ENDPOINT` | `https://api.minimax.io/v1/api/openplatform/coding_plan/remains` |
|
|
103
|
+
| `PI_MINIMAX_CN_USAGE_ENDPOINT` | `https://api.minimaxi.com/v1/token_plan/remains` |
|
|
104
|
+
| `PI_MINIMAX_CN_LEGACY_USAGE_ENDPOINT` | `https://api.minimaxi.com/v1/api/openplatform/coding_plan/remains` |
|
|
105
|
+
| `PI_OPENROUTER_CREDITS_ENDPOINT` | `https://openrouter.ai/api/v1/credits` |
|
|
106
|
+
| `PI_OPENROUTER_KEY_ENDPOINT` | `https://openrouter.ai/api/v1/key` |
|
|
107
|
+
| `PI_DEEPSEEK_BALANCE_ENDPOINT` | `https://api.deepseek.com/user/balance` |
|
|
108
|
+
| `PI_MOONSHOT_BALANCE_ENDPOINT` | `https://api.moonshot.ai/v1/users/me/balance` |
|
|
109
|
+
| `PI_MOONSHOT_CN_BALANCE_ENDPOINT` | `https://api.moonshot.cn/v1/users/me/balance` |
|
|
110
|
+
| `PI_BASETEN_USAGE_ENDPOINT` | `https://api.baseten.co/v1/billing/usage_summary` |
|
|
111
|
+
|
|
112
|
+
**Security:** the corresponding provider token is sent as a bearer token to the configured endpoint. Only override these variables with an endpoint you trust.
|
|
113
|
+
|
|
114
|
+
The Codex and Claude usage endpoints are fixed to their first-party services. Claude responses are cached briefly in the system temporary directory to coordinate multiple Pi processes and reduce rate limiting. The cache contains usage values, not credentials.
|
|
115
|
+
|
|
116
|
+
## Financial metrics roadmap
|
|
117
|
+
|
|
118
|
+
Quota percentages and monetary account data have different meaning and color semantics. OpenRouter, DeepSeek, Moonshot, and MiniMax financial data are rendered as neutral account values; percentages are used only when an actual limit exists.
|
|
119
|
+
|
|
120
|
+
### Future: Qwen Token Plan
|
|
121
|
+
|
|
122
|
+
Qwen Token Plan Individual has a documented seven-day Credits quota, but Qwen currently directs users to console usage details and prohibits API-key automation. Add Qwen support only when Qwen documents and authorizes a key-authenticated usage endpoint compatible with Pi's resolved `sk-sp-…` credential. Do not use browser cookies or console-session tokens. The endpoint must expose used Credits, quota limit, reset time, and any separate Credit Pack balance; validate it with redacted fixtures before implementation.
|
|
123
|
+
|
|
124
|
+
See [provider support research](docs/provider-research.md) for the supporting Qwen investigation.
|
|
125
|
+
|
|
126
|
+
## Development
|
|
127
|
+
|
|
128
|
+
Install Node.js 22.19+ and Bun 1.3, then run:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npm install
|
|
132
|
+
npm run check
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`npm run check` performs a strict TypeScript check and runs the Bun test suite.
|
|
136
|
+
|
|
137
|
+
Maintainers should follow the complete [release and npm publication guide](docs/releasing.md): prepare the release, stage it for npm browser approval, then finalize it after 2FA approval. Pushing a Git tag does not publish automatically.
|
|
138
|
+
|
|
139
|
+
## Credits
|
|
140
|
+
|
|
141
|
+
This extension is based on and inspired by:
|
|
142
|
+
|
|
143
|
+
- [CodexBar](https://github.com/steipete/CodexBar)
|
|
144
|
+
- [rho usage-bars](https://github.com/mikeyobrien/rho/tree/main/extensions/usage-bars)
|
|
145
|
+
- [ajarellanod/pi-usage-bars](https://github.com/ajarellanod/pi-usage-bars)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Provider support research
|
|
2
2
|
|
|
3
|
-
This document records providers considered for usage-bar support
|
|
3
|
+
This document records providers considered for usage-bar support. Recheck blocked findings when a provider publishes a new quota, balance, or billing API.
|
|
4
4
|
|
|
5
5
|
## Qwen Token Plan
|
|
6
6
|
|
|
@@ -22,11 +22,11 @@ Do not estimate account-wide quota from requests observed by this extension: oth
|
|
|
22
22
|
|
|
23
23
|
## Baseten
|
|
24
24
|
|
|
25
|
-
**Status:**
|
|
25
|
+
**Status:** Supported as of 2026-08-28.
|
|
26
26
|
|
|
27
|
-
Pi
|
|
27
|
+
Pi's `baseten` provider resolves `BASETEN_API_KEY`. Baseten documents `GET https://api.baseten.co/v1/billing/usage_summary`, authenticated with `Authorization: Bearer $BASETEN_API_KEY`, with required UTC `start_date` and `end_date` parameters (maximum range: 31 days). The response reports `credits_used` for dedicated serving, training, and Model APIs. The extension queries the current UTC calendar month and reports the aggregate Credits used; it intentionally does not manufacture a remaining balance or quota percentage.
|
|
28
28
|
|
|
29
|
-
**Recheck when:** Baseten publishes a first-party balance,
|
|
29
|
+
**Recheck when:** Baseten publishes a first-party balance, budget, or quota API that permits a more complete account indicator.
|
|
30
30
|
|
|
31
31
|
## Acceptance criteria for a new provider
|
|
32
32
|
|
package/docs/releasing.md
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
# Releasing
|
|
2
|
-
|
|
3
|
-
This repository uses semantic versions. The package version, changelog heading, Git tag, and npm version must agree.
|
|
4
|
-
|
|
5
|
-
Local releases use npm staged publishing followed by browser 2FA approval. Browser login only authenticates the CLI; it does not publish or approve a staged package. The GitHub Actions publish workflow is manual-only; pushing a tag does not publish the package.
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
- Write access to `hknet/pi-usage-bars`.
|
|
10
|
-
- Publish access to the npm scope `@hk_net`.
|
|
11
|
-
- Node.js 22.19 or newer.
|
|
12
|
-
- A clean, synchronized `main` branch.
|
|
13
|
-
|
|
14
|
-
Never place an npm token in the repository, command history, or endpoint configuration. Complete npm's browser or OTP authorization when prompted.
|
|
15
|
-
|
|
16
|
-
## Recommended release script
|
|
17
|
-
|
|
18
|
-
From the repository root, provide the exact new semantic version:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
cd /path/to/pi-usage-bars
|
|
22
|
-
scripts/release.sh X.Y.Z
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
From Windows PowerShell, run the Bash workflow through WSL (replace the WSL path with your checkout):
|
|
26
|
-
|
|
27
|
-
```powershell
|
|
28
|
-
wsl bash -lc 'cd /mnt/c/path/to/pi-usage-bars && ./scripts/release.sh X.Y.Z'
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
The repository's `.gitattributes` keeps shell scripts on LF endings so they remain executable in WSL even when Git for Windows uses `core.autocrlf=true`.
|
|
32
|
-
|
|
33
|
-
This **default command only prepares the release**. It deliberately stops before npm login or publication, so the pushed release commit can be reviewed first. The launcher first executes an immutable temporary copy of itself, so editing the script while a release is running cannot corrupt that run.
|
|
34
|
-
|
|
35
|
-
Preparation:
|
|
36
|
-
|
|
37
|
-
1. verifies that `main` is clean and synchronized with `origin/main`;
|
|
38
|
-
2. rejects an existing npm version or Git tag;
|
|
39
|
-
3. updates `package.json` and `package-lock.json` without creating an early tag;
|
|
40
|
-
4. promotes the `Unreleased` changelog entries into a dated release while preserving an empty `Unreleased` heading;
|
|
41
|
-
5. installs dependencies with `npm ci --no-audit`, provisions a temporary pinned Bun binary, and runs typecheck, tests, detailed dependency audits, and package dry-run; and
|
|
42
|
-
6. commits and pushes the release source.
|
|
43
|
-
|
|
44
|
-
After reviewing the prepared commit, stage it for browser approval:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
scripts/release.sh X.Y.Z stage
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
From Windows PowerShell:
|
|
51
|
-
|
|
52
|
-
```powershell
|
|
53
|
-
wsl bash -lc 'cd /mnt/c/path/to/pi-usage-bars && ./scripts/release.sh X.Y.Z stage'
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
`stage` submits the package to npm's staged-publishing queue. It **does not publish live**, does not open a browser, and does not tag Git. If npm authentication is needed, run `npm login --auth-type=web` manually first; this only authenticates the CLI.
|
|
57
|
-
|
|
58
|
-
In [npmjs.com](https://www.npmjs.com), open **Staged Packages**, review the staged tarball, and click **Approve**. npm prompts for 2FA during approval. After npm shows the version as live, finalize the release:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
scripts/release.sh X.Y.Z finalize
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
From Windows PowerShell:
|
|
65
|
-
|
|
66
|
-
```powershell
|
|
67
|
-
wsl bash -lc 'cd /mnt/c/path/to/pi-usage-bars && ./scripts/release.sh X.Y.Z finalize'
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
`finalize` refuses to run until the exact version is live in the npm registry. It then verifies registry metadata and creates/pushes the annotated Git tag. It never stages or publishes a package.
|
|
71
|
-
|
|
72
|
-
Use `--yes` only for attended preparation:
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
scripts/release.sh X.Y.Z --yes # prepare only
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Recovery
|
|
79
|
-
|
|
80
|
-
Staging and finalization are safe to rerun: `stage` refuses if the exact version is already live, and `finalize` refuses until it is live. Never force-push a release tag.
|
|
81
|
-
|
|
82
|
-
The release script first prints a full dependency audit with package names, dependency paths, affected ranges, and available fixes. This is informational because it includes development-only dependencies. It then runs a blocking production-only audit, which rejects high or critical production findings.
|
|
83
|
-
|
|
84
|
-
Show script help with:
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
scripts/release.sh --help
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Post-release verification
|
|
91
|
-
|
|
92
|
-
Confirm installation through Pi:
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
pi install npm:@hk_net/pi-usage-bars
|
|
96
|
-
# If already installed from npm:
|
|
97
|
-
pi update npm:@hk_net/pi-usage-bars
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Restart Pi, or use `/reload`, then run `/usage`.
|
|
101
|
-
|
|
102
|
-
## GitHub Actions alternative
|
|
103
|
-
|
|
104
|
-
The **Publish to npm (manual)** workflow is available as an alternative. It requires the `NPM_TOKEN` repository secret and publishes with npm provenance. Do not run it after publishing the same version locally.
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
This repository uses semantic versions. The package version, changelog heading, Git tag, and npm version must agree.
|
|
4
|
+
|
|
5
|
+
Local releases use npm staged publishing followed by browser 2FA approval. Browser login only authenticates the CLI; it does not publish or approve a staged package. The GitHub Actions publish workflow is manual-only; pushing a tag does not publish the package.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Write access to `hknet/pi-usage-bars`.
|
|
10
|
+
- Publish access to the npm scope `@hk_net`.
|
|
11
|
+
- Node.js 22.19 or newer.
|
|
12
|
+
- A clean, synchronized `main` branch.
|
|
13
|
+
|
|
14
|
+
Never place an npm token in the repository, command history, or endpoint configuration. Complete npm's browser or OTP authorization when prompted.
|
|
15
|
+
|
|
16
|
+
## Recommended release script
|
|
17
|
+
|
|
18
|
+
From the repository root, provide the exact new semantic version:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd /path/to/pi-usage-bars
|
|
22
|
+
scripts/release.sh X.Y.Z
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
From Windows PowerShell, run the Bash workflow through WSL (replace the WSL path with your checkout):
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
wsl bash -lc 'cd /mnt/c/path/to/pi-usage-bars && ./scripts/release.sh X.Y.Z'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The repository's `.gitattributes` keeps shell scripts on LF endings so they remain executable in WSL even when Git for Windows uses `core.autocrlf=true`.
|
|
32
|
+
|
|
33
|
+
This **default command only prepares the release**. It deliberately stops before npm login or publication, so the pushed release commit can be reviewed first. The launcher first executes an immutable temporary copy of itself, so editing the script while a release is running cannot corrupt that run.
|
|
34
|
+
|
|
35
|
+
Preparation:
|
|
36
|
+
|
|
37
|
+
1. verifies that `main` is clean and synchronized with `origin/main`;
|
|
38
|
+
2. rejects an existing npm version or Git tag;
|
|
39
|
+
3. updates `package.json` and `package-lock.json` without creating an early tag;
|
|
40
|
+
4. promotes the `Unreleased` changelog entries into a dated release while preserving an empty `Unreleased` heading;
|
|
41
|
+
5. installs dependencies with `npm ci --no-audit`, provisions a temporary pinned Bun binary, and runs typecheck, tests, detailed dependency audits, and package dry-run; and
|
|
42
|
+
6. commits and pushes the release source.
|
|
43
|
+
|
|
44
|
+
After reviewing the prepared commit, stage it for browser approval:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
scripts/release.sh X.Y.Z stage
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
From Windows PowerShell:
|
|
51
|
+
|
|
52
|
+
```powershell
|
|
53
|
+
wsl bash -lc 'cd /mnt/c/path/to/pi-usage-bars && ./scripts/release.sh X.Y.Z stage'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`stage` submits the package to npm's staged-publishing queue. It **does not publish live**, does not open a browser, and does not tag Git. If npm authentication is needed, run `npm login --auth-type=web` manually first; this only authenticates the CLI.
|
|
57
|
+
|
|
58
|
+
In [npmjs.com](https://www.npmjs.com), open **Staged Packages**, review the staged tarball, and click **Approve**. npm prompts for 2FA during approval. After npm shows the version as live, finalize the release:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
scripts/release.sh X.Y.Z finalize
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
From Windows PowerShell:
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
wsl bash -lc 'cd /mnt/c/path/to/pi-usage-bars && ./scripts/release.sh X.Y.Z finalize'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`finalize` refuses to run until the exact version is live in the npm registry. It then verifies registry metadata and creates/pushes the annotated Git tag. It never stages or publishes a package.
|
|
71
|
+
|
|
72
|
+
Use `--yes` only for attended preparation:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
scripts/release.sh X.Y.Z --yes # prepare only
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Recovery
|
|
79
|
+
|
|
80
|
+
Staging and finalization are safe to rerun: `stage` refuses if the exact version is already live, and `finalize` refuses until it is live. Never force-push a release tag.
|
|
81
|
+
|
|
82
|
+
The release script first prints a full dependency audit with package names, dependency paths, affected ranges, and available fixes. This is informational because it includes development-only dependencies. It then runs a blocking production-only audit, which rejects high or critical production findings.
|
|
83
|
+
|
|
84
|
+
Show script help with:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
scripts/release.sh --help
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Post-release verification
|
|
91
|
+
|
|
92
|
+
Confirm installation through Pi:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pi install npm:@hk_net/pi-usage-bars
|
|
96
|
+
# If already installed from npm:
|
|
97
|
+
pi update npm:@hk_net/pi-usage-bars
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Restart Pi, or use `/reload`, then run `/usage`.
|
|
101
|
+
|
|
102
|
+
## GitHub Actions alternative
|
|
103
|
+
|
|
104
|
+
The **Publish to npm (manual)** workflow is available as an alternative. It requires the `NPM_TOKEN` repository secret and publishes with npm provenance. Do not run it after publishing the same version locally.
|