@benvargas/pi-openai-fast 1.0.5 → 1.1.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
@@ -39,7 +39,11 @@ pi -e npm:@benvargas/pi-openai-fast --fast
39
39
  Config files follow the same project-over-global pattern as the other packages:
40
40
 
41
41
  - Project: `<repo>/.pi/extensions/pi-openai-fast.json`
42
- - Global: `~/.pi/agent/extensions/pi-openai-fast.json`
42
+ - Global: `<agent dir>/extensions/pi-openai-fast.json`
43
+
44
+ The global path uses pi's agent directory — typically `~/.pi/agent`, but it follows `PI_CODING_AGENT_DIR` when that is set, matching where pi itself reads and writes config.
45
+
46
+ Releases before this one always used `~/.pi/agent`, even with `PI_CODING_AGENT_DIR` set. If the agent directory differs from `~/.pi/agent` and has no config yet, an existing `~/.pi/agent/extensions/pi-openai-fast.json` is copied there once so previous settings carry over; a config already present in the agent directory is never overwritten.
43
47
 
44
48
  If neither exists, the extension writes a default global config on first run.
45
49
 
@@ -51,6 +55,7 @@ Default config:
51
55
  "active": false,
52
56
  "supportedModels": [
53
57
  "openai/gpt-5.4",
58
+ "openai/gpt-5.4-mini",
54
59
  "openai/gpt-5.5",
55
60
  "openai/gpt-5.6-sol",
56
61
  "openai/gpt-5.6-terra",
@@ -77,6 +82,8 @@ Project config overrides global config. `/fast on` and `/fast off` write to the
77
82
  - When `persistState` is enabled, the last `/fast` setting also carries across brand-new pi sessions.
78
83
  - Resumed sessions do not override the config-backed startup state.
79
84
  - On configured models, fast mode maps to OpenAI `service_tier=priority`.
85
+ - `openai/gpt-5.4-mini` is in the defaults for the API-key provider only: OpenAI publishes Fast-mode pricing for it, but the ChatGPT (`openai-codex`) side offers no fast tier for gpt-5.4-mini. `gpt-5.4-nano`, `gpt-5.4-pro`, and `gpt-5.5-pro` have no published Fast-mode pricing and are left out.
86
+ - If a default set from an older release is found in your config, it is upgraded to the current defaults automatically; customized `supportedModels` lists are left untouched.
80
87
 
81
88
  ## Uninstall
82
89
 
@@ -6,22 +6,28 @@
6
6
  *
7
7
  * Startup state comes from `pi-openai-fast.json`, not resumed session history.
8
8
  * Config precedence is project `.pi/extensions/pi-openai-fast.json` over
9
- * global `~/.pi/agent/extensions/pi-openai-fast.json`.
9
+ * global `<agent dir>/extensions/pi-openai-fast.json`, where the agent dir is
10
+ * pi's getAgentDir() (typically `~/.pi/agent`, honoring PI_CODING_AGENT_DIR).
11
+ * Releases before 0.84 always used `~/.pi/agent`; when the agent dir differs
12
+ * and holds no config yet, the legacy global file is copied there once.
10
13
  *
11
14
  * `supportedModels` controls which `provider/model-id` pairs receive the flag.
12
15
  */
13
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
16
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
14
17
  import { homedir } from "node:os";
15
- import { dirname, join } from "node:path";
16
- import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
18
+ import { dirname, join, resolve } from "node:path";
19
+ import { type ExtensionAPI, type ExtensionContext, getAgentDir } from "@earendil-works/pi-coding-agent";
17
20
 
18
21
  const FAST_COMMAND = "fast";
19
22
  const FAST_FLAG = "fast";
20
23
  const FAST_CONFIG_BASENAME = "pi-openai-fast.json";
21
24
  const FAST_COMMAND_ARGS = ["on", "off", "status"] as const;
22
25
  const FAST_SERVICE_TIER = "priority";
26
+ // `openai/gpt-5.4-mini` has an official Fast-mode price and is API-key only: the
27
+ // ChatGPT (openai-codex) catalog exposes no priority tier for gpt-5.4-mini.
23
28
  const DEFAULT_SUPPORTED_MODEL_KEYS = [
24
29
  "openai/gpt-5.4",
30
+ "openai/gpt-5.4-mini",
25
31
  "openai/gpt-5.5",
26
32
  "openai/gpt-5.6-sol",
27
33
  "openai/gpt-5.6-terra",
@@ -35,6 +41,18 @@ const DEFAULT_SUPPORTED_MODEL_KEYS = [
35
41
  const LEGACY_DEFAULT_SUPPORTED_MODEL_KEY_SETS = [
36
42
  ["openai/gpt-5.4", "openai-codex/gpt-5.4"],
37
43
  ["openai/gpt-5.4", "openai/gpt-5.5", "openai-codex/gpt-5.4", "openai-codex/gpt-5.5"],
44
+ [
45
+ "openai/gpt-5.4",
46
+ "openai/gpt-5.5",
47
+ "openai/gpt-5.6-sol",
48
+ "openai/gpt-5.6-terra",
49
+ "openai/gpt-5.6-luna",
50
+ "openai-codex/gpt-5.4",
51
+ "openai-codex/gpt-5.5",
52
+ "openai-codex/gpt-5.6-sol",
53
+ "openai-codex/gpt-5.6-terra",
54
+ "openai-codex/gpt-5.6-luna",
55
+ ],
38
56
  ] as const;
39
57
 
40
58
  interface FastModeState {
@@ -80,14 +98,19 @@ function getConfigCwd(ctx: ExtensionContext): string {
80
98
 
81
99
  function getConfigPaths(
82
100
  cwd: string,
83
- homeDir: string = homedir(),
101
+ homeDir?: string,
84
102
  ): {
85
103
  projectConfigPath: string;
86
104
  globalConfigPath: string;
105
+ legacyGlobalConfigPath: string;
87
106
  } {
107
+ const agentDir = homeDir === undefined ? getAgentDir() : join(homeDir, ".pi", "agent");
108
+ // Pre-0.84 releases always wrote the global config under ~/.pi/agent, ignoring PI_CODING_AGENT_DIR.
109
+ const legacyAgentDir = join(homeDir ?? homedir(), ".pi", "agent");
88
110
  return {
89
111
  projectConfigPath: join(cwd, ".pi", "extensions", FAST_CONFIG_BASENAME),
90
- globalConfigPath: join(homeDir, ".pi", "agent", "extensions", FAST_CONFIG_BASENAME),
112
+ globalConfigPath: join(agentDir, "extensions", FAST_CONFIG_BASENAME),
113
+ legacyGlobalConfigPath: join(legacyAgentDir, "extensions", FAST_CONFIG_BASENAME),
91
114
  };
92
115
  }
93
116
 
@@ -207,8 +230,25 @@ function ensureDefaultConfigFile(projectConfigPath: string, globalConfigPath: st
207
230
  writeConfigFile(globalConfigPath, DEFAULT_CONFIG_FILE);
208
231
  }
209
232
 
210
- function resolveFastConfig(cwd: string, homeDir: string = homedir()): ResolvedFastConfig {
211
- const { projectConfigPath, globalConfigPath } = getConfigPaths(cwd, homeDir);
233
+ function migrateLegacyGlobalConfigFile(legacyGlobalConfigPath: string, globalConfigPath: string): void {
234
+ if (resolve(legacyGlobalConfigPath) === resolve(globalConfigPath)) {
235
+ return;
236
+ }
237
+ if (existsSync(globalConfigPath) || !existsSync(legacyGlobalConfigPath)) {
238
+ return;
239
+ }
240
+ try {
241
+ mkdirSync(dirname(globalConfigPath), { recursive: true });
242
+ copyFileSync(legacyGlobalConfigPath, globalConfigPath);
243
+ } catch (error) {
244
+ const message = error instanceof Error ? error.message : String(error);
245
+ console.warn(`[pi-openai-fast] Failed to migrate ${legacyGlobalConfigPath} to ${globalConfigPath}: ${message}`);
246
+ }
247
+ }
248
+
249
+ function resolveFastConfig(cwd: string, homeDir?: string): ResolvedFastConfig {
250
+ const { projectConfigPath, globalConfigPath, legacyGlobalConfigPath } = getConfigPaths(cwd, homeDir);
251
+ migrateLegacyGlobalConfigFile(legacyGlobalConfigPath, globalConfigPath);
212
252
  ensureDefaultConfigFile(projectConfigPath, globalConfigPath);
213
253
 
214
254
  const globalConfig = readConfigFile(globalConfigPath) ?? {};
@@ -415,6 +455,7 @@ export const _test = {
415
455
  parseSupportedModelKey,
416
456
  parseSupportedModels,
417
457
  migrateSupportedModelKeys,
458
+ migrateLegacyGlobalConfigFile,
418
459
  readConfigFile,
419
460
  resolveFastConfig,
420
461
  isFastSupportedModel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benvargas/pi-openai-fast",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "description": "OpenAI fast mode toggle for pi - Enables priority service tier on supported GPT-5 models",
5
5
  "keywords": [
6
6
  "pi",