@juicesharp/rpiv-btw 0.1.1 → 0.7.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 +1 -1
- package/btw-ui.ts +11 -36
- package/btw.ts +3 -9
- package/index.ts +1 -5
- package/package.json +16 -6
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Ask a side question without polluting the main conversation. `rpiv-btw` adds `/btw <question>` to [Pi Agent](https://github.com/badlogic/pi-mono) — a lightweight side agent picks up a **read-only clone** of your current conversation and answers in a panel at the bottom of the terminal. The side agent remembers its own `/btw` thread for follow-ups, while your main chat keeps going — its transcript is never polluted.
|
|
7
7
|
|
|
8
|
-

|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
package/btw-ui.ts
CHANGED
|
@@ -24,21 +24,18 @@
|
|
|
24
24
|
* (f fork key deferred)
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import type {
|
|
28
|
-
|
|
29
|
-
Theme,
|
|
30
|
-
} from "@mariozechner/pi-coding-agent";
|
|
27
|
+
import type { ExtensionCommandContext, Theme } from "@mariozechner/pi-coding-agent";
|
|
28
|
+
import type { OverlayOptions } from "@mariozechner/pi-tui";
|
|
31
29
|
import {
|
|
30
|
+
type Component,
|
|
32
31
|
Key,
|
|
33
32
|
matchesKey,
|
|
34
|
-
|
|
33
|
+
type TUI,
|
|
35
34
|
truncateToWidth,
|
|
35
|
+
visibleWidth,
|
|
36
36
|
wrapTextWithAnsi,
|
|
37
|
-
type Component,
|
|
38
|
-
type TUI,
|
|
39
37
|
} from "@mariozechner/pi-tui";
|
|
40
|
-
import type
|
|
41
|
-
import { userMessageText, type BtwTurn } from "./btw.js";
|
|
38
|
+
import { type BtwTurn, userMessageText } from "./btw.js";
|
|
42
39
|
|
|
43
40
|
const BTW_OVERLAY_OPTIONS: OverlayOptions = {
|
|
44
41
|
anchor: "bottom-center",
|
|
@@ -85,7 +82,7 @@ export class BtwOverlayController implements Component {
|
|
|
85
82
|
history: BtwTurn[],
|
|
86
83
|
private readonly theme: Theme,
|
|
87
84
|
private readonly tui: TUI,
|
|
88
|
-
private readonly done: (result
|
|
85
|
+
private readonly done: (result?: undefined) => void,
|
|
89
86
|
private readonly controller: AbortController,
|
|
90
87
|
private readonly onClearHistory: () => void,
|
|
91
88
|
) {
|
|
@@ -131,9 +128,7 @@ export class BtwOverlayController implements Component {
|
|
|
131
128
|
|
|
132
129
|
render(width: number): string[] {
|
|
133
130
|
const banner = this.renderBanner(width);
|
|
134
|
-
const historyLines = this.history.map((h) =>
|
|
135
|
-
this.historyLine(userMessageText(h.userMessage), width),
|
|
136
|
-
);
|
|
131
|
+
const historyLines = this.history.map((h) => this.historyLine(userMessageText(h.userMessage), width));
|
|
137
132
|
const echoLine = this.echoLine(this.question, width);
|
|
138
133
|
const answerLines = this.renderAnswer(width);
|
|
139
134
|
const footerAvail = Math.max(1, width - SIDE_PAD.length);
|
|
@@ -142,25 +137,10 @@ export class BtwOverlayController implements Component {
|
|
|
142
137
|
if (this.history.length > 0) footerParts.push(FOOTER_CLEAR);
|
|
143
138
|
footerParts.push(FOOTER_DISMISS);
|
|
144
139
|
const footer =
|
|
145
|
-
SIDE_PAD +
|
|
146
|
-
truncateToWidth(
|
|
147
|
-
this.theme.fg("dim", footerParts.join(FOOTER_SEP)),
|
|
148
|
-
footerAvail,
|
|
149
|
-
"…",
|
|
150
|
-
false,
|
|
151
|
-
);
|
|
140
|
+
SIDE_PAD + truncateToWidth(this.theme.fg("dim", footerParts.join(FOOTER_SEP)), footerAvail, "…", false);
|
|
152
141
|
|
|
153
142
|
// Natural content: banner + blank + history + echo + blank + answer + blank + footer
|
|
154
|
-
const natural: string[] = [
|
|
155
|
-
banner,
|
|
156
|
-
"",
|
|
157
|
-
...historyLines,
|
|
158
|
-
echoLine,
|
|
159
|
-
"",
|
|
160
|
-
...answerLines,
|
|
161
|
-
"",
|
|
162
|
-
footer,
|
|
163
|
-
];
|
|
143
|
+
const natural: string[] = [banner, "", ...historyLines, echoLine, "", ...answerLines, "", footer];
|
|
164
144
|
|
|
165
145
|
// Clip to terminal height if we overflow. Bottom-anchor keeps footer+answer visible;
|
|
166
146
|
// ↑/↓ scrolls the top (history) up into the clipped region.
|
|
@@ -204,12 +184,7 @@ export class BtwOverlayController implements Component {
|
|
|
204
184
|
const qAvail = Math.max(0, bodyAvail - prefixWidth);
|
|
205
185
|
const qClean = question.replace(/\s+/g, " ").trim();
|
|
206
186
|
const qTrunc = truncateToWidth(qClean, qAvail, "…", false);
|
|
207
|
-
return (
|
|
208
|
-
SIDE_PAD +
|
|
209
|
-
this.theme.fg("accent", BTW_LITERAL) +
|
|
210
|
-
" " +
|
|
211
|
-
this.theme.fg("muted", qTrunc)
|
|
212
|
-
);
|
|
187
|
+
return `${SIDE_PAD + this.theme.fg("accent", BTW_LITERAL)} ${this.theme.fg("muted", qTrunc)}`;
|
|
213
188
|
}
|
|
214
189
|
|
|
215
190
|
private renderAnswer(width: number): string[] {
|
package/btw.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
import { readFileSync } from "node:fs";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import {
|
|
13
|
-
completeSimple,
|
|
14
13
|
type AssistantMessage,
|
|
14
|
+
completeSimple,
|
|
15
15
|
type Message,
|
|
16
16
|
type StopReason,
|
|
17
17
|
type UserMessage,
|
|
@@ -158,9 +158,7 @@ function getCrossSessionHint(): string {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
if (allTurns.length === 0) return "";
|
|
161
|
-
const recent = allTurns
|
|
162
|
-
.sort((a, b) => a.ts - b.ts)
|
|
163
|
-
.slice(-CROSS_SESSION_HINT_LIMIT);
|
|
161
|
+
const recent = allTurns.sort((a, b) => a.ts - b.ts).slice(-CROSS_SESSION_HINT_LIMIT);
|
|
164
162
|
const lines = recent.map((t, i) => `${i + 1}. ${t.q.replace(/\s+/g, " ").slice(0, 200)}`);
|
|
165
163
|
return `\n\n## Recent /btw questions across sessions (oldest first)\n\n${lines.join("\n")}`;
|
|
166
164
|
}
|
|
@@ -303,11 +301,7 @@ export function registerBtwCommand(pi: ExtensionAPI): void {
|
|
|
303
301
|
});
|
|
304
302
|
}
|
|
305
303
|
|
|
306
|
-
async function handleBtwCommand(
|
|
307
|
-
_pi: ExtensionAPI,
|
|
308
|
-
args: string,
|
|
309
|
-
ctx: ExtensionCommandContext,
|
|
310
|
-
): Promise<void> {
|
|
304
|
+
async function handleBtwCommand(_pi: ExtensionAPI, args: string, ctx: ExtensionCommandContext): Promise<void> {
|
|
311
305
|
if (!ctx.hasUI) {
|
|
312
306
|
ctx.ui.notify(MSG_REQUIRES_INTERACTIVE, "error");
|
|
313
307
|
return;
|
package/index.ts
CHANGED
|
@@ -8,11 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
11
|
-
import {
|
|
12
|
-
registerBtwCommand,
|
|
13
|
-
registerInvalidationHooks,
|
|
14
|
-
registerMessageEndSnapshot,
|
|
15
|
-
} from "./btw.js";
|
|
11
|
+
import { registerBtwCommand, registerInvalidationHooks, registerMessageEndSnapshot } from "./btw.js";
|
|
16
12
|
|
|
17
13
|
export default function (pi: ExtensionAPI): void {
|
|
18
14
|
registerBtwCommand(pi);
|
package/package.json
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-btw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Pi extension: /btw side-question slash command — ask the same primary model a one-off side question without polluting the main conversation",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi-extension",
|
|
8
|
+
"rpiv",
|
|
9
|
+
"btw",
|
|
10
|
+
"side-question",
|
|
11
|
+
"overlay"
|
|
12
|
+
],
|
|
6
13
|
"type": "module",
|
|
7
14
|
"license": "MIT",
|
|
8
15
|
"author": "juicesharp",
|
|
9
16
|
"repository": {
|
|
10
17
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/juicesharp/rpiv-
|
|
18
|
+
"url": "git+https://github.com/juicesharp/rpiv-mono.git",
|
|
19
|
+
"directory": "packages/rpiv-btw"
|
|
12
20
|
},
|
|
13
|
-
"homepage": "https://github.com/juicesharp/rpiv-btw#readme",
|
|
21
|
+
"homepage": "https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-btw#readme",
|
|
14
22
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/juicesharp/rpiv-
|
|
23
|
+
"url": "https://github.com/juicesharp/rpiv-mono/issues"
|
|
16
24
|
},
|
|
17
25
|
"publishConfig": {
|
|
18
26
|
"access": "public"
|
|
@@ -26,7 +34,9 @@
|
|
|
26
34
|
"LICENSE"
|
|
27
35
|
],
|
|
28
36
|
"pi": {
|
|
29
|
-
"extensions": [
|
|
37
|
+
"extensions": [
|
|
38
|
+
"./index.ts"
|
|
39
|
+
]
|
|
30
40
|
},
|
|
31
41
|
"peerDependencies": {
|
|
32
42
|
"@mariozechner/pi-ai": "*",
|