@h-rig/cli 0.0.6-alpha.6 → 0.0.6-alpha.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/bin/rig.js +4184 -1228
- package/dist/src/commands/_cli-format.js +369 -0
- package/dist/src/commands/_connection-state.js +12 -6
- package/dist/src/commands/_doctor-checks.js +79 -34
- package/dist/src/commands/_help-catalog.js +445 -0
- package/dist/src/commands/_operator-surface.js +220 -0
- package/dist/src/commands/_operator-view.js +1124 -64
- package/dist/src/commands/_parsers.js +0 -2
- package/dist/src/commands/_pi-frontend.js +1080 -0
- package/dist/src/commands/_pi-install.js +4 -3
- package/dist/src/commands/_pi-remote-session.js +771 -0
- package/dist/src/commands/_pi-worker-bridge-extension.js +834 -0
- package/dist/src/commands/_policy.js +0 -2
- package/dist/src/commands/_preflight.js +98 -116
- package/dist/src/commands/_run-driver-helpers.js +34 -2
- package/dist/src/commands/_server-client.js +225 -48
- package/dist/src/commands/_snapshot-upload.js +74 -30
- package/dist/src/commands/_spinner.js +63 -0
- package/dist/src/commands/_task-picker.js +44 -16
- package/dist/src/commands/agent.js +8 -9
- package/dist/src/commands/browser.js +4 -6
- package/dist/src/commands/connect.js +134 -26
- package/dist/src/commands/dist.js +4 -6
- package/dist/src/commands/doctor.js +79 -34
- package/dist/src/commands/github.js +76 -32
- package/dist/src/commands/inbox.js +410 -31
- package/dist/src/commands/init.js +398 -90
- package/dist/src/commands/inspect.js +296 -23
- package/dist/src/commands/inspector.js +2 -4
- package/dist/src/commands/pi.js +168 -0
- package/dist/src/commands/plugin.js +81 -22
- package/dist/src/commands/profile-and-review.js +8 -10
- package/dist/src/commands/queue.js +2 -3
- package/dist/src/commands/remote.js +18 -20
- package/dist/src/commands/repo-git-harness.js +6 -8
- package/dist/src/commands/run.js +1422 -131
- package/dist/src/commands/server.js +280 -40
- package/dist/src/commands/setup.js +84 -45
- package/dist/src/commands/task-report-bug.js +5 -7
- package/dist/src/commands/task-run-driver.js +710 -70
- package/dist/src/commands/task.js +1861 -260
- package/dist/src/commands/test.js +3 -5
- package/dist/src/commands/workspace.js +4 -6
- package/dist/src/commands.js +4143 -1181
- package/dist/src/index.js +4156 -1203
- package/dist/src/launcher.js +5 -3
- package/dist/src/report-bug.js +3 -3
- package/dist/src/runner.js +5 -19
- package/package.json +7 -5
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/cli/src/commands/_help-catalog.ts
|
|
3
|
+
import { intro, log, note, outro } from "@clack/prompts";
|
|
4
|
+
import pc from "picocolors";
|
|
5
|
+
var TOP_LEVEL_SECTIONS = [
|
|
6
|
+
{
|
|
7
|
+
title: "Start here",
|
|
8
|
+
subtitle: "one-time setup for a repo",
|
|
9
|
+
commands: [
|
|
10
|
+
{ command: "rig init", description: "Wizard: config, GitHub auth, task source, server, Pi wiring." },
|
|
11
|
+
{ command: "rig doctor", description: "Check every part of the wiring \u2014 run this when anything feels off." },
|
|
12
|
+
{ command: "rig server use <alias|local>", description: "Pick which Rig server owns this repo (`rig server list` to see them)." }
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: "Work",
|
|
17
|
+
subtitle: "find a task and put an agent on it",
|
|
18
|
+
commands: [
|
|
19
|
+
{ command: "rig task list", description: "What's on the board (from the selected source/server)." },
|
|
20
|
+
{ command: "rig task next", description: "The next ready task, as a card." },
|
|
21
|
+
{ command: "rig task run --next", description: "Dispatch an agent; interactive mode opens the native Pi session." },
|
|
22
|
+
{ command: "rig task run <id> --detach", description: "Fire-and-forget a specific task." }
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: "Watch & steer",
|
|
27
|
+
subtitle: "live runs are observable and steerable, attached or not",
|
|
28
|
+
commands: [
|
|
29
|
+
{ command: "rig run status", description: "Active and recent runs at a glance." },
|
|
30
|
+
{ command: "rig run attach <id> --follow", description: "Join the live Pi session (worker keeps running if you /detach)." },
|
|
31
|
+
{ command: "rig run steer <id> -m <text>", description: "Drop a message into a live worker without attaching." },
|
|
32
|
+
{ command: "rig run stop <id>", description: "Cancel a running worker." }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: "Unblock & gate",
|
|
37
|
+
subtitle: "answer what workers ask; control what merges",
|
|
38
|
+
commands: [
|
|
39
|
+
{ command: "rig inbox approvals", description: "Approvals workers are waiting on (then `rig inbox approve \u2026`)." },
|
|
40
|
+
{ command: "rig inbox inputs", description: "Questions workers asked (then `rig inbox respond \u2026`)." },
|
|
41
|
+
{ command: "rig review show|set", description: "The completion review gate (Greptile is mandatory on merges)." }
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: "Extend",
|
|
46
|
+
subtitle: "more Pi, more plugins",
|
|
47
|
+
commands: [
|
|
48
|
+
{ command: "rig pi search <term>", description: "Discover community Pi extensions on npm." },
|
|
49
|
+
{ command: "rig pi add <pkg>", description: "Add a Pi extension to this project (workers pick it up too)." },
|
|
50
|
+
{ command: "rig plugin list", description: "What the rig.config.ts plugins contribute." }
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
var PRIMARY_GROUPS = [
|
|
55
|
+
{
|
|
56
|
+
name: "server",
|
|
57
|
+
summary: "Choose, inspect, and start the Rig server that owns tasks and runs.",
|
|
58
|
+
usage: ["rig server <status|list|add|use|start> [options]"],
|
|
59
|
+
commands: [
|
|
60
|
+
{ command: "status", description: "Show the selected server for this repo.", primary: true },
|
|
61
|
+
{ command: "use local", description: "Switch this repo to the local Rig server.", primary: true },
|
|
62
|
+
{ command: "add <alias> <url>", description: "Save a remote Rig server URL.", primary: true },
|
|
63
|
+
{ command: "use <alias>", description: "Select a saved remote server alias.", primary: true },
|
|
64
|
+
{ command: "list", description: "List saved local/remote server aliases.", primary: true },
|
|
65
|
+
{ command: "start [--host <host>] [--port <n>]", description: "Start a local rig-server process." }
|
|
66
|
+
],
|
|
67
|
+
examples: [
|
|
68
|
+
"rig server status",
|
|
69
|
+
"rig server add prod https://where.rig-does.work",
|
|
70
|
+
"rig server use prod",
|
|
71
|
+
"rig server use local",
|
|
72
|
+
"rig server start --port 3773"
|
|
73
|
+
],
|
|
74
|
+
next: ["Use `rig task list` to see server-owned work.", "Use `rig run list` or `rig run attach <id> --follow` to monitor runs."],
|
|
75
|
+
advanced: ["Compatibility alias: `rig connect ...` remains callable."]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "task",
|
|
79
|
+
summary: "Find work, start Pi-backed runs, and validate task results.",
|
|
80
|
+
usage: ["rig task <list|next|show|run> [options]"],
|
|
81
|
+
commands: [
|
|
82
|
+
{ command: "list [--assignee <login|@me>] [--state open|closed]", description: "List tasks from the selected server/source.", primary: true },
|
|
83
|
+
{ command: "next [filters]", description: "Render the next matching task as a selected-task card.", primary: true },
|
|
84
|
+
{ command: "show <id>|--task <id> [--raw]", description: "Show a human task summary; --raw prints the full payload.", primary: true },
|
|
85
|
+
{ command: "run [#<issue>|<task-id>|--next|--task <id>]", description: "Submit a task run; interactive follows with bundled Pi.", primary: true },
|
|
86
|
+
{ command: "validate|verify [--task <id>]", description: "Run configured task checks/review gates." },
|
|
87
|
+
{ command: "details --task <id>", description: "Show full task info from the configured source." },
|
|
88
|
+
{ command: "reopen [--task <id> | --all] [--reason <text>]", description: "Reopen closed task(s) in the configured source." },
|
|
89
|
+
{ command: "reset --task <id>", description: "Compatibility spelling of `reopen --task <id>`." },
|
|
90
|
+
{ command: "artifacts|artifact-dir|artifact-write", description: "Inspect or write task artifacts." },
|
|
91
|
+
{ command: "report-bug", description: "Create a structured bug report/task." }
|
|
92
|
+
],
|
|
93
|
+
examples: [
|
|
94
|
+
"rig task list --assignee @me --limit 20",
|
|
95
|
+
"rig task next",
|
|
96
|
+
"rig task show 123 --raw",
|
|
97
|
+
"rig task run --next",
|
|
98
|
+
"rig task run #123 --runtime-adapter pi",
|
|
99
|
+
"rig task run --title 'Investigate deploy drift' --initial-prompt 'Check server health'"
|
|
100
|
+
],
|
|
101
|
+
next: ["Use `--detach` to submit without attaching.", "Use `rig run attach <run-id> --follow` to rejoin a live run."]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "run",
|
|
105
|
+
summary: "Observe, attach to, and control Rig runs.",
|
|
106
|
+
usage: ["rig run <list|status|show|attach|stop> [options]"],
|
|
107
|
+
commands: [
|
|
108
|
+
{ command: "list", description: "List recent runs from the selected server or local state.", primary: true },
|
|
109
|
+
{ command: "status", description: "Render active and recent run groups.", primary: true },
|
|
110
|
+
{ command: "show <id>|--run <id> [--raw]", description: "Show a human run summary; --raw prints the full payload.", primary: true },
|
|
111
|
+
{ command: "attach <run-id>|--run <id> [--follow]", description: "Attach to the run; --follow opens the enriched bundled Pi (worker brain).", primary: true },
|
|
112
|
+
{ command: "stop [<run-id>|--run <id>]", description: "Request stop for one run or local active runs.", primary: true },
|
|
113
|
+
{ command: "steer <run-id> --message <text>", description: "Queue a steering message into a live worker without attaching." },
|
|
114
|
+
{ command: "timeline --run <id> [--follow]", description: "Stream raw run timeline events." },
|
|
115
|
+
{ command: "resume", description: "Resume the most recent interrupted local run." },
|
|
116
|
+
{ command: "restart", description: "Restart the most recent local run from a clean runtime." },
|
|
117
|
+
{ command: "delete|cleanup", description: "Remove completed run records/artifacts." }
|
|
118
|
+
],
|
|
119
|
+
examples: [
|
|
120
|
+
"rig run list",
|
|
121
|
+
"rig run status",
|
|
122
|
+
"rig run show <run-id>",
|
|
123
|
+
"rig run attach <run-id> --follow",
|
|
124
|
+
"rig run stop <run-id>"
|
|
125
|
+
],
|
|
126
|
+
next: ["Use `rig task run --next` to create a new run.", "Use `--json` when scripts need the full structured record."]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "inbox",
|
|
130
|
+
summary: "Review approval and user-input requests that block worker runs.",
|
|
131
|
+
usage: ["rig inbox <approvals|approve|inputs|respond> [options]"],
|
|
132
|
+
commands: [
|
|
133
|
+
{ command: "approvals [--run <id>] [--task <id>]", description: "List pending approvals.", primary: true },
|
|
134
|
+
{ command: "inputs [--run <id>] [--task <id>]", description: "List pending user-input requests.", primary: true },
|
|
135
|
+
{ command: "approve --run <id> --request <id> --decision approve|reject", description: "Resolve an approval request." },
|
|
136
|
+
{ command: "respond --run <id> --request <id> --answer key=value", description: "Answer a user-input request." }
|
|
137
|
+
],
|
|
138
|
+
examples: [
|
|
139
|
+
"rig inbox approvals",
|
|
140
|
+
"rig inbox inputs --run <run-id>",
|
|
141
|
+
"rig inbox approve --run <run-id> --request <request-id> --decision approve"
|
|
142
|
+
],
|
|
143
|
+
next: ["Rejoin the run after resolving a block: `rig run attach <run-id> --follow`."]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "review",
|
|
147
|
+
summary: "Inspect or change completion review gate policy.",
|
|
148
|
+
usage: ["rig review <show|set>"],
|
|
149
|
+
commands: [
|
|
150
|
+
{ command: "show", description: "Show current review gate settings.", primary: true },
|
|
151
|
+
{ command: "set <off|advisory|required> [--provider greptile]", description: "Change review strictness/provider.", primary: true }
|
|
152
|
+
],
|
|
153
|
+
examples: ["rig review show", "rig review set required --provider greptile"],
|
|
154
|
+
next: ["Use `rig inbox approvals` for blocked run handoffs."]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "init",
|
|
158
|
+
summary: "Set up Rig for this repo: server, GitHub auth, checkout strategy, task source, and Pi wiring.",
|
|
159
|
+
usage: ["rig init [--yes] [--server local|remote] [--repo owner/repo] [--remote-url <url>]"],
|
|
160
|
+
commands: [
|
|
161
|
+
{ command: "init", description: "Interactive setup wizard for a new or existing Rig repo.", primary: true },
|
|
162
|
+
{ command: "init --yes", description: "Non-interactive setup using detected/default settings.", primary: true },
|
|
163
|
+
{ command: "init --server remote --remote-url <url>", description: "Link this repo to a remote Rig server.", primary: true },
|
|
164
|
+
{ command: "init --repair", description: "Repair missing private state without replacing project config." }
|
|
165
|
+
],
|
|
166
|
+
examples: [
|
|
167
|
+
"rig init",
|
|
168
|
+
"rig init --yes --repo humanity-org/humanwork",
|
|
169
|
+
"rig init --server remote --remote-url https://where.rig-does.work --repo owner/repo"
|
|
170
|
+
],
|
|
171
|
+
next: ["After init, run `rig server status`.", "Then use `rig task list` and `rig task run --next` for day-to-day work."]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "doctor",
|
|
175
|
+
summary: "Diagnostics for project/server/GitHub/Pi state.",
|
|
176
|
+
usage: ["rig doctor"],
|
|
177
|
+
commands: [
|
|
178
|
+
{ command: "doctor", description: "Run setup and runtime diagnostics.", primary: true },
|
|
179
|
+
{ command: "check", description: "Compatibility spelling for diagnostics." }
|
|
180
|
+
],
|
|
181
|
+
examples: ["rig doctor", "rig doctor --json"],
|
|
182
|
+
next: ["Use `rig server status` and `rig github auth status` to inspect common failure points."]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "github",
|
|
186
|
+
summary: "GitHub auth helpers for the selected Rig server.",
|
|
187
|
+
usage: ["rig github auth <status|import-gh|token>"],
|
|
188
|
+
commands: [
|
|
189
|
+
{ command: "auth status", description: "Show GitHub auth state.", primary: true },
|
|
190
|
+
{ command: "auth import-gh", description: "Import the current `gh` token into the selected server." },
|
|
191
|
+
{ command: "auth token --token <token>", description: "Store a token on the selected server." }
|
|
192
|
+
],
|
|
193
|
+
examples: ["rig github auth status", "rig github auth import-gh"],
|
|
194
|
+
next: ["After auth is valid, use `rig task run --next`."]
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
var ADVANCED_GROUPS = [
|
|
198
|
+
{ name: "connect", summary: "Compatibility alias for `rig server` selection commands.", usage: ["rig connect <status|list|add|use>"], commands: [{ command: "status|list|add|use", description: "Use `rig server ...` for the primary UX." }] },
|
|
199
|
+
{ name: "setup", summary: "Bootstrap/check local setup.", usage: ["rig setup <bootstrap|check|preflight>"], commands: [{ command: "bootstrap|check|preflight", description: "Setup helpers." }] },
|
|
200
|
+
{
|
|
201
|
+
name: "inspect",
|
|
202
|
+
summary: "Inspect logs, artifacts, graphs, failures for a task.",
|
|
203
|
+
usage: ["rig inspect <logs|artifacts|failures|graph|audit|diff> --task <id>"],
|
|
204
|
+
commands: [
|
|
205
|
+
{ command: "logs --task <id>", description: "Latest run log for a task (local or selected server)." },
|
|
206
|
+
{ command: "artifacts --task <id>", description: "List the task's completion artifacts." },
|
|
207
|
+
{ command: "failures --task <id>", description: "Recorded failures for a task." },
|
|
208
|
+
{ command: "graph", description: "Task dependency graph." },
|
|
209
|
+
{ command: "audit", description: "Controlled-command audit trail." },
|
|
210
|
+
{ command: "diff --task <id>", description: "Changed files for a task." }
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
{ name: "repo", summary: "Repository sync/baseline helpers.", usage: ["rig repo <sync|reset-baseline>"], commands: [{ command: "sync", description: "Sync project repository state." }] },
|
|
214
|
+
{ name: "profile", summary: "Runtime profile/model defaults.", usage: ["rig profile <show|set>"], commands: [{ command: "show", description: "Show active profile." }] },
|
|
215
|
+
{
|
|
216
|
+
name: "browser",
|
|
217
|
+
summary: "Browser/app diagnostics for browser-required tasks.",
|
|
218
|
+
usage: ["rig browser <help|explain|demo|app|hp-next> [options]"],
|
|
219
|
+
commands: [
|
|
220
|
+
{ command: "help", description: "Rich browser command help (canonical: `rig browser help`)." },
|
|
221
|
+
{ command: "explain", description: "Explain the browser-required task contract." },
|
|
222
|
+
{ command: "demo", description: "Run browser demo flows against a local page." },
|
|
223
|
+
{ command: "app", description: "Launch the Rig Browser workstation app." },
|
|
224
|
+
{ command: "hp-next <dev|check|e2e|reset>", description: "Drive the hp-next browser test harness." }
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "pi",
|
|
229
|
+
summary: "Manage Pi extension packages for this project (community extensions from npm/git).",
|
|
230
|
+
usage: ["rig pi <list|add|remove|search> [args]"],
|
|
231
|
+
commands: [
|
|
232
|
+
{ command: "list", description: "Show project and user Pi extension packages." },
|
|
233
|
+
{ command: "add <source>", description: "Add an npm/git Pi extension to .pi/settings.json (auto-installs at next session)." },
|
|
234
|
+
{ command: "remove <source>", description: "Remove an operator-added Pi extension." },
|
|
235
|
+
{ command: "search [term]", description: "Discover Pi extension packages on the npm registry." }
|
|
236
|
+
],
|
|
237
|
+
examples: ["rig pi search subagents", "rig pi add pi-subagents", "rig pi list"],
|
|
238
|
+
next: ["Config-managed extensions: declare `runtime: { pi: { packages: [...] } }` in rig.config.ts \u2014 workers pick them up automatically."]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "plugin",
|
|
242
|
+
summary: "Plugin listing, validation, and plugin-contributed commands.",
|
|
243
|
+
usage: ["rig plugin <list|validate|run> [options]"],
|
|
244
|
+
commands: [
|
|
245
|
+
{ command: "list", description: "List plugins declared in rig.config.ts and their contributions." },
|
|
246
|
+
{ command: "validate --task <id>", description: "Run plugin-contributed validators for a task." },
|
|
247
|
+
{ command: "run <command-id> [args...]", description: "Execute a plugin-contributed CLI command (also callable as `rig <command-id>`)." }
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
{ name: "queue", summary: "Run task queues locally.", usage: ["rig queue run [options]"], commands: [{ command: "run", description: "Process queue work." }] },
|
|
251
|
+
{ name: "agent", summary: "Runtime agent workspace helpers.", usage: ["rig agent <list|prepare|run|cleanup>"], commands: [{ command: "list", description: "List prepared agents." }] },
|
|
252
|
+
{ name: "inspector", summary: "Event stream and drift scanners.", usage: ["rig inspector <stream|scan-upstream-drift>"], commands: [{ command: "stream", description: "Stream events." }] },
|
|
253
|
+
{ name: "dist", summary: "Build/install packaged Rig CLI.", usage: ["rig dist <build|install|doctor>"], commands: [{ command: "build", description: "Build distribution." }] },
|
|
254
|
+
{ name: "workspace", summary: "Workspace topology/service helpers.", usage: ["rig workspace <summary|topology|remote-hosts>"], commands: [{ command: "summary", description: "Show workspace summary." }] },
|
|
255
|
+
{ name: "remote", summary: "Compatibility remote orchestration controls.", usage: ["rig remote <status|watch|pause|resume|...>"], commands: [{ command: "status", description: "Show remote state." }] },
|
|
256
|
+
{ name: "git", summary: "Pass through to Rig git-flow helper.", usage: ["rig git <args...>"], commands: [{ command: "<args...>", description: "Advanced git flow operations." }] },
|
|
257
|
+
{ name: "harness", summary: "Pass through to runtime harness CLI.", usage: ["rig harness <args...>"], commands: [{ command: "<args...>", description: "Advanced harness operations." }] },
|
|
258
|
+
{ name: "test", summary: "Project test wrappers.", usage: ["rig test <unit|e2e|all>"], commands: [{ command: "all", description: "Run configured project tests." }] }
|
|
259
|
+
];
|
|
260
|
+
var ADVANCED_COMMANDS = [
|
|
261
|
+
{ command: "rig server task-run ...", description: "Internal server-owned task execution entry point." },
|
|
262
|
+
{ command: "rig server notify-test [--event <type>]", description: "Internal event notification smoke command." },
|
|
263
|
+
{ command: "rig run start|start-serial|start-parallel", description: "Local epic queue starters (server-owned tasks use `rig task run ...`)." },
|
|
264
|
+
{ command: "rig remote orchestrate-*", description: "Compatibility remote orchestration commands." }
|
|
265
|
+
];
|
|
266
|
+
var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
|
|
267
|
+
function heading(title) {
|
|
268
|
+
return pc.bold(pc.cyan(title));
|
|
269
|
+
}
|
|
270
|
+
function renderRigBanner(version) {
|
|
271
|
+
const m = (s) => pc.bold(pc.magenta(s));
|
|
272
|
+
const c = (s) => pc.bold(pc.cyan(s));
|
|
273
|
+
const y = (s) => pc.yellow(s);
|
|
274
|
+
const d = (s) => pc.dim(s);
|
|
275
|
+
const lines = [
|
|
276
|
+
m(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ") + d(" \u2591\u2592\u2593\u2588 "),
|
|
277
|
+
m(" \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D ") + d("\u2593\u2592\u2591"),
|
|
278
|
+
c(" \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557") + d(" \u2591\u2592"),
|
|
279
|
+
c(" \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551") + d(" \u2588\u2593\u2591"),
|
|
280
|
+
y(" \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D") + d(" \u2592\u2591"),
|
|
281
|
+
y(" \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D "),
|
|
282
|
+
"",
|
|
283
|
+
` ${c("\u25E2\u25E4")} ${pc.bold("the control rig for autonomous coding agents")} ${m("//")} ${d("you are the operator")}`,
|
|
284
|
+
version ? ` ${d(`v${version} \xB7 jack in: rig task run --next`)}` : ` ${d("jack in: rig task run --next")}`
|
|
285
|
+
];
|
|
286
|
+
return lines.join(`
|
|
287
|
+
`);
|
|
288
|
+
}
|
|
289
|
+
function commandLine(command, description) {
|
|
290
|
+
const commandColumn = command.length >= 38 ? `${command} ` : command.padEnd(38);
|
|
291
|
+
return `${pc.dim("\u2502")} ${pc.bold(commandColumn)} ${description}`;
|
|
292
|
+
}
|
|
293
|
+
function renderCommandBlock(commands) {
|
|
294
|
+
return commands.map((entry) => commandLine(entry.command, entry.description)).join(`
|
|
295
|
+
`);
|
|
296
|
+
}
|
|
297
|
+
function renderGroup(group) {
|
|
298
|
+
const lines = [
|
|
299
|
+
`${heading(`rig ${group.name}`)} \u2014 ${group.summary}`,
|
|
300
|
+
"",
|
|
301
|
+
pc.bold("Usage"),
|
|
302
|
+
...group.usage.map((line) => ` ${line}`),
|
|
303
|
+
"",
|
|
304
|
+
pc.bold("Commands"),
|
|
305
|
+
...group.commands.map((entry) => commandLine(entry.command, entry.description))
|
|
306
|
+
];
|
|
307
|
+
if (group.examples?.length) {
|
|
308
|
+
lines.push("", pc.bold("Examples"), ...group.examples.map((line) => ` ${pc.dim("$")} ${line}`));
|
|
309
|
+
}
|
|
310
|
+
if (group.next?.length) {
|
|
311
|
+
lines.push("", pc.bold("Next steps"), ...group.next.map((line) => ` ${pc.dim("\u203A")} ${line}`));
|
|
312
|
+
}
|
|
313
|
+
if (group.advanced?.length) {
|
|
314
|
+
lines.push("", pc.bold("Compatibility / advanced"), ...group.advanced.map((line) => ` ${pc.dim("\u203A")} ${line}`));
|
|
315
|
+
}
|
|
316
|
+
return lines.join(`
|
|
317
|
+
`);
|
|
318
|
+
}
|
|
319
|
+
function renderTopLevelHelp() {
|
|
320
|
+
return [
|
|
321
|
+
`${heading("rig")} ${pc.dim("\u2014 server-owned task/run control plane for Pi-backed engineering work")}`,
|
|
322
|
+
pc.dim("Current path: select a server, choose a task, submit a run, attach with native Pi, clear inbox/review gates."),
|
|
323
|
+
"",
|
|
324
|
+
...TOP_LEVEL_SECTIONS.flatMap((section) => [
|
|
325
|
+
`${pc.bold(pc.magenta(`\u25C7 ${section.title}`))} \u2014 ${pc.dim(section.subtitle)}`,
|
|
326
|
+
renderCommandBlock(section.commands),
|
|
327
|
+
""
|
|
328
|
+
]),
|
|
329
|
+
pc.dim("More: `rig help --advanced` for dev/compatibility commands; `rig <group> --help` for rich per-group help; `rig --version` for the installed version."),
|
|
330
|
+
"",
|
|
331
|
+
pc.bold("Global options"),
|
|
332
|
+
commandLine("--project <path>", "Use a project root instead of auto-discovery."),
|
|
333
|
+
commandLine("--json", "Emit structured output for scripts/agents."),
|
|
334
|
+
commandLine("--dry-run", "Print the command plan without mutating state.")
|
|
335
|
+
].join(`
|
|
336
|
+
`).trimEnd();
|
|
337
|
+
}
|
|
338
|
+
function renderAdvancedHelp() {
|
|
339
|
+
return [
|
|
340
|
+
`${heading("rig advanced")} \u2014 compatibility, diagnostics, and internal surfaces`,
|
|
341
|
+
"",
|
|
342
|
+
pc.bold("Primary groups"),
|
|
343
|
+
" server, task, run, inbox, review, init, doctor, github",
|
|
344
|
+
"",
|
|
345
|
+
pc.bold("Advanced commands"),
|
|
346
|
+
...ADVANCED_COMMANDS.map((entry) => commandLine(entry.command, entry.description)),
|
|
347
|
+
"",
|
|
348
|
+
pc.bold("Advanced groups"),
|
|
349
|
+
...ADVANCED_GROUPS.map((group) => commandLine(group.name, group.summary)),
|
|
350
|
+
"",
|
|
351
|
+
pc.dim("All groups remain callable. Prefer `rig server`, `rig task`, `rig run`, `rig inbox`, and `rig review` for day-to-day work.")
|
|
352
|
+
].join(`
|
|
353
|
+
`);
|
|
354
|
+
}
|
|
355
|
+
function renderGroupHelp(groupName) {
|
|
356
|
+
const group = ALL_GROUPS.find((candidate) => candidate.name === groupName);
|
|
357
|
+
return group ? renderGroup(group) : null;
|
|
358
|
+
}
|
|
359
|
+
function listHelpGroups() {
|
|
360
|
+
return ALL_GROUPS.map((group) => group.name);
|
|
361
|
+
}
|
|
362
|
+
function shouldUseClackOutput() {
|
|
363
|
+
return Boolean(process.stdout.isTTY) && process.env.RIG_CLI_PLAIN_HELP !== "1";
|
|
364
|
+
}
|
|
365
|
+
function printTopLevelHelp(state = {}) {
|
|
366
|
+
if (!shouldUseClackOutput()) {
|
|
367
|
+
console.log(renderTopLevelHelp());
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
console.log(renderRigBanner(state.version));
|
|
371
|
+
console.log("");
|
|
372
|
+
if (state.projectInitialized === false) {
|
|
373
|
+
intro("no rig project in this directory");
|
|
374
|
+
note([
|
|
375
|
+
commandLine("rig init", "Set this repo up: config, GitHub auth, task source, server, Pi."),
|
|
376
|
+
commandLine("rig init --yes", "Same, non-interactive, sensible defaults."),
|
|
377
|
+
commandLine("rig doctor", "Already initialized somewhere else? Check the wiring.")
|
|
378
|
+
].join(`
|
|
379
|
+
`), "Get started");
|
|
380
|
+
outro("After init: rig task run --next puts an agent on your next task.");
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
intro(state.selectedServer ? `server: ${state.selectedServer}` : "rig");
|
|
384
|
+
for (const section of TOP_LEVEL_SECTIONS) {
|
|
385
|
+
note(renderCommandBlock(section.commands), `${section.title} \u2014 ${section.subtitle}`);
|
|
386
|
+
}
|
|
387
|
+
log.info("More: rig help --advanced \xB7 rig <group> --help \xB7 rig --version");
|
|
388
|
+
note([
|
|
389
|
+
commandLine("--project <path>", "Use a project root instead of auto-discovery."),
|
|
390
|
+
commandLine("--json", "Emit structured output for scripts/agents."),
|
|
391
|
+
commandLine("--dry-run", "Print the command plan without mutating state.")
|
|
392
|
+
].join(`
|
|
393
|
+
`), "Global options");
|
|
394
|
+
outro("init \u2192 task run \u2192 watch/steer \u2192 inbox/review \u2192 merged.");
|
|
395
|
+
}
|
|
396
|
+
function printAdvancedHelp() {
|
|
397
|
+
if (!shouldUseClackOutput()) {
|
|
398
|
+
console.log(renderAdvancedHelp());
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
intro("rig advanced");
|
|
402
|
+
note(ADVANCED_COMMANDS.map((entry) => commandLine(entry.command, entry.description)).join(`
|
|
403
|
+
`), "Advanced commands");
|
|
404
|
+
note(ADVANCED_GROUPS.map((group) => commandLine(group.name, group.summary)).join(`
|
|
405
|
+
`), "Advanced groups");
|
|
406
|
+
outro("Primary daily flow: rig server \xB7 rig task \xB7 rig run \xB7 rig inbox \xB7 rig review.");
|
|
407
|
+
}
|
|
408
|
+
function printGroupHelpDocument(groupName) {
|
|
409
|
+
const rendered = renderGroupHelp(groupName) ?? renderTopLevelHelp();
|
|
410
|
+
if (!shouldUseClackOutput()) {
|
|
411
|
+
console.log(rendered);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const group = ALL_GROUPS.find((candidate) => candidate.name === groupName);
|
|
415
|
+
if (!group) {
|
|
416
|
+
printTopLevelHelp();
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
intro(`rig ${group.name}`);
|
|
420
|
+
note(group.summary, "Purpose");
|
|
421
|
+
note(group.usage.join(`
|
|
422
|
+
`), "Usage");
|
|
423
|
+
note(group.commands.map((entry) => commandLine(entry.command, entry.description)).join(`
|
|
424
|
+
`), "Commands");
|
|
425
|
+
if (group.examples?.length)
|
|
426
|
+
note(group.examples.map((line) => `$ ${line}`).join(`
|
|
427
|
+
`), "Examples");
|
|
428
|
+
if (group.next?.length)
|
|
429
|
+
note(group.next.map((line) => `\u203A ${line}`).join(`
|
|
430
|
+
`), "Next steps");
|
|
431
|
+
if (group.advanced?.length)
|
|
432
|
+
log.info(group.advanced.join(`
|
|
433
|
+
`));
|
|
434
|
+
outro("Run with --json when scripts need structured output.");
|
|
435
|
+
}
|
|
436
|
+
export {
|
|
437
|
+
renderTopLevelHelp,
|
|
438
|
+
renderRigBanner,
|
|
439
|
+
renderGroupHelp,
|
|
440
|
+
renderAdvancedHelp,
|
|
441
|
+
printTopLevelHelp,
|
|
442
|
+
printGroupHelpDocument,
|
|
443
|
+
printAdvancedHelp,
|
|
444
|
+
listHelpGroups
|
|
445
|
+
};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/cli/src/commands/_operator-surface.ts
|
|
3
|
+
import { createInterface } from "readline";
|
|
4
|
+
import { createInterface as createPromptInterface } from "readline/promises";
|
|
5
|
+
var CANONICAL_STAGES = [
|
|
6
|
+
"Connect",
|
|
7
|
+
"GitHub/task sync",
|
|
8
|
+
"Prepare workspace",
|
|
9
|
+
"Launch Pi",
|
|
10
|
+
"Plan",
|
|
11
|
+
"Implement",
|
|
12
|
+
"Validate",
|
|
13
|
+
"Commit",
|
|
14
|
+
"Open PR",
|
|
15
|
+
"Review/CI",
|
|
16
|
+
"Merge",
|
|
17
|
+
"Complete"
|
|
18
|
+
];
|
|
19
|
+
function logDetail(log) {
|
|
20
|
+
return typeof log.detail === "string" ? log.detail.trim() : "";
|
|
21
|
+
}
|
|
22
|
+
function parseProviderProtocolLog(title, detail) {
|
|
23
|
+
if (title.trim().toLowerCase() !== "agent output")
|
|
24
|
+
return null;
|
|
25
|
+
if (!detail.startsWith("{") || !detail.endsWith("}"))
|
|
26
|
+
return null;
|
|
27
|
+
try {
|
|
28
|
+
const record = JSON.parse(detail);
|
|
29
|
+
if (!record || typeof record !== "object" || Array.isArray(record))
|
|
30
|
+
return null;
|
|
31
|
+
const type = record.type;
|
|
32
|
+
return typeof type === "string" && [
|
|
33
|
+
"assistant",
|
|
34
|
+
"message_start",
|
|
35
|
+
"message_update",
|
|
36
|
+
"message_end",
|
|
37
|
+
"stream_event",
|
|
38
|
+
"tool_result",
|
|
39
|
+
"tool_execution_start",
|
|
40
|
+
"tool_execution_update",
|
|
41
|
+
"tool_execution_end",
|
|
42
|
+
"turn_start",
|
|
43
|
+
"turn_end"
|
|
44
|
+
].includes(type) ? record : null;
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function renderProviderProtocolLog(record) {
|
|
50
|
+
const type = typeof record.type === "string" ? record.type : "";
|
|
51
|
+
if (type === "tool_execution_start" || type === "tool_execution_update" || type === "tool_execution_end") {
|
|
52
|
+
const toolName = String(record.toolName ?? record.name ?? "tool");
|
|
53
|
+
const status = type === "tool_execution_start" ? "started" : type === "tool_execution_end" ? record.isError === true || record.result && typeof record.result === "object" && !Array.isArray(record.result) && record.result.isError === true ? "failed" : "completed" : "running";
|
|
54
|
+
return `[Pi tool] ${toolName} ${status}`;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
function entryId(entry, fallback) {
|
|
59
|
+
return typeof entry.id === "string" && entry.id.trim() ? entry.id : fallback;
|
|
60
|
+
}
|
|
61
|
+
function renderOperatorSnapshot(snapshot) {
|
|
62
|
+
const run = snapshot.run.run && typeof snapshot.run.run === "object" ? snapshot.run.run : snapshot.run;
|
|
63
|
+
const runId = String(run.runId ?? run.id ?? "run");
|
|
64
|
+
const status = String(run.status ?? "unknown");
|
|
65
|
+
const logs = snapshot.logs ?? [];
|
|
66
|
+
const latestByStage = new Map;
|
|
67
|
+
for (const log of logs) {
|
|
68
|
+
const title = String(log.title ?? "").toLowerCase();
|
|
69
|
+
const stageName = String(log.stage ?? "").toLowerCase();
|
|
70
|
+
const stage = CANONICAL_STAGES.find((candidate) => candidate.toLowerCase() === title || candidate.toLowerCase() === stageName);
|
|
71
|
+
if (stage)
|
|
72
|
+
latestByStage.set(stage, log);
|
|
73
|
+
}
|
|
74
|
+
const stageLines = CANONICAL_STAGES.flatMap((stage) => {
|
|
75
|
+
const match = latestByStage.get(stage);
|
|
76
|
+
return match ? [`${stage}: ${String(match.status ?? status)}${logDetail(match) ? ` \u2014 ${logDetail(match)}` : ""}`] : [];
|
|
77
|
+
});
|
|
78
|
+
return [`Rig run ${runId}: ${status}`, ...stageLines].join(`
|
|
79
|
+
`);
|
|
80
|
+
}
|
|
81
|
+
function createPiRunStreamRenderer(output = process.stdout) {
|
|
82
|
+
let lastSnapshot = "";
|
|
83
|
+
const assistantTextById = new Map;
|
|
84
|
+
const seenTimeline = new Set;
|
|
85
|
+
const seenLogs = new Set;
|
|
86
|
+
const writeLine = (line) => output.write(`${line}
|
|
87
|
+
`);
|
|
88
|
+
return {
|
|
89
|
+
renderSnapshot(snapshot) {
|
|
90
|
+
const rendered = renderOperatorSnapshot(snapshot);
|
|
91
|
+
if (rendered && rendered !== lastSnapshot) {
|
|
92
|
+
writeLine(rendered);
|
|
93
|
+
lastSnapshot = rendered;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
renderTimeline(entries) {
|
|
97
|
+
for (const [index, entry] of entries.entries()) {
|
|
98
|
+
const id = entryId(entry, `timeline:${index}:${String(entry.cursor ?? "")}`);
|
|
99
|
+
if (entry.type === "assistant_message" && typeof entry.text === "string") {
|
|
100
|
+
const text = entry.text;
|
|
101
|
+
const previousText = assistantTextById.get(id) ?? "";
|
|
102
|
+
if (!previousText && text.trim()) {
|
|
103
|
+
writeLine("[Pi assistant]");
|
|
104
|
+
}
|
|
105
|
+
if (text.startsWith(previousText)) {
|
|
106
|
+
const delta = text.slice(previousText.length);
|
|
107
|
+
if (delta)
|
|
108
|
+
output.write(delta);
|
|
109
|
+
} else if (text.trim() && text !== previousText) {
|
|
110
|
+
if (previousText)
|
|
111
|
+
writeLine(`
|
|
112
|
+
[Pi assistant]`);
|
|
113
|
+
output.write(text);
|
|
114
|
+
}
|
|
115
|
+
assistantTextById.set(id, text);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (seenTimeline.has(id))
|
|
119
|
+
continue;
|
|
120
|
+
seenTimeline.add(id);
|
|
121
|
+
if (entry.type === "tool_execution_start" || entry.type === "tool_execution_update" || entry.type === "tool_execution_end" || entry.type === "mcp_tool_call") {
|
|
122
|
+
writeLine(`[Pi tool] ${String(entry.toolName ?? entry.name ?? entry.title ?? entry.type)} ${String(entry.status ?? entry.state ?? "")}`.trim());
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (entry.type === "timeline_warning") {
|
|
126
|
+
writeLine(`[Rig timeline] ${String(entry.detail ?? entry.message ?? "timeline unavailable")}`);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (entry.type === "action") {
|
|
130
|
+
const text = String(entry.detail ?? entry.message ?? entry.title ?? "").trim();
|
|
131
|
+
if (text)
|
|
132
|
+
writeLine(`[Rig action] ${text}`);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (entry.type === "user_message") {
|
|
136
|
+
const text = String(entry.text ?? entry.message ?? entry.detail ?? "").trim();
|
|
137
|
+
if (text)
|
|
138
|
+
writeLine(`[Operator] ${text}`);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const fallback = String(entry.detail ?? entry.message ?? entry.text ?? entry.title ?? "").trim();
|
|
142
|
+
if (fallback)
|
|
143
|
+
writeLine(`[${String(entry.type ?? "timeline")}] ${fallback}`);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
renderLogs(entries) {
|
|
147
|
+
for (const [index, entry] of entries.entries()) {
|
|
148
|
+
const id = entryId(entry, `log:${index}:${String(entry.createdAt ?? "")}:${String(entry.title ?? "")}`);
|
|
149
|
+
if (seenLogs.has(id))
|
|
150
|
+
continue;
|
|
151
|
+
seenLogs.add(id);
|
|
152
|
+
const title = String(entry.title ?? "");
|
|
153
|
+
if (CANONICAL_STAGES.some((stage) => stage.toLowerCase() === title.toLowerCase()))
|
|
154
|
+
continue;
|
|
155
|
+
const detail = logDetail(entry);
|
|
156
|
+
if (!detail)
|
|
157
|
+
continue;
|
|
158
|
+
const protocolRecord = parseProviderProtocolLog(title, detail);
|
|
159
|
+
if (protocolRecord) {
|
|
160
|
+
const protocolLine = renderProviderProtocolLog(protocolRecord);
|
|
161
|
+
if (protocolLine)
|
|
162
|
+
writeLine(protocolLine);
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
writeLine(`[${title || "Rig log"}] ${detail}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function createOperatorSurface(options = {}) {
|
|
171
|
+
const input = options.input ?? process.stdin;
|
|
172
|
+
const output = options.output ?? process.stdout;
|
|
173
|
+
const errorOutput = options.errorOutput ?? process.stderr;
|
|
174
|
+
const renderer = createPiRunStreamRenderer(output);
|
|
175
|
+
const writeLine = (line) => output.write(`${line}
|
|
176
|
+
`);
|
|
177
|
+
return {
|
|
178
|
+
mode: "pi-compatible-text",
|
|
179
|
+
...renderer,
|
|
180
|
+
info: writeLine,
|
|
181
|
+
error: (message) => errorOutput.write(`${message}
|
|
182
|
+
`),
|
|
183
|
+
attachCommandInput(handler) {
|
|
184
|
+
if (options.interactive === false || !input.isTTY)
|
|
185
|
+
return null;
|
|
186
|
+
const rl = createInterface({ input, output: process.stdout, terminal: false });
|
|
187
|
+
rl.on("line", (line) => {
|
|
188
|
+
Promise.resolve(handler(line)).catch((error) => writeLine(`Operator command failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
189
|
+
});
|
|
190
|
+
return { close: () => rl.close() };
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function taskId(task) {
|
|
195
|
+
return typeof task.id === "string" && task.id.trim() ? task.id : "<unknown>";
|
|
196
|
+
}
|
|
197
|
+
function taskTitle(task) {
|
|
198
|
+
return typeof task.title === "string" && task.title.trim() ? task.title : "Untitled task";
|
|
199
|
+
}
|
|
200
|
+
function taskStatus(task) {
|
|
201
|
+
return typeof task.status === "string" && task.status.trim() ? task.status : "unknown";
|
|
202
|
+
}
|
|
203
|
+
function renderTaskPickerRows(tasks) {
|
|
204
|
+
return tasks.map((task, index) => `${index + 1}. ${taskId(task)} \xB7 ${taskStatus(task)} \xB7 ${taskTitle(task)}`);
|
|
205
|
+
}
|
|
206
|
+
async function promptForTaskSelection(question) {
|
|
207
|
+
const rl = createPromptInterface({ input: process.stdin, output: process.stdout });
|
|
208
|
+
try {
|
|
209
|
+
return await rl.question(question);
|
|
210
|
+
} finally {
|
|
211
|
+
rl.close();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
export {
|
|
215
|
+
renderTaskPickerRows,
|
|
216
|
+
renderOperatorSnapshot,
|
|
217
|
+
promptForTaskSelection,
|
|
218
|
+
createPiRunStreamRenderer,
|
|
219
|
+
createOperatorSurface
|
|
220
|
+
};
|