@h-rig/cli 0.0.6-alpha.88 → 0.0.6-alpha.89

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 (70) hide show
  1. package/dist/bin/rig.js +1159 -292
  2. package/dist/src/app/board.js +462 -48
  3. package/dist/src/app-opentui/adapters/doctor.js +458 -46
  4. package/dist/src/app-opentui/adapters/family.js +670 -147
  5. package/dist/src/app-opentui/adapters/fleet.js +477 -46
  6. package/dist/src/app-opentui/adapters/inbox.js +477 -46
  7. package/dist/src/app-opentui/adapters/init.js +497 -74
  8. package/dist/src/app-opentui/adapters/inspect.js +477 -46
  9. package/dist/src/app-opentui/adapters/pi-attach.js +484 -53
  10. package/dist/src/app-opentui/adapters/run-detail.js +477 -46
  11. package/dist/src/app-opentui/adapters/server.d.ts +26 -0
  12. package/dist/src/app-opentui/adapters/server.js +676 -59
  13. package/dist/src/app-opentui/adapters/tasks.js +539 -81
  14. package/dist/src/app-opentui/autocomplete.js +4 -2
  15. package/dist/src/app-opentui/bootstrap.js +1155 -288
  16. package/dist/src/app-opentui/command-palette.js +37 -10
  17. package/dist/src/app-opentui/index.js +566 -89
  18. package/dist/src/app-opentui/intent.js +33 -8
  19. package/dist/src/app-opentui/keymap.js +43 -29
  20. package/dist/src/app-opentui/pi-host-child.js +465 -53
  21. package/dist/src/app-opentui/react/App.js +104 -44
  22. package/dist/src/app-opentui/react/ChromeHost.js +16 -4
  23. package/dist/src/app-opentui/react/launch.js +555 -88
  24. package/dist/src/app-opentui/react/nav.js +1 -1
  25. package/dist/src/app-opentui/registry.js +1062 -237
  26. package/dist/src/app-opentui/remote-link.d.ts +10 -0
  27. package/dist/src/app-opentui/remote-link.js +47 -0
  28. package/dist/src/app-opentui/runtime.js +566 -89
  29. package/dist/src/app-opentui/scenes/doctor.js +1 -1
  30. package/dist/src/app-opentui/scenes/error.js +50 -4
  31. package/dist/src/app-opentui/scenes/family.js +60 -6
  32. package/dist/src/app-opentui/scenes/fleet.js +65 -13
  33. package/dist/src/app-opentui/scenes/help.js +4 -2
  34. package/dist/src/app-opentui/scenes/init.js +12 -12
  35. package/dist/src/app-opentui/scenes/main.js +7 -7
  36. package/dist/src/app-opentui/scenes/server.js +83 -11
  37. package/dist/src/app-opentui/scenes/tasks.js +79 -16
  38. package/dist/src/app-opentui/state.js +25 -5
  39. package/dist/src/app-opentui/surface-catalog.js +4 -2
  40. package/dist/src/app-opentui/types.d.ts +1 -1
  41. package/dist/src/commands/_cli-format.d.ts +10 -1
  42. package/dist/src/commands/_cli-format.js +5 -2
  43. package/dist/src/commands/_connection-state.d.ts +11 -1
  44. package/dist/src/commands/_connection-state.js +50 -5
  45. package/dist/src/commands/_doctor-checks.js +458 -46
  46. package/dist/src/commands/_help-catalog.js +4 -2
  47. package/dist/src/commands/_json-output.js +4 -0
  48. package/dist/src/commands/_operator-view.js +465 -53
  49. package/dist/src/commands/_pi-frontend.js +465 -53
  50. package/dist/src/commands/_preflight.js +509 -72
  51. package/dist/src/commands/_server-client.d.ts +33 -0
  52. package/dist/src/commands/_server-client.js +477 -46
  53. package/dist/src/commands/_server-events.js +446 -41
  54. package/dist/src/commands/_snapshot-upload.js +460 -48
  55. package/dist/src/commands/connect.js +620 -15
  56. package/dist/src/commands/doctor.js +458 -46
  57. package/dist/src/commands/github.js +462 -50
  58. package/dist/src/commands/inbox.js +458 -46
  59. package/dist/src/commands/init.js +497 -74
  60. package/dist/src/commands/inspect.js +458 -46
  61. package/dist/src/commands/run.js +465 -53
  62. package/dist/src/commands/server.js +647 -163
  63. package/dist/src/commands/setup.js +463 -51
  64. package/dist/src/commands/stats.js +462 -48
  65. package/dist/src/commands/task-run-driver.js +464 -52
  66. package/dist/src/commands/task.js +520 -81
  67. package/dist/src/commands.js +670 -147
  68. package/dist/src/index.js +674 -147
  69. package/dist/src/launcher.js +4 -0
  70. package/package.json +8 -8
@@ -305,7 +305,7 @@ function sparklineString(values, width) {
305
305
 
306
306
  // packages/cli/src/app-opentui/scenes/main.ts
307
307
  var CONFIGURED_MENU = [
308
- ["init", "setup, reconfigure, repair project state", { id: "init", label: "init", intent: { scene: "command", argv: ["init"], action: { kind: "command-run", label: "Run init" } }, message: "run setup/reconfigure flow" }],
308
+ ["init", "guided setup, reconfigure, repair project state", { id: "init", label: "init", intent: { scene: "init", argv: ["init"], action: { kind: "refresh", label: "Open init" } }, message: "open native init flow" }],
309
309
  ["server", "local/remote target, auth, linkage", { id: "server", label: "server", intent: { scene: "server", argv: ["server", "status"], action: { kind: "refresh", label: "Checking server" } }, message: "check selected server" }],
310
310
  ["github", "auth, selected repo, stored token", { id: "github", label: "github", intent: { scene: "server", argv: ["github", "auth", "status"], action: { kind: "refresh", label: "Checking GitHub auth" } }, message: "check GitHub auth" }],
311
311
  ["tasks", "browse, filter, dispatch, attach active work", { id: "tasks", label: "tasks", intent: { scene: "tasks", argv: ["tasks"], action: { kind: "refresh", label: "Opening tasks" } }, message: "selected tasks" }],
@@ -324,10 +324,10 @@ var CONFIGURED_MENU = [
324
324
  ["help", "all actions, shortcuts, mouse controls", { id: "help", label: "help", intent: { scene: "help", argv: ["help"], action: { kind: "none", label: "Opening help" } }, message: "selected help" }]
325
325
  ];
326
326
  var ONBOARD_PRIMARY = {
327
- id: "onboard-setup",
328
- label: "Start guided setup",
329
- intent: { scene: "init", argv: ["init"], action: { kind: "refresh", label: "Setup" } },
330
- message: "open the guided setup checklist"
327
+ id: "onboard-init",
328
+ label: "Start guided init",
329
+ intent: { scene: "init", argv: ["init"], action: { kind: "refresh", label: "Init" } },
330
+ message: "open the native init checklist"
331
331
  };
332
332
  var ONBOARD_SECONDARY = [
333
333
  ["server", "select a local or remote target", { id: "server", label: "server", intent: { scene: "server", argv: ["server", "status"], action: { kind: "refresh", label: "Checking server" } }, message: "check selected server" }],
@@ -390,7 +390,7 @@ function configuredMenuRows(selectedIndex) {
390
390
  }));
391
391
  }
392
392
  function onboardingRows(selectedIndex) {
393
- const primary = selectableDeckRow({ label: "setup", detail: "Start guided setup \u2014 recommended", active: selectedIndex === 0 }, ONBOARD_PRIMARY);
393
+ const primary = selectableDeckRow({ label: "init", detail: "Start guided init \u2014 recommended", active: selectedIndex === 0 }, ONBOARD_PRIMARY);
394
394
  const secondary = ONBOARD_SECONDARY.map(([label, detail, item], index) => ({
395
395
  ...deckRow({ label, detail, index: index + 1, active: selectedIndex === index + 1, activateOnClick: true }),
396
396
  selectable: item
@@ -454,7 +454,7 @@ function renderMainScene(state, layout) {
454
454
  statusLine(state)
455
455
  ] : [
456
456
  line("WELCOME", { fg: RIG_UI.ink, bold: true }),
457
- line("This project isn't set up yet. One guided flow gets you running.", { fg: RIG_UI.ink2 }),
457
+ line("This project isn't initialized yet. One native init flow gets you running.", { fg: RIG_UI.ink2 }),
458
458
  blank(),
459
459
  line("GET STARTED", { fg: RIG_UI.ink, bold: true }),
460
460
  ...onboardingRows(actionSelected),
@@ -557,12 +557,13 @@ var PRIMARY_GROUPS = [
557
557
  {
558
558
  name: "server",
559
559
  summary: "Choose, inspect, and start the Rig server that owns tasks and runs.",
560
- usage: ["rig server <status|list|add|use|start> [options]"],
560
+ usage: ["rig server <status|list|add|use|repair-link|start> [options]"],
561
561
  commands: [
562
- { command: "status", description: "Show the selected server for this repo.", primary: true },
562
+ { command: "status", description: "Show the selected server and remote project-root link for this repo.", primary: true },
563
563
  { command: "use local", description: "Switch this repo to the local Rig server.", primary: true },
564
564
  { command: "add <alias> <url>", description: "Save a remote Rig server URL.", primary: true },
565
565
  { command: "use <alias>", description: "Select a saved remote server alias.", primary: true },
566
+ { command: "repair-link [--prepare|--backfill-only] [--repo owner/repo]", description: "Backfill or prepare the selected remote's server-host checkout link.", primary: true },
566
567
  { command: "list", description: "List saved local/remote server aliases.", primary: true },
567
568
  { command: "start [--host <host>] [--port <n>]", description: "Start a local rig-server process." }
568
569
  ],
@@ -570,6 +571,7 @@ var PRIMARY_GROUPS = [
570
571
  "rig server status",
571
572
  "rig server add prod https://where.rig-does.work",
572
573
  "rig server use prod",
574
+ "rig server repair-link --repo owner/repo",
573
575
  "rig server use local",
574
576
  "rig server start --port 3773"
575
577
  ],
@@ -1133,17 +1135,63 @@ function renderHelpScene(state, layout) {
1133
1135
  });
1134
1136
  }
1135
1137
 
1138
+ // packages/cli/src/app-opentui/remote-link.ts
1139
+ var REPAIRABLE_REMOTE_LINK_STATUSES = new Set([
1140
+ "auth_required",
1141
+ "project_not_registered",
1142
+ "no_server_checkout",
1143
+ "invalid_root",
1144
+ "needs_prepare",
1145
+ "error"
1146
+ ]);
1147
+ function remoteProjectLinkError(message) {
1148
+ return /no server-host project root link|remote project(?:-root)? link|x-rig-project-root|serverProjectRoot/i.test(message ?? "");
1149
+ }
1150
+ function serverRecordForRemoteLink(state) {
1151
+ const server = state.data.server;
1152
+ return server && typeof server === "object" && !Array.isArray(server) ? server : null;
1153
+ }
1154
+ function remoteProjectLinkState(state) {
1155
+ const serverRecord = serverRecordForRemoteLink(state);
1156
+ if (!serverRecord || serverRecord.kind !== "remote")
1157
+ return null;
1158
+ const link = serverRecord.remoteProjectLink;
1159
+ if (link && typeof link === "object" && !Array.isArray(link))
1160
+ return link;
1161
+ const direct = state.data.remoteProjectLink;
1162
+ if (direct && typeof direct === "object" && !Array.isArray(direct))
1163
+ return direct;
1164
+ return null;
1165
+ }
1166
+ function shouldOfferRemoteLinkRepair(state, message) {
1167
+ const link = remoteProjectLinkState(state);
1168
+ if (link) {
1169
+ if (link.ok === true)
1170
+ return false;
1171
+ const status = link.status ?? "";
1172
+ return REPAIRABLE_REMOTE_LINK_STATUSES.has(status);
1173
+ }
1174
+ const serverRecord = serverRecordForRemoteLink(state);
1175
+ if (serverRecord && serverRecord.kind !== "remote")
1176
+ return false;
1177
+ return remoteProjectLinkError(message ?? state.error?.message);
1178
+ }
1179
+
1136
1180
  // packages/cli/src/app-opentui/scenes/error.ts
1137
1181
  var ERROR_ACTIONS = [
1138
1182
  { detail: "return to dashboard", item: { id: "main", label: "main", intent: { scene: "main", argv: [], action: { kind: "refresh", label: "Back to dashboard" } }, message: "back to dashboard" } },
1139
1183
  { detail: "run diagnostics", item: { id: "doctor", label: "doctor", intent: { scene: "doctor", argv: ["doctor"], action: { kind: "doctor-run", label: "Run doctor" } }, message: "run diagnostics" } },
1140
- { detail: "open server controls", item: { id: "server", label: "server", intent: { scene: "server", argv: ["server", "status"], action: { kind: "refresh", label: "Open server controls" } }, message: "open server controls" } },
1141
- { detail: "repair project/server/auth link", item: { id: "repair", label: "repair", intent: { scene: "command", argv: ["init", "--repair"], action: { kind: "command-run", label: "Repair project link" } }, message: "repair project link" } }
1184
+ { detail: "open server controls", item: { id: "server", label: "server", intent: { scene: "server", argv: ["server", "status"], action: { kind: "refresh", label: "Open server controls" } }, message: "open server controls" } }
1142
1185
  ];
1186
+ var ERROR_REPAIR_LINK_ACTION = { detail: "backfill or prepare selected remote project-root link", item: { id: "repair-link", label: "repair link", intent: { scene: "server", argv: ["server", "repair-link"], action: { kind: "remote-link-repair", label: "Repair remote link", payload: { returnScene: "server" } } }, message: "repair remote project link" } };
1187
+ function errorActions(state) {
1188
+ return shouldOfferRemoteLinkRepair(state, state.error?.message) ? [...ERROR_ACTIONS, ERROR_REPAIR_LINK_ACTION] : ERROR_ACTIONS;
1189
+ }
1143
1190
  function renderErrorScene(state) {
1144
1191
  const message = state.error?.message ?? "Unknown app error";
1145
1192
  const hint = state.error?.hint ?? "Use the actions below to recover.";
1146
- const selected = Math.max(0, Math.min(3, state.selection.index));
1193
+ const actions = errorActions(state);
1194
+ const selected = Math.max(0, Math.min(actions.length - 1, state.selection.index));
1147
1195
  return makeSceneFrame({
1148
1196
  scene: "error",
1149
1197
  title: "Error",
@@ -1161,7 +1209,7 @@ function renderErrorScene(state) {
1161
1209
  ...hint ? [line(hint, { fg: RIG_UI.yellow })] : [],
1162
1210
  line("", { fg: RIG_UI.ink3 }),
1163
1211
  line("ACTIONS", { fg: RIG_UI.ink3, bold: true }),
1164
- ...ERROR_ACTIONS.map(({ detail, item }, index) => selectableDeckRow({ label: item.label, detail, index, active: selected === index }, item))
1212
+ ...actions.map(({ detail, item }, index) => selectableDeckRow({ label: item.label, detail, index, active: selected === index }, item))
1165
1213
  ],
1166
1214
  backgroundColor: RIG_UI.panel,
1167
1215
  backgroundAlpha: 184,
@@ -1635,16 +1683,31 @@ function taskViewIntent(argv, command = "", rest = [], raw) {
1635
1683
  const { payload, label } = taskViewPayload(command, rest);
1636
1684
  return intent("tasks", argv, "refresh", payload, label, raw);
1637
1685
  }
1638
- function routeServer(argv, command, raw, checkingLabel) {
1639
- if (!command || command === "status") {
1686
+ function routeServer(argv, command, rest, raw, checkingLabel) {
1687
+ if (!command || command === "status" || command === "list") {
1640
1688
  return intent("server", argv, "refresh", undefined, command ? checkingLabel : "Loading server", raw);
1641
1689
  }
1690
+ if (command === "use") {
1691
+ const alias = firstNonOption(rest);
1692
+ if (alias === "local")
1693
+ return intent("server", argv, "server-use-local", undefined, "Use local server", raw);
1694
+ if (alias)
1695
+ return intent("server", argv, "server-use-remote", { alias }, `Use ${alias}`, raw);
1696
+ return intent("server", argv, "refresh", undefined, "Select a remote alias in Server", raw);
1697
+ }
1698
+ if (command === "add")
1699
+ return intent("server", argv, "server-add-remote", { argv: [...argv] }, "Add remote server", raw);
1700
+ if (command === "repair-link")
1701
+ return intent("server", argv, "remote-link-repair", undefined, "Repair remote link", raw);
1642
1702
  return commandRunIntent(argv, raw);
1643
1703
  }
1644
1704
  function routeGithub(argv, command, rest, raw) {
1645
1705
  if (command === "auth" && (rest[0]?.toLowerCase() ?? "status") === "status" && rest.length <= 1) {
1646
1706
  return intent("server", argv, "refresh", undefined, "Checking GitHub auth", raw);
1647
1707
  }
1708
+ if (command === "auth" && rest[0]?.toLowerCase() === "import-gh" && rest.length <= 1) {
1709
+ return intent("server", argv, "github-auth-import", undefined, "Import GitHub auth", raw);
1710
+ }
1648
1711
  return commandRunIntent(argv, raw);
1649
1712
  }
1650
1713
  function routeDoctor(argv, command, raw) {
@@ -1693,11 +1756,16 @@ function intentFromArgv(argv) {
1693
1756
  return commandRunIntent(argv);
1694
1757
  }
1695
1758
  if (normalizedGroup === "server")
1696
- return routeServer(argv, normalizedCommand, undefined, "Checking server");
1759
+ return routeServer(argv, normalizedCommand, rest, undefined, "Checking server");
1697
1760
  if (normalizedGroup === "github")
1698
1761
  return routeGithub(argv, normalizedCommand, rest);
1699
- if (normalizedGroup === "init")
1700
- return commandRunIntent(argv);
1762
+ if (normalizedGroup === "init") {
1763
+ if (!normalizedCommand)
1764
+ return intent("init", argv, "refresh", undefined, "Open init");
1765
+ if (rest.includes("--yes") || normalizedCommand === "--yes")
1766
+ return intent("init", argv, "init-start", undefined, "Run init");
1767
+ return intent("init", argv, "refresh", undefined, "Open init");
1768
+ }
1701
1769
  if (normalizedGroup === "doctor")
1702
1770
  return routeDoctor(argv, normalizedCommand);
1703
1771
  if (normalizedGroup === "inbox")
@@ -1760,12 +1828,17 @@ function intentFromTypeBar(value) {
1760
1828
  return commandRunIntent(parts, value);
1761
1829
  return intent("tasks", parts, "refresh", undefined, "Select a task, then press Enter; or use run next", value);
1762
1830
  }
1763
- if (first === "init")
1764
- return commandRunIntent(parts, value);
1831
+ if (first === "init") {
1832
+ if (!second)
1833
+ return intent("init", parts, "refresh", undefined, "Open init", value);
1834
+ if (parts.includes("--yes"))
1835
+ return intent("init", parts, "init-start", undefined, "Run init", value);
1836
+ return intent("init", parts, "refresh", undefined, "Open init", value);
1837
+ }
1765
1838
  if (first === "doctor")
1766
1839
  return routeDoctor(parts, second, value);
1767
1840
  if (first === "server")
1768
- return routeServer(parts, second, value, "Loading server");
1841
+ return routeServer(parts, second, rest, value, "Loading server");
1769
1842
  if (first === "github")
1770
1843
  return routeGithub(parts, second, rest, value);
1771
1844
  if (first === "inbox")
@@ -1783,12 +1856,6 @@ function intentFromTypeBar(value) {
1783
1856
  return intentFromArgv(parts);
1784
1857
  }
1785
1858
 
1786
- // packages/cli/src/app-opentui/pi-pty-host.ts
1787
- function getActivePiHost() {
1788
- return null;
1789
- }
1790
- function stopActivePiHost(_reason) {}
1791
-
1792
1859
  // packages/cli/src/app-opentui/keymap.ts
1793
1860
  var autocompleteState;
1794
1861
  function clearTypeBar(context, message) {
@@ -1798,22 +1865,15 @@ function clearTypeBar(context, message) {
1798
1865
  context.emitTypeBarPatch({ value: "", mode: "nav", prompt: undefined, message });
1799
1866
  }
1800
1867
  function handleEmbeddedTerminalKey(context, key) {
1801
- const state = context.getState();
1802
- const piHost = getActivePiHost();
1803
- const commandHost = getActiveCommandHost();
1804
- const host = state.scene === "handoff" ? piHost : state.scene === "command" ? commandHost : null;
1868
+ if (context.getState().scene !== "command")
1869
+ return false;
1870
+ const host = getActiveCommandHost();
1805
1871
  if (!host)
1806
1872
  return false;
1807
1873
  if (key.ctrl && key.name === "]") {
1808
- if (state.scene === "handoff") {
1809
- stopActivePiHost("operator detach");
1810
- clearTypeBar(context, "detached from Pi");
1811
- context.runAppAction("Opening runs", () => context.runtime.runIntent({ scene: "fleet", argv: ["runs"], action: { kind: "refresh", label: "Opening runs" } }));
1812
- } else {
1813
- stopActiveCommandHost("operator detach");
1814
- clearTypeBar(context, "closed command");
1815
- context.runAppAction("Project menu", () => context.runtime.runIntent({ scene: "main", argv: ["main"], action: { kind: "none", label: "Project menu" } }));
1816
- }
1874
+ stopActiveCommandHost("operator detach");
1875
+ clearTypeBar(context, "closed command");
1876
+ context.runAppAction("Project menu", () => context.runtime.runIntent({ scene: "main", argv: ["main"], action: { kind: "none", label: "Project menu" } }));
1817
1877
  return true;
1818
1878
  }
1819
1879
  const sequence = key.raw || key.sequence;
@@ -3235,7 +3295,7 @@ var PRIMARY_NAV = [
3235
3295
  { id: "tasks", label: "Tasks", scene: "tasks", argv: ["tasks"], enterLabel: "Tasks", member: ["tasks"] },
3236
3296
  { id: "inbox", label: "Inbox", scene: "inbox", argv: ["inbox"], enterLabel: "Inbox", member: ["inbox"], badge: inboxPendingCount },
3237
3297
  { id: "stats", label: "Stats", scene: "family", argv: ["stats"], enterLabel: "Stats", member: ["family"] },
3238
- { id: "setup", label: "Setup", scene: "init", argv: ["init"], enterLabel: "Setup", member: ["init", "doctor", "server", "pi", "plugin", "repo", "workspace"] },
3298
+ { id: "init", label: "Init", scene: "init", argv: ["init"], enterLabel: "Init", member: ["init", "doctor", "server", "pi", "plugin", "repo", "workspace"] },
3239
3299
  { id: "help", label: "Help", scene: "help", argv: ["help"], enterLabel: "Help", member: ["help"] }
3240
3300
  ];
3241
3301
  function activeNavSection(scene) {
@@ -3256,7 +3316,7 @@ function entryIntentForScene(scene) {
3256
3316
  case "doctor":
3257
3317
  return { scene, argv: ["doctor"], action: { kind: "doctor-run", label: "Doctor" } };
3258
3318
  case "init":
3259
- return { scene, argv: ["init"], action: { kind: "refresh", label: "Setup" } };
3319
+ return { scene, argv: ["init"], action: { kind: "refresh", label: "Init" } };
3260
3320
  case "run-detail":
3261
3321
  return { scene, argv: ["run", "status"], action: { kind: "refresh", label: "Run" } };
3262
3322
  case "pi":
@@ -3290,7 +3350,7 @@ function sceneSectionLabel(scene) {
3290
3350
  handoff: "pi console",
3291
3351
  server: "server",
3292
3352
  doctor: "doctor",
3293
- init: "setup",
3353
+ init: "init",
3294
3354
  pi: "pi",
3295
3355
  plugin: "plugins",
3296
3356
  repo: "repo",
@@ -3678,7 +3738,7 @@ var PRIMARY_NAV2 = [
3678
3738
  { id: "tasks", label: "Tasks", scene: "tasks", argv: ["tasks"], enterLabel: "Tasks", member: ["tasks"] },
3679
3739
  { id: "inbox", label: "Inbox", scene: "inbox", argv: ["inbox"], enterLabel: "Inbox", member: ["inbox"], badge: inboxPendingCount2 },
3680
3740
  { id: "stats", label: "Stats", scene: "family", argv: ["stats"], enterLabel: "Stats", member: ["family"] },
3681
- { id: "setup", label: "Setup", scene: "init", argv: ["init"], enterLabel: "Setup", member: ["init", "doctor", "server", "pi", "plugin", "repo", "workspace"] },
3741
+ { id: "init", label: "Init", scene: "init", argv: ["init"], enterLabel: "Init", member: ["init", "doctor", "server", "pi", "plugin", "repo", "workspace"] },
3682
3742
  { id: "help", label: "Help", scene: "help", argv: ["help"], enterLabel: "Help", member: ["help"] }
3683
3743
  ];
3684
3744
  function navSectionIntent(section) {
@@ -460,12 +460,13 @@ var PRIMARY_GROUPS = [
460
460
  {
461
461
  name: "server",
462
462
  summary: "Choose, inspect, and start the Rig server that owns tasks and runs.",
463
- usage: ["rig server <status|list|add|use|start> [options]"],
463
+ usage: ["rig server <status|list|add|use|repair-link|start> [options]"],
464
464
  commands: [
465
- { command: "status", description: "Show the selected server for this repo.", primary: true },
465
+ { command: "status", description: "Show the selected server and remote project-root link for this repo.", primary: true },
466
466
  { command: "use local", description: "Switch this repo to the local Rig server.", primary: true },
467
467
  { command: "add <alias> <url>", description: "Save a remote Rig server URL.", primary: true },
468
468
  { command: "use <alias>", description: "Select a saved remote server alias.", primary: true },
469
+ { command: "repair-link [--prepare|--backfill-only] [--repo owner/repo]", description: "Backfill or prepare the selected remote's server-host checkout link.", primary: true },
469
470
  { command: "list", description: "List saved local/remote server aliases.", primary: true },
470
471
  { command: "start [--host <host>] [--port <n>]", description: "Start a local rig-server process." }
471
472
  ],
@@ -473,6 +474,7 @@ var PRIMARY_GROUPS = [
473
474
  "rig server status",
474
475
  "rig server add prod https://where.rig-does.work",
475
476
  "rig server use prod",
477
+ "rig server repair-link --repo owner/repo",
476
478
  "rig server use local",
477
479
  "rig server start --port 3773"
478
480
  ],
@@ -1398,6 +1400,16 @@ import {
1398
1400
  TextTableRenderable
1399
1401
  } from "@opentui/core";
1400
1402
 
1403
+ // packages/cli/src/app-opentui/remote-link.ts
1404
+ var REPAIRABLE_REMOTE_LINK_STATUSES = new Set([
1405
+ "auth_required",
1406
+ "project_not_registered",
1407
+ "no_server_checkout",
1408
+ "invalid_root",
1409
+ "needs_prepare",
1410
+ "error"
1411
+ ]);
1412
+
1401
1413
  // packages/cli/src/app-opentui/runtime.ts
1402
1414
  var PRELOADER_BACKDROP = RGBA7.fromHex(RIG_UI.bg);
1403
1415
  function inboxPendingCount(state) {
@@ -1415,7 +1427,7 @@ var PRIMARY_NAV = [
1415
1427
  { id: "tasks", label: "Tasks", scene: "tasks", argv: ["tasks"], enterLabel: "Tasks", member: ["tasks"] },
1416
1428
  { id: "inbox", label: "Inbox", scene: "inbox", argv: ["inbox"], enterLabel: "Inbox", member: ["inbox"], badge: inboxPendingCount },
1417
1429
  { id: "stats", label: "Stats", scene: "family", argv: ["stats"], enterLabel: "Stats", member: ["family"] },
1418
- { id: "setup", label: "Setup", scene: "init", argv: ["init"], enterLabel: "Setup", member: ["init", "doctor", "server", "pi", "plugin", "repo", "workspace"] },
1430
+ { id: "init", label: "Init", scene: "init", argv: ["init"], enterLabel: "Init", member: ["init", "doctor", "server", "pi", "plugin", "repo", "workspace"] },
1419
1431
  { id: "help", label: "Help", scene: "help", argv: ["help"], enterLabel: "Help", member: ["help"] }
1420
1432
  ];
1421
1433
  function activeNavSection(scene) {
@@ -1432,7 +1444,7 @@ function sceneSectionLabel(scene) {
1432
1444
  handoff: "pi console",
1433
1445
  server: "server",
1434
1446
  doctor: "doctor",
1435
- init: "setup",
1447
+ init: "init",
1436
1448
  pi: "pi",
1437
1449
  plugin: "plugins",
1438
1450
  repo: "repo",