@xynogen/pix-optimizer 1.0.1 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-optimizer",
3
- "version": "1.0.1",
3
+ "version": "1.0.6",
4
4
  "description": "Performance optimization suite for Pi Coding Agent - caveman mode + RTK tool rewriting + jq/TOON JSON compression",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -15,6 +15,9 @@
15
15
  "pi": {
16
16
  "extensions": [
17
17
  "./src/index.ts"
18
+ ],
19
+ "skills": [
20
+ "./src/skills"
18
21
  ]
19
22
  },
20
23
  "keywords": [
package/src/json.ts CHANGED
@@ -223,10 +223,16 @@ export function json(
223
223
  status: OptimizerStatus,
224
224
  ): OptimizerHandle {
225
225
  let enabled = true;
226
+ let jqAvailable: boolean | null = null;
227
+ let toonAvailable: boolean | null = null;
226
228
 
227
229
  // Report into the shared optimizer indicator.
228
230
  function syncStatus(ctx: Pick<ExtensionContext, "ui">) {
229
- status.set("toon", enabled, ctx);
231
+ status.set(
232
+ "toon",
233
+ enabled && jqAvailable !== false && toonAvailable !== false,
234
+ ctx,
235
+ );
230
236
  }
231
237
 
232
238
  pi.on("session_start", async (_event, ctx) => {
@@ -247,10 +253,36 @@ export function json(
247
253
 
248
254
  // Inject the JSON-handling nudge into the system prompt, but ONLY when the
249
255
  // user prompt actually mentions JSON / a related token — otherwise it's dead
250
- // weight in every turn.
251
- pi.on("before_agent_start", async (event) => {
256
+ // weight in every turn. Probe jq/toon lazily here (not at session_start) so
257
+ // we don't add startup overhead for a workflow the user may never trigger.
258
+ pi.on("before_agent_start", async (event, ctx) => {
252
259
  if (!enabled) return undefined;
253
260
  if (!mentionsJson(event.prompt)) return undefined;
261
+
262
+ // Probe once on first JSON-relevant prompt.
263
+ if (jqAvailable === null || toonAvailable === null) {
264
+ const [jqRes, toonRes] = await Promise.all([
265
+ pi.exec("which", ["jq"], { timeout: 1000 }).catch(() => ({ code: 1 })),
266
+ pi
267
+ .exec("which", ["toon"], { timeout: 1000 })
268
+ .catch(() => ({ code: 1 })),
269
+ ]);
270
+ jqAvailable = jqRes.code === 0;
271
+ toonAvailable = toonRes.code === 0;
272
+ if (!jqAvailable)
273
+ ctx.ui.notify(
274
+ "jq not found — JSON/TOON guidance disabled. Install: sudo apt install jq or brew install jq",
275
+ "warning",
276
+ );
277
+ if (!toonAvailable)
278
+ ctx.ui.notify(
279
+ "toon not found — JSON/TOON guidance disabled. Install: bun add -g @toon-format/cli or npm i -g @toon-format/cli",
280
+ "warning",
281
+ );
282
+ syncStatus(ctx);
283
+ }
284
+
285
+ if (jqAvailable === false || toonAvailable === false) return undefined;
254
286
  const existing = event.systemPrompt ?? "";
255
287
  return { systemPrompt: `${JSON_SYSTEM_PROMPT}\n\n${existing}` };
256
288
  });
package/src/rtk.ts CHANGED
@@ -286,7 +286,14 @@ export function rtk(
286
286
  // Keep the status indicator in sync across the agent lifecycle. Probe
287
287
  // availability on session start so the icon reflects reality immediately.
288
288
  pi.on("session_start", async (_event, ctx) => {
289
- await checkRtkAvailability();
289
+ const probe = await checkRtkAvailability();
290
+ if (!probe.available && !warnedMissing) {
291
+ ctx.ui.notify(
292
+ "rtk not found — RTK rewriting disabled. Install: cargo install rtk-ai",
293
+ "warning",
294
+ );
295
+ warnedMissing = true;
296
+ }
290
297
  syncStatus(ctx);
291
298
  });
292
299
  pi.on("agent_start", async (_event, ctx) => {
@@ -340,13 +347,6 @@ export function rtk(
340
347
  const probe = await checkRtkAvailability();
341
348
 
342
349
  if (!probe.available) {
343
- if (!warnedMissing) {
344
- ctx.ui.notify(
345
- "RTK binary not found. Install: cargo install rtk-ai",
346
- "warning",
347
- );
348
- warnedMissing = true;
349
- }
350
350
  return undefined; // Don't rewrite if rtk not available
351
351
  }
352
352