@h-rig/cli 0.0.6-alpha.76 → 0.0.6-alpha.78

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.
Files changed (32) hide show
  1. package/dist/bin/rig.js +10130 -9246
  2. package/dist/src/app/board.js +1783 -0
  3. package/dist/src/app/drone-ui.js +294 -0
  4. package/dist/src/{commands/_tui-theme.js → app/theme.js} +16 -1
  5. package/dist/src/commands/_async-ui.js +74 -3
  6. package/dist/src/commands/_cli-format.js +107 -29
  7. package/dist/src/commands/_doctor-checks.js +3 -1
  8. package/dist/src/commands/_help-catalog.js +8 -70
  9. package/dist/src/commands/_operator-view.js +184 -7
  10. package/dist/src/commands/_pi-frontend.js +184 -7
  11. package/dist/src/commands/_preflight.js +3 -1
  12. package/dist/src/commands/_server-client.js +3 -1
  13. package/dist/src/commands/_snapshot-upload.js +3 -1
  14. package/dist/src/commands/_task-picker.js +132 -7
  15. package/dist/src/commands/browser.js +306 -30
  16. package/dist/src/commands/connect.js +146 -20
  17. package/dist/src/commands/doctor.js +77 -4
  18. package/dist/src/commands/github.js +77 -4
  19. package/dist/src/commands/inbox.js +171 -88
  20. package/dist/src/commands/init.js +349 -9
  21. package/dist/src/commands/inspect.js +77 -4
  22. package/dist/src/commands/run.js +214 -28
  23. package/dist/src/commands/server.js +149 -21
  24. package/dist/src/commands/setup.js +77 -4
  25. package/dist/src/commands/stats.js +109 -107
  26. package/dist/src/commands/task-report-bug.js +231 -40
  27. package/dist/src/commands/task-run-driver.js +3 -1
  28. package/dist/src/commands/task.js +355 -184
  29. package/dist/src/commands.js +10126 -9242
  30. package/dist/src/index.js +10131 -9247
  31. package/package.json +8 -9
  32. package/dist/src/commands/_operator-board.js +0 -730
@@ -475,7 +475,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
475
475
  })() : null;
476
476
  if (!response.ok) {
477
477
  const diagnostics = diagnosticMessage(payload);
478
- const detail = diagnostics ?? (text || response.statusText);
478
+ const rawDetail = diagnostics ?? (text || response.statusText);
479
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
480
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
479
481
  const failure = await buildServerFailureContext(context.projectRoot, server);
480
482
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
481
483
  ${failure.contextLine}`, 1, { hint: failure.hint });
@@ -785,8 +787,79 @@ function createTtySpinner(input) {
785
787
  };
786
788
  }
787
789
 
790
+ // packages/cli/src/app/theme.ts
791
+ var RIG_PALETTE = {
792
+ ink: "#f2f3f6",
793
+ ink2: "#aeb0ba",
794
+ ink3: "#6c6e79",
795
+ ink4: "#44464f",
796
+ accent: "#ccff4d",
797
+ accentDim: "#a9d63f",
798
+ cyan: "#56d8ff",
799
+ red: "#ff5d5d",
800
+ yellow: "#ffd24d"
801
+ };
802
+ function hexToRgb(hex) {
803
+ const value = hex.replace("#", "");
804
+ return [
805
+ Number.parseInt(value.slice(0, 2), 16),
806
+ Number.parseInt(value.slice(2, 4), 16),
807
+ Number.parseInt(value.slice(4, 6), 16)
808
+ ];
809
+ }
810
+ function fg(hex) {
811
+ const [r, g, b] = hexToRgb(hex);
812
+ return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
813
+ }
814
+ var ink = fg(RIG_PALETTE.ink);
815
+ var ink2 = fg(RIG_PALETTE.ink2);
816
+ var ink3 = fg(RIG_PALETTE.ink3);
817
+ var ink4 = fg(RIG_PALETTE.ink4);
818
+ var accent = fg(RIG_PALETTE.accent);
819
+ var accentDim = fg(RIG_PALETTE.accentDim);
820
+ var cyan = fg(RIG_PALETTE.cyan);
821
+ var red = fg(RIG_PALETTE.red);
822
+ var yellow = fg(RIG_PALETTE.yellow);
823
+ function bold(text) {
824
+ return `\x1B[1m${text}\x1B[22m`;
825
+ }
826
+ var DRONE_ART = [
827
+ " .-=-. .-=-. ",
828
+ " ( !!! ) ( !!! ) ",
829
+ " '-=-'._ _.'-=-' ",
830
+ " '._ _.' ",
831
+ " '=$$$$$$$=.' ",
832
+ " =$$$$$$$$$$$= ",
833
+ " $$$@@@@@@@@@@$$$ ",
834
+ " $$$@@ @@$$$ ",
835
+ " $$@ ? @$$$ ",
836
+ " $$$@ '-' @$$$ ",
837
+ " $$$@@ @@$$$ ",
838
+ " $$$@@@@@@@@@@$$$ ",
839
+ " =$$$$$$$$$$$= ",
840
+ " '=$$$$$$$=.' ",
841
+ " _.' '._ ",
842
+ " .-=-.' '.-=-. ",
843
+ " ( !!! ) ( !!! ) ",
844
+ " '-=-' '-=-' "
845
+ ];
846
+ var EYE_FRAMES = ["@", "o", "."];
847
+ var DRONE_WIDTH = DRONE_ART[0].length;
848
+ var DRONE_HEIGHT = DRONE_ART.length;
849
+ var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
850
+ function microDroneFrame(tick) {
851
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
852
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
853
+ return `(${blade})${eye}(${blade})`;
854
+ }
855
+ var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
856
+ function renderMicroDroneFrame(tick) {
857
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
858
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
859
+ return `${ink4("(")}${cyan(blade)}${ink4(")")}${bold(accent(eye))}${ink4("(")}${cyan(blade)}${ink4(")")}`;
860
+ }
861
+
788
862
  // packages/cli/src/commands/_async-ui.ts
789
- var CLACK_SPINNER_FRAMES = ["\u25D2", "\u25D0", "\u25D3", "\u25D1"];
790
863
  var DONE_SYMBOL = pc.green("\u25C7");
791
864
  var FAIL_SYMBOL = pc.red("\u25A0");
792
865
  var activeUpdate = null;
@@ -820,8 +893,8 @@ async function withSpinner(label, work, options = {}) {
820
893
  const spinner = createTtySpinner({
821
894
  label,
822
895
  output,
823
- frames: CLACK_SPINNER_FRAMES,
824
- styleFrame: (frame) => pc.magenta(frame)
896
+ frames: MICRO_DRONE_FRAMES,
897
+ styleFrame: (frame) => renderMicroDroneFrame(Math.max(0, MICRO_DRONE_FRAMES.indexOf(frame)))
825
898
  });
826
899
  const update = (next) => {
827
900
  lastLabel = next;
@@ -342,7 +342,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
342
342
  })() : null;
343
343
  if (!response.ok) {
344
344
  const diagnostics = diagnosticMessage(payload);
345
- const detail = diagnostics ?? (text || response.statusText);
345
+ const rawDetail = diagnostics ?? (text || response.statusText);
346
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
347
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
346
348
  const failure = await buildServerFailureContext(context.projectRoot, server);
347
349
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
348
350
  ${failure.contextLine}`, 1, { hint: failure.hint });
@@ -361,33 +363,80 @@ var RESUMABLE_RUN_STATUSES = new Set([
361
363
  "needs_attention"
362
364
  ]);
363
365
 
364
- // packages/cli/src/commands/_cli-format.ts
365
- import { log, note } from "@clack/prompts";
366
- import pc from "picocolors";
367
- function shouldUseClackOutput() {
368
- return Boolean(process.stdout.isTTY) && process.env.RIG_CLI_PLAIN_HELP !== "1";
366
+ // packages/cli/src/app/drone-ui.ts
367
+ import { ProcessTerminal, TUI, Text, Input, SelectList, matchesKey } from "@earendil-works/pi-tui";
368
+
369
+ // packages/cli/src/app/theme.ts
370
+ var RIG_PALETTE = {
371
+ ink: "#f2f3f6",
372
+ ink2: "#aeb0ba",
373
+ ink3: "#6c6e79",
374
+ ink4: "#44464f",
375
+ accent: "#ccff4d",
376
+ accentDim: "#a9d63f",
377
+ cyan: "#56d8ff",
378
+ red: "#ff5d5d",
379
+ yellow: "#ffd24d"
380
+ };
381
+ function hexToRgb(hex) {
382
+ const value = hex.replace("#", "");
383
+ return [
384
+ Number.parseInt(value.slice(0, 2), 16),
385
+ Number.parseInt(value.slice(2, 4), 16),
386
+ Number.parseInt(value.slice(4, 6), 16)
387
+ ];
369
388
  }
370
- function printFormattedOutput(message, options = {}) {
371
- if (!shouldUseClackOutput()) {
372
- console.log(message);
373
- return;
374
- }
375
- if (options.title)
376
- note(message, options.title);
377
- else
378
- log.message(message);
389
+ function fg(hex) {
390
+ const [r, g, b] = hexToRgb(hex);
391
+ return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
379
392
  }
380
- function formatSection(title, subtitle) {
381
- return `${pc.bold(pc.cyan("\u25C6"))} ${pc.bold(title)}${subtitle ? pc.dim(` \u2014 ${subtitle}`) : ""}`;
393
+ var ink = fg(RIG_PALETTE.ink);
394
+ var ink2 = fg(RIG_PALETTE.ink2);
395
+ var ink3 = fg(RIG_PALETTE.ink3);
396
+ var ink4 = fg(RIG_PALETTE.ink4);
397
+ var accent = fg(RIG_PALETTE.accent);
398
+ var accentDim = fg(RIG_PALETTE.accentDim);
399
+ var cyan = fg(RIG_PALETTE.cyan);
400
+ var red = fg(RIG_PALETTE.red);
401
+ var yellow = fg(RIG_PALETTE.yellow);
402
+ function bold(text) {
403
+ return `\x1B[1m${text}\x1B[22m`;
382
404
  }
383
- function formatNextSteps(steps) {
384
- if (steps.length === 0)
385
- return [];
386
- return [pc.bold("Next"), ...steps.map((step) => `${pc.dim("\u203A")} ${step}`)];
405
+ var DRONE_ART = [
406
+ " .-=-. .-=-. ",
407
+ " ( !!! ) ( !!! ) ",
408
+ " '-=-'._ _.'-=-' ",
409
+ " '._ _.' ",
410
+ " '=$$$$$$$=.' ",
411
+ " =$$$$$$$$$$$= ",
412
+ " $$$@@@@@@@@@@$$$ ",
413
+ " $$$@@ @@$$$ ",
414
+ " $$@ ? @$$$ ",
415
+ " $$$@ '-' @$$$ ",
416
+ " $$$@@ @@$$$ ",
417
+ " $$$@@@@@@@@@@$$$ ",
418
+ " =$$$$$$$$$$$= ",
419
+ " '=$$$$$$$=.' ",
420
+ " _.' '._ ",
421
+ " .-=-.' '.-=-. ",
422
+ " ( !!! ) ( !!! ) ",
423
+ " '-=-' '-=-' "
424
+ ];
425
+ var EYE_FRAMES = ["@", "o", "."];
426
+ var DRONE_WIDTH = DRONE_ART[0].length;
427
+ var DRONE_HEIGHT = DRONE_ART.length;
428
+ var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
429
+ function microDroneFrame(tick) {
430
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
431
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
432
+ return `(${blade})${eye}(${blade})`;
433
+ }
434
+ var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
435
+ function renderMicroDroneFrame(tick) {
436
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
437
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
438
+ return `${ink4("(")}${cyan(blade)}${ink4(")")}${bold(accent(eye))}${ink4("(")}${cyan(blade)}${ink4(")")}`;
387
439
  }
388
-
389
- // packages/cli/src/commands/_async-ui.ts
390
- import pc2 from "picocolors";
391
440
 
392
441
  // packages/cli/src/commands/_spinner.ts
393
442
  var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
@@ -450,8 +499,40 @@ function createTtySpinner(input) {
450
499
  };
451
500
  }
452
501
 
502
+ // packages/cli/src/app/drone-ui.ts
503
+ function droneNote(message, title) {
504
+ if (title)
505
+ console.log(` ${accentDim("\u25C7")} ${bold(ink2(title))}`);
506
+ for (const line of message.split(`
507
+ `)) {
508
+ console.log(` ${ink4("\u2502")} ${line}`);
509
+ }
510
+ }
511
+
512
+ // packages/cli/src/commands/_cli-format.ts
513
+ import pc from "picocolors";
514
+ var themeDim = (value) => ink3(value);
515
+ function shouldUseClackOutput() {
516
+ return Boolean(process.stdout.isTTY) && process.env.RIG_CLI_PLAIN_HELP !== "1";
517
+ }
518
+ function printFormattedOutput(message, options = {}) {
519
+ if (!shouldUseClackOutput()) {
520
+ console.log(message);
521
+ return;
522
+ }
523
+ droneNote(message, options.title);
524
+ }
525
+ function formatSection(title, subtitle) {
526
+ return `${pc.bold(accent("\u25C6"))} ${pc.bold(title)}${subtitle ? themeDim(` \u2014 ${subtitle}`) : ""}`;
527
+ }
528
+ function formatNextSteps(steps) {
529
+ if (steps.length === 0)
530
+ return [];
531
+ return [pc.bold("Next"), ...steps.map((step) => `${accent("\u203A")} ${step}`)];
532
+ }
533
+
453
534
  // packages/cli/src/commands/_async-ui.ts
454
- var CLACK_SPINNER_FRAMES = ["\u25D2", "\u25D0", "\u25D3", "\u25D1"];
535
+ import pc2 from "picocolors";
455
536
  var DONE_SYMBOL = pc2.green("\u25C7");
456
537
  var FAIL_SYMBOL = pc2.red("\u25A0");
457
538
  var activeUpdate = null;
@@ -485,8 +566,8 @@ async function withSpinner(label, work, options = {}) {
485
566
  const spinner = createTtySpinner({
486
567
  label,
487
568
  output,
488
- frames: CLACK_SPINNER_FRAMES,
489
- styleFrame: (frame) => pc2.magenta(frame)
569
+ frames: MICRO_DRONE_FRAMES,
570
+ styleFrame: (frame) => renderMicroDroneFrame(Math.max(0, MICRO_DRONE_FRAMES.indexOf(frame)))
490
571
  });
491
572
  const update = (next) => {
492
573
  lastLabel = next;
@@ -508,7 +589,6 @@ async function withSpinner(label, work, options = {}) {
508
589
  }
509
590
 
510
591
  // packages/cli/src/commands/_help-catalog.ts
511
- import { intro, log as log2, note as note2, outro } from "@clack/prompts";
512
592
  import pc3 from "picocolors";
513
593
  var TOP_LEVEL_SECTIONS = [
514
594
  {
@@ -811,25 +891,6 @@ var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
811
891
  function heading(title) {
812
892
  return pc3.bold(pc3.cyan(title));
813
893
  }
814
- function renderRigBanner(version) {
815
- const m = (s) => pc3.bold(pc3.magenta(s));
816
- const c = (s) => pc3.bold(pc3.cyan(s));
817
- const y = (s) => pc3.yellow(s);
818
- const d = (s) => pc3.dim(s);
819
- const lines = [
820
- m(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ") + d(" \u2591\u2592\u2593\u2588 "),
821
- m(" \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D ") + d("\u2593\u2592\u2591"),
822
- c(" \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557") + d(" \u2591\u2592"),
823
- c(" \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551") + d(" \u2588\u2593\u2591"),
824
- y(" \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D") + d(" \u2592\u2591"),
825
- y(" \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D "),
826
- "",
827
- ` ${c("\u25E2\u25E4")} ${pc3.bold("the control rig for autonomous coding agents")} ${m("//")} ${d("you are the operator")}`,
828
- version ? ` ${d(`v${version} \xB7 jack in: rig task run --next`)}` : ` ${d("jack in: rig task run --next")}`
829
- ];
830
- return lines.join(`
831
- `);
832
- }
833
894
  function commandLine(command, description) {
834
895
  const commandColumn = command.length >= 38 ? `${command} ` : command.padEnd(38);
835
896
  return `${pc3.dim("\u2502")} ${pc3.bold(commandColumn)} ${description}`;
@@ -883,67 +944,8 @@ function renderGroupHelp(groupName) {
883
944
  const group = ALL_GROUPS.find((candidate) => candidate.name === groupName);
884
945
  return group ? renderGroup(group) : null;
885
946
  }
886
- function shouldUseClackOutput2() {
887
- return Boolean(process.stdout.isTTY) && process.env.RIG_CLI_PLAIN_HELP !== "1";
888
- }
889
- function printTopLevelHelp(state = {}) {
890
- if (!shouldUseClackOutput2()) {
891
- console.log(renderTopLevelHelp());
892
- return;
893
- }
894
- console.log(renderRigBanner(state.version));
895
- console.log("");
896
- if (state.projectInitialized === false) {
897
- intro("no rig project in this directory");
898
- note2([
899
- commandLine("rig init", "Set this repo up: config, GitHub auth, task source, server, Pi."),
900
- commandLine("rig init --yes", "Same, non-interactive, sensible defaults."),
901
- commandLine("rig doctor", "Already initialized somewhere else? Check the wiring.")
902
- ].join(`
903
- `), "Get started");
904
- outro("After init: rig task run --next puts an agent on your next task.");
905
- return;
906
- }
907
- intro(state.selectedServer ? `server: ${state.selectedServer}` : "rig");
908
- for (const section of TOP_LEVEL_SECTIONS) {
909
- note2(renderCommandBlock(section.commands), `${section.title} \u2014 ${section.subtitle}`);
910
- }
911
- log2.info("More: rig help --advanced \xB7 rig <group> --help \xB7 rig --version");
912
- note2([
913
- commandLine("--project <path>", "Use a project root instead of auto-discovery."),
914
- commandLine("--json", "Emit structured output for scripts/agents."),
915
- commandLine("--dry-run", "Print the command plan without mutating state.")
916
- ].join(`
917
- `), "Global options");
918
- outro("init \u2192 task run \u2192 attach (Pi console: watch + steer live) \u2192 inbox \u2192 merged.");
919
- }
920
947
  function printGroupHelpDocument(groupName) {
921
- const rendered = renderGroupHelp(groupName) ?? renderTopLevelHelp();
922
- if (!shouldUseClackOutput2()) {
923
- console.log(rendered);
924
- return;
925
- }
926
- const group = ALL_GROUPS.find((candidate) => candidate.name === groupName);
927
- if (!group) {
928
- printTopLevelHelp();
929
- return;
930
- }
931
- intro(`rig ${group.name}`);
932
- note2(group.summary, "Purpose");
933
- note2(group.usage.join(`
934
- `), "Usage");
935
- note2(group.commands.map((entry) => commandLine(entry.command, entry.description)).join(`
936
- `), "Commands");
937
- if (group.examples?.length)
938
- note2(group.examples.map((line) => `$ ${line}`).join(`
939
- `), "Examples");
940
- if (group.next?.length)
941
- note2(group.next.map((line) => `\u203A ${line}`).join(`
942
- `), "Next steps");
943
- if (group.advanced?.length)
944
- log2.info(group.advanced.join(`
945
- `));
946
- outro("Run with --json when scripts need structured output.");
948
+ console.log(renderGroupHelp(groupName) ?? renderTopLevelHelp());
947
949
  }
948
950
 
949
951
  // packages/cli/src/commands/stats.ts