pi-banana 2.0.4 → 2.0.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/extensions/index.ts +25 -12
- package/package.json +1 -1
package/extensions/index.ts
CHANGED
|
@@ -191,12 +191,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
191
191
|
"Generate or edit a PNG/JPEG image with Google's Nano Banana 2 " +
|
|
192
192
|
"(Gemini 3.1 Flash Image) or Nano Banana Pro. The image is shown " +
|
|
193
193
|
"inline in the terminal AND saved to disk so it can be re-used. " +
|
|
194
|
-
"Pass `
|
|
194
|
+
"Pass `referenceImages` (array of paths) to iterate on existing pictures.",
|
|
195
195
|
promptSnippet:
|
|
196
196
|
"Generate or edit images with Google Nano Banana via the GOOGLE_API_KEY env var.",
|
|
197
197
|
promptGuidelines: [
|
|
198
198
|
"Call banana_image when the user asks to create, draw, illustrate, or edit a picture.",
|
|
199
|
-
"For tweaks like 'make the sky purple', pass the previous file path as
|
|
199
|
+
"For tweaks like 'make the sky purple', pass the previous file path (or paths) as referenceImages to banana_image.",
|
|
200
200
|
"Default quality 'fast' is right for most asks; switch to 'high' only when the user explicitly wants top quality.",
|
|
201
201
|
],
|
|
202
202
|
parameters: Type.Object({
|
|
@@ -225,12 +225,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
225
225
|
default: DEFAULT_QUALITY,
|
|
226
226
|
}),
|
|
227
227
|
),
|
|
228
|
-
|
|
229
|
-
Type.String({
|
|
228
|
+
referenceImages: Type.Optional(
|
|
229
|
+
Type.Array(Type.String(), {
|
|
230
230
|
description:
|
|
231
|
-
"Optional path to
|
|
231
|
+
"Optional path(s) to existing image(s) (PNG/JPEG/WebP/GIF) to edit or iterate on. " +
|
|
232
232
|
"Relative paths resolve to the current working directory.",
|
|
233
|
-
})
|
|
233
|
+
})
|
|
234
234
|
),
|
|
235
235
|
outputPath: Type.Optional(
|
|
236
236
|
Type.String({
|
|
@@ -241,6 +241,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
241
241
|
),
|
|
242
242
|
}),
|
|
243
243
|
|
|
244
|
+
prepareArguments(args: any) {
|
|
245
|
+
if (args.referenceImage !== undefined) {
|
|
246
|
+
args.referenceImages = Array.isArray(args.referenceImage)
|
|
247
|
+
? args.referenceImage
|
|
248
|
+
: [args.referenceImage];
|
|
249
|
+
delete args.referenceImage;
|
|
250
|
+
}
|
|
251
|
+
return args;
|
|
252
|
+
},
|
|
253
|
+
|
|
244
254
|
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
245
255
|
const aspectRatio = params.aspectRatio ?? "1:1";
|
|
246
256
|
const imageSize = params.imageSize ?? "1K";
|
|
@@ -265,10 +275,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
265
275
|
inlineData?: { mimeType: string; data: string };
|
|
266
276
|
}> = [];
|
|
267
277
|
let editing = false;
|
|
268
|
-
if (params.
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
278
|
+
if (params.referenceImages && params.referenceImages.length > 0) {
|
|
279
|
+
for (const refPath of params.referenceImages) {
|
|
280
|
+
const ref = await loadReferenceImage(cwd, refPath);
|
|
281
|
+
parts.push({ inlineData: ref });
|
|
282
|
+
editing = true;
|
|
283
|
+
}
|
|
272
284
|
}
|
|
273
285
|
parts.push({ text: params.prompt });
|
|
274
286
|
|
|
@@ -365,8 +377,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
365
377
|
);
|
|
366
378
|
await writeFile(outPath, Buffer.from(base64, "base64"));
|
|
367
379
|
|
|
380
|
+
const refStr = params.referenceImages?.join(", ") ?? "";
|
|
368
381
|
const summary = editing
|
|
369
|
-
? `Edited "${
|
|
382
|
+
? `Edited "${refStr}" → ${outPath}`
|
|
370
383
|
: `Generated → ${outPath}`;
|
|
371
384
|
|
|
372
385
|
return {
|
|
@@ -385,7 +398,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
385
398
|
mimeType,
|
|
386
399
|
outputPath: outPath,
|
|
387
400
|
editing,
|
|
388
|
-
|
|
401
|
+
referenceImages: params.referenceImages,
|
|
389
402
|
},
|
|
390
403
|
};
|
|
391
404
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-banana",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "Generate and edit images in pi using Google Nano Banana 2 (gemini-3.1-flash-image) and Nano Banana Pro. Inline terminal preview, reference-image editing, auto-save.",
|
|
5
5
|
"author": "Francesco Frapporti <effedue@gmail.com>",
|
|
6
6
|
"license": "MIT",
|