@narumitw/pi-btw 0.57.0 β 0.58.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 +57 -141
- package/dist/index.ts +466 -41
- package/dist/index.ts.map +4 -4
- package/docs/workflows.md +74 -0
- package/package.json +2 -1
- package/src/btw.ts +15 -1
- package/src/fullscreen-ui.ts +32 -2
- package/src/keybindings.ts +330 -0
- package/src/menu.ts +136 -19
- package/src/settings.ts +32 -0
- package/src/side-thread.ts +57 -5
- package/src/transcript-pager.ts +52 -30
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Only context you explicitly bring back is loaded into the main editor.
|
|
|
13
13
|
- Keeps side questions and answers out of the main conversation by default.
|
|
14
14
|
- Brings back the latest answer, a question suffix, an exact range, or the complete thread only when requested.
|
|
15
15
|
- Uses Pi's current model and thinking level or saved pi-btw choices.
|
|
16
|
+
- Offers BTW-only exit, thinking-cycle, and bring-to-main keybindings.
|
|
16
17
|
|
|
17
18
|
## π¦ Install
|
|
18
19
|
|
|
@@ -43,117 +44,16 @@ The side thread stays separate until you explicitly bring context to the main ed
|
|
|
43
44
|
|
|
44
45
|
## π¬ Commands
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
| Command | Purpose |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `/btw` | Choose context, start or resume a side thread, or change settings. |
|
|
50
|
+
| `/btw <question>` | Start a new side thread immediately with the supplied question. |
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Examples:
|
|
55
|
-
|
|
56
|
-
```text
|
|
57
|
-
/btw
|
|
58
|
-
/btw what does this TypeScript error mean?
|
|
59
|
-
/btw summarize the current implementation before we continue
|
|
60
|
-
/btw is this API name idiomatic?
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Choose context or resume a thread
|
|
64
|
-
|
|
65
|
-
Running `/btw` opens a manager with **Start side thread** selected first.
|
|
66
|
-
**Start from main thread treeβ¦** opens Pi's session tree and uses the root-to-selected-entry path, including the selected entry, as context.
|
|
67
|
-
This choice preserves the main editor draft and does not navigate, fork, append to, or switch the main conversation.
|
|
68
|
-
The tree is a snapshot of persisted entries, and the side thread keeps immutable context even if the main conversation later changes.
|
|
69
|
-
Escape returns to the manager, and Ctrl+C closes the flow.
|
|
70
|
-
Native tree copying reports success or failure.
|
|
71
|
-
An explicit `Shift+L` label edit is the only main-session mutation available from this selector and persists through Pi.
|
|
72
|
-
|
|
73
|
-
When non-empty threads exist in memory, **Resume side thread** opens a bounded searchable list.
|
|
74
|
-
Search matches the first question and question count while retaining each raw thread ID.
|
|
75
|
-
Each row uses the first question as its fixed title and shows the question count.
|
|
76
|
-
Rows are ordered by the newest recorded answer or visible error; opening and closing without a new result does not reorder them.
|
|
77
|
-
**Settings** controls the starting thinking level, fixed-level shortcut memory, and automatic selection copying.
|
|
78
|
-
`/btw <question>` bypasses the manager and always starts a new thread.
|
|
79
|
-
|
|
80
|
-
### Use the side-thread workspace
|
|
81
|
-
|
|
82
|
-
The side thread uses a dedicated full-screen terminal view with answers above the editor.
|
|
83
|
-
The main agent can continue running, but main-screen rendering stays suspended until `/btw` closes so new output cannot move a mouse selection.
|
|
84
|
-
Returning to Pi redraws everything produced while the main view was hidden.
|
|
85
|
-
|
|
86
|
-
A fixed `btw Β· side thread` header identifies the workspace while scrolling.
|
|
87
|
-
Messages use Pi's normal user and assistant presentation without turn numbers or role labels.
|
|
88
|
-
Type a question and press Enter for each turn.
|
|
89
|
-
Previous successful questions and answers remain visible and available to the side model.
|
|
90
|
-
|
|
91
|
-
Drag the primary mouse button across transcript text to select it.
|
|
92
|
-
Automatic selection copying is on by default and immediately requests a copy through Pi's host clipboard helper.
|
|
93
|
-
When **Copy selection automatically** is off, the selection stays highlighted and Pi's effective `app.message.copy` binding copies it.
|
|
94
|
-
Manual mode requires Pi's current fullscreen selection APIs.
|
|
95
|
-
If those APIs are unavailable, pi-btw restores the main TUI and asks you to update Pi or re-enable automatic copying.
|
|
96
|
-
The view reports `No selection to copy` when that binding is used without an active selection.
|
|
97
|
-
It reports `Copied!` when Pi accepts a clipboard request and `Copy failed` when Pi rejects it.
|
|
98
|
-
Actual clipboard access still depends on the operating system and terminal.
|
|
99
|
-
Ctrl+C always cancels the side flow, even when `app.message.copy` is also mapped to Ctrl+C.
|
|
100
|
-
|
|
101
|
-
Press `Ctrl+Shift+F` to search completed or in-progress transcript content.
|
|
102
|
-
Press Enter or `Ctrl+G` for the next match, `Shift+Enter` or `Ctrl+Shift+G` for the previous match, and Escape to close search.
|
|
103
|
-
Search uses Pi's active theme, excludes fixed header and footer text, and returns focus to the composer when closed.
|
|
104
|
-
|
|
105
|
-
### Change thinking level or queue steering
|
|
106
|
-
|
|
107
|
-
The header shows the side thread's current thinking level.
|
|
108
|
-
In the composer, use Pi's configured `app.thinking.cycle` shortcut (`Shift+Tab` by default) to cycle levels supported by the side model.
|
|
109
|
-
Later questions use the displayed level until it changes again.
|
|
110
|
-
For a fixed starting level, shortcut changes are saved to `pi-btw.json` by default.
|
|
111
|
-
Turn **Remember thinking level changes** off to keep them local to the thread.
|
|
112
|
-
With **Same as main thread**, shortcut changes are always local.
|
|
113
|
-
Neither setting changes the main session's thinking level.
|
|
114
|
-
|
|
115
|
-
During a response, the transcript and composer remain visible above `Answeringβ¦`.
|
|
116
|
-
Submit another question to queue it as `Steering`.
|
|
117
|
-
Queued questions appear in submission order and run one at a time after the active response.
|
|
118
|
-
Each queued question uses the side thread's thinking level when its turn starts.
|
|
119
|
-
A failed response remains visible and does not discard later queued questions.
|
|
120
|
-
Steering never appends to the main conversation or editor.
|
|
121
|
-
|
|
122
|
-
Use the mouse wheel, trackpad, or `PgUp`/`PgDn` to scroll transcript history.
|
|
123
|
-
On Pi 0.85 or newer, scrolling away from a following transcript shows **Jump to latest message** over its final visible row.
|
|
124
|
-
Click the control or use Pi's effective `tui.altScreen.bottom` binding (`End` by default) to resume at the latest content.
|
|
125
|
-
The control disappears after the transcript returns to follow-end mode.
|
|
126
|
-
The footer shows history keys only when scrolling is available.
|
|
127
|
-
Ctrl+C cancels the active response and discards the current draft and steering queue.
|
|
128
|
-
Completed questions, answers, and visible errors remain available through Resume until the extension instance ends.
|
|
129
|
-
|
|
130
|
-
### Bring context to the main editor
|
|
131
|
-
|
|
132
|
-
After a successful answer, press `Ctrl+R` to choose context for the main editor.
|
|
133
|
-
The scope menu shows the size of the latest question and answer and the full thread.
|
|
134
|
-
Choose the latest question and answer, everything from one question onward, an exact range, or the full thread.
|
|
135
|
-
Question-suffix, exact-range, and full-thread choices preview the editable context block before the side thread closes.
|
|
136
|
-
Escape returns, while Ctrl+C closes without bringing context back.
|
|
137
|
-
|
|
138
|
-
The exact-range selector supports whole-line and editor-style character selection.
|
|
139
|
-
It reports selected line, message, and approximate token counts.
|
|
140
|
-
Press Space to select the current raw source line, use Up or Down to extend by lines, and press Space again to clear.
|
|
141
|
-
Alternatively, move with arrow keys and extend a character selection with Shift plus an arrow key.
|
|
142
|
-
Starting a Shift selection replaces an active line selection.
|
|
143
|
-
Selected lines show a `β` marker as well as highlighting.
|
|
144
|
-
Pi's configured keys control vertical navigation, bringing, and going back, with Up, Down, Enter, and Escape as defaults.
|
|
145
|
-
Selection follows raw source text rather than terminal-wrapped rows.
|
|
146
|
-
|
|
147
|
-
Bringing context closes the side thread and loads a deterministic, editable block into Pi's main editor without sending it.
|
|
148
|
-
If a draft already exists, append is the recommended default.
|
|
149
|
-
Replace is marked destructive and requires a second confirmation.
|
|
150
|
-
Cancel returns to the side thread without changing either draft, and concurrent editor updates are preserved.
|
|
151
|
-
A success message reports whether context was loaded, appended, or replaced and gives its approximate size.
|
|
152
|
-
|
|
153
|
-
Without an explicit bring action, closing `/btw` never changes the main conversation.
|
|
154
|
-
Non-empty threads remain in memory only for Resume during the current extension instance.
|
|
155
|
-
`/new`, Pi `/resume`, `/reload`, extension replacement, and process restart discard retained threads.
|
|
156
|
-
Unsent drafts, steering queues, interrupted answers, and model credentials are not retained.
|
|
52
|
+
Both routes require TUI mode and a model with usable credentials; see [Settings](#-settings).
|
|
53
|
+
Side questions and selected conversation context are sent to that model's provider.
|
|
54
|
+
Bringing context back fills the main editor without submitting; replacing an existing draft requires confirmation.
|
|
55
|
+
Ctrl+C cancels the response and discards the current draft and queued questions, but completed exchanges remain resumable in memory.
|
|
56
|
+
Read the [workflow guide](./docs/workflows.md) for context selection, copying, search, steering, and draft recovery; `/new`, `/resume`, `/reload`, and restart discard retained threads.
|
|
157
57
|
|
|
158
58
|
## βοΈ Settings
|
|
159
59
|
|
|
@@ -204,6 +104,44 @@ A failed Settings-screen save instead restores the previous displayed value.
|
|
|
204
104
|
Turn **Copy selection automatically** off to retain highlighted selections and copy them with Pi's effective `app.message.copy` binding.
|
|
205
105
|
Pi-btw does not inherit Pi core's setting of the same name because Pi's public extension API does not expose its effective value.
|
|
206
106
|
|
|
107
|
+
### Keybindings
|
|
108
|
+
|
|
109
|
+
Open `/btw` β **Settings**, select a shortcut row, then choose **Edit key combinationβ¦** or **Restore default**.
|
|
110
|
+
Type a key name such as `ctrl+q` or `f6`; this is not a key-recording prompt.
|
|
111
|
+
Changes save immediately and apply when opening or resuming BTW, without `/reload`. Escape cancels an unfinished edit, not earlier saves.
|
|
112
|
+
The literal `/btw settings` remains a side question, not a settings subcommand.
|
|
113
|
+
|
|
114
|
+
| JSON field under `keybindings` | Default | Action |
|
|
115
|
+
| --- | --- | --- |
|
|
116
|
+
| `exit` | `ctrl+c` | Cancel and leave the dedicated side-thread workspace, including its nested dialogs. |
|
|
117
|
+
| `cycleThinkingLevel` | Inherit Pi's `app.thinking.cycle` | Cycle supported levels while composing or generating. |
|
|
118
|
+
| `bringToMain` | `ctrl+r` | Open the bring-to-main chooser after a completed answer. |
|
|
119
|
+
|
|
120
|
+
For example, merge these overrides into `pi-btw.json`:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"keybindings": {
|
|
125
|
+
"exit": "ctrl+q",
|
|
126
|
+
"cycleThinkingLevel": "f6",
|
|
127
|
+
"bringToMain": "f7"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Each override accepts one Pi key name with optional `ctrl`, `shift`, `alt`, and `super` modifiers; modifier order and letter case do not matter.
|
|
133
|
+
Letters, digits, Pi special keys and symbols are recognized, except the literal `+`, which Pi's matcher cannot parse as a base key.
|
|
134
|
+
Function keys `f1`β`f12` and Escape accept no modifiers; Clear accepts only no modifier, Shift, or Ctrl.
|
|
135
|
+
Actual availability depends on the terminal; `super` and some modified combinations require extended keyboard reporting.
|
|
136
|
+
|
|
137
|
+
New overrides cannot take ordinary typing keys or conflict with BTW actions, Pi editing, selection, search, scrolling, or enabled manual-copy bindings.
|
|
138
|
+
Pi's explicitly configured printable thinking shortcuts remain inherited for compatibility.
|
|
139
|
+
If a saved override becomes conflicting, BTW warns and uses an available default; if none is usable, that shortcut is unavailable and its activation hint is omitted.
|
|
140
|
+
An explicitly unbound Pi thinking action stays unbound. Remove an override field to restore its default; neither saving nor resetting modifies Pi's global keybindings.
|
|
141
|
+
**Ctrl+C always remains available as hard cancel**, even after configuring another exit key. Shortcut handling does not interpret bracketed-paste payloads as commands.
|
|
142
|
+
|
|
143
|
+
### Persistence
|
|
144
|
+
|
|
207
145
|
Reading a missing settings file has no side effects.
|
|
208
146
|
Pi-btw creates it only after a Settings change or a remembered shortcut change.
|
|
209
147
|
Within one Pi process, saves run in order and publish atomically through a same-directory temporary file and rename.
|
|
@@ -223,40 +161,18 @@ The file is read for every `/btw` invocation, so edits apply without `/reload`.
|
|
|
223
161
|
|
|
224
162
|
## ποΈ Package layout
|
|
225
163
|
|
|
226
|
-
```
|
|
164
|
+
```text
|
|
227
165
|
packages/pi-btw/
|
|
228
|
-
βββ
|
|
229
|
-
βββ
|
|
230
|
-
β βββ
|
|
231
|
-
βββ
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
β βββ fullscreen-ui.ts
|
|
236
|
-
β βββ main-tree-picker.ts
|
|
237
|
-
β βββ menu.ts
|
|
238
|
-
β βββ settings.ts
|
|
239
|
-
β βββ side-thread.ts
|
|
240
|
-
β βββ text.ts
|
|
241
|
-
β βββ transcript-pager.ts
|
|
242
|
-
βββ test/
|
|
243
|
-
βββ README.md
|
|
244
|
-
βββ LICENSE
|
|
245
|
-
βββ tsconfig.json
|
|
246
|
-
βββ package.json
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
The package exposes its Pi extension through `package.json`:
|
|
250
|
-
|
|
251
|
-
```json
|
|
252
|
-
{
|
|
253
|
-
"pi": {
|
|
254
|
-
"extensions": ["./dist/index.ts"]
|
|
255
|
-
}
|
|
256
|
-
}
|
|
166
|
+
βββ src/ # Authoritative implementation and helpers
|
|
167
|
+
β βββ index.ts # Thin Pi entrypoint
|
|
168
|
+
β βββ btw.ts # Side-thread lifecycle and command
|
|
169
|
+
βββ dist/ # Generated Jiti runtime
|
|
170
|
+
βββ docs/ # Side-thread workflows and controls
|
|
171
|
+
βββ scripts/build-runtime.mjs # Runtime builder
|
|
172
|
+
βββ test/ # Behavior and lifecycle coverage
|
|
257
173
|
```
|
|
258
174
|
|
|
259
|
-
The generated runtime is built from
|
|
175
|
+
The generated runtime is built from `src/index.ts` and does not import back into `src`.
|
|
260
176
|
|
|
261
177
|
## π Keywords
|
|
262
178
|
|