pi-better-openai 0.1.18 → 0.1.19
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 +90 -1
- package/index.ts +180 -1019
- package/package.json +5 -2
- package/src/codex-auth.ts +105 -0
- package/src/config.ts +294 -0
- package/src/fast-controller.ts +109 -0
- package/src/format.ts +36 -0
- package/src/image.ts +73 -80
- package/src/pet-footer-controller.ts +611 -0
- package/src/pets.ts +124 -32
- package/src/usage-controller.ts +214 -0
- package/src/usage.ts +10 -27
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-better-openai
|
|
2
2
|
|
|
3
|
-
A pi extension for OpenAI subscription workflows: fast mode, usage visibility, footer polish, and image generation through `openai-codex` auth.
|
|
3
|
+
A pi extension for OpenAI subscription workflows: fast mode, usage visibility, footer polish, custom Codex pets, and image generation through `openai-codex` auth.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -16,6 +16,15 @@ Or install from npm:
|
|
|
16
16
|
pi install npm:pi-better-openai
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
## Authentication
|
|
20
|
+
|
|
21
|
+
Usage display and image generation require pi's `openai-codex` OAuth credentials.
|
|
22
|
+
|
|
23
|
+
1. In pi, run `/login openai-codex`.
|
|
24
|
+
2. Verify subscription usage with `/openai-usage`, or open `/openai-settings` and check **Diagnostics**.
|
|
25
|
+
3. The extension reads auth from pi's agent auth store, normally `~/.pi/agent/auth.json`. Do not copy, paste, or commit values from this file.
|
|
26
|
+
4. If `PI_CODING_AGENT_DIR` is set, the auth store and global generated-image directory use that agent directory instead of `~/.pi/agent`.
|
|
27
|
+
|
|
19
28
|
## Features
|
|
20
29
|
|
|
21
30
|
- Fast mode for supported OpenAI models, toggled with `/fast` or in `/openai-settings`.
|
|
@@ -31,6 +40,86 @@ pi install npm:pi-better-openai
|
|
|
31
40
|
- `/openai-usage` shows current OpenAI subscription usage.
|
|
32
41
|
- `/openai-settings` opens settings, diagnostics, and config details.
|
|
33
42
|
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
The extension reads JSON config from two locations:
|
|
46
|
+
|
|
47
|
+
- Project config: `.pi/extensions/pi-better-openai.json`
|
|
48
|
+
- Global config: `~/.pi/agent/extensions/pi-better-openai.json`
|
|
49
|
+
|
|
50
|
+
Project overrides global. Global values fill fields omitted by the project file. Invalid enum values are ignored, and numeric settings are clamped to safe ranges.
|
|
51
|
+
|
|
52
|
+
Default supported models:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
["openai/gpt-5.4", "openai/gpt-5.5", "openai-codex/gpt-5.4", "openai-codex/gpt-5.5"]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Example config:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"persistState": true,
|
|
63
|
+
"desiredActive": false,
|
|
64
|
+
"supportedModels": ["openai/gpt-5.5", "openai-codex/gpt-5.5"],
|
|
65
|
+
"usage": {
|
|
66
|
+
"enabled": true,
|
|
67
|
+
"refreshIntervalMs": 60000,
|
|
68
|
+
"showOnlyOnSubscriptionModels": true,
|
|
69
|
+
"showResetTimes": true
|
|
70
|
+
},
|
|
71
|
+
"footer": {
|
|
72
|
+
"mode": "status"
|
|
73
|
+
},
|
|
74
|
+
"image": {
|
|
75
|
+
"enabled": true,
|
|
76
|
+
"defaultModel": "gpt-5.5",
|
|
77
|
+
"defaultSave": "project",
|
|
78
|
+
"outputFormat": "png",
|
|
79
|
+
"timeoutMs": 180000
|
|
80
|
+
},
|
|
81
|
+
"pets": {
|
|
82
|
+
"enabled": false,
|
|
83
|
+
"slug": "",
|
|
84
|
+
"placement": "inline-right",
|
|
85
|
+
"state": "idle",
|
|
86
|
+
"thinkingState": "review",
|
|
87
|
+
"toolState": "running",
|
|
88
|
+
"failedToolState": "failed",
|
|
89
|
+
"idleEmotes": true,
|
|
90
|
+
"idleEmoteIntervalMs": 30000,
|
|
91
|
+
"sizeCells": 10
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Image generation
|
|
97
|
+
|
|
98
|
+
Use the command for quick generation:
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
/openai-image draw an otter reading a terminal
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Agents can call the `openai_image` tool directly. Supported parameters:
|
|
105
|
+
|
|
106
|
+
- `prompt` (required): pass the user's image wording verbatim.
|
|
107
|
+
- `action`: `auto`, `generate`, or `edit`.
|
|
108
|
+
- `images`: project-local reference/edit image paths. Paths must stay inside the current workspace and point to readable PNG, JPEG, WebP, or GIF files.
|
|
109
|
+
- `model`: Codex image model override, for example `openai-codex/gpt-5.5`.
|
|
110
|
+
- `outputFormat`: `png`, `jpeg`, or `webp`.
|
|
111
|
+
- `save`: `project`, `global`, `custom`, or `none`.
|
|
112
|
+
- `saveDir`: required for `save: "custom"` unless `PI_IMAGE_SAVE_DIR` is set.
|
|
113
|
+
|
|
114
|
+
Save modes:
|
|
115
|
+
|
|
116
|
+
- `project` writes to `.pi/generated-images/` in the current project.
|
|
117
|
+
- `global` writes to the agent `generated-images` directory, normally `~/.pi/agent/generated-images/` or `$PI_CODING_AGENT_DIR/generated-images/`.
|
|
118
|
+
- `custom` writes to `saveDir` or `PI_IMAGE_SAVE_DIR`.
|
|
119
|
+
- `none` returns the image without saving it.
|
|
120
|
+
|
|
121
|
+
The repository ignores `.pi/`, so generated images and local config should not be committed.
|
|
122
|
+
|
|
34
123
|
## Codex pets
|
|
35
124
|
|
|
36
125
|
Codex pets are an OpenAI Codex app feature, so the floating overlay and pet picker are still controlled by Codex (`Settings → Appearance → Pets` or `/pet`). This extension can also render compatible custom pet spritesheets directly in pi's Better OpenAI footer.
|