@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/dist/cli.js CHANGED
@@ -24,6 +24,8 @@ Usage:
24
24
  bypane chart --series name:1,2,3 [flags] Show braille chart (flags or JSON stdin)
25
25
  bypane log [--title <t>] [--id <id>] [--append] Stream lines from stdin into a log surface
26
26
  bypane ask --prompt <q> [flags] Ask human a gated decision (blocks until submit)
27
+ bypane ui [spec.json] [--wait] [flags] Render a generative UI tree (sliders, timelines, charts…)
28
+ bypane app [file.ts] [--code <ts>] [flags] Run a custom tui-sdk app in an isolated companion worker
27
29
  bypane list | state [id] | close [id] | demo Inspect or manage active workspace
28
30
 
29
31
  Global flags:
@@ -65,6 +67,7 @@ function parseArgv(argv) {
65
67
  key === "yes" ||
66
68
  key === "force" ||
67
69
  key === "append" ||
70
+ key === "wait" ||
68
71
  key === "no-wait" ||
69
72
  key === "no-dock" ||
70
73
  key === "no-focus" ||
@@ -116,6 +119,8 @@ function parseArgv(argv) {
116
119
  "chart",
117
120
  "log",
118
121
  "ask",
122
+ "ui",
123
+ "app",
119
124
  "list",
120
125
  "state",
121
126
  "close",
@@ -265,6 +270,38 @@ export function createIpcHandler(store, getAgentDriver, redraw) {
265
270
  const answer = await store.waitForAsk(surface.id, req.timeoutMs);
266
271
  return { id: req.id, ok: true, data: { id: surface.id, answer } };
267
272
  }
273
+ case "ui_wait": {
274
+ const surface = store.present({ ...req.payload, wait: true });
275
+ redraw();
276
+ const submission = await store.waitForUi(surface.id, req.timeoutMs);
277
+ const latest = store.get(surface.id);
278
+ return {
279
+ id: req.id,
280
+ ok: true,
281
+ data: {
282
+ id: surface.id,
283
+ submission,
284
+ state: latest && latest.kind === "ui" ? latest.state : {},
285
+ notes: latest?.notes ?? [],
286
+ },
287
+ };
288
+ }
289
+ case "app_wait": {
290
+ const surface = store.present({ ...req.payload, wait: true });
291
+ redraw();
292
+ const submission = await store.waitForApp(surface.id, req.timeoutMs);
293
+ const latest = store.get(surface.id);
294
+ return {
295
+ id: req.id,
296
+ ok: true,
297
+ data: {
298
+ id: surface.id,
299
+ submission,
300
+ state: latest && latest.kind === "app" ? latest.state : {},
301
+ notes: latest?.notes ?? [],
302
+ },
303
+ };
304
+ }
268
305
  case "list":
269
306
  return { id: req.id, ok: true, data: { session: store.session, surfaces: store.listSummaries() } };
270
307
  case "get_state":
@@ -331,6 +368,18 @@ async function pushDemoToSession(session, origin, reqId, autoDock) {
331
368
  focus: false,
332
369
  };
333
370
  }
371
+ else if (s.kind === "ui") {
372
+ payload = {
373
+ id: s.id,
374
+ kind: "ui",
375
+ title: s.title,
376
+ root: s.root,
377
+ state: s.state,
378
+ wait: s.submission.status === "pending",
379
+ origin,
380
+ focus: false,
381
+ };
382
+ }
334
383
  else {
335
384
  continue;
336
385
  }
@@ -368,6 +417,7 @@ async function runTuiMode(session, loadDemo) {
368
417
  const code = await app.done();
369
418
  clearInterval(toastTimer);
370
419
  unsub();
420
+ ui.dispose();
371
421
  server.close();
372
422
  process.exit(code);
373
423
  }
@@ -612,6 +662,90 @@ async function main() {
612
662
  process.stdout.write(`${JSON.stringify(res.data)}\n`);
613
663
  return;
614
664
  }
665
+ if (parsed.command === "ui") {
666
+ const file = parsed.positionals[0];
667
+ const raw = (file ? readFileSync(resolve(file), "utf8") : await readStdinAll()).trim();
668
+ if (!raw) {
669
+ process.stderr.write('Usage: cat ui.json | bypane ui [--id <id>] [--title <t>] [--wait]\n');
670
+ process.exit(1);
671
+ }
672
+ const spec = JSON.parse(raw);
673
+ const isBareNode = typeof spec.type === "string" && !("root" in spec) && !("body" in spec);
674
+ const root = (isBareNode ? spec : (spec.root ?? spec.body));
675
+ if (!root || typeof root !== "object" || typeof root.type !== "string") {
676
+ process.stderr.write("Error: UI spec must include a valid root/body node with a `type` field.\n");
677
+ process.exit(1);
678
+ }
679
+ const wait = Boolean(parsed.flags.wait || spec.wait);
680
+ const payload = {
681
+ id: strFlag(parsed.flags, "id") ?? (typeof spec.id === "string" ? spec.id : undefined),
682
+ kind: "ui",
683
+ title: strFlag(parsed.flags, "title") ?? (typeof spec.title === "string" ? spec.title : "Interactive UI"),
684
+ root,
685
+ state: spec.state && typeof spec.state === "object" && !Array.isArray(spec.state)
686
+ ? spec.state
687
+ : undefined,
688
+ preserveState: typeof spec.preserveState === "boolean" ? spec.preserveState : undefined,
689
+ wait,
690
+ origin,
691
+ focus: wait ? true : focus,
692
+ };
693
+ const res = await sendIpc(session, wait ? { id: reqId, op: "ui_wait", payload } : { id: reqId, op: "present", payload }, { autoDock });
694
+ if (!res.ok) {
695
+ process.stderr.write(`Error: ${res.error}\n`);
696
+ process.exit(1);
697
+ }
698
+ process.stdout.write(`${JSON.stringify(res.data)}\n`);
699
+ return;
700
+ }
701
+ if (parsed.command === "app") {
702
+ const file = parsed.positionals[0];
703
+ const inlineFlag = strFlag(parsed.flags, "code");
704
+ const stateRaw = strFlag(parsed.flags, "state");
705
+ let state;
706
+ if (stateRaw !== undefined) {
707
+ try {
708
+ const parsedState = JSON.parse(stateRaw);
709
+ if (!parsedState || typeof parsedState !== "object" || Array.isArray(parsedState)) {
710
+ throw new Error("--state must be a JSON object");
711
+ }
712
+ state = parsedState;
713
+ }
714
+ catch (err) {
715
+ process.stderr.write(`Error parsing --state JSON: ${err.message}\n`);
716
+ process.exit(1);
717
+ }
718
+ }
719
+ const id = strFlag(parsed.flags, "id");
720
+ const stdinCode = !file && inlineFlag === undefined && !(id && state) ? await readStdinAll() : "";
721
+ const code = inlineFlag !== undefined ? inlineFlag : stdinCode.trim() ? stdinCode : undefined;
722
+ const absPath = file ? resolve(file) : undefined;
723
+ if (!absPath && code === undefined && !(id && state)) {
724
+ process.stderr.write('Usage: bypane app <view.ts> [--id <id>] [--title <t>] [--state \'{"k":1}\'] [--wait]\n' +
725
+ " or: cat view.ts | bypane app --id <id> --title <t>\n" +
726
+ ' or: bypane app --id <existing-id> --state \'{"k":2}\'\n');
727
+ process.exit(1);
728
+ }
729
+ const wait = Boolean(parsed.flags.wait);
730
+ const payload = {
731
+ id,
732
+ kind: "app",
733
+ title: strFlag(parsed.flags, "title"),
734
+ path: absPath,
735
+ code,
736
+ state,
737
+ wait,
738
+ origin,
739
+ focus: wait ? true : focus,
740
+ };
741
+ const res = await sendIpc(session, wait ? { id: reqId, op: "app_wait", payload } : { id: reqId, op: "present", payload }, { autoDock });
742
+ if (!res.ok) {
743
+ process.stderr.write(`Error: ${res.error}\n`);
744
+ process.exit(1);
745
+ }
746
+ process.stdout.write(`${JSON.stringify(res.data)}\n`);
747
+ return;
748
+ }
615
749
  if (parsed.command === "list") {
616
750
  const res = await sendIpc(session, { id: reqId, op: "list" }, { autoDock: false });
617
751
  if (!res.ok) {
package/dist/demo.js CHANGED
@@ -162,5 +162,269 @@ export function loadDemoSurfaces(store) {
162
162
  origin: { mux: "standalone", label: "demo-agent" },
163
163
  focus: false,
164
164
  });
165
+ store.present({
166
+ id: "demo-tuner",
167
+ kind: "ui",
168
+ title: "Rollout Tuner",
169
+ origin: { mux: "standalone", label: "demo-agent" },
170
+ focus: false,
171
+ state: {
172
+ replicas: 4,
173
+ canaryPct: 20,
174
+ region: "us-east",
175
+ autoRollback: true,
176
+ },
177
+ root: {
178
+ type: "col",
179
+ gap: 1,
180
+ children: [
181
+ {
182
+ type: "row",
183
+ gap: 1,
184
+ children: [
185
+ {
186
+ type: "box",
187
+ title: "Est. Cost",
188
+ child: {
189
+ type: "stat",
190
+ label: "{{replicas}} pods · {{region}}",
191
+ value: "${{replicas * 38}}/mo",
192
+ delta: "{{region == 'global' ? '+2x edge' : 'single region'}}",
193
+ tone: "{{replicas > 10 ? 'warn' : 'primary'}}",
194
+ },
195
+ },
196
+ {
197
+ type: "box",
198
+ title: "Projected p99",
199
+ child: {
200
+ type: "stat",
201
+ label: "at {{canaryPct}}% traffic",
202
+ value: "{{round(14 + 48 / sqrt(replicas))}} ms",
203
+ delta: "{{autoRollback ? 'guard ON' : 'guard OFF'}}",
204
+ tone: "{{replicas >= 4 ? 'success' : 'warn'}}",
205
+ },
206
+ },
207
+ {
208
+ type: "box",
209
+ title: "Blast Radius",
210
+ child: {
211
+ type: "meter",
212
+ label: "Canary exposure",
213
+ value: "{{canaryPct}}",
214
+ min: 0,
215
+ max: 100,
216
+ format: "{{percent}}%",
217
+ tone: "{{canaryPct > 50 ? 'warn' : 'success'}}",
218
+ },
219
+ },
220
+ ],
221
+ },
222
+ {
223
+ type: "box",
224
+ title: "Controls (Tab to focus · ←/→ or drag sliders)",
225
+ children: [
226
+ {
227
+ type: "slider",
228
+ bind: "replicas",
229
+ label: "Replicas",
230
+ min: 1,
231
+ max: 16,
232
+ step: 1,
233
+ unit: "pods",
234
+ },
235
+ {
236
+ type: "slider",
237
+ bind: "canaryPct",
238
+ label: "Canary traffic",
239
+ min: 5,
240
+ max: 100,
241
+ step: 5,
242
+ unit: "%",
243
+ },
244
+ {
245
+ type: "segmented",
246
+ bind: "region",
247
+ label: "Region",
248
+ options: [
249
+ { value: "us-east", label: "us-east" },
250
+ { value: "eu-west", label: "eu-west" },
251
+ { value: "global", label: "global" },
252
+ ],
253
+ },
254
+ {
255
+ type: "toggle",
256
+ bind: "autoRollback",
257
+ label: "Auto-rollback on error spike",
258
+ description: "halts rollout if 5xx > 0.5%",
259
+ },
260
+ ],
261
+ },
262
+ {
263
+ type: "chart",
264
+ title: "Simulated p99 Latency Curve",
265
+ unit: "ms",
266
+ min: 0,
267
+ max: 80,
268
+ series: [
269
+ {
270
+ name: "p99",
271
+ color: "#7aa2ff",
272
+ values: {
273
+ points: 24,
274
+ expr: "round(14 + (48 / sqrt(replicas)) * (0.65 + 0.55 * t) + sin(t * 9) * 1.6, 1)",
275
+ },
276
+ },
277
+ {
278
+ name: "p50",
279
+ color: "#5fd787",
280
+ values: {
281
+ points: 24,
282
+ expr: "round(6 + (16 / sqrt(replicas)) * (0.75 + 0.35 * t), 1)",
283
+ },
284
+ },
285
+ ],
286
+ },
287
+ {
288
+ type: "row",
289
+ gap: 1,
290
+ children: [
291
+ {
292
+ type: "button",
293
+ action: "preset-safe",
294
+ label: "Safe Default",
295
+ set: { replicas: 4, canaryPct: 10, region: "us-east", autoRollback: true },
296
+ },
297
+ {
298
+ type: "button",
299
+ action: "preset-scale",
300
+ label: "High Scale",
301
+ set: { replicas: 12, canaryPct: 50, region: "global", autoRollback: true },
302
+ },
303
+ {
304
+ type: "button",
305
+ action: "apply",
306
+ label: "Apply Rollout",
307
+ variant: "primary",
308
+ submit: true,
309
+ },
310
+ ],
311
+ },
312
+ ],
313
+ },
314
+ });
315
+ store.present({
316
+ id: "demo-timeline",
317
+ kind: "ui",
318
+ title: "Release Timeline",
319
+ origin: { mux: "standalone", label: "demo-agent" },
320
+ focus: false,
321
+ state: {
322
+ stage: "canary",
323
+ },
324
+ root: {
325
+ type: "col",
326
+ gap: 1,
327
+ children: [
328
+ {
329
+ type: "box",
330
+ title: "Pipeline Waterfall (↑/↓ or click stage to inspect)",
331
+ child: {
332
+ type: "timeline",
333
+ bind: "stage",
334
+ mode: "gantt",
335
+ unit: "s",
336
+ min: 0,
337
+ max: 120,
338
+ items: [
339
+ {
340
+ id: "typecheck",
341
+ label: "Typecheck & Lint",
342
+ status: "done",
343
+ start: 0,
344
+ end: 14,
345
+ meta: "14s",
346
+ detail: "tsc --noEmit passed across 12 source files with 0 warnings.",
347
+ },
348
+ {
349
+ id: "build",
350
+ label: "scriptc Native Build",
351
+ status: "done",
352
+ start: 14,
353
+ end: 36,
354
+ meta: "22s",
355
+ detail: "Compiled 1.9 MB native binary (darwin-arm64 + linux-x64).",
356
+ },
357
+ {
358
+ id: "tests",
359
+ label: "Headless TUI Suite",
360
+ status: "done",
361
+ start: 36,
362
+ end: 58,
363
+ meta: "22s",
364
+ detail: "All createTestApp, IPC socket, MCP, and gate tests green.",
365
+ },
366
+ {
367
+ id: "canary",
368
+ label: "Canary Rollout (20%)",
369
+ status: "active",
370
+ start: 58,
371
+ end: 94,
372
+ meta: "live",
373
+ detail: "Monitoring p99 latency (0.25 ms) and error rate (0.00%) across canary nodes.",
374
+ },
375
+ {
376
+ id: "global",
377
+ label: "Global Promotion",
378
+ status: "pending",
379
+ start: 94,
380
+ end: 120,
381
+ meta: "queued",
382
+ detail: "Awaiting human approval or automated canary bake completion.",
383
+ },
384
+ ],
385
+ },
386
+ },
387
+ {
388
+ type: "box",
389
+ title: "Selected Stage · {{stage_item.label}}",
390
+ children: [
391
+ {
392
+ type: "row",
393
+ gap: 2,
394
+ children: [
395
+ {
396
+ type: "stat",
397
+ label: "Status",
398
+ value: "{{upper(stage_item.status)}}",
399
+ tone: "{{stage_item.status == 'done' ? 'success' : stage_item.status == 'active' ? 'primary' : 'muted'}}",
400
+ },
401
+ {
402
+ type: "stat",
403
+ label: "Window",
404
+ value: "{{stage_item.start}}s → {{stage_item.end}}s",
405
+ delta: "{{stage_item.end - stage_item.start}}s span",
406
+ tone: "code",
407
+ },
408
+ ],
409
+ },
410
+ {
411
+ type: "text",
412
+ content: "{{stage_item.detail}}",
413
+ tone: "default",
414
+ },
415
+ ],
416
+ },
417
+ {
418
+ type: "meter",
419
+ label: "Overall release progress",
420
+ value: 72,
421
+ min: 0,
422
+ max: 100,
423
+ format: "{{percent}}% complete",
424
+ tone: "primary",
425
+ },
426
+ ],
427
+ },
428
+ });
165
429
  store.focus("demo-plan");
166
430
  }