@h-rig/cli 0.0.6-alpha.9 → 0.0.6-alpha.90

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 (114) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/build-rig-binaries.d.ts +2 -0
  3. package/dist/bin/rig.d.ts +2 -0
  4. package/dist/bin/rig.js +11052 -6668
  5. package/dist/src/app/board.d.ts +23 -0
  6. package/dist/src/app/board.js +1786 -0
  7. package/dist/src/app/drone-ui.d.ts +37 -0
  8. package/dist/src/app/drone-ui.js +294 -0
  9. package/dist/src/app/theme.d.ts +47 -0
  10. package/dist/src/app/theme.js +150 -0
  11. package/dist/src/commands/_async-ui.d.ts +13 -0
  12. package/dist/src/commands/_async-ui.js +223 -0
  13. package/dist/src/commands/_authority-runs.d.ts +22 -0
  14. package/dist/src/commands/_authority-runs.js +2 -3
  15. package/dist/src/commands/_cli-format.d.ts +49 -0
  16. package/dist/src/commands/_cli-format.js +447 -0
  17. package/dist/src/commands/_connection-state.d.ts +44 -0
  18. package/dist/src/commands/_connection-state.js +30 -11
  19. package/dist/src/commands/_doctor-checks.d.ts +52 -0
  20. package/dist/src/commands/_doctor-checks.js +180 -44
  21. package/dist/src/commands/_help-catalog.d.ts +51 -0
  22. package/dist/src/commands/_help-catalog.js +442 -0
  23. package/dist/src/commands/_json-output.d.ts +11 -0
  24. package/dist/src/commands/_json-output.js +56 -0
  25. package/dist/src/commands/_operator-surface.d.ts +34 -0
  26. package/dist/src/commands/_operator-surface.js +220 -0
  27. package/dist/src/commands/_operator-view.d.ts +30 -0
  28. package/dist/src/commands/_operator-view.js +803 -73
  29. package/dist/src/commands/_parsers.d.ts +15 -0
  30. package/dist/src/commands/_parsers.js +18 -11
  31. package/dist/src/commands/_paths.d.ts +11 -0
  32. package/dist/src/commands/_pi-frontend.d.ts +27 -0
  33. package/dist/src/commands/_pi-frontend.js +742 -0
  34. package/dist/src/commands/_pi-install.d.ts +42 -0
  35. package/dist/src/commands/_pi-install.js +5 -4
  36. package/dist/src/commands/_policy.d.ts +8 -0
  37. package/dist/src/commands/_policy.js +12 -5
  38. package/dist/src/commands/_preflight.d.ts +22 -0
  39. package/dist/src/commands/_preflight.js +190 -128
  40. package/dist/src/commands/_probes.d.ts +1 -0
  41. package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
  42. package/dist/src/commands/_run-driver-helpers.js +75 -22
  43. package/dist/src/commands/_run-replay.d.ts +24 -0
  44. package/dist/src/commands/_run-replay.js +142 -0
  45. package/dist/src/commands/_server-client.d.ts +186 -0
  46. package/dist/src/commands/_server-client.js +360 -61
  47. package/dist/src/commands/_snapshot-upload.d.ts +39 -0
  48. package/dist/src/commands/_snapshot-upload.js +163 -39
  49. package/dist/src/commands/_spinner.d.ts +25 -0
  50. package/dist/src/commands/_spinner.js +65 -0
  51. package/dist/src/commands/_task-picker.d.ts +9 -0
  52. package/dist/src/commands/_task-picker.js +172 -19
  53. package/dist/src/commands/agent.d.ts +3 -0
  54. package/dist/src/commands/agent.js +39 -20
  55. package/dist/src/commands/browser.d.ts +65 -0
  56. package/dist/src/commands/browser.js +334 -51
  57. package/dist/src/commands/connect.d.ts +7 -0
  58. package/dist/src/commands/connect.js +272 -33
  59. package/dist/src/commands/dist.d.ts +28 -0
  60. package/dist/src/commands/dist.js +19 -12
  61. package/dist/src/commands/doctor.d.ts +3 -0
  62. package/dist/src/commands/doctor.js +378 -45
  63. package/dist/src/commands/github.d.ts +3 -0
  64. package/dist/src/commands/github.js +375 -53
  65. package/dist/src/commands/inbox.d.ts +30 -0
  66. package/dist/src/commands/inbox.js +760 -70
  67. package/dist/src/commands/init.d.ts +74 -0
  68. package/dist/src/commands/init.js +963 -119
  69. package/dist/src/commands/inspect.d.ts +3 -0
  70. package/dist/src/commands/inspect.js +588 -32
  71. package/dist/src/commands/inspector.d.ts +3 -0
  72. package/dist/src/commands/inspector.js +20 -13
  73. package/dist/src/commands/pi.d.ts +3 -0
  74. package/dist/src/commands/pi.js +177 -0
  75. package/dist/src/commands/plugin.d.ts +16 -0
  76. package/dist/src/commands/plugin.js +95 -27
  77. package/dist/src/commands/profile-and-review.d.ts +4 -0
  78. package/dist/src/commands/profile-and-review.js +26 -19
  79. package/dist/src/commands/queue.d.ts +3 -0
  80. package/dist/src/commands/queue.js +32 -12
  81. package/dist/src/commands/remote.d.ts +3 -0
  82. package/dist/src/commands/remote.js +43 -36
  83. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  84. package/dist/src/commands/repo-git-harness.js +22 -15
  85. package/dist/src/commands/run.d.ts +3 -0
  86. package/dist/src/commands/run.js +1379 -159
  87. package/dist/src/commands/server.d.ts +7 -0
  88. package/dist/src/commands/server.js +502 -57
  89. package/dist/src/commands/setup.d.ts +16 -0
  90. package/dist/src/commands/setup.js +390 -63
  91. package/dist/src/commands/stats.d.ts +12 -0
  92. package/dist/src/commands/stats.js +1051 -0
  93. package/dist/src/commands/task-report-bug.d.ts +19 -0
  94. package/dist/src/commands/task-report-bug.js +260 -62
  95. package/dist/src/commands/task-run-driver.d.ts +132 -0
  96. package/dist/src/commands/task-run-driver.js +886 -130
  97. package/dist/src/commands/task.d.ts +14 -0
  98. package/dist/src/commands/task.js +1644 -314
  99. package/dist/src/commands/test.d.ts +3 -0
  100. package/dist/src/commands/test.js +15 -8
  101. package/dist/src/commands/workspace.d.ts +3 -0
  102. package/dist/src/commands/workspace.js +18 -11
  103. package/dist/src/commands.d.ts +29 -0
  104. package/dist/src/commands.js +10967 -6637
  105. package/dist/src/index.d.ts +4 -0
  106. package/dist/src/index.js +10168 -5787
  107. package/dist/src/launcher.d.ts +61 -0
  108. package/dist/src/launcher.js +77 -13
  109. package/dist/src/report-bug.d.ts +44 -0
  110. package/dist/src/report-bug.js +3 -3
  111. package/dist/src/runner.d.ts +47 -0
  112. package/dist/src/runner.js +16 -22
  113. package/dist/src/withMutedConsole.d.ts +2 -0
  114. package/package.json +13 -6
@@ -0,0 +1,442 @@
1
+ // @bun
2
+ // packages/cli/src/commands/_help-catalog.ts
3
+ import pc from "picocolors";
4
+ function helpCatalog() {
5
+ return { sections: TOP_LEVEL_SECTIONS, groups: ALL_GROUPS };
6
+ }
7
+ var TOP_LEVEL_SECTIONS = [
8
+ {
9
+ title: "Pi console",
10
+ subtitle: "the operator surface \u2014 every attach opens the run's FULL Pi session",
11
+ commands: [
12
+ { command: "rig run attach <run-id>", description: "Open the run's Pi console: complete transcript (live AND finished runs), worker turns streaming in live." },
13
+ { command: "type a message", description: "Inside the console, plain text steers the worker mid-turn \u2014 it lands in the agent's context, not a local model." },
14
+ { command: "!<command>", description: "Inside the console, runs shell in the WORKER's workspace; output streams back into the transcript." },
15
+ { command: "/<command>", description: "The palette includes the WORKER session's slash commands ([worker]-tagged) next to /rig." },
16
+ { command: "/rig abort | /rig stop", description: "Abort the worker's current turn, or stop the whole run, from inside the console." },
17
+ { command: "rig run steer <id> --message <text>", description: "Steer without attaching \u2014 queue a message; the worker picks it up within seconds." }
18
+ ]
19
+ },
20
+ {
21
+ title: "Start here",
22
+ subtitle: "one-time setup, pick a server",
23
+ commands: [
24
+ { command: "rig init", description: "Wizard: config, GitHub auth, task source, server, Pi wiring." },
25
+ { command: "rig server use <alias|local>", description: "Pick which Rig server owns this repo (`rig server list` to see them)." },
26
+ { command: "rig server status", description: "Show the selected server for this repo." }
27
+ ]
28
+ },
29
+ {
30
+ title: "Work",
31
+ subtitle: "find a task, put an agent on it, answer what it asks",
32
+ commands: [
33
+ { command: "rig task list", description: "What's on the board (from the selected source/server)." },
34
+ { command: "rig task run --next", description: "Dispatch an agent on the next ready task; interactive mode drops you into its Pi console." },
35
+ { command: "rig run status", description: "Active and recent runs at a glance." },
36
+ { command: "rig run attach <id> --follow", description: "Same as plain attach \u2014 the Pi console is always the interactive surface." },
37
+ { command: "rig inbox approvals", description: "Approvals workers are waiting on (then `rig inbox approve \u2026`)." }
38
+ ]
39
+ },
40
+ {
41
+ title: "Watch",
42
+ subtitle: "fleet metrics and per-task forensics",
43
+ commands: [
44
+ { command: "rig stats [--since 7d]", description: "Fleet metrics: completion/failure rates, median run time, steering, stalls." },
45
+ { command: "rig inspect logs --task <id>", description: "Latest run log for a task." },
46
+ { command: "rig inspect diff --task <id>", description: "Changed files for a task." }
47
+ ]
48
+ },
49
+ {
50
+ title: "Unblock",
51
+ subtitle: "diagnose wiring, fix auth",
52
+ commands: [
53
+ { command: "rig doctor", description: "Check every part of the wiring \u2014 run this when anything feels off." },
54
+ { command: "rig github auth status", description: "GitHub auth state on the selected server." }
55
+ ]
56
+ },
57
+ {
58
+ title: "Extend",
59
+ subtitle: "plugins contribute validators, hooks, task sources, commands",
60
+ commands: [
61
+ { command: "rig plugin list", description: "What the rig.config.ts plugins contribute." },
62
+ { command: "rig plugin run <command-id>", description: "Execute a plugin-contributed CLI command." }
63
+ ]
64
+ }
65
+ ];
66
+ var PRIMARY_GROUPS = [
67
+ {
68
+ name: "server",
69
+ summary: "Choose, inspect, and start the Rig server that owns tasks and runs.",
70
+ usage: ["rig server <status|list|add|use|start> [options]"],
71
+ commands: [
72
+ { command: "status", description: "Show the selected server for this repo.", primary: true },
73
+ { command: "use local", description: "Switch this repo to the local Rig server.", primary: true },
74
+ { command: "add <alias> <url>", description: "Save a remote Rig server URL.", primary: true },
75
+ { command: "use <alias>", description: "Select a saved remote server alias.", primary: true },
76
+ { command: "list", description: "List saved local/remote server aliases.", primary: true },
77
+ { command: "start [--host <host>] [--port <n>]", description: "Start a local rig-server process." }
78
+ ],
79
+ examples: [
80
+ "rig server status",
81
+ "rig server add prod https://where.rig-does.work",
82
+ "rig server use prod",
83
+ "rig server use local",
84
+ "rig server start --port 3773"
85
+ ],
86
+ next: ["Use `rig task list` to see server-owned work.", "Use `rig run list` or `rig run attach <id> --follow` to monitor runs."]
87
+ },
88
+ {
89
+ name: "task",
90
+ summary: "Find work, start Pi-backed runs, and validate task results.",
91
+ usage: ["rig task <list|next|show|run> [options]"],
92
+ commands: [
93
+ { command: "list [--assignee <login|me|@me>] [--state open|closed]", description: "List tasks from the selected server/source.", primary: true },
94
+ { command: "next [filters]", description: "Render the next matching task as a selected-task card.", primary: true },
95
+ { command: "show <id>|--task <id> [--raw]", description: "Show a human task summary; --raw prints the full payload.", primary: true },
96
+ { command: "run [#<issue>|<task-id>|--next|--task <id>]", description: "Submit a task run; interactive follows with bundled Pi.", primary: true },
97
+ { command: "ready", description: "List task IDs that are runnable now." },
98
+ { command: "validate|verify [--task <id>]", description: "Run configured task checks/review gates." },
99
+ { command: "details --task <id>", description: "Show full task info from the configured source." },
100
+ { command: "reopen [--task <id> | --all] [--reason <text>]", description: "Reopen closed task(s) in the configured source." },
101
+ { command: "artifacts|artifact-dir|artifact-write", description: "Inspect or write task artifacts." },
102
+ { command: "report-bug", description: "Create a structured bug report/task." }
103
+ ],
104
+ examples: [
105
+ "rig task list --assignee @me --limit 20",
106
+ "rig task next",
107
+ "rig task show 123 --raw",
108
+ "rig task run --next",
109
+ "rig task run #123 --runtime-adapter pi",
110
+ "rig task run --title 'Investigate deploy drift' --initial-prompt 'Check server health'"
111
+ ],
112
+ next: ["Use `--detach` to submit without attaching.", "Use `rig run attach <run-id> --follow` to rejoin a live run."]
113
+ },
114
+ {
115
+ name: "run",
116
+ summary: "Observe, attach to, and control Rig runs. `attach` opens the Pi console \u2014 the full worker session, live.",
117
+ usage: ["rig run <list|status|show|attach|steer|stop|resume|restart> [options]"],
118
+ commands: [
119
+ { command: "list", description: "List recent runs from the selected server or local state.", primary: true },
120
+ { command: "status", description: "Render active and recent run groups.", primary: true },
121
+ { command: "show <id>|--run <id> [--raw]", description: "Show a human run summary; --raw prints the full payload.", primary: true },
122
+ { command: "attach <run-id>|--run <id>", description: "Open the run's Pi console \u2014 see 'Inside the console' below. Works on live AND finished runs.", primary: true },
123
+ { command: "steer <run-id> --message <text>", description: "Queue a steering message into a live worker without attaching \u2014 delivered into the agent's context within seconds.", primary: true },
124
+ { command: "stop [<run-id>|--run <id>]", description: "Request stop for one run or local active runs.", primary: true },
125
+ { command: "resume [<run-id>]", description: "Resume an interrupted run on the selected server (defaults to the most recent resumable)." },
126
+ { command: "restart [<run-id>]", description: "Re-dispatch a run from a clean runtime, reopening its Pi session where possible." },
127
+ { command: "timeline --run <id> [--follow]", description: "Stream raw run timeline events (scripts; humans should attach)." },
128
+ { command: "replay <run-id>|--run <id> [--with-session]", description: "Print the run's consolidated run.jsonl as a merged timeline; --with-session interleaves the Pi session log." },
129
+ { command: "delete|cleanup", description: "Remove completed run records/artifacts." }
130
+ ],
131
+ examples: [
132
+ "rig run attach <run-id> # full session console \u2014 live mirror, steering, worker shell",
133
+ "rig run steer <run-id> --message 'focus on the failing test first'",
134
+ "rig run list",
135
+ "rig run show <run-id>",
136
+ "rig run stop <run-id>"
137
+ ],
138
+ next: [
139
+ "Inside the console: the run's COMPLETE transcript loads on open (finished runs too), and new worker turns stream in live.",
140
+ "Inside the console: plain text = steering into the worker's context \xB7 !<cmd> = shell in the WORKER workspace \xB7 /<cmd> includes the worker session's commands \xB7 /rig abort stops the current turn.",
141
+ "The console is read-write but remote-only: nothing runs on your machine; the worker keeps running when you exit.",
142
+ "Use `rig task run --next` to create a new run; interactive mode drops you straight into its console.",
143
+ "Use `--json` when scripts need the full structured record."
144
+ ]
145
+ },
146
+ {
147
+ name: "inbox",
148
+ summary: "Review approval and user-input requests that block worker runs.",
149
+ usage: ["rig inbox <approvals|approve|inputs|respond> [options]"],
150
+ commands: [
151
+ { command: "approvals [--run <id>] [--task <id>]", description: "List pending approvals.", primary: true },
152
+ { command: "inputs [--run <id>] [--task <id>]", description: "List pending user-input requests.", primary: true },
153
+ { command: "approve --run <id> --request <id> --decision approve|reject", description: "Resolve an approval request." },
154
+ { command: "respond --run <id> --request <id> --answer key=value", description: "Answer a user-input request." }
155
+ ],
156
+ examples: [
157
+ "rig inbox approvals",
158
+ "rig inbox inputs --run <run-id>",
159
+ "rig inbox approve --run <run-id> --request <request-id> --decision approve"
160
+ ],
161
+ next: ["Rejoin the run after resolving a block: `rig run attach <run-id> --follow`."]
162
+ },
163
+ {
164
+ name: "stats",
165
+ summary: "Fleet metrics computed from on-disk run journals (no server required).",
166
+ usage: ["rig stats [show] [--since <7d|30d|ISO date>]"],
167
+ commands: [
168
+ { command: "show [--since <window>]", description: "Total runs, completion/failure/needs-attention rates, median run time, steering, stalls, approvals.", primary: true }
169
+ ],
170
+ examples: [
171
+ "rig stats",
172
+ "rig stats --since 7d",
173
+ "rig stats --since 2026-06-01 --json"
174
+ ],
175
+ next: ["Inspect outliers with `rig run list` and `rig run show <run-id>`.", "Use `--json` for the schema'd envelope (see docs/cli-json.md)."]
176
+ },
177
+ {
178
+ name: "inspect",
179
+ summary: "Inspect logs, artifacts, graphs, failures for a task.",
180
+ usage: ["rig inspect <logs|artifacts|failures|graph|audit|diff> --task <id>"],
181
+ commands: [
182
+ { command: "logs --task <id>", description: "Latest run log for a task (local or selected server).", primary: true },
183
+ { command: "artifacts --task <id>", description: "List the task's completion artifacts.", primary: true },
184
+ { command: "failures --task <id>", description: "Recorded failures for a task.", primary: true },
185
+ { command: "diff --task <id>", description: "Changed files for a task.", primary: true },
186
+ { command: "graph", description: "Task dependency graph." },
187
+ { command: "audit", description: "Controlled-command audit trail." }
188
+ ],
189
+ examples: ["rig inspect logs --task <id>", "rig inspect diff --task <id>"],
190
+ next: ["Use `rig stats` for fleet-level metrics across runs."]
191
+ },
192
+ {
193
+ name: "repo",
194
+ summary: "Repository sync/baseline helpers for the Rig-managed checkout.",
195
+ usage: ["rig repo <sync|reset-baseline>"],
196
+ commands: [
197
+ { command: "sync", description: "Sync project repository state.", primary: true },
198
+ { command: "reset-baseline", description: "Reset the managed baseline for the repo." }
199
+ ],
200
+ examples: ["rig repo sync"]
201
+ },
202
+ {
203
+ name: "plugin",
204
+ summary: "Plugin listing, validation, and plugin-contributed commands.",
205
+ usage: ["rig plugin <list|validate|run> [options]"],
206
+ commands: [
207
+ { command: "list", description: "List plugins declared in rig.config.ts and their contributions.", primary: true },
208
+ { command: "validate --task <id>", description: "Run plugin-contributed validators for a task.", primary: true },
209
+ { command: "run <command-id> [args...]", description: "Execute a plugin-contributed CLI command (also callable as `rig <command-id>`)." }
210
+ ],
211
+ examples: ["rig plugin list", "rig plugin run <command-id>"]
212
+ },
213
+ {
214
+ name: "init",
215
+ summary: "Set up Rig for this repo: server, GitHub auth, checkout strategy, task source, and Pi wiring.",
216
+ usage: ["rig init [--yes] [--server local|remote] [--repo owner/repo] [--remote-url <url>]"],
217
+ commands: [
218
+ { command: "init", description: "Interactive setup wizard for a new or existing Rig repo.", primary: true },
219
+ { command: "init --demo", description: "Offline demo project: files task source + 3 sample tasks, zero GitHub.", primary: true },
220
+ { command: "init --yes", description: "Non-interactive setup using detected/default settings.", primary: true },
221
+ { command: "init --server remote --remote-url <url>", description: "Link this repo to a remote Rig server.", primary: true },
222
+ { command: "init --repair", description: "Repair missing private state without replacing project config." }
223
+ ],
224
+ examples: [
225
+ "rig init",
226
+ "rig init --demo",
227
+ "rig init --yes --repo humanity-org/humanwork",
228
+ "rig init --server remote --remote-url https://where.rig-does.work --repo owner/repo"
229
+ ],
230
+ next: ["After init, run `rig server status`.", "Then use `rig task list` and `rig task run --next` for day-to-day work."]
231
+ },
232
+ {
233
+ name: "doctor",
234
+ summary: "Diagnostics for project/server/GitHub/Pi state.",
235
+ usage: ["rig doctor"],
236
+ commands: [
237
+ { command: "doctor", description: "Run setup and runtime diagnostics.", primary: true },
238
+ { command: "check", description: "Compatibility spelling for diagnostics." }
239
+ ],
240
+ examples: ["rig doctor", "rig doctor --json"],
241
+ next: ["Use `rig server status` and `rig github auth status` to inspect common failure points."]
242
+ },
243
+ {
244
+ name: "github",
245
+ summary: "GitHub auth helpers for the selected Rig server.",
246
+ usage: ["rig github auth <status|import-gh|token>"],
247
+ commands: [
248
+ { command: "auth status", description: "Show GitHub auth state.", primary: true },
249
+ { command: "auth import-gh", description: "Import the current `gh` token into the selected server." },
250
+ { command: "auth token --token <token>", description: "Store a token on the selected server." }
251
+ ],
252
+ examples: ["rig github auth status", "rig github auth import-gh"],
253
+ next: ["After auth is valid, use `rig task run --next`."]
254
+ }
255
+ ];
256
+ var ADVANCED_GROUPS = [
257
+ { name: "setup", summary: "Bootstrap/check local setup.", usage: ["rig setup <bootstrap|check|preflight>"], commands: [{ command: "bootstrap|check|preflight", description: "Setup helpers." }] },
258
+ { name: "profile", summary: "Runtime profile/model defaults.", usage: ["rig profile <show|set>"], commands: [{ command: "show", description: "Show active profile." }] },
259
+ {
260
+ name: "review",
261
+ summary: "Inspect or change completion review gate policy.",
262
+ usage: ["rig review <show|set>"],
263
+ commands: [
264
+ { command: "show", description: "Show current review gate settings." },
265
+ { command: "set <off|advisory|required> [--provider greptile]", description: "Change review strictness/provider." }
266
+ ],
267
+ examples: ["rig review show", "rig review set required --provider greptile"],
268
+ next: ["Use `rig inbox approvals` for blocked run handoffs."]
269
+ },
270
+ {
271
+ name: "browser",
272
+ summary: "Browser/app diagnostics for browser-required tasks.",
273
+ usage: ["rig browser <help|explain|demo|app|hp-next> [options]"],
274
+ commands: [
275
+ { command: "help", description: "Rich browser command help (canonical: `rig browser help`)." },
276
+ { command: "explain", description: "Explain the browser-required task contract." },
277
+ { command: "demo", description: "Run browser demo flows against a local page." },
278
+ { command: "app", description: "Launch the Rig Browser workstation app." },
279
+ { command: "hp-next <dev|check|e2e|reset>", description: "Drive the hp-next browser test harness." }
280
+ ]
281
+ },
282
+ {
283
+ name: "pi",
284
+ summary: "Manage Pi extension packages for this project (community extensions from npm/git).",
285
+ usage: ["rig pi <list|add|remove|search> [args]"],
286
+ commands: [
287
+ { command: "list", description: "Show project and user Pi extension packages." },
288
+ { command: "add <source>", description: "Add an npm/git Pi extension to .pi/settings.json (auto-installs at next session)." },
289
+ { command: "remove <source>", description: "Remove an operator-added Pi extension." },
290
+ { command: "search [term]", description: "Discover Pi extension packages on the npm registry." }
291
+ ],
292
+ examples: ["rig pi search subagents", "rig pi add pi-subagents", "rig pi list"],
293
+ next: ["Config-managed extensions: declare `runtime: { pi: { packages: [...] } }` in rig.config.ts \u2014 workers pick them up automatically."]
294
+ },
295
+ { name: "queue", summary: "Run task queues locally.", usage: ["rig queue run [options]"], commands: [{ command: "run", description: "Process queue work." }] },
296
+ { name: "agent", summary: "Runtime agent workspace helpers.", usage: ["rig agent <list|prepare|run|cleanup>"], commands: [{ command: "list", description: "List prepared agents." }] },
297
+ { name: "inspector", summary: "Event stream and drift scanners.", usage: ["rig inspector <stream|scan-upstream-drift>"], commands: [{ command: "stream", description: "Stream events." }] },
298
+ { name: "dist", summary: "Build/install packaged Rig CLI.", usage: ["rig dist <build|install|doctor>"], commands: [{ command: "build", description: "Build distribution." }] },
299
+ { name: "workspace", summary: "Workspace topology/service helpers.", usage: ["rig workspace <summary|topology|remote-hosts>"], commands: [{ command: "summary", description: "Show workspace summary." }] },
300
+ { name: "remote", summary: "Compatibility remote orchestration controls.", usage: ["rig remote <status|watch|pause|resume|...>"], commands: [{ command: "status", description: "Show remote state." }] },
301
+ { name: "git", summary: "Pass through to Rig git-flow helper.", usage: ["rig git <args...>"], commands: [{ command: "<args...>", description: "Advanced git flow operations." }] },
302
+ { name: "harness", summary: "Pass through to runtime harness CLI.", usage: ["rig harness <args...>"], commands: [{ command: "<args...>", description: "Advanced harness operations." }] },
303
+ { name: "test", summary: "Project test wrappers.", usage: ["rig test <unit|e2e|all>"], commands: [{ command: "all", description: "Run configured project tests." }] }
304
+ ];
305
+ var ADVANCED_COMMANDS = [
306
+ { command: "rig server task-run ...", description: "Internal server-owned task execution entry point." },
307
+ { command: "rig server notify-test [--event <type>]", description: "Internal event notification smoke command." },
308
+ { command: "rig run start|start-serial|start-parallel", description: "Local epic queue starters (server-owned tasks use `rig task run ...`)." },
309
+ { command: "rig remote orchestrate-*", description: "Compatibility remote orchestration commands." }
310
+ ];
311
+ var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
312
+ function heading(title) {
313
+ return pc.bold(pc.cyan(title));
314
+ }
315
+ function renderRigBanner(version) {
316
+ const m = (s) => pc.bold(pc.magenta(s));
317
+ const c = (s) => pc.bold(pc.cyan(s));
318
+ const y = (s) => pc.yellow(s);
319
+ const d = (s) => pc.dim(s);
320
+ const lines = [
321
+ m(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ") + d(" \u2591\u2592\u2593\u2588 "),
322
+ m(" \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D ") + d("\u2593\u2592\u2591"),
323
+ c(" \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557") + d(" \u2591\u2592"),
324
+ c(" \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551") + d(" \u2588\u2593\u2591"),
325
+ y(" \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D") + d(" \u2592\u2591"),
326
+ y(" \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D "),
327
+ "",
328
+ ` ${c("\u25E2\u25E4")} ${pc.bold("the control rig for autonomous coding agents")} ${m("//")} ${d("you are the operator")}`,
329
+ version ? ` ${d(`v${version} \xB7 jack in: rig task run --next`)}` : ` ${d("jack in: rig task run --next")}`
330
+ ];
331
+ return lines.join(`
332
+ `);
333
+ }
334
+ function commandLine(command, description) {
335
+ const commandColumn = command.length >= 38 ? `${command} ` : command.padEnd(38);
336
+ return `${pc.dim("\u2502")} ${pc.bold(commandColumn)} ${description}`;
337
+ }
338
+ function renderCommandBlock(commands) {
339
+ return commands.map((entry) => commandLine(entry.command, entry.description)).join(`
340
+ `);
341
+ }
342
+ function renderGroup(group) {
343
+ const lines = [
344
+ `${heading(`rig ${group.name}`)} \u2014 ${group.summary}`,
345
+ "",
346
+ pc.bold("Usage"),
347
+ ...group.usage.map((line) => ` ${line}`),
348
+ "",
349
+ pc.bold("Commands"),
350
+ ...group.commands.map((entry) => commandLine(entry.command, entry.description))
351
+ ];
352
+ if (group.examples?.length) {
353
+ lines.push("", pc.bold("Examples"), ...group.examples.map((line) => ` ${pc.dim("$")} ${line}`));
354
+ }
355
+ if (group.next?.length) {
356
+ lines.push("", pc.bold("Next steps"), ...group.next.map((line) => ` ${pc.dim("\u203A")} ${line}`));
357
+ }
358
+ if (group.advanced?.length) {
359
+ lines.push("", pc.bold("Compatibility / advanced"), ...group.advanced.map((line) => ` ${pc.dim("\u203A")} ${line}`));
360
+ }
361
+ return lines.join(`
362
+ `);
363
+ }
364
+ function renderTopLevelHelp() {
365
+ return [
366
+ `${heading("rig")} ${pc.dim("\u2014 server-owned task/run control plane for Pi-backed engineering work")}`,
367
+ pc.dim("The loop: pick a task, dispatch an agent, open its Pi console (`rig run attach <id>`) to watch and steer it live, clear inbox gates, merge."),
368
+ "",
369
+ ...TOP_LEVEL_SECTIONS.flatMap((section) => [
370
+ `${pc.bold(pc.magenta(`\u25C7 ${section.title}`))} \u2014 ${pc.dim(section.subtitle)}`,
371
+ renderCommandBlock(section.commands),
372
+ ""
373
+ ]),
374
+ pc.dim("More: `rig help --advanced` for dev/compatibility commands; `rig <group> --help` for rich per-group help; `rig --version` for the installed version."),
375
+ "",
376
+ pc.bold("Global options"),
377
+ commandLine("--project <path>", "Use a project root instead of auto-discovery."),
378
+ commandLine("--json", "Emit structured output for scripts/agents."),
379
+ commandLine("--dry-run", "Print the command plan without mutating state.")
380
+ ].join(`
381
+ `).trimEnd();
382
+ }
383
+ function renderAdvancedHelp() {
384
+ return [
385
+ `${heading("rig advanced")} \u2014 compatibility, diagnostics, and internal surfaces`,
386
+ "",
387
+ pc.bold("Primary groups"),
388
+ " init, server, task, run, inbox, repo, plugin, inspect, stats, doctor, github",
389
+ "",
390
+ pc.bold("Advanced commands"),
391
+ ...ADVANCED_COMMANDS.map((entry) => commandLine(entry.command, entry.description)),
392
+ "",
393
+ pc.bold("Advanced groups"),
394
+ ...ADVANCED_GROUPS.map((group) => commandLine(group.name, group.summary)),
395
+ "",
396
+ pc.dim("All groups remain callable. Prefer `rig server`, `rig task`, `rig run`, and `rig inbox` for day-to-day work.")
397
+ ].join(`
398
+ `);
399
+ }
400
+ function renderGroupHelp(groupName) {
401
+ const group = ALL_GROUPS.find((candidate) => candidate.name === groupName);
402
+ return group ? renderGroup(group) : null;
403
+ }
404
+ function listHelpGroups() {
405
+ return ALL_GROUPS.map((group) => group.name);
406
+ }
407
+ function suggestGroupCommandForWord(word) {
408
+ const normalized = word.trim().toLowerCase();
409
+ if (!normalized)
410
+ return null;
411
+ for (const group of ALL_GROUPS) {
412
+ for (const entry of group.commands) {
413
+ const firstToken = entry.command.split(/\s+/)[0] ?? "";
414
+ const names = firstToken.split("|").map((name) => name.trim().toLowerCase());
415
+ if (names.includes(normalized)) {
416
+ return `rig ${group.name} ${normalized}`;
417
+ }
418
+ }
419
+ }
420
+ return null;
421
+ }
422
+ function printTopLevelHelp(state = {}) {
423
+ console.log(renderTopLevelHelp());
424
+ }
425
+ function printAdvancedHelp() {
426
+ console.log(renderAdvancedHelp());
427
+ }
428
+ function printGroupHelpDocument(groupName) {
429
+ console.log(renderGroupHelp(groupName) ?? renderTopLevelHelp());
430
+ }
431
+ export {
432
+ suggestGroupCommandForWord,
433
+ renderTopLevelHelp,
434
+ renderRigBanner,
435
+ renderGroupHelp,
436
+ renderAdvancedHelp,
437
+ printTopLevelHelp,
438
+ printGroupHelpDocument,
439
+ printAdvancedHelp,
440
+ listHelpGroups,
441
+ helpCatalog
442
+ };
@@ -0,0 +1,11 @@
1
+ import { type RigCliOutputEnvelope } from "@rig/contracts";
2
+ /**
3
+ * Build the versioned `{ v: 1, command, data }` envelope for a command
4
+ * outcome, or null when the command has no output schema (legacy payload)
5
+ * or the details fail validation (warned on stderr, legacy payload).
6
+ */
7
+ export declare function buildCliJsonEnvelope(outcome: unknown, options?: {
8
+ warn?: (message: string) => void;
9
+ }): RigCliOutputEnvelope | null;
10
+ /** Commands with a versioned --json envelope (for help/docs/tests). */
11
+ export declare function listSchematizedCliCommands(): string[];
@@ -0,0 +1,56 @@
1
+ // @bun
2
+ // packages/cli/src/commands/_json-output.ts
3
+ import { Schema } from "effect";
4
+ import {
5
+ RigDoctorCheckOutput,
6
+ RigInboxApprovalsOutput,
7
+ RigInboxInputsOutput,
8
+ RigRunListOutput,
9
+ RigRunShowOutput,
10
+ RigServerStatusOutput,
11
+ RigStatsOutput,
12
+ RigTaskListOutput,
13
+ RigTaskShowOutput
14
+ } from "@rig/contracts";
15
+ var CLI_OUTPUT_SCHEMAS = {
16
+ "task list": RigTaskListOutput,
17
+ "task show": RigTaskShowOutput,
18
+ "run list": RigRunListOutput,
19
+ "run show": RigRunShowOutput,
20
+ "server status": RigServerStatusOutput,
21
+ "inbox approvals": RigInboxApprovalsOutput,
22
+ "inbox inputs": RigInboxInputsOutput,
23
+ "doctor check": RigDoctorCheckOutput,
24
+ "stats show": RigStatsOutput
25
+ };
26
+ function isCommandOutcomeLike(value) {
27
+ if (!value || typeof value !== "object" || Array.isArray(value))
28
+ return false;
29
+ const record = value;
30
+ return typeof record.group === "string" && typeof record.command === "string";
31
+ }
32
+ function buildCliJsonEnvelope(outcome, options = {}) {
33
+ if (!isCommandOutcomeLike(outcome))
34
+ return null;
35
+ const commandKey = `${outcome.group} ${outcome.command}`;
36
+ const schema = CLI_OUTPUT_SCHEMAS[commandKey];
37
+ if (!schema)
38
+ return null;
39
+ const warn = options.warn ?? ((message) => console.error(message));
40
+ const envelope = { v: 1, command: commandKey, data: outcome.details ?? {} };
41
+ try {
42
+ Schema.decodeUnknownSync(schema)(JSON.parse(JSON.stringify(envelope)));
43
+ return envelope;
44
+ } catch (error) {
45
+ warn(`[rig] --json output for "${commandKey}" failed schema validation; printing legacy payload. ` + `(${error instanceof Error ? error.message.split(`
46
+ `)[0] : String(error)})`);
47
+ return null;
48
+ }
49
+ }
50
+ function listSchematizedCliCommands() {
51
+ return Object.keys(CLI_OUTPUT_SCHEMAS).sort();
52
+ }
53
+ export {
54
+ listSchematizedCliCommands,
55
+ buildCliJsonEnvelope
56
+ };
@@ -0,0 +1,34 @@
1
+ import type { WorkspaceTaskRecord } from "./_server-client";
2
+ export type OperatorSnapshot = {
3
+ readonly run: Record<string, unknown>;
4
+ readonly logs?: readonly Record<string, unknown>[];
5
+ readonly timeline?: readonly Record<string, unknown>[];
6
+ };
7
+ export declare function renderOperatorSnapshot(snapshot: OperatorSnapshot): string;
8
+ export type PiRunStreamRenderer = {
9
+ renderSnapshot(snapshot: OperatorSnapshot): void;
10
+ renderTimeline(entries: readonly Record<string, unknown>[]): void;
11
+ renderLogs(entries: readonly Record<string, unknown>[]): void;
12
+ };
13
+ export declare function createPiRunStreamRenderer(output?: Pick<NodeJS.WriteStream, "write">): PiRunStreamRenderer;
14
+ export type OperatorSurface = PiRunStreamRenderer & {
15
+ readonly mode: "text" | "pi-compatible-text";
16
+ info(message: string): void;
17
+ error(message: string): void;
18
+ attachCommandInput(handler: (line: string) => void | Promise<void>): {
19
+ close(): void;
20
+ } | null;
21
+ };
22
+ export declare function createOperatorSurface(options?: {
23
+ readonly input?: NodeJS.ReadStream;
24
+ readonly output?: Pick<NodeJS.WriteStream, "write"> & {
25
+ readonly isTTY?: boolean;
26
+ };
27
+ readonly errorOutput?: Pick<NodeJS.WriteStream, "write">;
28
+ readonly interactive?: boolean;
29
+ }): OperatorSurface;
30
+ export type TaskPickerRenderer = {
31
+ readonly writeLine: (line: string) => void;
32
+ };
33
+ export declare function renderTaskPickerRows(tasks: readonly WorkspaceTaskRecord[]): string[];
34
+ export declare function promptForTaskSelection(question: string): Promise<string>;