@diegopetrucci/pi-openai-fast 0.1.4 → 0.1.5
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 +1 -1
- package/index.ts +17 -6
- package/package.json +1 -1
package/README.md
CHANGED
package/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
type ExtensionContext,
|
|
7
7
|
} from "@earendil-works/pi-coding-agent";
|
|
8
8
|
|
|
9
|
+
const CONFIG_DIR_NAME = ".pi";
|
|
10
|
+
|
|
9
11
|
const EXTENSION_ID = "openai-fast";
|
|
10
12
|
const PROVIDER_ID = "openai-codex";
|
|
11
13
|
const API_ID = "openai-codex-responses";
|
|
@@ -33,6 +35,11 @@ type SessionState = {
|
|
|
33
35
|
lastInjectedModel?: string;
|
|
34
36
|
};
|
|
35
37
|
|
|
38
|
+
type ProjectConfigContext = {
|
|
39
|
+
cwd: string;
|
|
40
|
+
isProjectTrusted?: () => boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
36
43
|
type RecursivePartial<T> = {
|
|
37
44
|
[P in keyof T]?: T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
38
45
|
};
|
|
@@ -71,21 +78,25 @@ function mergeConfig(
|
|
|
71
78
|
};
|
|
72
79
|
}
|
|
73
80
|
|
|
81
|
+
function canReadProjectConfig(ctx: ProjectConfigContext): boolean {
|
|
82
|
+
return typeof ctx.isProjectTrusted === "function" && ctx.isProjectTrusted();
|
|
83
|
+
}
|
|
84
|
+
|
|
74
85
|
function findProjectConfigPath(cwd: string): string {
|
|
75
86
|
let current = cwd;
|
|
76
87
|
while (true) {
|
|
77
|
-
const candidate = join(current,
|
|
88
|
+
const candidate = join(current, CONFIG_DIR_NAME, "openai-fast.json");
|
|
78
89
|
if (existsSync(candidate)) return candidate;
|
|
79
90
|
|
|
80
91
|
const parent = dirname(current);
|
|
81
|
-
if (parent === current) return join(cwd,
|
|
92
|
+
if (parent === current) return join(cwd, CONFIG_DIR_NAME, "openai-fast.json");
|
|
82
93
|
current = parent;
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
96
|
|
|
86
|
-
function loadConfig(
|
|
97
|
+
function loadConfig(ctx: ProjectConfigContext): OpenAIFastConfig {
|
|
87
98
|
const globalConfig = readConfigFile(join(getAgentDir(), "extensions", "openai-fast.json"));
|
|
88
|
-
const projectConfig = readConfigFile(findProjectConfigPath(cwd));
|
|
99
|
+
const projectConfig = canReadProjectConfig(ctx) ? readConfigFile(findProjectConfigPath(ctx.cwd)) : {};
|
|
89
100
|
return mergeConfig(mergeConfig(DEFAULT_CONFIG, globalConfig), projectConfig);
|
|
90
101
|
}
|
|
91
102
|
|
|
@@ -211,7 +222,7 @@ export default function openAIFastExtension(pi: ExtensionAPI) {
|
|
|
211
222
|
let state = states.get(ctx.sessionManager);
|
|
212
223
|
if (!state) {
|
|
213
224
|
state = {
|
|
214
|
-
config: loadConfig(ctx
|
|
225
|
+
config: loadConfig(ctx),
|
|
215
226
|
override: "auto",
|
|
216
227
|
};
|
|
217
228
|
states.set(ctx.sessionManager, state);
|
|
@@ -221,7 +232,7 @@ export default function openAIFastExtension(pi: ExtensionAPI) {
|
|
|
221
232
|
|
|
222
233
|
pi.on("session_start", (_event, ctx) => {
|
|
223
234
|
const state: SessionState = {
|
|
224
|
-
config: loadConfig(ctx
|
|
235
|
+
config: loadConfig(ctx),
|
|
225
236
|
override: "auto",
|
|
226
237
|
};
|
|
227
238
|
states.set(ctx.sessionManager, state);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegopetrucci/pi-openai-fast",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "A pi extension that enables OpenAI Codex Fast mode for ChatGPT-auth GPT-5.4 and GPT-5.5 by injecting the priority service tier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|