@bypane/cli 0.1.0 → 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.
- package/README.md +77 -22
- package/dist/app-host.js +408 -0
- package/dist/app-protocol.js +1 -0
- package/dist/app-worker.js +556 -0
- package/dist/cli.js +134 -0
- package/dist/demo.js +264 -0
- package/dist/expr.js +460 -0
- package/dist/mcp.js +114 -5
- package/dist/multiplexer.js +4 -2
- package/dist/primitives.js +669 -0
- package/dist/selection.js +170 -0
- package/dist/setup.js +22 -21
- package/dist/skill.js +52 -10
- package/dist/state.js +446 -19
- package/dist/ui-surface.js +744 -0
- package/dist/ui.js +482 -36
- package/examples/spring-studio.ts +420 -0
- package/package.json +2 -1
- package/skills/bypane/SKILL.md +52 -10
|
@@ -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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bypane/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"dist",
|
|
34
|
+
"examples",
|
|
34
35
|
"skills",
|
|
35
36
|
"README.md",
|
|
36
37
|
"LICENSE"
|
package/skills/bypane/SKILL.md
CHANGED
|
@@ -3,10 +3,12 @@ name: bypane
|
|
|
3
3
|
description: >
|
|
4
4
|
Use bypane to project interactive visual surfaces (Markdown plans with
|
|
5
5
|
checklists, QuickLook files and PNG images, filterable tables, braille charts,
|
|
6
|
-
live logs,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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.
|
|
10
12
|
license: MIT
|
|
11
13
|
---
|
|
12
14
|
|
|
@@ -31,6 +33,18 @@ active pane without stealing focus.
|
|
|
31
33
|
- **Branching human decisions (`ask`):** Use `ask` for explicit select,
|
|
32
34
|
multiselect, text, or confirm prompts. `ask` is strictly human-gated—agents
|
|
33
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`).
|
|
34
48
|
|
|
35
49
|
Do not use `bypane` for short one-line replies or routine command noise.
|
|
36
50
|
|
|
@@ -42,7 +56,9 @@ same workspace socket).
|
|
|
42
56
|
|
|
43
57
|
### MCP tools (`bypane mcp`)
|
|
44
58
|
|
|
45
|
-
- `bypane_present` — show or update `markdown`, `file`, `image`, `table`, `chart`, or `
|
|
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`)
|
|
46
62
|
- `bypane_append_log` — append lines to an existing `log` surface
|
|
47
63
|
- `bypane_ask` — human-gated `select` | `multiselect` | `text` | `confirm` (blocks until submitted unless `wait: false`)
|
|
48
64
|
- `bypane_list` — list open tabs and active surface
|
|
@@ -80,7 +96,32 @@ bypane chart --id latency --title "Latency" --unit ms \
|
|
|
80
96
|
bypane ask --id deploy --title "Deploy" --mode select \
|
|
81
97
|
--prompt "Pick rollout channel" --option canary --option prod
|
|
82
98
|
|
|
83
|
-
#
|
|
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)
|
|
84
125
|
bypane state
|
|
85
126
|
bypane state plan
|
|
86
127
|
```
|
|
@@ -88,7 +129,8 @@ bypane state plan
|
|
|
88
129
|
## Updating in place & reading feedback
|
|
89
130
|
|
|
90
131
|
- Reuse `--id <stable-id>` (or `id` in MCP) when updating an existing plan,
|
|
91
|
-
table, or
|
|
92
|
-
- When the user
|
|
93
|
-
|
|
94
|
-
|
|
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.
|