@hk_net/pi-usage-bars 0.4.5 → 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 CHANGED
@@ -2,6 +2,35 @@
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
+
15
+ ## [0.5.0] - 2026-08-22
16
+
17
+ ### Added
18
+
19
+ - Added a `--usage` extension flag that prints one JSON line for the active provider and exits, providing a non-interactive Pi loader, credential, and endpoint smoke test.
20
+
21
+ ### Changed
22
+
23
+ - Raised the minimum supported Pi version from 0.81.1 to 0.84.2; older Pi releases are no longer claimed or tested as compatible.
24
+ - Namespaced the footer status and inter-extension usage update event to avoid collisions with other Pi extensions. **Breaking for event consumers:** listeners using the previous undocumented `usage:update` event must switch to `@hk_net/pi-usage-bars:update`.
25
+ - Bounded the `/usage` provider viewport, expanded only the selected provider, and added the configured page-up/page-down navigation bindings for smaller terminals.
26
+ - Removed redundant active-model checks on every turn in favor of Pi's `session_start` and `model_select` lifecycle events.
27
+ - Cancelled an obsolete in-flight provider request immediately when the selected model provider changes, allowing the new provider to refresh without waiting for the old request timeout.
28
+ - Isolated and documented the current Pi OAuth source-label compatibility check. Pi 0.84.2 exposes `AuthResult.source` as a human-readable label but no public typed credential discriminator, so Claude subscription detection must currently recognize the `"OAuth"` label.
29
+
30
+ ### Tests
31
+
32
+ - Added lifecycle coverage for shutdown and replacement-session cancellation, repeated-start interval cleanup, `/usage` closure cancellation, model changes during active polling, and model-selection event wiring.
33
+
5
34
  ## [0.4.5] - 2026-08-22
6
35
 
7
36
  ### Changed
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,129 +1,145 @@
1
- # pi-usage-bars
2
-
3
- Quota, balance, and spend indicators for [Pi](https://github.com/earendil-works/pi).
4
-
5
- ![Codex footer bar](https://raw.githubusercontent.com/hknet/pi-usage-bars/main/assets/codex.png)
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
- 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.
29
-
30
- 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.
31
-
32
- 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.
33
-
34
- Google Gemini CLI and Google Antigravity are not supported because Pi removed those built-in providers in version 0.71.0.
35
-
36
- ## Requirements
37
-
38
- - Pi 0.81.1 or newer (tested with the current Pi 0.84.2 release)
39
- - Node.js 22.19 or newer when using the npm-distributed Pi CLI
40
-
41
- 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.
42
-
43
- ## Install
44
-
45
- Install the npm package:
46
-
47
- ```bash
48
- pi install npm:@hk_net/pi-usage-bars
49
- ```
50
-
51
- Or install the latest source directly from GitHub:
52
-
53
- ```bash
54
- pi install https://github.com/hknet/pi-usage-bars
55
- ```
56
-
57
- Restart Pi after installation, or use `/reload` when the package is already installed.
58
-
59
- Update an existing npm installation with:
60
-
61
- ```bash
62
- pi update npm:@hk_net/pi-usage-bars
63
- ```
64
-
65
- ## Use
66
-
67
- ### Footer usage bars
68
-
69
- 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.
70
-
71
- ![Claude footer bar](https://raw.githubusercontent.com/hknet/pi-usage-bars/main/assets/claude.png)
72
-
73
- Usage refresh runs in interactive TUI sessions every two minutes. It does not run in print, JSON, or RPC mode.
74
-
75
- ### `/usage`
76
-
77
- Run `/usage` to open a searchable list of configured supported providers.
78
-
79
- ![/usage command](https://raw.githubusercontent.com/hknet/pi-usage-bars/main/assets/usage-command.png)
80
-
81
- ## Endpoint configuration
82
-
83
- First-party monitoring endpoints can be overridden:
84
-
85
- | Variable | Default |
86
- | --- | --- |
87
- | `PI_ZAI_USAGE_ENDPOINT` | `https://api.z.ai/api/monitor/usage/quota/limit` |
88
- | `PI_ZAI_CODING_CN_USAGE_ENDPOINT` | `https://open.bigmodel.cn/api/monitor/usage/quota/limit` |
89
- | `PI_KIMI_USAGE_ENDPOINT` | `https://api.kimi.com/coding/v1/usages` |
90
- | `PI_MINIMAX_USAGE_ENDPOINT` | `https://api.minimax.io/v1/token_plan/remains` |
91
- | `PI_MINIMAX_LEGACY_USAGE_ENDPOINT` | `https://api.minimax.io/v1/api/openplatform/coding_plan/remains` |
92
- | `PI_MINIMAX_CN_USAGE_ENDPOINT` | `https://api.minimaxi.com/v1/token_plan/remains` |
93
- | `PI_MINIMAX_CN_LEGACY_USAGE_ENDPOINT` | `https://api.minimaxi.com/v1/api/openplatform/coding_plan/remains` |
94
- | `PI_OPENROUTER_CREDITS_ENDPOINT` | `https://openrouter.ai/api/v1/credits` |
95
- | `PI_OPENROUTER_KEY_ENDPOINT` | `https://openrouter.ai/api/v1/key` |
96
- | `PI_DEEPSEEK_BALANCE_ENDPOINT` | `https://api.deepseek.com/user/balance` |
97
- | `PI_MOONSHOT_BALANCE_ENDPOINT` | `https://api.moonshot.ai/v1/users/me/balance` |
98
- | `PI_MOONSHOT_CN_BALANCE_ENDPOINT` | `https://api.moonshot.cn/v1/users/me/balance` |
99
-
100
- **Security:** the corresponding provider token is sent as a bearer token to the configured endpoint. Only override these variables with an endpoint you trust.
101
-
102
- 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.
103
-
104
- ## Financial metrics roadmap
105
-
106
- 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.
107
-
108
- See [provider support research](docs/provider-research.md) for providers investigated but currently blocked by the absence of a suitable first-party usage API, including Qwen Token Plan and Baseten.
109
-
110
- ## Development
111
-
112
- Install Node.js 22.19+ and Bun 1.3, then run:
113
-
114
- ```bash
115
- npm install
116
- npm run check
117
- ```
118
-
119
- `npm run check` performs a strict TypeScript check and runs the Bun test suite.
120
-
121
- 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.
122
-
123
- ## Credits
124
-
125
- This extension is based on and inspired by:
126
-
127
- - [CodexBar](https://github.com/steipete/CodexBar)
128
- - [rho usage-bars](https://github.com/mikeyobrien/rho/tree/main/extensions/usage-bars)
129
- - [ajarellanod/pi-usage-bars](https://github.com/ajarellanod/pi-usage-bars)
1
+ # pi-usage-bars
2
+
3
+ Quota, balance, and spend indicators for [Pi](https://github.com/earendil-works/pi).
4
+
5
+ ![Codex footer bar](https://raw.githubusercontent.com/hknet/pi-usage-bars/main/assets/codex.png)
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
+ ![Claude footer bar](https://raw.githubusercontent.com/hknet/pi-usage-bars/main/assets/claude.png)
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 but currently blocked by the absence of a suitable first-party API. Recheck these findings when a provider publishes a new quota, balance, or billing API.
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:** Blocked — no account-usage surface found as of 2026-08-13.
25
+ **Status:** Supported as of 2026-08-28.
26
26
 
27
- Pi 0.84.0 added the `baseten` provider using `BASETEN_API_KEY`. Baseten is primarily usage-billed, and research found no documented API-key endpoint for account balance, credits, budget utilization, or billing usage that this extension could safely query.
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, credits, budget, or billing-usage API accessible with the inference credential or a documented monitoring credential.
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,84 +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
- 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.
26
-
27
- Preparation:
28
-
29
- 1. verifies that `main` is clean and synchronized with `origin/main`;
30
- 2. rejects an existing npm version or Git tag;
31
- 3. updates `package.json` and `package-lock.json` without creating an early tag;
32
- 4. promotes the `Unreleased` changelog entries into a dated release while preserving an empty `Unreleased` heading;
33
- 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
34
- 6. commits and pushes the release source.
35
-
36
- After reviewing the prepared commit, stage it for browser approval:
37
-
38
- ```bash
39
- scripts/release.sh X.Y.Z stage
40
- ```
41
-
42
- `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.
43
-
44
- 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:
45
-
46
- ```bash
47
- scripts/release.sh X.Y.Z finalize
48
- ```
49
-
50
- `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.
51
-
52
- Use `--yes` only for attended preparation:
53
-
54
- ```bash
55
- scripts/release.sh X.Y.Z --yes # prepare only
56
- ```
57
-
58
- ## Recovery
59
-
60
- 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.
61
-
62
- 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.
63
-
64
- Show script help with:
65
-
66
- ```bash
67
- scripts/release.sh --help
68
- ```
69
-
70
- ## Post-release verification
71
-
72
- Confirm installation through Pi:
73
-
74
- ```bash
75
- pi install npm:@hk_net/pi-usage-bars
76
- # If already installed from npm:
77
- pi update npm:@hk_net/pi-usage-bars
78
- ```
79
-
80
- Restart Pi, or use `/reload`, then run `/usage`.
81
-
82
- ## GitHub Actions alternative
83
-
84
- 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.