@h-rig/cli 0.0.6-alpha.77 → 0.0.6-alpha.79

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 (91) hide show
  1. package/dist/bin/build-rig-binaries.d.ts +2 -0
  2. package/dist/bin/rig.d.ts +2 -0
  3. package/dist/bin/rig.js +10214 -9309
  4. package/dist/src/app/board.d.ts +23 -0
  5. package/dist/src/app/board.js +1786 -0
  6. package/dist/src/app/drone-ui.d.ts +37 -0
  7. package/dist/src/app/drone-ui.js +294 -0
  8. package/dist/src/app/theme.d.ts +47 -0
  9. package/dist/src/{commands/_tui-theme.js → app/theme.js} +16 -1
  10. package/dist/src/commands/_async-ui.d.ts +13 -0
  11. package/dist/src/commands/_async-ui.js +74 -3
  12. package/dist/src/commands/_authority-runs.d.ts +22 -0
  13. package/dist/src/commands/_cli-format.d.ts +49 -0
  14. package/dist/src/commands/_cli-format.js +26 -8
  15. package/dist/src/commands/_connection-state.d.ts +44 -0
  16. package/dist/src/commands/_doctor-checks.d.ts +52 -0
  17. package/dist/src/commands/_doctor-checks.js +3 -1
  18. package/dist/src/commands/_help-catalog.d.ts +51 -0
  19. package/dist/src/commands/_help-catalog.js +9 -70
  20. package/dist/src/commands/_json-output.d.ts +11 -0
  21. package/dist/src/commands/_operator-surface.d.ts +34 -0
  22. package/dist/src/commands/_operator-view.d.ts +30 -0
  23. package/dist/src/commands/_operator-view.js +184 -7
  24. package/dist/src/commands/_parsers.d.ts +15 -0
  25. package/dist/src/commands/_paths.d.ts +11 -0
  26. package/dist/src/commands/_pi-frontend.d.ts +27 -0
  27. package/dist/src/commands/_pi-frontend.js +184 -7
  28. package/dist/src/commands/_pi-install.d.ts +42 -0
  29. package/dist/src/commands/_pi-install.js +1 -1
  30. package/dist/src/commands/_policy.d.ts +8 -0
  31. package/dist/src/commands/_preflight.d.ts +22 -0
  32. package/dist/src/commands/_preflight.js +3 -1
  33. package/dist/src/commands/_probes.d.ts +1 -0
  34. package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
  35. package/dist/src/commands/_run-replay.d.ts +24 -0
  36. package/dist/src/commands/_server-client.d.ts +186 -0
  37. package/dist/src/commands/_server-client.js +3 -1
  38. package/dist/src/commands/_snapshot-upload.d.ts +39 -0
  39. package/dist/src/commands/_snapshot-upload.js +3 -1
  40. package/dist/src/commands/_spinner.d.ts +25 -0
  41. package/dist/src/commands/_task-picker.d.ts +9 -0
  42. package/dist/src/commands/_task-picker.js +132 -7
  43. package/dist/src/commands/agent.d.ts +3 -0
  44. package/dist/src/commands/browser.d.ts +65 -0
  45. package/dist/src/commands/browser.js +306 -30
  46. package/dist/src/commands/connect.d.ts +7 -0
  47. package/dist/src/commands/connect.js +130 -64
  48. package/dist/src/commands/dist.d.ts +28 -0
  49. package/dist/src/commands/doctor.d.ts +3 -0
  50. package/dist/src/commands/doctor.js +77 -4
  51. package/dist/src/commands/github.d.ts +3 -0
  52. package/dist/src/commands/github.js +77 -4
  53. package/dist/src/commands/inbox.d.ts +30 -0
  54. package/dist/src/commands/inbox.js +101 -78
  55. package/dist/src/commands/init.d.ts +74 -0
  56. package/dist/src/commands/init.js +350 -10
  57. package/dist/src/commands/inspect.d.ts +3 -0
  58. package/dist/src/commands/inspect.js +77 -4
  59. package/dist/src/commands/inspector.d.ts +3 -0
  60. package/dist/src/commands/pi.d.ts +3 -0
  61. package/dist/src/commands/plugin.d.ts +16 -0
  62. package/dist/src/commands/profile-and-review.d.ts +4 -0
  63. package/dist/src/commands/queue.d.ts +3 -0
  64. package/dist/src/commands/remote.d.ts +3 -0
  65. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  66. package/dist/src/commands/run.d.ts +3 -0
  67. package/dist/src/commands/run.js +195 -69
  68. package/dist/src/commands/server.d.ts +7 -0
  69. package/dist/src/commands/server.js +133 -65
  70. package/dist/src/commands/setup.d.ts +16 -0
  71. package/dist/src/commands/setup.js +77 -4
  72. package/dist/src/commands/stats.d.ts +12 -0
  73. package/dist/src/commands/stats.js +57 -113
  74. package/dist/src/commands/task-report-bug.d.ts +19 -0
  75. package/dist/src/commands/task-report-bug.js +231 -40
  76. package/dist/src/commands/task-run-driver.d.ts +132 -0
  77. package/dist/src/commands/task-run-driver.js +26 -3
  78. package/dist/src/commands/task.d.ts +14 -0
  79. package/dist/src/commands/task.js +341 -229
  80. package/dist/src/commands/test.d.ts +3 -0
  81. package/dist/src/commands/workspace.d.ts +3 -0
  82. package/dist/src/commands.d.ts +29 -0
  83. package/dist/src/commands.js +10194 -9289
  84. package/dist/src/index.d.ts +4 -0
  85. package/dist/src/index.js +10200 -9295
  86. package/dist/src/launcher.d.ts +61 -0
  87. package/dist/src/report-bug.d.ts +44 -0
  88. package/dist/src/runner.d.ts +47 -0
  89. package/dist/src/withMutedConsole.d.ts +2 -0
  90. package/package.json +10 -9
  91. package/dist/src/commands/_operator-board.js +0 -730
@@ -382,7 +382,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
382
382
  })() : null;
383
383
  if (!response.ok) {
384
384
  const diagnostics = diagnosticMessage(payload);
385
- const detail = diagnostics ?? (text || response.statusText);
385
+ const rawDetail = diagnostics ?? (text || response.statusText);
386
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
387
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
386
388
  const failure = await buildServerFailureContext(context.projectRoot, server);
387
389
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
388
390
  ${failure.contextLine}`, 1, { hint: failure.hint });
@@ -807,8 +809,8 @@ function createOperatorSurface(options = {}) {
807
809
  }
808
810
 
809
811
  // packages/cli/src/commands/_pi-frontend.ts
810
- import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
811
- import { tmpdir } from "os";
812
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, mkdtempSync, readFileSync as readFileSync3, rmSync, writeFileSync as writeFileSync2 } from "fs";
813
+ import { homedir as homedir2, tmpdir } from "os";
812
814
  import { join as join2 } from "path";
813
815
  import { main as runPiMain } from "@earendil-works/pi-coding-agent";
814
816
  import createPiRigExtension from "@rig/pi-rig";
@@ -877,8 +879,79 @@ function createTtySpinner(input) {
877
879
  };
878
880
  }
879
881
 
882
+ // packages/cli/src/app/theme.ts
883
+ var RIG_PALETTE = {
884
+ ink: "#f2f3f6",
885
+ ink2: "#aeb0ba",
886
+ ink3: "#6c6e79",
887
+ ink4: "#44464f",
888
+ accent: "#ccff4d",
889
+ accentDim: "#a9d63f",
890
+ cyan: "#56d8ff",
891
+ red: "#ff5d5d",
892
+ yellow: "#ffd24d"
893
+ };
894
+ function hexToRgb(hex) {
895
+ const value = hex.replace("#", "");
896
+ return [
897
+ Number.parseInt(value.slice(0, 2), 16),
898
+ Number.parseInt(value.slice(2, 4), 16),
899
+ Number.parseInt(value.slice(4, 6), 16)
900
+ ];
901
+ }
902
+ function fg(hex) {
903
+ const [r, g, b] = hexToRgb(hex);
904
+ return (text2) => `\x1B[38;2;${r};${g};${b}m${text2}\x1B[39m`;
905
+ }
906
+ var ink = fg(RIG_PALETTE.ink);
907
+ var ink2 = fg(RIG_PALETTE.ink2);
908
+ var ink3 = fg(RIG_PALETTE.ink3);
909
+ var ink4 = fg(RIG_PALETTE.ink4);
910
+ var accent = fg(RIG_PALETTE.accent);
911
+ var accentDim = fg(RIG_PALETTE.accentDim);
912
+ var cyan = fg(RIG_PALETTE.cyan);
913
+ var red = fg(RIG_PALETTE.red);
914
+ var yellow = fg(RIG_PALETTE.yellow);
915
+ function bold(text2) {
916
+ return `\x1B[1m${text2}\x1B[22m`;
917
+ }
918
+ var DRONE_ART = [
919
+ " .-=-. .-=-. ",
920
+ " ( !!! ) ( !!! ) ",
921
+ " '-=-'._ _.'-=-' ",
922
+ " '._ _.' ",
923
+ " '=$$$$$$$=.' ",
924
+ " =$$$$$$$$$$$= ",
925
+ " $$$@@@@@@@@@@$$$ ",
926
+ " $$$@@ @@$$$ ",
927
+ " $$@ ? @$$$ ",
928
+ " $$$@ '-' @$$$ ",
929
+ " $$$@@ @@$$$ ",
930
+ " $$$@@@@@@@@@@$$$ ",
931
+ " =$$$$$$$$$$$= ",
932
+ " '=$$$$$$$=.' ",
933
+ " _.' '._ ",
934
+ " .-=-.' '.-=-. ",
935
+ " ( !!! ) ( !!! ) ",
936
+ " '-=-' '-=-' "
937
+ ];
938
+ var EYE_FRAMES = ["@", "o", "."];
939
+ var DRONE_WIDTH = DRONE_ART[0].length;
940
+ var DRONE_HEIGHT = DRONE_ART.length;
941
+ var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
942
+ function microDroneFrame(tick) {
943
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
944
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
945
+ return `(${blade})${eye}(${blade})`;
946
+ }
947
+ var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
948
+ function renderMicroDroneFrame(tick) {
949
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
950
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
951
+ return `${ink4("(")}${cyan(blade)}${ink4(")")}${bold(accent(eye))}${ink4("(")}${cyan(blade)}${ink4(")")}`;
952
+ }
953
+
880
954
  // packages/cli/src/commands/_async-ui.ts
881
- var CLACK_SPINNER_FRAMES = ["\u25D2", "\u25D0", "\u25D3", "\u25D1"];
882
955
  var DONE_SYMBOL = pc.green("\u25C7");
883
956
  var FAIL_SYMBOL = pc.red("\u25A0");
884
957
  var activeUpdate = null;
@@ -912,8 +985,8 @@ async function withSpinner(label, work, options = {}) {
912
985
  const spinner = createTtySpinner({
913
986
  label,
914
987
  output,
915
- frames: CLACK_SPINNER_FRAMES,
916
- styleFrame: (frame) => pc.magenta(frame)
988
+ frames: MICRO_DRONE_FRAMES,
989
+ styleFrame: (frame) => renderMicroDroneFrame(Math.max(0, MICRO_DRONE_FRAMES.indexOf(frame)))
917
990
  });
918
991
  const update = (next) => {
919
992
  lastLabel = next;
@@ -954,6 +1027,7 @@ function buildOperatorPiEnv(input) {
954
1027
  return {
955
1028
  PI_CODING_AGENT_SESSION_DIR: input.sessionDir,
956
1029
  PI_SKIP_VERSION_CHECK: "1",
1030
+ PI_HIDDEN_COMMANDS: "import,fork,clone,tree,new,resume,trust",
957
1031
  RIG_PI_OPERATOR_SESSION: "1",
958
1032
  RIG_RUN_ID: input.runId,
959
1033
  RIG_SERVER_URL: input.serverUrl,
@@ -963,6 +1037,10 @@ function buildOperatorPiEnv(input) {
963
1037
  }
964
1038
  async function prepareOperatorConsole(context, runId, tempSessionDir) {
965
1039
  const server = await ensureServerForCli(context.projectRoot);
1040
+ const localCwd = join2(homedir2(), ".rig", "drones", runId.slice(0, 8));
1041
+ mkdirSync2(localCwd, { recursive: true });
1042
+ trustDroneCwd(localCwd);
1043
+ installRigPiTheme();
966
1044
  let sessionFileArg = [];
967
1045
  try {
968
1046
  const payload = await requestServerJson(context, `/api/runs/${encodeURIComponent(runId)}/session-file`);
@@ -976,7 +1054,7 @@ async function prepareOperatorConsole(context, runId, tempSessionDir) {
976
1054
  try {
977
1055
  const header = JSON.parse(line);
978
1056
  if (header.type === "session" && typeof header.cwd === "string") {
979
- return JSON.stringify({ ...header, cwd: process.cwd() });
1057
+ return JSON.stringify({ ...header, cwd: localCwd });
980
1058
  }
981
1059
  } catch {}
982
1060
  return line;
@@ -988,6 +1066,105 @@ async function prepareOperatorConsole(context, runId, tempSessionDir) {
988
1066
  } catch {}
989
1067
  return { server, sessionFileArg };
990
1068
  }
1069
+ var RIG_PI_THEME = {
1070
+ $schema: "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
1071
+ name: "rig",
1072
+ vars: {
1073
+ acid: "#ccff4d",
1074
+ acidDim: "#a9d63f",
1075
+ cyan: "#56d8ff",
1076
+ red: "#ff5d5d",
1077
+ yellow: "#ffd24d",
1078
+ ink: "#f2f3f6",
1079
+ ink2: "#aeb0ba",
1080
+ ink3: "#6c6e79",
1081
+ ink4: "#44464f",
1082
+ panel: "#101115",
1083
+ panelUser: "#14161b",
1084
+ toolPending: "#0e1013",
1085
+ toolSuccess: "#10150c",
1086
+ toolError: "#1a0f0f",
1087
+ customMsg: "#0f1410"
1088
+ },
1089
+ colors: {
1090
+ accent: "acid",
1091
+ border: "ink4",
1092
+ borderAccent: "acid",
1093
+ borderMuted: "ink4",
1094
+ success: "acid",
1095
+ error: "red",
1096
+ warning: "yellow",
1097
+ muted: "ink3",
1098
+ dim: "ink4",
1099
+ text: "ink",
1100
+ thinkingText: "ink3",
1101
+ selectedBg: "panel",
1102
+ userMessageBg: "panelUser",
1103
+ userMessageText: "ink",
1104
+ customMessageBg: "customMsg",
1105
+ customMessageText: "ink2",
1106
+ customMessageLabel: "acidDim",
1107
+ toolPendingBg: "toolPending",
1108
+ toolSuccessBg: "toolSuccess",
1109
+ toolErrorBg: "toolError",
1110
+ toolTitle: "ink",
1111
+ toolOutput: "ink3",
1112
+ mdHeading: "acid",
1113
+ mdLink: "cyan",
1114
+ mdLinkUrl: "ink4",
1115
+ mdCode: "acidDim",
1116
+ mdCodeBlock: "ink2",
1117
+ mdCodeBlockBorder: "ink4",
1118
+ mdQuote: "ink3",
1119
+ mdQuoteBorder: "ink4",
1120
+ mdHr: "ink4",
1121
+ mdListBullet: "acid",
1122
+ toolDiffAdded: "acid",
1123
+ toolDiffRemoved: "red",
1124
+ toolDiffContext: "ink3",
1125
+ syntaxComment: "ink3",
1126
+ syntaxKeyword: "cyan",
1127
+ syntaxFunction: "acid",
1128
+ syntaxVariable: "ink",
1129
+ syntaxString: "acidDim",
1130
+ syntaxNumber: "yellow",
1131
+ syntaxType: "cyan",
1132
+ syntaxOperator: "ink2",
1133
+ syntaxPunctuation: "ink3",
1134
+ thinkingOff: "ink4",
1135
+ thinkingMinimal: "ink3",
1136
+ thinkingLow: "ink2",
1137
+ thinkingMedium: "cyan",
1138
+ thinkingHigh: "acidDim",
1139
+ thinkingXhigh: "acid",
1140
+ bashMode: "cyan"
1141
+ }
1142
+ };
1143
+ function trustDroneCwd(localCwd) {
1144
+ try {
1145
+ const agentDir = join2(homedir2(), ".pi", "agent");
1146
+ mkdirSync2(agentDir, { recursive: true });
1147
+ const trustPath = join2(agentDir, "trust.json");
1148
+ const store = existsSync4(trustPath) ? JSON.parse(readFileSync3(trustPath, "utf8")) : {};
1149
+ if (store[localCwd] !== true) {
1150
+ store[localCwd] = true;
1151
+ writeFileSync2(trustPath, `${JSON.stringify(store, null, "\t")}
1152
+ `);
1153
+ }
1154
+ } catch {}
1155
+ }
1156
+ function installRigPiTheme() {
1157
+ try {
1158
+ const themesDir = join2(homedir2(), ".pi", "agent", "themes");
1159
+ mkdirSync2(themesDir, { recursive: true });
1160
+ const themePath = join2(themesDir, "rig.json");
1161
+ const next = `${JSON.stringify(RIG_PI_THEME, null, "\t")}
1162
+ `;
1163
+ if (!existsSync4(themePath) || readFileSync3(themePath, "utf8") !== next) {
1164
+ writeFileSync2(themePath, next);
1165
+ }
1166
+ } catch {}
1167
+ }
991
1168
  async function attachRunBundledPiFrontend(context, input) {
992
1169
  const tempSessionDir = mkdtempSync(join2(tmpdir(), "rig-pi-frontend-sessions-"));
993
1170
  const { server, sessionFileArg } = await withSpinner(`Opening Pi console for run ${input.runId}\u2026`, () => prepareOperatorConsole(context, input.runId, tempSessionDir), { outputMode: context.outputMode });
@@ -1124,67 +1301,19 @@ async function attachRunOperatorView(context, input) {
1124
1301
  return { ...snapshot, steered, detached };
1125
1302
  }
1126
1303
 
1127
- // packages/cli/src/commands/_cli-format.ts
1128
- import { log, note } from "@clack/prompts";
1129
- import pc2 from "picocolors";
1130
-
1131
- // packages/cli/src/commands/_tui-theme.ts
1132
- var RIG_PALETTE = {
1133
- ink: "#f2f3f6",
1134
- ink2: "#aeb0ba",
1135
- ink3: "#6c6e79",
1136
- ink4: "#44464f",
1137
- accent: "#ccff4d",
1138
- accentDim: "#a9d63f",
1139
- cyan: "#56d8ff",
1140
- red: "#ff5d5d",
1141
- yellow: "#ffd24d"
1142
- };
1143
- function hexToRgb(hex) {
1144
- const value = hex.replace("#", "");
1145
- return [
1146
- Number.parseInt(value.slice(0, 2), 16),
1147
- Number.parseInt(value.slice(2, 4), 16),
1148
- Number.parseInt(value.slice(4, 6), 16)
1149
- ];
1150
- }
1151
- function fg(hex) {
1152
- const [r, g, b] = hexToRgb(hex);
1153
- return (text2) => `\x1B[38;2;${r};${g};${b}m${text2}\x1B[39m`;
1304
+ // packages/cli/src/app/drone-ui.ts
1305
+ import { ProcessTerminal, TUI, Text, Input, SelectList, matchesKey } from "@earendil-works/pi-tui";
1306
+ function droneNote(message, title) {
1307
+ if (title)
1308
+ console.log(` ${accentDim("\u25C7")} ${bold(ink2(title))}`);
1309
+ for (const line of message.split(`
1310
+ `)) {
1311
+ console.log(` ${ink4("\u2502")} ${line}`);
1312
+ }
1154
1313
  }
1155
- var ink = fg(RIG_PALETTE.ink);
1156
- var ink2 = fg(RIG_PALETTE.ink2);
1157
- var ink3 = fg(RIG_PALETTE.ink3);
1158
- var ink4 = fg(RIG_PALETTE.ink4);
1159
- var accent = fg(RIG_PALETTE.accent);
1160
- var accentDim = fg(RIG_PALETTE.accentDim);
1161
- var cyan = fg(RIG_PALETTE.cyan);
1162
- var red = fg(RIG_PALETTE.red);
1163
- var yellow = fg(RIG_PALETTE.yellow);
1164
- var DRONE_ART = [
1165
- " .-=-. .-=-. ",
1166
- " ( !!! ) ( !!! ) ",
1167
- " '-=-'._ _.'-=-' ",
1168
- " '._ _.' ",
1169
- " '=$$$$$$$=.' ",
1170
- " =$$$$$$$$$$$= ",
1171
- " $$$@@@@@@@@@@$$$ ",
1172
- " $$$@@ @@$$$ ",
1173
- " $$@ ? @$$$ ",
1174
- " $$$@ '-' @$$$ ",
1175
- " $$$@@ @@$$$ ",
1176
- " $$$@@@@@@@@@@$$$ ",
1177
- " =$$$$$$$$$$$= ",
1178
- " '=$$$$$$$=.' ",
1179
- " _.' '._ ",
1180
- " .-=-.' '.-=-. ",
1181
- " ( !!! ) ( !!! ) ",
1182
- " '-=-' '-=-' "
1183
- ];
1184
- var DRONE_WIDTH = DRONE_ART[0].length;
1185
- var DRONE_HEIGHT = DRONE_ART.length;
1186
1314
 
1187
1315
  // packages/cli/src/commands/_cli-format.ts
1316
+ import pc2 from "picocolors";
1188
1317
  var themeDim = (value) => ink3(value);
1189
1318
  var themeFaint = (value) => ink4(value);
1190
1319
  function stringField(record, key, fallback = "") {
@@ -1250,10 +1379,7 @@ function printFormattedOutput(message, options = {}) {
1250
1379
  console.log(message);
1251
1380
  return;
1252
1381
  }
1253
- if (options.title)
1254
- note(message, options.title);
1255
- else
1256
- log.message(message);
1382
+ droneNote(message, options.title);
1257
1383
  }
1258
1384
  function formatStatusPill(status) {
1259
1385
  const label = status || "unknown";
@@ -0,0 +1,7 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import type { CommandOutcome } from "@rig/runtime/control-plane/runtime/types";
3
+ import { type SubmitTaskRunInput } from "./_server-client";
4
+ export type RigOwnedTaskRunFn = (context: RunnerContext, input: SubmitTaskRunInput) => Promise<unknown>;
5
+ export declare function executeServer(context: RunnerContext, args: string[], options: {
6
+ executeRigOwnedTaskRun: RigOwnedTaskRunFn;
7
+ }): Promise<CommandOutcome>;
@@ -69,8 +69,133 @@ function normalizeRuntimeAdapter(value) {
69
69
  return "claude-code";
70
70
  }
71
71
 
72
- // packages/cli/src/commands/connect.ts
73
- import { cancel, isCancel, select } from "@clack/prompts";
72
+ // packages/cli/src/app/drone-ui.ts
73
+ import { ProcessTerminal, TUI, Text, Input, SelectList, matchesKey } from "@earendil-works/pi-tui";
74
+
75
+ // packages/cli/src/app/theme.ts
76
+ var RIG_PALETTE = {
77
+ ink: "#f2f3f6",
78
+ ink2: "#aeb0ba",
79
+ ink3: "#6c6e79",
80
+ ink4: "#44464f",
81
+ accent: "#ccff4d",
82
+ accentDim: "#a9d63f",
83
+ cyan: "#56d8ff",
84
+ red: "#ff5d5d",
85
+ yellow: "#ffd24d"
86
+ };
87
+ function hexToRgb(hex) {
88
+ const value = hex.replace("#", "");
89
+ return [
90
+ Number.parseInt(value.slice(0, 2), 16),
91
+ Number.parseInt(value.slice(2, 4), 16),
92
+ Number.parseInt(value.slice(4, 6), 16)
93
+ ];
94
+ }
95
+ function fg(hex) {
96
+ const [r, g, b] = hexToRgb(hex);
97
+ return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
98
+ }
99
+ var ink = fg(RIG_PALETTE.ink);
100
+ var ink2 = fg(RIG_PALETTE.ink2);
101
+ var ink3 = fg(RIG_PALETTE.ink3);
102
+ var ink4 = fg(RIG_PALETTE.ink4);
103
+ var accent = fg(RIG_PALETTE.accent);
104
+ var accentDim = fg(RIG_PALETTE.accentDim);
105
+ var cyan = fg(RIG_PALETTE.cyan);
106
+ var red = fg(RIG_PALETTE.red);
107
+ var yellow = fg(RIG_PALETTE.yellow);
108
+ function bold(text) {
109
+ return `\x1B[1m${text}\x1B[22m`;
110
+ }
111
+ var DRONE_ART = [
112
+ " .-=-. .-=-. ",
113
+ " ( !!! ) ( !!! ) ",
114
+ " '-=-'._ _.'-=-' ",
115
+ " '._ _.' ",
116
+ " '=$$$$$$$=.' ",
117
+ " =$$$$$$$$$$$= ",
118
+ " $$$@@@@@@@@@@$$$ ",
119
+ " $$$@@ @@$$$ ",
120
+ " $$@ ? @$$$ ",
121
+ " $$$@ '-' @$$$ ",
122
+ " $$$@@ @@$$$ ",
123
+ " $$$@@@@@@@@@@$$$ ",
124
+ " =$$$$$$$$$$$= ",
125
+ " '=$$$$$$$=.' ",
126
+ " _.' '._ ",
127
+ " .-=-.' '.-=-. ",
128
+ " ( !!! ) ( !!! ) ",
129
+ " '-=-' '-=-' "
130
+ ];
131
+ var EYE_FRAMES = ["@", "o", "."];
132
+ var DRONE_WIDTH = DRONE_ART[0].length;
133
+ var DRONE_HEIGHT = DRONE_ART.length;
134
+ var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
135
+ function microDroneFrame(tick) {
136
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
137
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
138
+ return `(${blade})${eye}(${blade})`;
139
+ }
140
+ var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
141
+
142
+ // packages/cli/src/app/drone-ui.ts
143
+ var isTty = () => Boolean(process.stdout.isTTY);
144
+ function droneCancel(text) {
145
+ console.log(` ${red("\u2716")} ${ink3(text)}`);
146
+ }
147
+ var SELECT_THEME = {
148
+ selectedPrefix: (text) => accent(text),
149
+ selectedText: (text) => bold(ink(text)),
150
+ description: (text) => ink3(text),
151
+ scrollInfo: (text) => ink4(text),
152
+ noMatch: (text) => ink3(text)
153
+ };
154
+ async function runMiniTui(build) {
155
+ const terminal = new ProcessTerminal;
156
+ const tui = new TUI(terminal);
157
+ let settled = false;
158
+ return await new Promise((resolve) => {
159
+ const finish = (result) => {
160
+ if (settled)
161
+ return;
162
+ settled = true;
163
+ tui.stop();
164
+ resolve(result);
165
+ };
166
+ build(tui, finish);
167
+ tui.start();
168
+ });
169
+ }
170
+ async function droneSelect(input) {
171
+ if (!isTty() || input.options.length === 0) {
172
+ return input.initialValue ?? input.options[0]?.value ?? null;
173
+ }
174
+ return runMiniTui((tui, finish) => {
175
+ tui.addChild(new Text(` ${accent("\u258D")}${bold(ink(input.message))}`));
176
+ const items = input.options.map((option) => ({
177
+ value: option.value,
178
+ label: option.label,
179
+ ...option.hint ? { description: option.hint } : {}
180
+ }));
181
+ const list = new SelectList(items, Math.min(items.length, 12), SELECT_THEME);
182
+ const initialIndex = input.initialValue ? items.findIndex((item) => item.value === input.initialValue) : -1;
183
+ if (initialIndex > 0)
184
+ list.setSelectedIndex(initialIndex);
185
+ list.onSelect = (item) => finish(item.value);
186
+ list.onCancel = () => finish(null);
187
+ tui.addChild(list);
188
+ tui.addChild(new Text(ink4(" \u2191\u2193 navigate \xB7 enter select \xB7 esc cancel")));
189
+ tui.setFocus(list);
190
+ tui.addInputListener((data) => {
191
+ if (matchesKey(data, "ctrl+c") || matchesKey(data, "escape")) {
192
+ finish(null);
193
+ return { consume: true };
194
+ }
195
+ return;
196
+ });
197
+ });
198
+ }
74
199
 
75
200
  // packages/cli/src/commands/_connection-state.ts
76
201
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -182,66 +307,7 @@ function writeRepoServerProjectRoot(projectRoot, serverProjectRoot) {
182
307
  }
183
308
 
184
309
  // packages/cli/src/commands/_cli-format.ts
185
- import { log, note } from "@clack/prompts";
186
310
  import pc from "picocolors";
187
-
188
- // packages/cli/src/commands/_tui-theme.ts
189
- var RIG_PALETTE = {
190
- ink: "#f2f3f6",
191
- ink2: "#aeb0ba",
192
- ink3: "#6c6e79",
193
- ink4: "#44464f",
194
- accent: "#ccff4d",
195
- accentDim: "#a9d63f",
196
- cyan: "#56d8ff",
197
- red: "#ff5d5d",
198
- yellow: "#ffd24d"
199
- };
200
- function hexToRgb(hex) {
201
- const value = hex.replace("#", "");
202
- return [
203
- Number.parseInt(value.slice(0, 2), 16),
204
- Number.parseInt(value.slice(2, 4), 16),
205
- Number.parseInt(value.slice(4, 6), 16)
206
- ];
207
- }
208
- function fg(hex) {
209
- const [r, g, b] = hexToRgb(hex);
210
- return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
211
- }
212
- var ink = fg(RIG_PALETTE.ink);
213
- var ink2 = fg(RIG_PALETTE.ink2);
214
- var ink3 = fg(RIG_PALETTE.ink3);
215
- var ink4 = fg(RIG_PALETTE.ink4);
216
- var accent = fg(RIG_PALETTE.accent);
217
- var accentDim = fg(RIG_PALETTE.accentDim);
218
- var cyan = fg(RIG_PALETTE.cyan);
219
- var red = fg(RIG_PALETTE.red);
220
- var yellow = fg(RIG_PALETTE.yellow);
221
- var DRONE_ART = [
222
- " .-=-. .-=-. ",
223
- " ( !!! ) ( !!! ) ",
224
- " '-=-'._ _.'-=-' ",
225
- " '._ _.' ",
226
- " '=$$$$$$$=.' ",
227
- " =$$$$$$$$$$$= ",
228
- " $$$@@@@@@@@@@$$$ ",
229
- " $$$@@ @@$$$ ",
230
- " $$@ ? @$$$ ",
231
- " $$$@ '-' @$$$ ",
232
- " $$$@@ @@$$$ ",
233
- " $$$@@@@@@@@@@$$$ ",
234
- " =$$$$$$$$$$$= ",
235
- " '=$$$$$$$=.' ",
236
- " _.' '._ ",
237
- " .-=-.' '.-=-. ",
238
- " ( !!! ) ( !!! ) ",
239
- " '-=-' '-=-' "
240
- ];
241
- var DRONE_WIDTH = DRONE_ART[0].length;
242
- var DRONE_HEIGHT = DRONE_ART.length;
243
-
244
- // packages/cli/src/commands/_cli-format.ts
245
311
  var themeDim = (value) => ink3(value);
246
312
  var themeFaint = (value) => ink4(value);
247
313
  function truncate(value, width) {
@@ -346,13 +412,13 @@ async function promptForConnectionAlias(context) {
346
412
  hint: connection.kind === "remote" ? connection.baseUrl : "local"
347
413
  }))
348
414
  ].filter((option, index, all) => all.findIndex((candidate) => candidate.value === option.value) === index);
349
- const answer = await select({
415
+ const answer = await droneSelect({
350
416
  message: "Select Rig server for this repo",
351
417
  initialValue: repo?.selected ?? "local",
352
418
  options
353
419
  });
354
- if (isCancel(answer)) {
355
- cancel("No server selected.");
420
+ if (answer === null) {
421
+ droneCancel("No server selected.");
356
422
  throw new CliError("No server selected.", 3);
357
423
  }
358
424
  return String(answer);
@@ -606,7 +672,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
606
672
  })() : null;
607
673
  if (!response.ok) {
608
674
  const diagnostics = diagnosticMessage(payload);
609
- const detail = diagnostics ?? (text || response.statusText);
675
+ const rawDetail = diagnostics ?? (text || response.statusText);
676
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
677
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
610
678
  const failure = await buildServerFailureContext(context.projectRoot, server);
611
679
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
612
680
  ${failure.contextLine}`, 1, { hint: failure.hint });
@@ -0,0 +1,16 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import { type RigPluginWithRuntime } from "@rig/core";
3
+ import type { TaskSourceConfig } from "@rig/contracts";
4
+ import type { CommandOutcome } from "@rig/runtime/control-plane/runtime/types";
5
+ export declare function executeSetup(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
6
+ type SetupCheck = {
7
+ ok: boolean;
8
+ label: string;
9
+ hint?: string;
10
+ };
11
+ type SetupRigConfig = {
12
+ plugins?: readonly RigPluginWithRuntime[];
13
+ taskSource?: TaskSourceConfig;
14
+ };
15
+ export declare function buildTaskSourceKindSetupCheck(config: SetupRigConfig): SetupCheck | null;
16
+ export {};
@@ -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;