pi-banana 2.0.4 → 2.0.8

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.
Files changed (2) hide show
  1. package/extensions/index.ts +27 -12
  2. package/package.json +1 -1
@@ -191,12 +191,13 @@ 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 `referenceImage` to iterate on an existing picture.",
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 referenceImage to banana_image.",
199
+ "For tweaks like 'make the sky purple', pass the previous file path (or paths) as referenceImages to banana_image.",
200
+ "AVOID CHAINED EDITS: Editing an image that has already been edited causes quality loss. If the user asks for a subsequent tweak, prefer starting a brand new generation. Incorporate all their previous and new instructions into a single comprehensive prompt, and use the original reference images (not the intermediate edited outputs) to create a merged composition. Present this fresh generation by default, but comply if they explicitly insist on editing the edited version.",
200
201
  "Default quality 'fast' is right for most asks; switch to 'high' only when the user explicitly wants top quality.",
201
202
  ],
202
203
  parameters: Type.Object({
@@ -225,12 +226,13 @@ export default function (pi: ExtensionAPI) {
225
226
  default: DEFAULT_QUALITY,
226
227
  }),
227
228
  ),
228
- referenceImage: Type.Optional(
229
- Type.String({
229
+ referenceImages: Type.Optional(
230
+ Type.Array(Type.String(), {
230
231
  description:
231
- "Optional path to an existing image (PNG/JPEG/WebP/GIF) to edit or iterate on. " +
232
+ "Provide an ARRAY OF STRINGS containing the paths to existing images " +
233
+ "to edit or iterate on (e.g., ['old1.png', 'old2.png']). " +
232
234
  "Relative paths resolve to the current working directory.",
233
- }),
235
+ })
234
236
  ),
235
237
  outputPath: Type.Optional(
236
238
  Type.String({
@@ -241,6 +243,16 @@ export default function (pi: ExtensionAPI) {
241
243
  ),
242
244
  }),
243
245
 
246
+ prepareArguments(args: any) {
247
+ if (args.referenceImage !== undefined) {
248
+ args.referenceImages = Array.isArray(args.referenceImage)
249
+ ? args.referenceImage
250
+ : [args.referenceImage];
251
+ delete args.referenceImage;
252
+ }
253
+ return args;
254
+ },
255
+
244
256
  async execute(_toolCallId, params, signal, onUpdate, ctx) {
245
257
  const aspectRatio = params.aspectRatio ?? "1:1";
246
258
  const imageSize = params.imageSize ?? "1K";
@@ -265,10 +277,12 @@ export default function (pi: ExtensionAPI) {
265
277
  inlineData?: { mimeType: string; data: string };
266
278
  }> = [];
267
279
  let editing = false;
268
- if (params.referenceImage) {
269
- const ref = await loadReferenceImage(cwd, params.referenceImage);
270
- parts.push({ inlineData: ref });
271
- editing = true;
280
+ if (params.referenceImages && params.referenceImages.length > 0) {
281
+ for (const refPath of params.referenceImages) {
282
+ const ref = await loadReferenceImage(cwd, refPath);
283
+ parts.push({ inlineData: ref });
284
+ editing = true;
285
+ }
272
286
  }
273
287
  parts.push({ text: params.prompt });
274
288
 
@@ -365,8 +379,9 @@ export default function (pi: ExtensionAPI) {
365
379
  );
366
380
  await writeFile(outPath, Buffer.from(base64, "base64"));
367
381
 
382
+ const refStr = params.referenceImages?.join(", ") ?? "";
368
383
  const summary = editing
369
- ? `Edited "${params.referenceImage}" → ${outPath}`
384
+ ? `Edited "${refStr}" → ${outPath}`
370
385
  : `Generated → ${outPath}`;
371
386
 
372
387
  return {
@@ -385,7 +400,7 @@ export default function (pi: ExtensionAPI) {
385
400
  mimeType,
386
401
  outputPath: outPath,
387
402
  editing,
388
- referenceImage: params.referenceImage,
403
+ referenceImages: params.referenceImages,
389
404
  },
390
405
  };
391
406
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-banana",
3
- "version": "2.0.4",
3
+ "version": "2.0.8",
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",