pi-better-openai 0.1.2 → 0.1.4

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
@@ -44,8 +44,9 @@ pi --fast
44
44
  - OpenAI subscription usage display via `/openai-usage` and the footer.
45
45
  - Interactive settings picker via `/openai-settings`.
46
46
  - Footer customization for model, thinking, fast mode, usage, and token/cost context.
47
- - OpenAI image generation/editing through the `openai_image` tool.
47
+ - OpenAI image generation/editing through the `openai_image` tool and `/openai-image` command.
48
48
  - Commands:
49
49
  - `/fast` toggles fast mode.
50
+ - `/openai-image <prompt>` generates an image directly.
50
51
  - `/openai-usage` shows current OpenAI subscription usage.
51
52
  - `/openai-settings` opens settings, diagnostics, and config details.
@@ -8,6 +8,7 @@ import { isRecord } from "./config.ts";
8
8
  import { readCodexAuth } from "./usage.ts";
9
9
 
10
10
  const OPENAI_IMAGE_TOOL = "openai_image";
11
+ const OPENAI_IMAGE_COMMAND = "openai-image";
11
12
  const CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
12
13
  const DEFAULT_TIMEOUT_MS = 180_000;
13
14
 
@@ -387,6 +388,28 @@ export function registerOpenAIImage(pi: ExtensionAPI, getConfig: (ctx: Extension
387
388
  };
388
389
  }
389
390
 
391
+ pi.registerCommand(OPENAI_IMAGE_COMMAND, {
392
+ description: "Generate an image with OpenAI Codex image generation",
393
+ handler: async (args, ctx) => {
394
+ const prompt = args.trim();
395
+ if (!prompt) {
396
+ ctx.ui.notify("Usage: /openai-image <prompt>", "error");
397
+ return;
398
+ }
399
+ ctx.ui.notify("Requesting OpenAI image...", "info");
400
+ const result = await generate({ prompt }, ctx);
401
+ pi.sendMessage({
402
+ customType: "openai-image",
403
+ content: [
404
+ { type: "text", text: resultText(result) },
405
+ { type: "image", data: result.data, mimeType: result.mimeType }
406
+ ],
407
+ display: true,
408
+ details: result
409
+ });
410
+ }
411
+ });
412
+
390
413
  pi.registerTool({
391
414
  name: OPENAI_IMAGE_TOOL,
392
415
  label: "OpenAI image",
@@ -419,6 +442,7 @@ export const _imageTest = {
419
442
  CODEX_RESPONSES_URL,
420
443
  DEFAULT_TIMEOUT_MS,
421
444
  OPENAI_IMAGE_TOOL,
445
+ OPENAI_IMAGE_COMMAND,
422
446
  extractAccountIdFromJwt,
423
447
  imageMimeType,
424
448
  dataUrlParts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-openai",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Personal pi extension that improves OpenAI with fast mode, usage stats, and footer polish.",
5
5
  "keywords": [
6
6
  "fast",