pi-render-btw 0.5.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/LICENSE +22 -0
- package/README.md +214 -0
- package/docs/btw-overlay.png +0 -0
- package/extensions/btw.ts +2421 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dan Bachelder (original pi-btw)
|
|
4
|
+
Copyright (c) 2026 ESSO0428 (pi-render-btw — markdown rendering fork)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# pi-render-btw
|
|
2
|
+
|
|
3
|
+
> Fork of [pi-btw](https://github.com/dbachelder/pi-btw) with **markdown rendering** in the floating window.
|
|
4
|
+
|
|
5
|
+
A [pi](https://github.com/earendil-works/pi-mono) extension that adds a `/btw` side conversation channel
|
|
6
|
+
with **full markdown rendering** (syntax highlighting, bold, code blocks, lists, etc.) inside the overlay.
|
|
7
|
+
|
|
8
|
+
`/btw` opens a real pi sub-session with coding-tool access, and it runs immediately even while the main agent is still busy.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
- opens a parallel side conversation without interrupting the main run
|
|
15
|
+
- runs that side conversation as a real pi sub-session with `read` / `bash` / `edit` / `write` tool access
|
|
16
|
+
- keeps a continuous BTW thread by default
|
|
17
|
+
- supports `/btw:tangent` for a contextless side thread that does not inherit the current main-session conversation
|
|
18
|
+
- opens a focused BTW modal shell with its own composer and transcript
|
|
19
|
+
- keeps the BTW overlay open while you switch focus back to the main editor with `Alt+/`
|
|
20
|
+
- keeps BTW thread entries out of the main agent's future context
|
|
21
|
+
- supports BTW-only model and thinking overrides without changing the main thread settings
|
|
22
|
+
- lets you inject the full thread, or a summary of it, back into the main agent
|
|
23
|
+
- optionally saves an individual BTW exchange as a visible session note with `--save`
|
|
24
|
+
|
|
25
|
+
## ✨ Markdown rendering
|
|
26
|
+
|
|
27
|
+
Unlike the original pi-btw, **pi-render-btw** renders assistant responses inside the floating
|
|
28
|
+
window using pi TUI's built-in `Markdown` component. This means:
|
|
29
|
+
|
|
30
|
+
- **Bold**, *italic*, ~~strikethrough~~, `inline code`, and ``code blocks`` with **syntax highlighting**
|
|
31
|
+
- Lists (ordered & unordered), blockquotes, horizontal rules
|
|
32
|
+
- Headings and links
|
|
33
|
+
- Cached rendering for performance — markdown is only re-rendered when the content or terminal width changes
|
|
34
|
+
- Streaming responses fall back to plain text for speed; completed turns are rendered as markdown
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
### From npm
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pi install npm:pi-render-btw
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### From git
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pi install git:github.com/ESSO0428/pi-render-btw
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Then reload pi:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
/reload
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### From a local checkout
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pi install /path/to/pi-render-btw
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
/btw what file defines this route?
|
|
66
|
+
/btw how would you refactor this parser?
|
|
67
|
+
/btw --save summarize the last error in one sentence
|
|
68
|
+
/btw:new let's start a fresh thread about auth
|
|
69
|
+
/btw:tangent brainstorm from first principles without using the current chat context
|
|
70
|
+
/btw:model openai gpt-5-mini openai-responses
|
|
71
|
+
/btw:thinking low
|
|
72
|
+
/btw:inject implement the plan we just discussed
|
|
73
|
+
/btw:summarize turn that side thread into a short handoff
|
|
74
|
+
/btw:clear
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Commands
|
|
78
|
+
|
|
79
|
+
### `/btw [--save] <question>`
|
|
80
|
+
|
|
81
|
+
- runs right away
|
|
82
|
+
- works while pi is busy
|
|
83
|
+
- creates or reuses a real BTW sub-session instead of a one-off completion call
|
|
84
|
+
- continues the current BTW thread
|
|
85
|
+
- opens or refreshes the focused BTW modal shell with **markdown rendering**
|
|
86
|
+
- streams into the BTW modal transcript/status surface
|
|
87
|
+
- persists the BTW exchange as hidden thread state
|
|
88
|
+
- with `--save`, also saves that single exchange as a visible session note
|
|
89
|
+
|
|
90
|
+
## Overlay controls
|
|
91
|
+
|
|
92
|
+
- `Alt+/` toggles focus between BTW and the main editor without closing the overlay
|
|
93
|
+
- `Ctrl+Alt+W` is a fallback focus toggle for terminals that do not deliver `Alt+/` as a usable shortcut
|
|
94
|
+
- `Esc` still dismisses BTW immediately while the overlay is focused
|
|
95
|
+
- BTW opens top-centered so the main session remains visible underneath it
|
|
96
|
+
|
|
97
|
+
### `/btw:new [question]`
|
|
98
|
+
|
|
99
|
+
- clears the current BTW thread
|
|
100
|
+
- starts a fresh thread that still inherits the current main-session context
|
|
101
|
+
- optionally asks the first question in the new thread immediately
|
|
102
|
+
- if no question is provided, opens a fresh BTW modal ready for the next prompt
|
|
103
|
+
|
|
104
|
+
### `/btw:tangent [--save] <question>`
|
|
105
|
+
|
|
106
|
+
- starts or continues a contextless tangent thread
|
|
107
|
+
- does not inherit the current main-session conversation
|
|
108
|
+
- if you switch from `/btw` to `/btw:tangent` (or back), the previous side thread is cleared so the modes do not mix
|
|
109
|
+
- opens or refreshes the same focused BTW modal shell
|
|
110
|
+
- with `--save`, also saves that single exchange as a visible session note
|
|
111
|
+
|
|
112
|
+
### `/btw:clear`
|
|
113
|
+
|
|
114
|
+
- dismisses the BTW modal/widget
|
|
115
|
+
- clears the current BTW thread
|
|
116
|
+
|
|
117
|
+
### `/btw:inject [instructions]`
|
|
118
|
+
|
|
119
|
+
- sends the full BTW thread back to the main agent as a user message
|
|
120
|
+
- if pi is busy, queues it as a follow-up
|
|
121
|
+
- clears the BTW thread after sending
|
|
122
|
+
|
|
123
|
+
### `/btw:summarize [instructions]`
|
|
124
|
+
|
|
125
|
+
- summarizes the BTW thread with the current effective BTW model
|
|
126
|
+
- always runs summarize with thinking off, even if BTW chat is using a thinking override
|
|
127
|
+
- injects the summary into the main agent
|
|
128
|
+
- if pi is busy, queues it as a follow-up
|
|
129
|
+
- clears the BTW thread after sending
|
|
130
|
+
|
|
131
|
+
### `/btw:model [<provider> <model> <api> | clear]`
|
|
132
|
+
|
|
133
|
+
- with no args, shows the current effective BTW model and whether it is inherited or overridden
|
|
134
|
+
- with values, sets a BTW-only model override
|
|
135
|
+
- `clear` removes the override and returns BTW to inheriting the main thread model
|
|
136
|
+
- if the configured BTW model has no credentials, BTW warns and falls back to the main thread model
|
|
137
|
+
|
|
138
|
+
### `/btw:thinking [<level> | clear]`
|
|
139
|
+
|
|
140
|
+
- with no args, shows the current effective BTW thinking level and whether it is inherited or overridden
|
|
141
|
+
- with a value, sets a BTW-only thinking override for normal BTW chat
|
|
142
|
+
- `clear` removes the override and returns BTW to inheriting the main thread thinking level
|
|
143
|
+
- changing `/btw:model` or `/btw:thinking` disposes the current BTW sub-session and applies the new settings on the next BTW prompt while preserving the hidden thread
|
|
144
|
+
|
|
145
|
+
## Behavior
|
|
146
|
+
|
|
147
|
+
### Real sub-session model
|
|
148
|
+
|
|
149
|
+
BTW is implemented as an actual pi sub-session with its own in-memory session state, transcript events, and tool surface.
|
|
150
|
+
|
|
151
|
+
- contextual `/btw` threads seed that sub-session from the current main-session branch while filtering out BTW-visible notes from the parent context
|
|
152
|
+
- `/btw:tangent` starts the same BTW UI in a contextless mode with no inherited main-session conversation
|
|
153
|
+
- BTW can inherit the main thread model/thinking settings or use BTW-only overrides via `/btw:model` and `/btw:thinking`
|
|
154
|
+
- `/btw:summarize` uses the current effective BTW model but keeps thinking off
|
|
155
|
+
- the overlay transcript/status line is driven from sub-session events, so tool activity, streaming deltas, failures, and recovery are all visible without scraping rendered output
|
|
156
|
+
- handoff commands (`/btw:inject` and `/btw:summarize`) read from the BTW sub-session thread rather than maintaining a separate manual transcript model
|
|
157
|
+
|
|
158
|
+
### In-modal slash behavior
|
|
159
|
+
|
|
160
|
+
Inside the BTW modal composer, slash handling is split at the BTW/session boundary:
|
|
161
|
+
|
|
162
|
+
- `/btw:new`, `/btw:tangent`, `/btw:clear`, `/btw:model`, `/btw:thinking`, `/btw:inject`, and `/btw:summarize` stay owned by BTW because they control BTW lifecycle, configuration, or handoff behavior
|
|
163
|
+
- any other slash-prefixed input is routed through the BTW sub-session's normal `prompt()` path
|
|
164
|
+
- this means ordinary pi slash commands like `/help` are handled by the sub-session instead of being rejected by a modal-only fallback
|
|
165
|
+
- if the sub-session cannot handle a slash command, BTW surfaces the real sub-session failure through the transcript/status state instead of inventing an "unsupported slash input" warning
|
|
166
|
+
|
|
167
|
+
This keeps BTW-owned lifecycle commands explicit while giving the side conversation the same slash-command surface as the underlying sub-session.
|
|
168
|
+
|
|
169
|
+
### Hidden BTW thread state
|
|
170
|
+
|
|
171
|
+
BTW exchanges are persisted in the session as hidden custom entries so they:
|
|
172
|
+
|
|
173
|
+
- survive reloads and restarts
|
|
174
|
+
- rehydrate the BTW modal shell for the current branch
|
|
175
|
+
- preserve whether the current side thread is a normal `/btw` thread or a contextless `/btw:tangent`
|
|
176
|
+
- preserve the current BTW-only model and thinking overrides for that session history
|
|
177
|
+
- stay out of the main agent's LLM context
|
|
178
|
+
|
|
179
|
+
### Visible saved notes
|
|
180
|
+
|
|
181
|
+
If you use `--save`, that one BTW exchange is also written as a visible custom message in the session transcript.
|
|
182
|
+
|
|
183
|
+
## Why
|
|
184
|
+
|
|
185
|
+
Sometimes you want to:
|
|
186
|
+
|
|
187
|
+
- ask a clarifying question while the main agent keeps working
|
|
188
|
+
- think through next steps without derailing the current turn
|
|
189
|
+
- explore an idea, then inject it back once it's ready
|
|
190
|
+
|
|
191
|
+
## Development
|
|
192
|
+
|
|
193
|
+
The extension entrypoint is:
|
|
194
|
+
|
|
195
|
+
- `extensions/btw.ts`
|
|
196
|
+
|
|
197
|
+
To use it without installing:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
pi -e /path/to/pi-render-btw
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Differences from pi-btw
|
|
204
|
+
|
|
205
|
+
| Feature | pi-btw | pi-render-btw |
|
|
206
|
+
|---------|--------|---------------|
|
|
207
|
+
| Markdown rendering in overlay | ❌ Plain text only | ✅ Full markdown with syntax highlighting |
|
|
208
|
+
| Cached markdown lines | — | ✅ Per-entry cache, cleared on theme change |
|
|
209
|
+
| Streaming fallback | — | ✅ Plain text during streaming for speed |
|
|
210
|
+
| `invalidate()` on theme change | ❌ No override | ✅ Clears markdown cache for proper theme refresh |
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
MIT — see [LICENSE](LICENSE).
|
|
Binary file
|