@aliou/pi-neuralwatt 0.17.0 → 0.18.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
@@ -75,10 +75,6 @@ https://github.com/user-attachments/assets/a8994940-c467-4744-a0f2-833cb63923ff
75
75
 
76
76
  When enabled, the extension notifies you when credits or energy are running low. When you have an active subscription, only energy warnings fire (credits are on-demand top-up only). Warnings use escalation on severity transitions and have a cooldown for `warning` level.
77
77
 
78
- ### Sub-bar Integration
79
-
80
- When a Neuralwatt model is active, the footer status bar shows live quota usage (credits and energy). The status updates after each response and on session start.
81
-
82
78
  ## Settings
83
79
 
84
80
  Configure features with `/neuralwatt:settings`:
@@ -86,7 +82,6 @@ Configure features with `/neuralwatt:settings`:
86
82
  - **API** — Choose between `openai-completions` (default) and `anthropic-messages`; applies on `/reload`
87
83
  - **Quota command** — Show/hide `/neuralwatt:quota`
88
84
  - **Quota warnings** — Enable/disable low quota notifications
89
- - **Sub-bar integration** — Show/hide usage in status bar
90
85
 
91
86
  The provider itself cannot be disabled — it is always loaded.
92
87
 
@@ -142,16 +142,6 @@ export function registerNeuralwattSettings(
142
142
  ),
143
143
  loaded.has("quotaWarnings"),
144
144
  ),
145
- featureRow(
146
- "subBarIntegration",
147
- "Sub-bar integration",
148
- "Toggle integration with the status bar and sub-core",
149
- featureValue(
150
- tabConfig?.subBarIntegration,
151
- resolved.subBarIntegration.enabled,
152
- ),
153
- loaded.has("subBarIntegration"),
154
- ),
155
145
  ],
156
146
  },
157
147
  ];
@@ -187,11 +177,6 @@ export function registerNeuralwattSettings(
187
177
  ...config,
188
178
  quotaWarnings: { ...config.quotaWarnings, enabled },
189
179
  };
190
- case "subBarIntegration":
191
- return {
192
- ...config,
193
- subBarIntegration: { ...config.subBarIntegration, enabled },
194
- };
195
180
  default:
196
181
  return null;
197
182
  }
@@ -105,17 +105,6 @@ const KIMI_K3: NeuralwattModelFamily = {
105
105
  },
106
106
  };
107
107
 
108
- // MoonshotAI. K2.7 Code has mandatory reasoning with no selectable efforts
109
- // (`supported_efforts: []`), so `buildThinkingLevelMap` nulls out every level.
110
- const KIMI_K2_7_CODE: NeuralwattModelFamily = {
111
- cost: { input: 0.95, output: 4.0, cacheRead: 0.095 },
112
- vision: true,
113
- reasoningMetadata: {
114
- supported_efforts: [],
115
- mandatory: true,
116
- },
117
- };
118
-
119
108
  // Xiaomi. MiMo-V2.6-Pro only has two reasoning behaviors: `high` (default)
120
109
  // and `none`; the API aliases every other effort onto those, with `minimal`
121
110
  // landing on `none`.
@@ -336,35 +325,6 @@ const FAMILIES: [NeuralwattModelFamily, NeuralwattVariantSpec[]][] = [
336
325
  },
337
326
  ],
338
327
  ],
339
- [
340
- KIMI_K2_7_CODE,
341
- [
342
- {
343
- id: "kimi-k2.7-code",
344
- name: "Kimi K2.7 Code",
345
- contextWindow: 262128,
346
- maxOutputTokens: null,
347
- reasoning: true,
348
- },
349
- {
350
- // K2.7 Code cannot disable thinking; the -fast variant caps the
351
- // reasoning budget (~64 tokens) rather than turning it off.
352
- id: "kimi-k2.7-code-fast",
353
- name: "Kimi K2.7 Code Fast",
354
- contextWindow: 262128,
355
- maxOutputTokens: null,
356
- reasoning: true,
357
- },
358
- {
359
- id: "kimi-k2.7-code-flex",
360
- name: "Kimi K2.7 Code (flex)",
361
- contextWindow: 262128,
362
- maxOutputTokens: null,
363
- reasoning: true,
364
- costMultiplier: 0.65,
365
- },
366
- ],
367
- ],
368
328
  [
369
329
  MIMO_V2_6_PRO,
370
330
  [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliou/pi-neuralwatt",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "private": false,
@@ -17,8 +17,7 @@
17
17
  "extensions": [
18
18
  "./extensions/provider/index.ts",
19
19
  "./extensions/command-quotas/index.ts",
20
- "./extensions/quota-warnings/index.ts",
21
- "./extensions/sub-bar-integration/index.ts"
20
+ "./extensions/quota-warnings/index.ts"
22
21
  ],
23
22
  "video": "https://assets.aliou.me/github/aliou/pi-neuralwatt/demo.mp4"
24
23
  },
@@ -71,8 +70,8 @@
71
70
  "test:watch": "vitest",
72
71
  "check:models": "tsx scripts/check-models.ts",
73
72
  "check:changesets": "tsx scripts/check-changesets.ts",
74
- "gen:schema": "pi-settings-schema -p src/config/types.ts -t NeuralwattConfig -o schema.json --version 0.12.0",
75
- "check:schema": "pi-settings-schema -p src/config/types.ts -t NeuralwattConfig -o schema.json --version 0.12.0 --check",
73
+ "gen:schema": "pi-settings-schema -p src/config/types.ts -t NeuralwattConfig -o schema.json",
74
+ "check:schema": "pi-settings-schema -p src/config/types.ts -t NeuralwattConfig -o schema.json --check",
76
75
  "check:lockfile": "pnpm install --frozen-lockfile --ignore-scripts",
77
76
  "prepare": "[ -d .git ] && husky || true",
78
77
  "changeset": "changeset",
package/schema.json CHANGED
@@ -16,10 +16,6 @@
16
16
  "$ref": "#/definitions/NeuralwattQuotaWarningsConfig",
17
17
  "description": "Quota warning feature."
18
18
  },
19
- "subBarIntegration": {
20
- "$ref": "#/definitions/NeuralwattSubBarIntegrationConfig",
21
- "description": "Sub-bar/status-bar integration feature."
22
- },
23
19
  "provider": {
24
20
  "$ref": "#/definitions/NeuralwattProviderConfig",
25
21
  "description": "Provider behavior (API surface)."
@@ -35,7 +31,7 @@
35
31
  "pattern": "^\\d{1,15}(\\.\\d{1,15})?(\\.\\d{1,15})?$"
36
32
  }
37
33
  ],
38
- "description": "Config schema version, stamped by migrations. Current version: 0.12.0."
34
+ "description": "Config schema version, stamped by migrations."
39
35
  }
40
36
  },
41
37
  "additionalProperties": false
@@ -60,16 +56,6 @@
60
56
  },
61
57
  "additionalProperties": false
62
58
  },
63
- "NeuralwattSubBarIntegrationConfig": {
64
- "type": "object",
65
- "properties": {
66
- "enabled": {
67
- "type": "boolean",
68
- "description": "Show usage in the sub-bar / status bar."
69
- }
70
- },
71
- "additionalProperties": false
72
- },
73
59
  "NeuralwattProviderConfig": {
74
60
  "type": "object",
75
61
  "properties": {
@@ -9,9 +9,6 @@ export const DEFAULT_CONFIG: ResolvedNeuralwattConfig = {
9
9
  quotaWarnings: {
10
10
  enabled: true,
11
11
  },
12
- subBarIntegration: {
13
- enabled: true,
14
- },
15
12
  provider: {
16
13
  api: "openai-completions",
17
14
  apiBaseUrl: NEURALWATT_API_BASE_URL,
@@ -26,11 +26,6 @@ function normalizeResolvedConfig(
26
26
  enabled:
27
27
  config.quotaWarnings?.enabled ?? DEFAULT_CONFIG.quotaWarnings.enabled,
28
28
  },
29
- subBarIntegration: {
30
- enabled:
31
- config.subBarIntegration?.enabled ??
32
- DEFAULT_CONFIG.subBarIntegration.enabled,
33
- },
34
29
  provider: {
35
30
  api: resolveApi(config.provider?.api),
36
31
  apiBaseUrl: resolveApiBaseUrl(config.provider?.apiBaseUrl),
@@ -0,0 +1,31 @@
1
+ import type { Migration } from "@aliou/pi-utils-settings";
2
+
3
+ export const SUB_BAR_GIST_URL =
4
+ "https://gist.github.com/aliou/9939544f3c5a4f917b0a8e5c0497cdb2";
5
+
6
+ interface PreRemovalNeuralwattConfig {
7
+ $schema?: string;
8
+ quotaCommand?: { enabled?: boolean };
9
+ quotaWarnings?: { enabled?: boolean };
10
+ subBarIntegration?: { enabled?: boolean };
11
+ provider?: {
12
+ api?: string;
13
+ apiBaseUrl?: string;
14
+ includeLegacyModelIds?: boolean;
15
+ includeEarlyAccessModels?: boolean;
16
+ };
17
+ }
18
+
19
+ export const removeSubBarIntegrationMigration: Migration<PreRemovalNeuralwattConfig> =
20
+ {
21
+ name: "remove-sub-bar-integration",
22
+ version: "0.18.0",
23
+ shouldRun: (config) => config.subBarIntegration !== undefined,
24
+ message: `[neuralwatt] The built-in sub-bar integration was removed. Test with \`pi -e ${SUB_BAR_GIST_URL}\` and install with \`pi install ${SUB_BAR_GIST_URL}\`. The standalone extension won't be kept up to date.`,
25
+ run: (config) => {
26
+ if (config.subBarIntegration === undefined) return config;
27
+
28
+ const { subBarIntegration: _removed, ...rest } = config;
29
+ return rest;
30
+ },
31
+ };
@@ -1,19 +1,18 @@
1
1
  import type { Migration } from "@aliou/pi-utils-settings";
2
- import type { NeuralwattConfig } from "../types";
3
2
 
4
3
  export {
5
4
  backupConfig,
6
5
  flatToNestedConfigMigration,
7
6
  } from "./02-flat-to-nested-config";
8
7
  export { renameHiddenToEarlyAccessMigration } from "./03-rename-hidden-to-early-access";
8
+ export { removeSubBarIntegrationMigration } from "./04-remove-sub-bar-integration";
9
9
 
10
10
  import { flatToNestedConfigMigration } from "./02-flat-to-nested-config";
11
11
  import { renameHiddenToEarlyAccessMigration } from "./03-rename-hidden-to-early-access";
12
+ import { removeSubBarIntegrationMigration } from "./04-remove-sub-bar-integration";
12
13
 
13
- // Each migration is typed against its own historical input shape. The loader
14
- // applies them in sequence on the raw config record, so they are cast to the
15
- // current config type for the array.
16
14
  export const migrations = [
17
15
  flatToNestedConfigMigration,
18
16
  renameHiddenToEarlyAccessMigration,
19
- ] as unknown as Migration<NeuralwattConfig>[];
17
+ removeSubBarIntegrationMigration,
18
+ ] as Migration<object>[];
@@ -8,11 +8,6 @@ export interface NeuralwattQuotaWarningsConfig {
8
8
  enabled?: boolean;
9
9
  }
10
10
 
11
- export interface NeuralwattSubBarIntegrationConfig {
12
- /** Show usage in the sub-bar / status bar. */
13
- enabled?: boolean;
14
- }
15
-
16
11
  /**
17
12
  * Neuralwatt serves every chat model twice: on an OpenAI-compatible
18
13
  * `chat/completions` endpoint and on a vLLM-backed Anthropic-compatible
@@ -43,9 +38,6 @@ export interface NeuralwattConfig {
43
38
  /** Quota warning feature. */
44
39
  quotaWarnings?: NeuralwattQuotaWarningsConfig;
45
40
 
46
- /** Sub-bar/status-bar integration feature. */
47
- subBarIntegration?: NeuralwattSubBarIntegrationConfig;
48
-
49
41
  /** Provider behavior (API surface). */
50
42
  provider?: NeuralwattProviderConfig;
51
43
  }
@@ -57,9 +49,6 @@ export interface ResolvedNeuralwattConfig {
57
49
  quotaWarnings: {
58
50
  enabled: boolean;
59
51
  };
60
- subBarIntegration: {
61
- enabled: boolean;
62
- };
63
52
  provider: {
64
53
  api: NeuralwattApi;
65
54
  apiBaseUrl: string;
package/src/events.ts CHANGED
@@ -1,10 +1,7 @@
1
1
  import type { ResolvedNeuralwattConfig } from "./config";
2
2
  import type { NeuralwattQuotas } from "./types/quota-api";
3
3
 
4
- export type NeuralwattFeatureId =
5
- | "quotaCommand"
6
- | "quotaWarnings"
7
- | "subBarIntegration";
4
+ export type NeuralwattFeatureId = "quotaCommand" | "quotaWarnings";
8
5
 
9
6
  export const NEURALWATT_EXTENSIONS_REQUEST_EVENT =
10
7
  "neuralwatt:extensions:request" as const;
@@ -1,131 +0,0 @@
1
- import type {
2
- ExtensionAPI,
3
- ExtensionContext,
4
- Theme,
5
- } from "@earendil-works/pi-coding-agent";
6
- import { configLoader } from "../../src/config";
7
- import {
8
- NEURALWATT_CONFIG_UPDATED_EVENT,
9
- NEURALWATT_EXTENSIONS_REGISTER_EVENT,
10
- NEURALWATT_EXTENSIONS_REQUEST_EVENT,
11
- NEURALWATT_QUOTAS_REQUEST_EVENT,
12
- NEURALWATT_QUOTAS_UPDATED_EVENT,
13
- type NeuralwattConfigUpdatedPayload,
14
- type NeuralwattQuotasUpdatedPayload,
15
- } from "../../src/events";
16
- import type { NeuralwattQuotas } from "../../src/types/quota-api";
17
- import {
18
- percentCreditsRemaining,
19
- percentEnergyRemaining,
20
- } from "../../src/utils/quota-bar";
21
- import { formatKwh, formatUsd } from "../../src/utils/quota-format";
22
- import { toUsageSnapshot } from "./snapshot";
23
-
24
- function formatStatus(quotas: NeuralwattQuotas, theme: Theme): string {
25
- const parts: string[] = [];
26
-
27
- const creditsRemaining = percentCreditsRemaining(quotas);
28
- const creditsColor =
29
- creditsRemaining > 50
30
- ? "success"
31
- : creditsRemaining > 20
32
- ? "warning"
33
- : "error";
34
- parts.push(
35
- `${theme.fg("dim", "credits:")} ${theme.fg(creditsColor, formatUsd(quotas.balance.credits_remaining_usd))}`,
36
- );
37
-
38
- if (quotas.subscription) {
39
- const energyRemaining = percentEnergyRemaining(quotas.subscription);
40
- const energyColor =
41
- energyRemaining > 50
42
- ? "success"
43
- : energyRemaining > 20
44
- ? "warning"
45
- : "error";
46
- parts.push(
47
- `${theme.fg("dim", "energy:")} ${theme.fg(energyColor, formatKwh(quotas.subscription.kwh_remaining))}`,
48
- );
49
- }
50
-
51
- return parts.join(" ");
52
- }
53
-
54
- export default async function (pi: ExtensionAPI) {
55
- await configLoader.load();
56
-
57
- let enabled = configLoader.getConfig().subBarIntegration.enabled;
58
- let subCoreReady = false;
59
- let currentProvider: string | undefined;
60
- let unsubscribeQuotas: (() => void) | undefined;
61
-
62
- // Listen for config changes at runtime
63
- pi.events.on(NEURALWATT_CONFIG_UPDATED_EVENT, (data: unknown) => {
64
- enabled = (data as NeuralwattConfigUpdatedPayload).config.subBarIntegration
65
- .enabled;
66
- });
67
-
68
- function isActive(): boolean {
69
- return currentProvider === "neuralwatt";
70
- }
71
-
72
- function emitUsage(quotas: NeuralwattQuotas): void {
73
- pi.events.emit("sub-core:update-current", {
74
- state: {
75
- provider: "neuralwatt",
76
- usage: toUsageSnapshot(quotas),
77
- },
78
- });
79
- }
80
-
81
- function requestQuotas(): void {
82
- pi.events.emit(NEURALWATT_QUOTAS_REQUEST_EVENT, undefined);
83
- }
84
-
85
- // The quota handler runs on the shared event bus, so it must only touch a
86
- // session ctx captured by a live session-scoped subscription: pi
87
- // invalidates session-bound ctx after session replacement (newSession/
88
- // fork/switchSession/reload), and dereferencing a stale ctx throws. We
89
- // subscribe in session_start (capturing the fresh ctx in the closure) and
90
- // unsubscribe in session_shutdown, before the ctx can go stale.
91
- function handleQuotas(ctx: ExtensionContext, data: unknown): void {
92
- if (!isActive() || !subCoreReady || !enabled) return;
93
- if (!data || typeof data !== "object") return;
94
- const { quotas } = data as NeuralwattQuotasUpdatedPayload;
95
- emitUsage(quotas);
96
-
97
- ctx.ui.setStatus("neuralwatt-usage", formatStatus(quotas, ctx.ui.theme));
98
- }
99
-
100
- pi.events.on("sub-core:ready", () => {
101
- subCoreReady = true;
102
- });
103
-
104
- pi.on("session_start", async (_event, ctx) => {
105
- unsubscribeQuotas?.();
106
- currentProvider = ctx.model?.provider;
107
- unsubscribeQuotas = pi.events.on(NEURALWATT_QUOTAS_UPDATED_EVENT, (data) =>
108
- handleQuotas(ctx, data),
109
- );
110
- });
111
-
112
- pi.on("model_select", async (_event, ctx) => {
113
- currentProvider = ctx.model?.provider;
114
-
115
- if (subCoreReady && isActive() && enabled) {
116
- requestQuotas();
117
- }
118
- });
119
-
120
- pi.on("session_shutdown", () => {
121
- unsubscribeQuotas?.();
122
- unsubscribeQuotas = undefined;
123
- currentProvider = undefined;
124
- });
125
-
126
- pi.events.on(NEURALWATT_EXTENSIONS_REQUEST_EVENT, () => {
127
- pi.events.emit(NEURALWATT_EXTENSIONS_REGISTER_EVENT, {
128
- feature: "subBarIntegration",
129
- });
130
- });
131
- }
@@ -1,47 +0,0 @@
1
- import type { NeuralwattQuotas } from "../../src/types/quota-api";
2
- import {
3
- percentCreditsRemaining,
4
- percentEnergyRemaining,
5
- } from "../../src/utils/quota-bar";
6
- import { formatKwh } from "../../src/utils/quota-format";
7
-
8
- interface RateWindow {
9
- label: string;
10
- usedPercent: number;
11
- resetDescription?: string;
12
- }
13
-
14
- export interface UsageSnapshot {
15
- provider: string;
16
- displayName: string;
17
- windows: RateWindow[];
18
- lastSuccessAt?: number;
19
- }
20
-
21
- export function toUsageSnapshot(quotas: NeuralwattQuotas): UsageSnapshot {
22
- const windows: RateWindow[] = [];
23
-
24
- const creditsRemaining = percentCreditsRemaining(quotas);
25
- const creditsUsed = 100 - creditsRemaining;
26
- windows.push({
27
- label: "Credits",
28
- usedPercent: Math.max(0, Math.min(100, creditsUsed)),
29
- });
30
-
31
- if (quotas.subscription) {
32
- const energyRemaining = percentEnergyRemaining(quotas.subscription);
33
- const energyUsed = 100 - energyRemaining;
34
- windows.push({
35
- label: "Energy",
36
- usedPercent: Math.max(0, Math.min(100, energyUsed)),
37
- resetDescription: `${formatKwh(quotas.subscription.kwh_remaining)} left`,
38
- });
39
- }
40
-
41
- return {
42
- provider: "neuralwatt",
43
- displayName: "Neuralwatt",
44
- windows,
45
- lastSuccessAt: Date.now(),
46
- };
47
- }