pi-btw 0.8.0 → 0.8.1

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
@@ -25,9 +25,9 @@ A small [pi](https://github.com/earendil-works/pi-mono) extension that adds a `/
25
25
 
26
26
  pi-btw supports Pi 0.85.1 through 1.x.
27
27
 
28
- Development dependencies target Pi 0.99.2. CI runs the tests and typecheck
28
+ Development dependencies target Pi 1.5.0. CI runs the tests and typecheck
29
29
  against the locked dependencies, Pi 0.85.1, and the latest published Pi release
30
- on each PR and weekly. Pi 0.99.2 requires Node.js 22.19.0 or newer.
30
+ on each PR and weekly. Pi 1.5.0 requires Node.js 22.19.0 or newer.
31
31
 
32
32
  ### From npm (after publish)
33
33
 
package/extensions/btw.ts CHANGED
@@ -311,8 +311,11 @@ function isCustomEntry(entry: unknown, customType: string): entry is { type: "cu
311
311
 
312
312
  function stripDynamicSystemPromptFooter(systemPrompt: string): string {
313
313
  return systemPrompt
314
- .replace(/\nCurrent date and time:[^\n]*(?:\nCurrent working directory:[^\n]*)?$/u, "")
315
- .replace(/\nCurrent working directory:[^\n]*$/u, "")
314
+ // Older Pi ends a custom prompt's footer with a newline, so allow trailing whitespace.
315
+ .replace(/\nCurrent date and time:[^\n]*(?:\nCurrent working directory:[^\n]*)?\s*$/u, "")
316
+ .replace(/\nCurrent working directory:[^\n]*\s*$/u, "")
317
+ // Pi 0.99+ renders the cwd as a `<cwd>` section, which the child adds again itself.
318
+ .replace(/(?:^|\n\n)<cwd>\n[^\n]*\n<\/cwd>(?=\n\n|$)/gu, "")
316
319
  .trim();
317
320
  }
318
321
 
@@ -2378,7 +2381,7 @@ export default function (pi: ExtensionAPI) {
2378
2381
  await resetThread(ctx, true, "contextual");
2379
2382
  }
2380
2383
 
2381
- await runBtw(ctx, question, save, "contextual");
2384
+ await startBtw(ctx, question, save, "contextual");
2382
2385
  return true;
2383
2386
  }
2384
2387
 
@@ -2398,7 +2401,7 @@ export default function (pi: ExtensionAPI) {
2398
2401
  return true;
2399
2402
  }
2400
2403
 
2401
- await runBtw(ctx, question, save, "tangent");
2404
+ await startBtw(ctx, question, save, "tangent");
2402
2405
  return true;
2403
2406
  }
2404
2407
 
@@ -2421,7 +2424,7 @@ export default function (pi: ExtensionAPI) {
2421
2424
  return true;
2422
2425
  }
2423
2426
 
2424
- await runBtw(ctx, question, save, "readonly");
2427
+ await startBtw(ctx, question, save, "readonly");
2425
2428
  return true;
2426
2429
  }
2427
2430
 
@@ -2434,7 +2437,7 @@ export default function (pi: ExtensionAPI) {
2434
2437
 
2435
2438
  await resetThread(ctx, true, "contextual");
2436
2439
  if (question) {
2437
- await runBtw(ctx, question, save, "contextual");
2440
+ await startBtw(ctx, question, save, "contextual");
2438
2441
  } else {
2439
2442
  await ensureBtwSession(ctx, "contextual");
2440
2443
  setOverlayStatus("Started a fresh BTW thread.", ctx);
@@ -2687,6 +2690,24 @@ export default function (pi: ExtensionAPI) {
2687
2690
  syncUi(ctx);
2688
2691
  }
2689
2692
 
2693
+ // Pi's interactive loop awaits command handlers, so waiting for the answer here
2694
+ // would hold every main-editor submit until BTW finishes. The overlay shows the
2695
+ // turn in the TUI; other modes deliver the answer as a session note, so a one-shot
2696
+ // run has to wait for it.
2697
+ function startBtw(
2698
+ ctx: ExtensionCommandContext,
2699
+ question: string,
2700
+ saveRequested: boolean,
2701
+ mode: BtwThreadMode,
2702
+ ): Promise<void> {
2703
+ const turn = runBtw(ctx, question, saveRequested, mode);
2704
+ if (!canRenderBtwOverlay(ctx)) {
2705
+ return turn;
2706
+ }
2707
+ turn.catch((error) => notify(ctx, error instanceof Error ? error.message : String(error), "error"));
2708
+ return Promise.resolve();
2709
+ }
2710
+
2690
2711
  async function runBtw(
2691
2712
  ctx: ExtensionCommandContext,
2692
2713
  question: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-btw",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "A pi extension for parallel side conversations with /btw",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -49,9 +49,9 @@
49
49
  "@earendil-works/pi-tui": ">=0.85.1 <2"
50
50
  },
51
51
  "devDependencies": {
52
- "@earendil-works/pi-ai": "0.99.2",
53
- "@earendil-works/pi-coding-agent": "0.99.2",
54
- "@earendil-works/pi-tui": "0.99.2",
52
+ "@earendil-works/pi-ai": "1.5.0",
53
+ "@earendil-works/pi-coding-agent": "1.5.0",
54
+ "@earendil-works/pi-tui": "1.5.0",
55
55
  "typescript": "^6.0.2",
56
56
  "vitest": "^4.1.11"
57
57
  }