@astrosheep/pi-quota 0.5.3 → 0.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/pi-quota",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/bar/quota.ts CHANGED
@@ -46,11 +46,9 @@ export function renderFooter(state: QuotaState, paint: Paint = plain, now = Date
46
46
  return renderBar([quotaElement(state, now)], paint);
47
47
  }
48
48
 
49
- const displayLabel: Record<string, string> = { deepseek: 'DeepSeek' };
50
-
51
49
  export function renderUsage(state: QuotaState, paint: Paint = plain, now = Date.now(), barWidth = 16): string[] {
52
50
  if (state.kind === 'hidden') return ['No quota adapter for the current provider.'];
53
- const title = displayLabel[state.provider] ?? state.label;
51
+ const title = state.label;
54
52
  const indent = (line: string) => line ? ` ${line}` : line;
55
53
  if (state.kind === 'loading') return [title, '', indent('Loading…')];
56
54
  if (state.kind === 'error') return [title, '', indent(errorText[state.code])];
package/src/extension.ts CHANGED
@@ -16,7 +16,8 @@ const STATUS_KEY = 'quota-bar';
16
16
  const USAGE_WIDGET = 'quota-bar:usage';
17
17
 
18
18
  export interface QuotaExtensionOptions {
19
- adapters?: readonly QuotaAdapter[]; // Extra adapters; duplicate IDs are rejected.
19
+ // Explicit adapters replace matching built-ins; duplicate explicit IDs are rejected.
20
+ adapters?: readonly QuotaAdapter[];
20
21
  providers?: readonly string[]; // Extra configured quota providers to include in /usage
21
22
  footer?: boolean; // false: query + /usage + structured events only
22
23
  intervalMs?: number;
@@ -25,8 +26,13 @@ export interface QuotaExtensionOptions {
25
26
 
26
27
  export function createQuotaExtension(options: QuotaExtensionOptions = {}) {
27
28
  return (pi: ExtensionAPI): void => {
28
- const registry = new AdapterRegistry([codexAdapter, kimiAdapter, openCodeGoAdapter,
29
- createDeepSeekAdapter('deepseek'), ...(options.adapters ?? [])]);
29
+ const explicitAdapters = options.adapters ?? [];
30
+ const explicitProviderIds = new Set(explicitAdapters.map(adapter => adapter.provider));
31
+ // Settings are deliberate user bindings, so they take precedence over defaults.
32
+ // AdapterRegistry still detects an ambiguous duplicate among explicit adapters.
33
+ const registry = new AdapterRegistry([
34
+ codexAdapter, kimiAdapter, openCodeGoAdapter, createDeepSeekAdapter('deepseek'),
35
+ ].filter(adapter => !explicitProviderIds.has(adapter.provider)).concat(explicitAdapters));
30
36
  let current: ExtensionContext | undefined;
31
37
  let selectedProvider: string | undefined;
32
38
  let timer: ReturnType<typeof setInterval> | undefined;
@@ -24,7 +24,7 @@ export function parseDeepSeekBalance(payload: unknown): AccountBalance {
24
24
 
25
25
  export function createDeepSeekAdapter(provider: string): QuotaAdapter {
26
26
  return {
27
- provider, label: provider,
27
+ provider, label: provider === 'deepseek' ? 'DeepSeek' : provider,
28
28
  async query(context) {
29
29
  const auth = await officialAuth(context, DEEPSEEK_ORIGIN);
30
30
  const payload = await context.getJson(`${DEEPSEEK_ORIGIN}/user/balance`,