@bypane/cli 0.0.0-stage → 0.2.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.
@@ -0,0 +1,420 @@
1
+ /**
2
+ * Custom bypane app example: Spring Studio
3
+ *
4
+ * Uses the full `tui` SDK (`drawShader`, `createCanvas`, `drawCanvas`, `drawBox`, `split`, `rgb`)
5
+ * combined with `bypane/primitives` (`Slider`, `Button`) inside an isolated companion worker.
6
+ *
7
+ * Run live beside your agent:
8
+ * bypane app examples/spring-studio.ts --id spring --title "Spring Studio"
9
+ */
10
+ import { createCanvas, drawBox, drawCanvas, drawShader, inset, paint, rgb, split, text, truncate } from "tui"
11
+ import { Button, Slider } from "bypane/primitives"
12
+
13
+ interface SpringAppContext {
14
+ state: Record<string, unknown>
15
+ setState: (patch: Record<string, unknown>) => void
16
+ submit: (action: string, patch?: Record<string, unknown>) => void
17
+ toast: (text: string, tone?: "info" | "success" | "error") => void
18
+ onState: (fn: (next: Record<string, unknown>) => void) => () => void
19
+ }
20
+
21
+ interface SpringSample {
22
+ points: number[]
23
+ overshootPct: number
24
+ settleMs: number
25
+ zeta: number
26
+ feel: string
27
+ }
28
+
29
+ function simulateSpring(stiffness: number, damping: number, mass: number, durationSec = 1.4, steps = 140): SpringSample {
30
+ const dt = durationSec / steps
31
+ let x = 0
32
+ let v = 0
33
+ let maxX = 0
34
+ let settleIdx = steps
35
+ const points: number[] = []
36
+
37
+ for (let i = 0; i <= steps; i++) {
38
+ points.push(x)
39
+ if (x > maxX) maxX = x
40
+ if (Math.abs(1 - x) > 0.008 || Math.abs(v) > 0.04) {
41
+ settleIdx = i
42
+ }
43
+ const acc = (-stiffness * (x - 1) - damping * v) / Math.max(0.1, mass)
44
+ v += acc * dt
45
+ x += v * dt
46
+ }
47
+
48
+ const zeta = damping / (2 * Math.sqrt(Math.max(1, stiffness * mass)))
49
+ const overshootPct = Math.max(0, Math.round((maxX - 1) * 100))
50
+ const settleMs = Math.round(settleIdx * dt * 1000)
51
+ const feel = zeta < 0.72 ? "Bouncy" : zeta < 0.96 ? "Snappy" : zeta <= 1.08 ? "Critical" : "Smooth"
52
+ return { points, overshootPct, settleMs, zeta, feel }
53
+ }
54
+
55
+ export default function createSpringStudio(ctx: SpringAppContext) {
56
+ let stiffness = Number(ctx.state.stiffness ?? 260)
57
+ let damping = Number(ctx.state.damping ?? 20)
58
+ let mass = Number(ctx.state.mass ?? 1)
59
+ let preset = String(ctx.state.preset ?? "custom")
60
+
61
+ // Live animated spring particle (0 <-> 1)
62
+ let target = 1
63
+ let pos = 0
64
+ let vel = 0
65
+ let elapsed = 0
66
+ let stageRect = { x: 0, y: 0, columns: 0, rows: 0 }
67
+
68
+ const curveCanvas = createCanvas("braille")
69
+ let sim = simulateSpring(stiffness, damping, mass)
70
+
71
+ function syncState(retrigger = false): void {
72
+ sim = simulateSpring(stiffness, damping, mass)
73
+ if (retrigger) {
74
+ pos = 0
75
+ vel = 0
76
+ target = 1
77
+ elapsed = 0
78
+ }
79
+ ctx.setState({
80
+ stiffness,
81
+ damping,
82
+ mass: Math.round(mass * 10) / 10,
83
+ zeta: Math.round(sim.zeta * 100) / 100,
84
+ overshootPct: sim.overshootPct,
85
+ settleMs: sim.settleMs,
86
+ feel: sim.feel,
87
+ preset,
88
+ })
89
+ }
90
+
91
+ function fireImpulse(): void {
92
+ target = target > 0.5 ? 0 : 1
93
+ elapsed = 0
94
+ }
95
+
96
+ function applyPreset(name: string, k: number, d: number, m: number): void {
97
+ preset = name
98
+ stiffness = k
99
+ damping = d
100
+ mass = m
101
+ syncState(true)
102
+ ctx.toast(`Loaded ${name} spring (k=${k}, d=${d}, m=${m})`, "info")
103
+ }
104
+
105
+ ctx.onState((next) => {
106
+ let changed = false
107
+ if (typeof next.stiffness === "number" && next.stiffness !== stiffness) {
108
+ stiffness = Math.max(40, Math.min(600, next.stiffness))
109
+ changed = true
110
+ }
111
+ if (typeof next.damping === "number" && next.damping !== damping) {
112
+ damping = Math.max(4, Math.min(60, next.damping))
113
+ changed = true
114
+ }
115
+ if (typeof next.mass === "number" && next.mass !== mass) {
116
+ mass = Math.max(0.4, Math.min(3, next.mass))
117
+ changed = true
118
+ }
119
+ if (changed) {
120
+ sim = simulateSpring(stiffness, damping, mass)
121
+ pos = 0
122
+ vel = 0
123
+ target = 1
124
+ elapsed = 0
125
+ }
126
+ })
127
+
128
+ syncState(false)
129
+
130
+ return {
131
+ fps: 30,
132
+ hints: ["Space bounce", "←/→ tune"],
133
+ summary() {
134
+ return `stiffness=${stiffness}, damping=${damping}, mass=${mass.toFixed(1)} (${sim.feel}, ${sim.settleMs}ms)`
135
+ },
136
+ view(frame: import("tui").Frame) {
137
+ // Advance real spring physics using frame.delta
138
+ const dtSec = Math.min(0.05, Math.max(0.001, (frame.delta || 33) / 1000))
139
+ const subSteps = 3
140
+ const subDt = dtSec / subSteps
141
+ for (let i = 0; i < subSteps; i++) {
142
+ const acc = (-stiffness * (pos - target) - damping * vel) / Math.max(0.1, mass)
143
+ vel += acc * subDt
144
+ pos += vel * subDt
145
+ }
146
+ elapsed += dtSec
147
+
148
+ const pad = inset(frame.rect, [0, 1])
149
+ if (pad.rows < 12 || pad.columns < 28) {
150
+ text(frame, pad.x, pad.y, `Spring k=${stiffness} d=${damping} m=${mass.toFixed(1)}`, frame.theme.heading, pad)
151
+ return
152
+ }
153
+
154
+ const [kpiRow, visualRow, controlsBox, actionRow] = split(pad, "rows", [4, -1, 8, 1], 1)
155
+
156
+ // 1. Top KPI strip
157
+ if (kpiRow && kpiRow.rows >= 3) {
158
+ const [k1, k2, k3] = split(kpiRow, "columns", [-1, -1, -1], 1)
159
+ if (k1) {
160
+ const inner = inset(drawBox(frame.cells, k1, { title: "Feel · ζ", style: frame.styles.style(frame.theme.border) }), [0, 1])
161
+ text(frame, inner.x, inner.y, truncate(`${sim.feel} (${sim.zeta.toFixed(2)})`, inner.columns), sim.zeta < 0.72 ? { fg: "#f5a623", bold: true } : frame.theme.primary, inner)
162
+ if (inner.rows >= 2) text(frame, inner.x, inner.y + 1, truncate(`k${stiffness} d${damping} m${mass.toFixed(1)}`, inner.columns), frame.theme.muted, inner)
163
+ }
164
+ if (k2) {
165
+ const inner = inset(drawBox(frame.cells, k2, { title: "Overshoot", style: frame.styles.style(frame.theme.border) }), [0, 1])
166
+ text(frame, inner.x, inner.y, `${sim.overshootPct}%`, sim.overshootPct > 25 ? { fg: "#ff7a90", bold: true } : frame.theme.success, inner)
167
+ if (inner.rows >= 2) text(frame, inner.x, inner.y + 1, truncate(sim.overshootPct === 0 ? "no bounce" : "above target", inner.columns), frame.theme.muted, inner)
168
+ }
169
+ if (k3) {
170
+ const inner = inset(drawBox(frame.cells, k3, { title: "Settle Time", style: frame.styles.style(frame.theme.border) }), [0, 1])
171
+ text(frame, inner.x, inner.y, `${sim.settleMs} ms`, frame.theme.code, inner)
172
+ if (inner.rows >= 2) text(frame, inner.x, inner.y + 1, truncate("to within 0.8%", inner.columns), frame.theme.muted, inner)
173
+ }
174
+ }
175
+
176
+ // 2. Custom `tui` visualizations: Animated Shader Stage + Braille Response Curve
177
+ if (visualRow && visualRow.rows >= 5) {
178
+ const [stageBox, curveBox] = split(visualRow, "columns", [-1, -1], 1)
179
+
180
+ if (stageBox && stageBox.columns >= 14) {
181
+ const inner = drawBox(frame.cells, stageBox, {
182
+ title: "Motion Stage (click)",
183
+ style: frame.styles.style(frame.theme.border),
184
+ })
185
+ stageRect = inner
186
+ if (inner.rows >= 3 && inner.columns >= 8) {
187
+ // Subtle animated ambient shader field synced with the moving spring puck!
188
+ const normPuck = Math.max(-0.2, Math.min(1.2, pos))
189
+ const puckPx = inner.columns * (0.12 + normPuck * 0.76)
190
+ const puckPy = inner.rows
191
+ drawShader(frame, inner, (x, y, t) => {
192
+ const dx = (x - puckPx) / Math.max(4, inner.columns * 0.28)
193
+ const dy = (y - puckPy) / Math.max(3, inner.rows * 0.8)
194
+ const dist = Math.sqrt(dx * dx + dy * dy)
195
+ const glow = Math.exp(-dist * dist * 1.45)
196
+ const wave = 0.5 + 0.5 * Math.sin(x * 0.14 - t * 2.2)
197
+ const r = 0.06 + glow * 0.36 + wave * 0.03
198
+ const g = 0.08 + glow * 0.44 + (sim.zeta < 0.72 ? glow * 0.08 : 0)
199
+ const b = 0.14 + glow * 0.72 + wave * 0.04
200
+ return rgb(r, g, b)
201
+ })
202
+
203
+ // Draw spring rail + live animated puck right on top of the shader!
204
+ const trackY = inner.y + Math.floor(inner.rows / 2)
205
+ const leftPad = inner.x + 2
206
+ const span = Math.max(4, inner.columns - 8)
207
+ const puckX = Math.max(inner.x + 1, Math.min(inner.x + inner.columns - 5, Math.round(leftPad + normPuck * span)))
208
+ text(frame, leftPad, trackY, "┄".repeat(Math.max(1, span + 3)), { fg: "#7588aa", bg: "#101624" }, inner)
209
+ paint(frame, { x: puckX, y: trackY, columns: 4, rows: 1 }, { fg: "#0e131d", bg: "#7aa2ff", bold: true })
210
+ text(frame, puckX, trackY, " ◆◆ ", { fg: "#0e131d", bg: "#7aa2ff", bold: true }, inner)
211
+
212
+ const labelY = inner.y + inner.rows - 1
213
+ if (labelY > trackY) {
214
+ const status = ` x=${pos.toFixed(2)} → ${target}.0 v=${vel.toFixed(1)} `
215
+ paint(frame, { x: inner.x, y: labelY, columns: inner.columns, rows: 1 }, { fg: "#cbd6ea", bg: "#101624" })
216
+ text(frame, inner.x, labelY, truncate(status, inner.columns), { fg: "#cbd6ea", bg: "#101624" }, inner)
217
+ }
218
+ }
219
+ }
220
+
221
+ if (curveBox && curveBox.columns >= 14) {
222
+ const inner = drawBox(frame.cells, curveBox, {
223
+ title: "Curve x(t) · 1.4s",
224
+ style: frame.styles.style(frame.theme.border),
225
+ })
226
+ if (inner.rows >= 3 && inner.columns >= 8) {
227
+ curveCanvas.resize(inner.columns, inner.rows)
228
+ const w = curveCanvas.width
229
+ const h = curveCanvas.height
230
+ const mapY = (val: number) => Math.round(h - 3 - (val / 1.45) * (h - 6))
231
+
232
+ // Reference line at target = 1.0
233
+ const refY = mapY(1)
234
+ for (let px = 0; px < w; px += 3) {
235
+ curveCanvas.set(px, refY, 0x465066)
236
+ }
237
+ // Baseline at 0.0
238
+ const baseY = mapY(0)
239
+ for (let px = 0; px < w; px += 4) {
240
+ curveCanvas.set(px, baseY, 0x333c4f)
241
+ }
242
+
243
+ // Analytical spring curve
244
+ const pts = sim.points
245
+ let prevX = 0
246
+ let prevY = mapY(pts[0] ?? 0)
247
+ for (let i = 1; i < pts.length; i++) {
248
+ const px = Math.round((i / (pts.length - 1)) * (w - 1))
249
+ const py = mapY(pts[i] ?? 0)
250
+ const col = (pts[i] ?? 0) > 1.01 ? 0xf5a623 : 0x5fd787
251
+ curveCanvas.line(prevX, prevY, px, py, col)
252
+ prevX = px
253
+ prevY = py
254
+ }
255
+
256
+ // Live playhead dot synced with the current bounce
257
+ const playFrac = Math.min(1, elapsed / 1.4)
258
+ const playIdx = Math.min(pts.length - 1, Math.round(playFrac * (pts.length - 1)))
259
+ const dotX = Math.round(playFrac * (w - 1))
260
+ const dotY = mapY(pts[playIdx] ?? 1)
261
+ curveCanvas.circle(dotX, dotY, 2, 0x7aa2ff)
262
+
263
+ drawCanvas(frame, inner, curveCanvas)
264
+ }
265
+ }
266
+ }
267
+
268
+ // 3. Interactive Sliders imported from `bypane/primitives`
269
+ if (controlsBox && controlsBox.rows >= 6) {
270
+ const inner = inset(
271
+ drawBox(frame.cells, controlsBox, {
272
+ title: "Physics Controls (←/→ or drag · Shift=5x)",
273
+ style: frame.styles.style(frame.theme.border),
274
+ }),
275
+ [0, 1],
276
+ )
277
+ const [s1, s2, s3] = split(inner, "rows", [2, 2, 2])
278
+ if (s1) {
279
+ Slider.Root(
280
+ frame,
281
+ {
282
+ id: "spring-stiffness",
283
+ label: "Stiffness",
284
+ min: 40,
285
+ max: 600,
286
+ step: 10,
287
+ value: stiffness,
288
+ onValueChange: (val) => {
289
+ preset = "custom"
290
+ stiffness = val
291
+ syncState(true)
292
+ },
293
+ },
294
+ (root) => Slider.Track(root, s1),
295
+ )
296
+ }
297
+ if (s2) {
298
+ Slider.Root(
299
+ frame,
300
+ {
301
+ id: "spring-damping",
302
+ label: "Damping",
303
+ min: 4,
304
+ max: 60,
305
+ step: 1,
306
+ value: damping,
307
+ onValueChange: (val) => {
308
+ preset = "custom"
309
+ damping = val
310
+ syncState(true)
311
+ },
312
+ },
313
+ (root) => Slider.Track(root, s2),
314
+ )
315
+ }
316
+ if (s3) {
317
+ Slider.Root(
318
+ frame,
319
+ {
320
+ id: "spring-mass",
321
+ label: "Mass",
322
+ min: 0.4,
323
+ max: 3.0,
324
+ step: 0.1,
325
+ unit: "kg",
326
+ value: Math.round(mass * 10) / 10,
327
+ onValueChange: (val) => {
328
+ preset = "custom"
329
+ mass = Math.round(val * 10) / 10
330
+ syncState(true)
331
+ },
332
+ },
333
+ (root) => Slider.Track(root, s3),
334
+ )
335
+ }
336
+ }
337
+
338
+ // 4. Presets + Apply Spring submit button
339
+ if (actionRow && actionRow.rows >= 1) {
340
+ const [b1, b2, b3, b4] = split(actionRow, "columns", [-1, -1, -1, -2], 1)
341
+ if (b1) {
342
+ Button.Root(
343
+ frame,
344
+ {
345
+ id: "preset-snappy",
346
+ label: "Snappy",
347
+ onPress: () => applyPreset("snappy", 380, 32, 1.0),
348
+ },
349
+ (root) => Button.Trigger(root, b1),
350
+ )
351
+ }
352
+ if (b2) {
353
+ Button.Root(
354
+ frame,
355
+ {
356
+ id: "preset-bouncy",
357
+ label: "Bouncy",
358
+ onPress: () => applyPreset("bouncy", 260, 12, 1.0),
359
+ },
360
+ (root) => Button.Trigger(root, b2),
361
+ )
362
+ }
363
+ if (b3) {
364
+ Button.Root(
365
+ frame,
366
+ {
367
+ id: "preset-gentle",
368
+ label: "Gentle",
369
+ onPress: () => applyPreset("gentle", 140, 22, 1.2),
370
+ },
371
+ (root) => Button.Trigger(root, b3),
372
+ )
373
+ }
374
+ if (b4) {
375
+ Button.Root(
376
+ frame,
377
+ {
378
+ id: "submit-spring",
379
+ label: "Apply Spring",
380
+ variant: "primary",
381
+ humanOnly: true,
382
+ onPress: ({ source }) => {
383
+ if (source === "agent") return
384
+ ctx.submit("apply", {
385
+ stiffness,
386
+ damping,
387
+ mass: Math.round(mass * 10) / 10,
388
+ zeta: Math.round(sim.zeta * 100) / 100,
389
+ overshootPct: sim.overshootPct,
390
+ settleMs: sim.settleMs,
391
+ feel: sim.feel,
392
+ })
393
+ },
394
+ },
395
+ (root) => Button.Trigger(root, b4),
396
+ )
397
+ }
398
+ }
399
+ },
400
+ keys(key: import("tui").Key) {
401
+ if (key.mouse && key.mouse.action === "press" && key.mouse.button === "left") {
402
+ const { x, y } = key.mouse
403
+ if (
404
+ x >= stageRect.x &&
405
+ x < stageRect.x + stageRect.columns &&
406
+ y >= stageRect.y &&
407
+ y < stageRect.y + stageRect.rows
408
+ ) {
409
+ fireImpulse()
410
+ return true
411
+ }
412
+ }
413
+ if (key.name === "char" && key.text === " ") {
414
+ fireImpulse()
415
+ return true
416
+ }
417
+ return false
418
+ },
419
+ }
420
+ }
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@bypane/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "A companion terminal pane beside your coding agent for interactive plans, checklists, QuickLook files/images, tables, charts, decisions, and one-key feedback push-back.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Vlad Arbatov",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/vladzima/bypane.git"
11
+ },
12
+ "homepage": "https://github.com/vladzima/bypane#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/vladzima/bypane/issues"
15
+ },
16
+ "keywords": [
17
+ "tui",
18
+ "terminal",
19
+ "cli",
20
+ "mcp",
21
+ "ai-agents",
22
+ "claude-code",
23
+ "codex",
24
+ "opencode",
25
+ "rex",
26
+ "tmux",
27
+ "tui-sdk"
28
+ ],
29
+ "bin": {
30
+ "bypane": "dist/cli.js"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "examples",
35
+ "skills",
36
+ "README.md",
37
+ "LICENSE"
38
+ ],
39
+ "engines": {
40
+ "node": ">=24.0.0"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js",
44
+ "prepublishOnly": "npm run typecheck && npm run build && npm test",
45
+ "start": "node src/cli.ts",
46
+ "setup": "node src/cli.ts setup",
47
+ "demo": "node src/cli.ts --demo",
48
+ "test": "node --test test/*.test.ts",
49
+ "typecheck": "tsc --noEmit",
50
+ "build:native": "npx scriptc build src/cli.ts -o bypane",
51
+ "coverage:native": "npx scriptc coverage src/cli.ts"
52
+ },
53
+ "dependencies": {
54
+ "tui": "^0.2.1"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^24.0.0",
58
+ "typescript": "^5.8.0"
59
+ }
60
+ }
@@ -0,0 +1,136 @@
1
+ ---
2
+ name: bypane
3
+ description: >
4
+ Use bypane to project interactive visual surfaces (Markdown plans with
5
+ checklists, QuickLook files and PNG images, filterable tables, braille charts,
6
+ live logs, human-gated decisions, and custom generative TUIs with sliders,
7
+ toggles, segmented pickers, meters, and interactive timelines) into a companion
8
+ terminal pane beside the user's chat. Use when sharing plans, screenshots,
9
+ binary files, comparison tables, metric series, multi-option decisions, or
10
+ bespoke interactive controls that are easier to comprehend and manipulate
11
+ spatially than in scrolling chat text.
12
+ license: MIT
13
+ ---
14
+
15
+ # bypane
16
+
17
+ `bypane` is a 2 ms companion terminal pane shared between you and the user.
18
+ Inside Rex or tmux, calling `bypane` auto-splits a companion pane beside the
19
+ active pane without stealing focus.
20
+
21
+ ## When to use bypane
22
+
23
+ - **Plans & checklists (`markdown`):** Push multi-step plans with `- [ ]` tasks
24
+ instead of printing long walls of text in chat. The user can toggle tasks
25
+ directly and leave notes (`n`); read their edits back with `state`.
26
+ - **Files, screenshots & binaries (`show`):** Push code snippets with line
27
+ ranges (`path:start-end`), PNG screenshots (rendered inline via Kitty/Ghostty
28
+ or half-blocks), or binary files (PDFs, videos, archives) so the user can
29
+ press `o` to open them on their local host (`rex open` / `open`).
30
+ - **Comparisons & data (`table` / `chart` / `log`):** Push structured rows as a
31
+ filterable, sortable table, numeric series as a braille chart, or streaming
32
+ output as a live log surface.
33
+ - **Branching human decisions (`ask`):** Use `ask` for explicit select,
34
+ multiselect, text, or confirm prompts. `ask` is strictly human-gated—agents
35
+ can pre-highlight an option, never submit on the user's behalf.
36
+ - **Custom generative TUIs (`ui`):** When a preset isn't enough, compose an
37
+ interactive surface from `tui-sdk` primitives—`col`, `row`, `box`, `divider`,
38
+ `text`, `badge`, `stat`, `markdown`, `meter`, `sparkline`, `chart`, `canvas`,
39
+ `table`, `slider`, `toggle`, `segmented`, `select`, `checkboxes`, `input`,
40
+ `timeline` (`steps` | `gantt`), and `button`—with reactive `{{expr}}` formulas,
41
+ human-gated `submit: true` buttons, and automatic state push-back.
42
+ - **Arbitrary `tui-sdk` apps (`app`):** When you need custom drawing, shaders,
43
+ live animations, interactive canvases, physics/motion visualizers, or bespoke
44
+ multi-pane tools beyond declarative primitives, push a TypeScript/JavaScript
45
+ module with `bypane app` / `bypane_app`. It runs inside an isolated worker
46
+ with full access to `"tui"` and `"bypane/primitives"`, sharing `bypane`'s
47
+ tabs, scoped notes (`n`), and push-back (`ctx.submit`, `ctx.send`, `s`).
48
+
49
+ Do not use `bypane` for short one-line replies or routine command noise.
50
+
51
+ ## Using MCP vs. CLI
52
+
53
+ Prefer the `bypane_*` MCP tools when the `bypane` MCP server is attached;
54
+ otherwise call the `bypane` CLI directly over shell (both speak to the exact
55
+ same workspace socket).
56
+
57
+ ### MCP tools (`bypane mcp`)
58
+
59
+ - `bypane_present` — show or update `markdown`, `file`, `image`, `table`, `chart`, `log`, `ui`, or `app`
60
+ - `bypane_ui` — compose a custom generative terminal UI tree (`root`, `state`, optional `wait: true` with human-gated `submit: true` button)
61
+ - `bypane_app` — run arbitrary TypeScript/JavaScript `tui` SDK code in an isolated companion worker (`path` or inline `code`, live `state` streaming, optional `wait: true` with `ctx.submit`)
62
+ - `bypane_append_log` — append lines to an existing `log` surface
63
+ - `bypane_ask` — human-gated `select` | `multiselect` | `text` | `confirm` (blocks until submitted unless `wait: false`)
64
+ - `bypane_list` — list open tabs and active surface
65
+ - `bypane_state` — read checked tasks, human notes, selected rows, and `ask` answers
66
+ - `bypane_close` — close a surface tab
67
+ - `bypane_snapshot` / `bypane_act` — inspect live UI components or perform non-destructive actions (tab switch, scroll, filter, pre-highlight)
68
+
69
+ ### CLI commands
70
+
71
+ If `bypane` is not on `PATH`, prefix commands with `npx -y @bypane/cli ...`.
72
+
73
+ ```bash
74
+ # Show Markdown, code with highlighted lines, PNG images, or binary QuickLook
75
+ bypane show PLAN.md
76
+ bypane show src/server.ts:40-85
77
+ bypane show screenshot.png --caption "After layout fix"
78
+ bypane show report.pdf
79
+
80
+ # Push inline Markdown with interactive checkboxes
81
+ bypane md --id plan --title "Rollout Plan" <<'EOF'
82
+ # Rollout
83
+ - [x] Run unit tests
84
+ - [ ] Verify staging metrics
85
+ - [ ] Tag release
86
+ EOF
87
+
88
+ # Pipe JSON array or CSV/TSV into a filterable, sortable table
89
+ cat benchmarks.json | bypane table --id bench --title "Benchmarks"
90
+
91
+ # Render a braille chart
92
+ bypane chart --id latency --title "Latency" --unit ms \
93
+ --series p50:14,12,13,11 --series p99:41,38,34,29
94
+
95
+ # Present a human-gated decision (prints JSON answer when user submits)
96
+ bypane ask --id deploy --title "Deploy" --mode select \
97
+ --prompt "Pick rollout channel" --option canary --option prod
98
+
99
+ # Compose a generative interactive UI (sliders, timelines, reactive stats/charts)
100
+ bypane ui --id tuner --title "Rollout Tuner" --wait <<'EOF'
101
+ {
102
+ "state": { "replicas": 4, "canaryPct": 20, "region": "us-east", "autoRollback": true },
103
+ "root": {
104
+ "type": "col", "gap": 1,
105
+ "children": [
106
+ { "type": "row", "gap": 1, "children": [
107
+ { "type": "box", "title": "Cost", "child": { "type": "stat", "label": "{{replicas}} pods", "value": "${{replicas * 38}}/mo" } },
108
+ { "type": "box", "title": "Exposure", "child": { "type": "meter", "value": "{{canaryPct}}", "min": 0, "max": 100 } }
109
+ ]},
110
+ { "type": "slider", "bind": "replicas", "label": "Replicas", "min": 1, "max": 16, "step": 1, "unit": "pods" },
111
+ { "type": "slider", "bind": "canaryPct", "label": "Canary", "min": 5, "max": 100, "step": 5, "unit": "%" },
112
+ { "type": "segmented", "bind": "region", "label": "Region", "options": ["us-east", "eu-west", "global"] },
113
+ { "type": "toggle", "bind": "autoRollback", "label": "Auto-rollback on error spike" },
114
+ { "type": "button", "action": "apply", "label": "Apply Rollout", "variant": "primary", "submit": true }
115
+ ]
116
+ }
117
+ }
118
+ EOF
119
+
120
+ # Run an arbitrary custom tui-sdk TypeScript app (or stream live state updates)
121
+ bypane app examples/spring-studio.ts --id spring --title "Spring Studio"
122
+ bypane app --id spring --state '{"stiffness":320,"damping":20}'
123
+
124
+ # Read back human edits (checked tasks, notes, selected table rows, UI/app state)
125
+ bypane state
126
+ bypane state plan
127
+ ```
128
+
129
+ ## Updating in place & reading feedback
130
+
131
+ - Reuse `--id <stable-id>` (or `id` in MCP) when updating an existing plan,
132
+ table, chart, UI, or app so you refresh the same tab instead of spawning duplicates.
133
+ - When the user highlights a Markdown/code fragment and adds a note (`n` → `Enter`),
134
+ clicks a `submit` button, or presses `s` in `bypane`, a compact `[bypane · <Title> (<kind>)]`
135
+ block with the active state or `Quote:` snippet is sent into your pane without duplicating
136
+ previously transmitted notes.