pi-btw 0.3.8 → 0.4.0

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
@@ -1,6 +1,6 @@
1
1
  # pi-btw
2
2
 
3
- A small [pi](https://github.com/badlogic/pi-mono) extension that adds a `/btw` side conversation channel.
3
+ A small [pi](https://github.com/earendil-works/pi-mono) extension that adds a `/btw` side conversation channel.
4
4
 
5
5
  `/btw` opens a real pi sub-session with coding-tool access, and it runs immediately even while the main agent is still busy.
6
6
 
package/extensions/btw.ts CHANGED
@@ -2,7 +2,6 @@ import {
2
2
  buildSessionContext,
3
3
  createAgentSession,
4
4
  createExtensionRuntime,
5
- codingTools,
6
5
  SessionManager,
7
6
  type AgentSession,
8
7
  type AgentSessionEvent,
@@ -10,8 +9,8 @@ import {
10
9
  type ExtensionCommandContext,
11
10
  type ExtensionContext,
12
11
  type ResourceLoader,
13
- } from "@mariozechner/pi-coding-agent";
14
- import { type AssistantMessage, type Message, type ThinkingLevel as AiThinkingLevel, type UserMessage } from "@mariozechner/pi-ai";
12
+ } from "@earendil-works/pi-coding-agent";
13
+ import { type AssistantMessage, type Message, type ThinkingLevel as AiThinkingLevel, type UserMessage } from "@earendil-works/pi-ai";
15
14
  import {
16
15
  Box,
17
16
  Container,
@@ -26,7 +25,7 @@ import {
26
25
  type KeybindingsManager,
27
26
  type OverlayHandle,
28
27
  type TUI,
29
- } from "@mariozechner/pi-tui";
28
+ } from "@earendil-works/pi-tui";
30
29
 
31
30
  const BTW_MESSAGE_TYPE = "btw-note";
32
31
  const BTW_ENTRY_TYPE = "btw-thread-entry";
@@ -56,6 +55,11 @@ const BTW_CONTINUE_THREAD_ASSISTANT_TEXT = "Understood, continuing our side conv
56
55
  type SessionThinkingLevel = "off" | AiThinkingLevel;
57
56
  type BtwThreadMode = "contextual" | "tangent";
58
57
  type SessionModel = NonNullable<ExtensionCommandContext["model"]>;
58
+ /**
59
+ * Loose model reference parsed from `/btw:model <provider> <id> <api>` and persisted to
60
+ * session entries. Resolved to a full SessionModel via ctx.modelRegistry.find(...).
61
+ */
62
+ type BtwModelRef = Pick<SessionModel, "provider" | "id" | "api">;
59
63
 
60
64
  type BtwDetails = {
61
65
  question: string;
@@ -216,7 +220,7 @@ function parseBtwArgs(args: string): ParsedBtwArgs {
216
220
  function parseBtwModelArgs(args: string):
217
221
  | { action: "show" }
218
222
  | { action: "clear" }
219
- | { action: "set"; model: SessionModel }
223
+ | { action: "set"; model: BtwModelRef }
220
224
  | { action: "invalid"; message: string } {
221
225
  const trimmed = args.trim();
222
226
  if (!trimmed) {
@@ -233,7 +237,7 @@ function parseBtwModelArgs(args: string):
233
237
  }
234
238
 
235
239
  const [provider, id, api] = parts;
236
- return { action: "set", model: { provider, id, api } };
240
+ return { action: "set", model: { provider, id, api } as BtwModelRef };
237
241
  }
238
242
 
239
243
  function parseBtwThinkingArgs(args: string):
@@ -1555,7 +1559,8 @@ export default function (pi: ExtensionAPI) {
1555
1559
  model: settings.model,
1556
1560
  modelRegistry: ctx.modelRegistry as AgentSession["modelRegistry"],
1557
1561
  thinkingLevel: settings.thinkingLevel,
1558
- tools: codingTools,
1562
+ // Match pi's default coding-agent toolset (read/bash/edit/write).
1563
+ tools: ["read", "bash", "edit", "write"],
1559
1564
  resourceLoader: createBtwResourceLoader(ctx),
1560
1565
  });
1561
1566
 
@@ -1760,7 +1765,19 @@ export default function (pi: ExtensionAPI) {
1760
1765
  return true;
1761
1766
  }
1762
1767
 
1763
- await setBtwModelOverride(ctx, parsed.action === "clear" ? null : parsed.model);
1768
+ if (parsed.action === "clear") {
1769
+ await setBtwModelOverride(ctx, null);
1770
+ return true;
1771
+ }
1772
+ const ref = parsed.model;
1773
+ const resolved = ctx.modelRegistry.find(ref.provider, ref.id);
1774
+ if (!resolved) {
1775
+ const message = `Unknown model ${ref.provider}/${ref.id}. Use /login or /models to add it before setting it as the BTW override.`;
1776
+ setOverlayStatus(message, ctx);
1777
+ notify(ctx, message, "error");
1778
+ return true;
1779
+ }
1780
+ await setBtwModelOverride(ctx, resolved);
1764
1781
  return true;
1765
1782
  }
1766
1783
 
@@ -1911,17 +1928,22 @@ export default function (pi: ExtensionAPI) {
1911
1928
 
1912
1929
  for (let i = 0; i < branch.length; i++) {
1913
1930
  if (isCustomEntry(branch[i], BTW_MODEL_OVERRIDE_TYPE)) {
1914
- const details = branch[i].data as BtwModelOverrideDetails | undefined;
1915
- btwModelOverride =
1916
- details?.action === "set"
1917
- ? { provider: details.provider, id: details.id, api: details.api }
1918
- : details?.action === "clear"
1919
- ? null
1920
- : btwModelOverride;
1931
+ const details = (branch[i] as unknown as { data?: BtwModelOverrideDetails }).data;
1932
+ if (details?.action === "set") {
1933
+ const resolved = ctx.modelRegistry.find(details.provider, details.id);
1934
+ if (resolved) {
1935
+ btwModelOverride = resolved;
1936
+ } else {
1937
+ // Configured override is no longer in the registry; drop it on restore.
1938
+ btwModelOverride = null;
1939
+ }
1940
+ } else if (details?.action === "clear") {
1941
+ btwModelOverride = null;
1942
+ }
1921
1943
  }
1922
1944
 
1923
1945
  if (isCustomEntry(branch[i], BTW_THINKING_OVERRIDE_TYPE)) {
1924
- const details = branch[i].data as BtwThinkingOverrideDetails | undefined;
1946
+ const details = (branch[i] as unknown as { data?: BtwThinkingOverrideDetails }).data;
1925
1947
  btwThinkingOverride =
1926
1948
  details?.action === "set"
1927
1949
  ? details.thinkingLevel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-btw",
3
- "version": "0.3.8",
3
+ "version": "0.4.0",
4
4
  "description": "A pi extension for parallel side conversations with /btw",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,9 +42,9 @@
42
42
  "image": "https://raw.githubusercontent.com/dbachelder/pi-btw/main/docs/btw-overlay.png"
43
43
  },
44
44
  "peerDependencies": {
45
- "@mariozechner/pi-ai": "^0.66.1",
46
- "@mariozechner/pi-coding-agent": "^0.66.1",
47
- "@mariozechner/pi-tui": "^0.66.1"
45
+ "@earendil-works/pi-ai": "^0.74.0",
46
+ "@earendil-works/pi-coding-agent": "^0.74.0",
47
+ "@earendil-works/pi-tui": "^0.74.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "typescript": "^6.0.2",