@monotykamary/pi-better-openai 0.1.23

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,191 @@
1
+ # pi-better-openai
2
+
3
+ A pi extension for OpenAI subscription workflows: fast mode, usage visibility, realtime voice, footer polish, custom Codex pets, and image generation through `openai-codex` auth.
4
+
5
+ ## Install
6
+
7
+ Requires Node.js 22.19.0 or newer.
8
+
9
+ Install from GitHub:
10
+
11
+ ```bash
12
+ pi install git:github.com/monotykamary/pi-better-openai
13
+ ```
14
+
15
+ Or install from npm:
16
+
17
+ ```bash
18
+ pi install npm:@monotykamary/pi-better-openai
19
+ ```
20
+
21
+ ## Authentication
22
+
23
+ Usage display, image generation, and live voice require pi's `openai-codex` OAuth credentials.
24
+
25
+ 1. In pi, run `/login openai-codex`.
26
+ 2. Verify subscription usage with `/openai-usage`, or open `/openai-settings` and check **Diagnostics**.
27
+ 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.
28
+ 4. If `PI_CODING_AGENT_DIR` is set, the auth store, global extension config, and global generated-image directory use that agent directory instead of `~/.pi/agent`. A leading `~/` is expanded to your home directory.
29
+
30
+ ## Features
31
+
32
+ - Fast mode for supported OpenAI models, toggled with `/fast` or in `/openai-settings`.
33
+ - OpenAI subscription usage display via `/openai-usage` and the footer.
34
+ - Interactive settings picker via `/openai-settings`.
35
+ - Footer customization for model, thinking, fast mode, usage, and token/cost context.
36
+ - OpenAI image generation/editing through the `openai_image` tool and `/openai-image` command.
37
+ - Codex-backed realtime voice through `/live`, with an animated microphone waveform and coding-task delegation into the active pi session.
38
+ - Animated Codex custom pets rendered in the Better OpenAI footer.
39
+ - Commands:
40
+ - `/fast` toggles fast mode.
41
+ - `/openai-image <prompt>` generates an image directly.
42
+ - `/live` starts or stops realtime voice mode. `Ctrl+Shift+L` is the keyboard toggle.
43
+ - `/pets [help|list|wake [slug]|tuck|select <slug>]` renders or manages custom pets from `${CODEX_HOME:-~/.codex}/pets`.
44
+ - `/openai-usage` shows current OpenAI subscription usage.
45
+ - `/openai-settings` opens settings, diagnostics, and config details.
46
+
47
+ ## Configuration
48
+
49
+ The extension reads JSON config from two locations:
50
+
51
+ - Project config: `.pi/extensions/pi-better-openai.json`
52
+ - Global config: `$PI_CODING_AGENT_DIR/extensions/pi-better-openai.json`, defaulting to `~/.pi/agent/extensions/pi-better-openai.json`
53
+
54
+ 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.
55
+
56
+ Default supported models:
57
+
58
+ ```json
59
+ [
60
+ "openai/gpt-5.4",
61
+ "openai/gpt-5.5",
62
+ "openai-codex/gpt-5.6-sol",
63
+ "openai-codex/gpt-5.6-terra",
64
+ "openai-codex/gpt-5.6-luna",
65
+ "openai-codex/gpt-5.4",
66
+ "openai-codex/gpt-5.5"
67
+ ]
68
+ ```
69
+
70
+ Example config:
71
+
72
+ ```json
73
+ {
74
+ "persistState": true,
75
+ "desiredActive": false,
76
+ "supportedModels": ["openai/gpt-5.5", "openai-codex/gpt-5.5"],
77
+ "usage": {
78
+ "enabled": true,
79
+ "refreshIntervalMs": 60000,
80
+ "showOnlyOnSubscriptionModels": true,
81
+ "showResetTimes": true
82
+ },
83
+ "footer": {
84
+ "mode": "status"
85
+ },
86
+ "image": {
87
+ "enabled": true,
88
+ "defaultModel": "gpt-5.5",
89
+ "defaultSave": "project",
90
+ "outputFormat": "png",
91
+ "timeoutMs": 180000
92
+ },
93
+ "live": {
94
+ "enabled": true,
95
+ "voice": "sol"
96
+ },
97
+ "pets": {
98
+ "enabled": false,
99
+ "slug": "",
100
+ "placement": "inline-right",
101
+ "state": "idle",
102
+ "thinkingState": "review",
103
+ "toolState": "running",
104
+ "failedToolState": "failed",
105
+ "idleEmotes": true,
106
+ "idleEmoteIntervalMs": 30000,
107
+ "sizeCells": 10
108
+ }
109
+ }
110
+ ```
111
+
112
+ ## Live voice
113
+
114
+ Run `/live` or press `Ctrl+Shift+L` to open the realtime voice panel. `Ctrl+L` remains pi's model selector, so the extension deliberately uses the shifted chord. While live mode has focus:
115
+
116
+ - `Space` toggles microphone mute.
117
+ - `Escape`, `Ctrl+C`, or `Ctrl+Shift+L` ends the call.
118
+ - The waveform reacts to microphone RMS level and the panel footer shows connecting, listening, working, speaking, muted, or error state.
119
+ - Streaming speech transcripts stay in the live panel. Coding and repository requests are delegated into the current pi agent session; normal tool and assistant output continues in the transcript, and the final result is spoken back through the live session.
120
+
121
+ Choose the spoken voice under **Live voice** in `/openai-settings`. Supported values are `arbor`, `breeze`, `cove`, `ember`, `juniper`, `maple`, `sol`, `spruce`, and `vale`.
122
+
123
+ Live mode requires interactive TUI mode, microphone/speaker access, `openai-codex` OAuth, and one of these native targets: macOS arm64/x64, Linux arm64/x64, or Windows x64. Standard `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, and `NO_PROXY` settings are honored for signaling and sideband traffic. Audio/WebRTC uses the MIT-licensed native platform packages from [`can1357/oh-my-pi`](https://github.com/can1357/oh-my-pi). The adapted implementation is attributed in [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md). On macOS, launchd-managed LocalTerm users should rerun `localterm install` after upgrading LocalTerm and allow its microphone prompt.
124
+
125
+ The feature uses Codex Desktop's experimental `gpt-live-1-codex`/Quicksilver protocol rather than the public OpenAI Realtime API. Upstream protocol or entitlement changes may temporarily break it.
126
+
127
+ ## Image generation
128
+
129
+ Use the command for quick generation:
130
+
131
+ ```text
132
+ /openai-image draw an otter reading a terminal
133
+ ```
134
+
135
+ Agents can call the `openai_image` tool directly. Supported parameters:
136
+
137
+ - `prompt` (required): pass the user's image wording verbatim.
138
+ - `action`: `auto`, `generate`, or `edit`.
139
+ - `images`: up to five distinct project-local reference/edit image paths. Paths must stay inside the current workspace and point to readable PNG, JPEG, WebP, or GIF files; each file is limited to 20 MB and the combined input to 50 MB.
140
+ - `model`: Codex image model override, for example `openai-codex/gpt-5.5`.
141
+ - `outputFormat`: `png`, `jpeg`, or `webp`.
142
+ - `save`: `project`, `global`, `custom`, or `none`.
143
+ - `saveDir`: required for `save: "custom"` unless `PI_IMAGE_SAVE_DIR` is set.
144
+
145
+ Save modes:
146
+
147
+ - `project` writes to `.pi/generated-images/` in the current project.
148
+ - `global` writes to the agent `generated-images` directory, normally `~/.pi/agent/generated-images/` or `$PI_CODING_AGENT_DIR/generated-images/`.
149
+ - `custom` writes to `saveDir` or `PI_IMAGE_SAVE_DIR`; relative paths are resolved from the current project.
150
+ - `none` returns the image without saving it.
151
+
152
+ The repository ignores `.pi/`, so generated images and local config should not be committed.
153
+
154
+ ## Codex pets
155
+
156
+ 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.
157
+
158
+ ```bash
159
+ /pets wake # render the selected pet, or pick one if none is selected
160
+ /pets wake <slug> # render a specific ready pet
161
+ /pets select <slug> # select a ready pet without changing visibility
162
+ /pets tuck # hide it
163
+ /pets list # list local custom pets and readiness diagnostics
164
+ ```
165
+
166
+ You can also enable **Footer pet** in `/openai-settings`, cycle installed pets with the **Pet** row, preview the selected pet in the footer, and tune placement (`inline-right` by default), idle, thinking/streaming, tool-execution, and any failed-tool animation states, plus random idle emotes and size.
167
+
168
+ To create a custom pet for the Codex app:
169
+
170
+ ```bash
171
+ $skill-installer hatch-pet
172
+ ```
173
+
174
+ Then reload Codex skills (`Cmd/Ctrl+K → Force Reload Skills`) and ask:
175
+
176
+ ```text
177
+ $hatch-pet create a new pet inspired by pi-better-openai
178
+ ```
179
+
180
+ Custom pets should end up in `${CODEX_HOME:-~/.codex}/pets/<pet-name>/` with `pet.json` and `spritesheet.webp`. The spritesheet must be a 1536×1872 atlas arranged as 8 columns by 9 animation rows. Animated footer rendering also requires a terminal image protocol supported by pi. Refresh custom pets in Codex settings and toggle the overlay with `/pet`.
181
+
182
+ ## Attribution
183
+
184
+ [`pi-better-openai`](https://github.com/mattleong/pi-better-openai) was originally created by [Matt Leong](https://github.com/mattleong). This fork is maintained and published under the `@monotykamary` namespace while retaining Matt's authorship and the original Git history. Realtime voice adaptations have separate attribution in [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md).
185
+
186
+ ## Screenshots
187
+
188
+ <!-- Add screenshots here. -->
189
+
190
+ <img width="983" height="851" alt="Screenshot 2026-04-29 at 11 53 23 PM" src="https://github.com/user-attachments/assets/07a2fb87-ef48-4396-8b12-124825c8d360" />
191
+ <img width="1327" height="102" alt="Screenshot 2026-04-29 at 11 34 49 PM" src="https://github.com/user-attachments/assets/22042782-c94e-491d-b5af-095f7f0810f9" />
@@ -0,0 +1,28 @@
1
+ # Third-party notices
2
+
3
+ ## oh-my-pi
4
+
5
+ Portions of `src/live/` are adapted from [`can1357/oh-my-pi`](https://github.com/can1357/oh-my-pi), including its live protocol, transport, session orchestration, attestation, and terminal visualizer design.
6
+
7
+ MIT License
8
+
9
+ Copyright (c) 2025 Mario Zechner
10
+ Copyright (c) 2025-2026 Can Bölük
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.