@h-rig/cli 0.0.6-alpha.22 → 0.0.6-alpha.220

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 (49) hide show
  1. package/README.md +6 -28
  2. package/package.json +9 -29
  3. package/dist/bin/build-rig-binaries.js +0 -107
  4. package/dist/bin/rig.js +0 -10655
  5. package/dist/src/commands/_authority-runs.js +0 -111
  6. package/dist/src/commands/_cli-format.js +0 -106
  7. package/dist/src/commands/_connection-state.js +0 -123
  8. package/dist/src/commands/_doctor-checks.js +0 -507
  9. package/dist/src/commands/_operator-surface.js +0 -204
  10. package/dist/src/commands/_operator-view.js +0 -731
  11. package/dist/src/commands/_parsers.js +0 -107
  12. package/dist/src/commands/_paths.js +0 -50
  13. package/dist/src/commands/_pi-install.js +0 -185
  14. package/dist/src/commands/_policy.js +0 -79
  15. package/dist/src/commands/_preflight.js +0 -483
  16. package/dist/src/commands/_probes.js +0 -13
  17. package/dist/src/commands/_run-driver-helpers.js +0 -289
  18. package/dist/src/commands/_server-client.js +0 -435
  19. package/dist/src/commands/_snapshot-upload.js +0 -318
  20. package/dist/src/commands/_task-picker.js +0 -76
  21. package/dist/src/commands/agent.js +0 -499
  22. package/dist/src/commands/browser.js +0 -890
  23. package/dist/src/commands/connect.js +0 -180
  24. package/dist/src/commands/dist.js +0 -402
  25. package/dist/src/commands/doctor.js +0 -517
  26. package/dist/src/commands/github.js +0 -281
  27. package/dist/src/commands/inbox.js +0 -160
  28. package/dist/src/commands/init.js +0 -1563
  29. package/dist/src/commands/inspect.js +0 -174
  30. package/dist/src/commands/inspector.js +0 -256
  31. package/dist/src/commands/plugin.js +0 -167
  32. package/dist/src/commands/profile-and-review.js +0 -178
  33. package/dist/src/commands/queue.js +0 -198
  34. package/dist/src/commands/remote.js +0 -507
  35. package/dist/src/commands/repo-git-harness.js +0 -221
  36. package/dist/src/commands/run.js +0 -1258
  37. package/dist/src/commands/server.js +0 -373
  38. package/dist/src/commands/setup.js +0 -687
  39. package/dist/src/commands/task-report-bug.js +0 -1083
  40. package/dist/src/commands/task-run-driver.js +0 -2554
  41. package/dist/src/commands/task.js +0 -1842
  42. package/dist/src/commands/test.js +0 -39
  43. package/dist/src/commands/workspace.js +0 -123
  44. package/dist/src/commands.js +0 -10334
  45. package/dist/src/index.js +0 -10673
  46. package/dist/src/launcher.js +0 -133
  47. package/dist/src/report-bug.js +0 -260
  48. package/dist/src/runner.js +0 -273
  49. package/dist/src/withMutedConsole.js +0 -42
@@ -1,204 +0,0 @@
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
- }
128
- }
129
- },
130
- renderLogs(entries) {
131
- for (const [index, entry] of entries.entries()) {
132
- const id = entryId(entry, `log:${index}:${String(entry.createdAt ?? "")}:${String(entry.title ?? "")}`);
133
- if (seenLogs.has(id))
134
- continue;
135
- seenLogs.add(id);
136
- const title = String(entry.title ?? "");
137
- if (CANONICAL_STAGES.some((stage) => stage.toLowerCase() === title.toLowerCase()))
138
- continue;
139
- const detail = logDetail(entry);
140
- if (!detail)
141
- continue;
142
- const protocolRecord = parseProviderProtocolLog(title, detail);
143
- if (protocolRecord) {
144
- const protocolLine = renderProviderProtocolLog(protocolRecord);
145
- if (protocolLine)
146
- writeLine(protocolLine);
147
- continue;
148
- }
149
- writeLine(`[${title || "Rig log"}] ${detail}`);
150
- }
151
- }
152
- };
153
- }
154
- function createOperatorSurface(options = {}) {
155
- const input = options.input ?? process.stdin;
156
- const output = options.output ?? process.stdout;
157
- const errorOutput = options.errorOutput ?? process.stderr;
158
- const renderer = createPiRunStreamRenderer(output);
159
- const writeLine = (line) => output.write(`${line}
160
- `);
161
- return {
162
- mode: "pi-compatible-text",
163
- ...renderer,
164
- info: writeLine,
165
- error: (message) => errorOutput.write(`${message}
166
- `),
167
- attachCommandInput(handler) {
168
- if (options.interactive === false || !input.isTTY)
169
- return null;
170
- const rl = createInterface({ input, output: process.stdout, terminal: false });
171
- rl.on("line", (line) => {
172
- Promise.resolve(handler(line)).catch((error) => writeLine(`Operator command failed: ${error instanceof Error ? error.message : String(error)}`));
173
- });
174
- return { close: () => rl.close() };
175
- }
176
- };
177
- }
178
- function taskId(task) {
179
- return typeof task.id === "string" && task.id.trim() ? task.id : "<unknown>";
180
- }
181
- function taskTitle(task) {
182
- return typeof task.title === "string" && task.title.trim() ? task.title : "Untitled task";
183
- }
184
- function taskStatus(task) {
185
- return typeof task.status === "string" && task.status.trim() ? task.status : "unknown";
186
- }
187
- function renderTaskPickerRows(tasks) {
188
- return tasks.map((task, index) => `${index + 1}. ${taskId(task)} \xB7 ${taskStatus(task)} \xB7 ${taskTitle(task)}`);
189
- }
190
- async function promptForTaskSelection(question) {
191
- const rl = createPromptInterface({ input: process.stdin, output: process.stdout });
192
- try {
193
- return await rl.question(question);
194
- } finally {
195
- rl.close();
196
- }
197
- }
198
- export {
199
- renderTaskPickerRows,
200
- renderOperatorSnapshot,
201
- promptForTaskSelection,
202
- createPiRunStreamRenderer,
203
- createOperatorSurface
204
- };