@narumitw/pi-usage 0.28.0 → 0.34.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/README.md CHANGED
@@ -16,7 +16,6 @@
16
16
  - Keeps the compact statusline scoped to the current provider and runtime account.
17
17
  - Isolates its five-minute in-memory cache by provider and a process-salted credential fingerprint.
18
18
  - Resolves credentials through Pi and never reads Pi, account-extension, Codex CLI, or provider auth files.
19
- - Retains `/codex-status` as a temporary argument-free compatibility alias.
20
19
 
21
20
  ## 📦 Install
22
21
 
@@ -57,8 +56,6 @@ Close
57
56
 
58
57
  There are intentionally no `/usage --refresh`, `/usage <provider>`, or `/usage --all` argument paths. Cross-provider traffic requires an explicit interactive choice.
59
58
 
60
- `/codex-status` opens the same menu during the migration period. Its former flags are not supported by `pi-usage`.
61
-
62
59
  ## 📋 Provider semantics
63
60
 
64
61
  ### OpenAI Codex
@@ -102,12 +99,11 @@ pi remove npm:@narumitw/pi-codex-usage
102
99
  pi install npm:@narumitw/pi-usage
103
100
  ```
104
101
 
105
- Do not load both packages together: both register `/codex-status`, so Pi must suffix duplicate commands and the two packages can publish overlapping usage status.
102
+ Remove the deprecated package rather than loading both usage extensions together.
106
103
 
107
104
  Behavior changes:
108
105
 
109
- - Use `/usage` as the primary entry point.
110
- - `/codex-status` is an argument-free compatibility alias.
106
+ - Use `/usage` as the only entry point; `/codex-status` is no longer registered.
111
107
  - Refresh and cross-provider operations are menu actions rather than flags.
112
108
  - Codex CLI fallback is removed to preserve active-runtime-account correctness.
113
109
  - The status key changes from `codex-usage` to `usage`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-usage",
3
- "version": "0.28.0",
3
+ "version": "0.34.0",
4
4
  "description": "Pi extension that shows current-account usage across supported model providers.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,8 +33,8 @@
33
33
  "@earendil-works/pi-coding-agent": ">=0.81.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@biomejs/biome": "2.5.3",
37
- "@earendil-works/pi-coding-agent": "0.81.0",
36
+ "@biomejs/biome": "2.5.5",
37
+ "@earendil-works/pi-coding-agent": "0.82.1",
38
38
  "@types/node": "26.1.1",
39
39
  "typescript": "7.0.2"
40
40
  },
package/src/format.ts CHANGED
@@ -174,11 +174,13 @@ function normalizedModelKeys(model: UsageModel): Set<string> {
174
174
  }
175
175
 
176
176
  function normalizeKey(value: string | undefined): string | undefined {
177
- const normalized = value
178
- ?.toLowerCase()
179
- .replace(/[^a-z0-9]+/g, "-")
180
- .replace(/^-+|-+$/g, "");
181
- return normalized || undefined;
177
+ const separated = value?.toLowerCase().replace(/[^a-z0-9]+/g, "-");
178
+ if (!separated) return undefined;
179
+ let start = 0;
180
+ let end = separated.length;
181
+ while (separated[start] === "-") start += 1;
182
+ while (end > start && separated[end - 1] === "-") end -= 1;
183
+ return separated.slice(start, end) || undefined;
182
184
  }
183
185
 
184
186
  function normalizedKeyHasToken(key: string, token: string): boolean {
@@ -192,9 +194,9 @@ function normalizedKeyHasToken(key: string, token: string): boolean {
192
194
 
193
195
  function compactLimitLabel(label: string): string {
194
196
  const normalized = label.replace(/[_-]+/g, " ").trim();
195
- return (normalized.match(/\bcodex\s+(.+)$/i)?.[1]?.trim() || normalized)
196
- .toLowerCase()
197
- .replace(/\s+/g, " ");
197
+ const codex = /\bcodex\s/iu.exec(normalized);
198
+ const suffix = codex ? normalized.slice(codex.index + codex[0].length).trim() : "";
199
+ return (suffix || normalized).toLowerCase().replace(/\s+/g, " ");
198
200
  }
199
201
 
200
202
  function formatPercentBucket(bucket: UsageBucket): string {
package/src/index.ts CHANGED
@@ -11,7 +11,6 @@ export {
11
11
  export { formatProviderStates, formatUsageReport, formatUsageStatusline } from "./format.js";
12
12
  export { normalizeCodexBackendPayload } from "./providers/codex.js";
13
13
  export { normalizeOpenRouterKeyPayload } from "./providers/openrouter.js";
14
- export { default } from "./usage.js";
15
14
  export {
16
15
  adapterForProvider,
17
16
  isStaleExtensionContextError,
@@ -33,3 +32,4 @@ export type {
33
32
  UsageSemanticsKind,
34
33
  UsageUnit,
35
34
  } from "./types.js";
35
+ export { default } from "./usage.js";
package/src/usage.ts CHANGED
@@ -606,10 +606,6 @@ export default function usageExtension(pi: ExtensionAPI) {
606
606
  description: "Show usage for the current runtime account",
607
607
  handler: commandHandler,
608
608
  });
609
- pi.registerCommand("codex-status", {
610
- description: "Open /usage (temporary compatibility alias)",
611
- handler: commandHandler,
612
- });
613
609
 
614
610
  pi.on("session_start", (_event, ctx) => {
615
611
  sessionActive = true;