@eduardo191labs/opencode-free-pi 0.7.31 → 0.7.32

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
@@ -123,9 +123,10 @@ Después de iniciar sesión, ejecuta `/reload` en OpenCode o reinícialo.
123
123
  funciona es pedir el trabajo explícito: con la regla de «escribe cada paso,
124
124
  recalcula por un segundo método y no respondas hasta que coincidan», el mismo
125
125
  modelo subió de ~450 a ~1250 tokens de razonamiento y acertó 5/5 problemas de
126
- lógica frente a 3/5 sin la regla. Por eso la guía de trabajo prioriza la
127
- respuesta lenta y verificada, y el límite de salida se deja amplio para que
128
- esa cadena no se trunque.
126
+ lógica frente a 3/5 sin la regla. Esa instrucción es una recomendación de uso
127
+ para tu mensaje, no un prompt que el plugin inyecte: el plugin no añade
128
+ instrucciones a la sesión. El límite de salida se deja amplio para que la
129
+ cadena de razonamiento no se trunque.
129
130
  - **Capacidades iguales al CLI**: todos los modelos se registran con
130
131
  razonamiento activo, coste cero, la ventana medida y el límite de salida que
131
132
  publica el upstream (32k por defecto, hasta 131k). No se fuerza temperatura ni
@@ -161,11 +162,11 @@ Después de iniciar sesión, ejecuta `/reload` en OpenCode o reinícialo.
161
162
  - **Timeouts del CLI**: 5 minutos para las cabeceras y para cada trozo de la
162
163
  respuesta, los mismos valores que `httpIdleTimeoutMs` de pi.
163
164
  - Anuncios e impresiones asociados al turno correcto. El contexto del anuncio se
164
- construye solo con el último mensaje real del usuario: se ignoran el
165
- recordatorio del plugin y los mensajes sintéticos que OpenCode inserta en el
166
- mismo turno (resultado de un subagente, salida de un shell en segundo plano,
167
- AGENTS.md, reinicio del servidor o respuesta interrumpida), que antes
168
- rotaban el anuncio a mitad de turno y enviaban ids internos como contexto.
165
+ construye solo con el último mensaje real del usuario: se ignoran los
166
+ mensajes sintéticos que OpenCode inserta en el mismo turno (resultado de un
167
+ subagente, salida de un shell en segundo plano, AGENTS.md, reinicio del
168
+ servidor o respuesta interrumpida), que antes rotaban el anuncio a mitad de
169
+ turno y enviaban ids internos como contexto.
169
170
  - Cada agente y subagente usa su propio `x-session-id`, `x-turn-id` y contexto
170
171
  de anuncios; nunca reutiliza los del agente principal.
171
172
  - **Cierre de sesión**: free-pi limita la cuenta a 4 sesiones simultáneas. El
package/dist/plugin.js CHANGED
@@ -115,18 +115,21 @@ async function setup(ctx) {
115
115
  const buildMain = () => withoutDenied(PROVIDER_ID, buildModels(currentMain, candidates, buildOptions));
116
116
  const buildDefense = () => withoutDenied(DEFENSE_PROVIDER_ID, buildModels(currentDefense, candidates, buildOptions));
117
117
  function indexModelState() {
118
- const mainNow = buildMain();
119
- const defenseNow = buildDefense();
120
- for (const [id, model] of Object.entries(mainNow)) {
118
+ // Rebuilt, not appended: a model that disappears or stops accepting images
119
+ // must stop being treated as image-capable, or a later `read` keeps sending
120
+ // an attachment the current catalog no longer supports.
121
+ const images = new Set();
122
+ for (const [id, model] of Object.entries(buildMain())) {
121
123
  if (model.modalities.input.includes("image")) {
122
- state.imageModels.add(`${PROVIDER_ID}/${id}`);
124
+ images.add(`${PROVIDER_ID}/${id}`);
123
125
  }
124
126
  }
125
- for (const [id, model] of Object.entries(defenseNow)) {
127
+ for (const [id, model] of Object.entries(buildDefense())) {
126
128
  if (model.modalities.input.includes("image")) {
127
- state.imageModels.add(`${DEFENSE_PROVIDER_ID}/${id}`);
129
+ images.add(`${DEFENSE_PROVIDER_ID}/${id}`);
128
130
  }
129
131
  }
132
+ state.imageModels = images;
130
133
  }
131
134
  indexModelState();
132
135
  const credential = await deps.activeCredential().catch(() => undefined);
@@ -161,55 +161,9 @@ async function registerToolHooks(ctx, deps, registrations) {
161
161
  status: event.status,
162
162
  ...(event.status === "completed" ? { result: event.result } : {}),
163
163
  });
164
- nudgeFailedTool(deps, event);
165
164
  replaceUnsupportedImages(deps, event);
166
165
  }));
167
166
  }
168
- /**
169
- * Adds the concrete next step to a tool failure the free models repeat.
170
- *
171
- * The scan of a week of sessions shows the same failures over and over: the
172
- * portable shell scanner rejects a heredoc or a nested-quote one-liner (72
173
- * times), `edit` gets identical strings (12) or an ambiguous `oldString` (8).
174
- * The model reads the bare error and often repeats the call. The hint is short
175
- * and only goes to free-pi sessions; other providers keep their own messages.
176
- */
177
- function nudgeFailedTool(deps, event) {
178
- if (event.status !== "error")
179
- return;
180
- if (!isFreePiSession(deps, event.sessionID))
181
- return;
182
- const error = event.error;
183
- if (!error || typeof error !== "object")
184
- return;
185
- const message = typeof error.message === "string" ? error.message : "";
186
- if (!message)
187
- return;
188
- let hint = "";
189
- if (message.includes("Portable shell scanner cannot analyze command")) {
190
- hint =
191
- " Write the script to a file with the write tool and run that file; on Windows use PowerShell cmdlets instead of cmd syntax.";
192
- }
193
- else if (/No changes to apply: oldString and newString are identical/i.test(message)) {
194
- hint =
195
- " Change the replacement text: oldString and newString must differ. Re-read the line you want to change first.";
196
- }
197
- else if (/Found \d+ matches? for oldString/i.test(message)) {
198
- hint =
199
- " Include enough surrounding lines so oldString matches exactly once, or set replaceAll when every occurrence must change.";
200
- }
201
- else if (/has not been read yet|read it before/i.test(message)) {
202
- hint = " Read the file with the read tool in this turn before editing it.";
203
- }
204
- if (!hint)
205
- return;
206
- try {
207
- error.message = `${message}${hint}`;
208
- }
209
- catch {
210
- // A frozen error still reaches the model unchanged; the hint is best effort.
211
- }
212
- }
213
167
  /**
214
168
  * Models whose upstream accepts images get them natively, so a `read` that
215
169
  * returns a picture must keep the file part. Text-only models would turn it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eduardo191labs/opencode-free-pi",
3
- "version": "0.7.31",
3
+ "version": "0.7.32",
4
4
  "description": "Ad-supported free-pi provider plugin for OpenCode on Windows, Linux, macOS and Termux",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/plugin.ts CHANGED
@@ -146,18 +146,21 @@ async function setup(ctx: Plugin.Context): Promise<() => Promise<void>> {
146
146
  );
147
147
 
148
148
  function indexModelState(): void {
149
- const mainNow = buildMain();
150
- const defenseNow = buildDefense();
151
- for (const [id, model] of Object.entries(mainNow)) {
149
+ // Rebuilt, not appended: a model that disappears or stops accepting images
150
+ // must stop being treated as image-capable, or a later `read` keeps sending
151
+ // an attachment the current catalog no longer supports.
152
+ const images = new Set<string>();
153
+ for (const [id, model] of Object.entries(buildMain())) {
152
154
  if (model.modalities.input.includes("image")) {
153
- state.imageModels.add(`${PROVIDER_ID}/${id}`);
155
+ images.add(`${PROVIDER_ID}/${id}`);
154
156
  }
155
157
  }
156
- for (const [id, model] of Object.entries(defenseNow)) {
158
+ for (const [id, model] of Object.entries(buildDefense())) {
157
159
  if (model.modalities.input.includes("image")) {
158
- state.imageModels.add(`${DEFENSE_PROVIDER_ID}/${id}`);
160
+ images.add(`${DEFENSE_PROVIDER_ID}/${id}`);
159
161
  }
160
162
  }
163
+ state.imageModels = images;
161
164
  }
162
165
  indexModelState();
163
166
 
@@ -239,49 +239,11 @@ async function registerToolHooks(
239
239
  status: event.status,
240
240
  ...(event.status === "completed" ? { result: event.result } : {}),
241
241
  });
242
- nudgeFailedTool(deps, event);
243
242
  replaceUnsupportedImages(deps, event);
244
243
  }),
245
244
  );
246
245
  }
247
246
 
248
- /**
249
- * Adds the concrete next step to a tool failure the free models repeat.
250
- *
251
- * The scan of a week of sessions shows the same failures over and over: the
252
- * portable shell scanner rejects a heredoc or a nested-quote one-liner (72
253
- * times), `edit` gets identical strings (12) or an ambiguous `oldString` (8).
254
- * The model reads the bare error and often repeats the call. The hint is short
255
- * and only goes to free-pi sessions; other providers keep their own messages.
256
- */
257
- function nudgeFailedTool(deps: Deps, event: any): void {
258
- if (event.status !== "error") return;
259
- if (!isFreePiSession(deps, event.sessionID)) return;
260
- const error = event.error;
261
- if (!error || typeof error !== "object") return;
262
- const message = typeof error.message === "string" ? error.message : "";
263
- if (!message) return;
264
- let hint = "";
265
- if (message.includes("Portable shell scanner cannot analyze command")) {
266
- hint =
267
- " Write the script to a file with the write tool and run that file; on Windows use PowerShell cmdlets instead of cmd syntax.";
268
- } else if (/No changes to apply: oldString and newString are identical/i.test(message)) {
269
- hint =
270
- " Change the replacement text: oldString and newString must differ. Re-read the line you want to change first.";
271
- } else if (/Found \d+ matches? for oldString/i.test(message)) {
272
- hint =
273
- " Include enough surrounding lines so oldString matches exactly once, or set replaceAll when every occurrence must change.";
274
- } else if (/has not been read yet|read it before/i.test(message)) {
275
- hint = " Read the file with the read tool in this turn before editing it.";
276
- }
277
- if (!hint) return;
278
- try {
279
- error.message = `${message}${hint}`;
280
- } catch {
281
- // A frozen error still reaches the model unchanged; the hint is best effort.
282
- }
283
- }
284
-
285
247
  /**
286
248
  * Models whose upstream accepts images get them natively, so a `read` that
287
249
  * returns a picture must keep the file part. Text-only models would turn it