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

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 (118) hide show
  1. package/README.md +18 -19
  2. package/dist/bin/build-rig-binaries.js +22 -10
  3. package/dist/bin/rig.d.ts +71 -1
  4. package/dist/bin/rig.js +15078 -11169
  5. package/dist/config/rig-default-config.yml +5 -0
  6. package/dist/src/app/drone-ui.d.ts +11 -14
  7. package/dist/src/app/drone-ui.js +70 -86
  8. package/dist/src/commands/_async-ui.d.ts +1 -4
  9. package/dist/src/commands/_async-ui.js +9 -111
  10. package/dist/src/commands/_cli-format.d.ts +16 -9
  11. package/dist/src/commands/_cli-format.js +167 -295
  12. package/dist/src/commands/_connection-state.d.ts +11 -1
  13. package/dist/src/commands/_connection-state.js +50 -5
  14. package/dist/src/commands/_doctor-checks.d.ts +0 -6
  15. package/dist/src/commands/_doctor-checks.js +79 -382
  16. package/dist/src/commands/_help-catalog.d.ts +1 -1
  17. package/dist/src/commands/_help-catalog.js +217 -157
  18. package/dist/src/commands/_inprocess-services.d.ts +33 -0
  19. package/dist/src/commands/_inprocess-services.js +102 -0
  20. package/dist/src/commands/_json-output.js +4 -0
  21. package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
  22. package/dist/src/commands/_lazy-reconcile.js +102 -0
  23. package/dist/src/commands/_paths.js +1 -1
  24. package/dist/src/commands/_pi-frontend.d.ts +18 -10
  25. package/dist/src/commands/_pi-frontend.js +37 -715
  26. package/dist/src/commands/_pi-install.js +18 -36
  27. package/dist/src/commands/_policy.d.ts +1 -1
  28. package/dist/src/commands/_policy.js +56 -15
  29. package/dist/src/commands/_run-bridge.d.ts +114 -0
  30. package/dist/src/commands/_run-bridge.js +387 -0
  31. package/dist/src/commands/_run-diagnostics.d.ts +9 -0
  32. package/dist/src/commands/_run-diagnostics.js +51 -0
  33. package/dist/src/commands/_run-driver-helpers.d.ts +8 -81
  34. package/dist/src/commands/_run-driver-helpers.js +79 -283
  35. package/dist/src/commands/_run-projection.d.ts +50 -0
  36. package/dist/src/commands/_run-projection.js +349 -0
  37. package/dist/src/commands/_run-subcommands.d.ts +3 -0
  38. package/dist/src/commands/_run-subcommands.js +31 -0
  39. package/dist/src/commands/_spinner.js +1 -1
  40. package/dist/src/commands/agent.d.ts +1 -1
  41. package/dist/src/commands/agent.js +8559 -239
  42. package/dist/src/commands/dist.d.ts +1 -1
  43. package/dist/src/commands/dist.js +27 -19
  44. package/dist/src/commands/doctor.d.ts +1 -1
  45. package/dist/src/commands/doctor.js +93 -475
  46. package/dist/src/commands/github.d.ts +1 -1
  47. package/dist/src/commands/github.js +113 -387
  48. package/dist/src/commands/inbox.d.ts +22 -24
  49. package/dist/src/commands/inbox.js +420 -691
  50. package/dist/src/commands/init.d.ts +6 -16
  51. package/dist/src/commands/init.js +334 -971
  52. package/dist/src/commands/inspect.d.ts +19 -2
  53. package/dist/src/commands/inspect.js +644 -610
  54. package/dist/src/commands/pi.d.ts +1 -1
  55. package/dist/src/commands/plugin.d.ts +1 -1
  56. package/dist/src/commands/plugin.js +486 -7
  57. package/dist/src/commands/profile-and-review.d.ts +1 -1
  58. package/dist/src/commands/profile-and-review.js +94 -56
  59. package/dist/src/commands/queue.js +1 -21
  60. package/dist/src/commands/remote.d.ts +1 -1
  61. package/dist/src/commands/remote.js +837 -14
  62. package/dist/src/commands/repo-git-harness.d.ts +1 -1
  63. package/dist/src/commands/repo-git-harness.js +57 -14
  64. package/dist/src/commands/run.d.ts +20 -2
  65. package/dist/src/commands/run.js +17579 -1759
  66. package/dist/src/commands/server.d.ts +2 -6
  67. package/dist/src/commands/server.js +141 -723
  68. package/dist/src/commands/setup.d.ts +1 -1
  69. package/dist/src/commands/setup.js +102 -484
  70. package/dist/src/commands/stats.d.ts +13 -10
  71. package/dist/src/commands/stats.js +689 -761
  72. package/dist/src/commands/task-run-driver.d.ts +50 -88
  73. package/dist/src/commands/task-run-driver.js +116 -2717
  74. package/dist/src/commands/task.d.ts +34 -13
  75. package/dist/src/commands/task.js +668 -2523
  76. package/dist/src/commands/test.d.ts +1 -1
  77. package/dist/src/commands/triage.d.ts +11 -0
  78. package/dist/src/commands/triage.js +227 -0
  79. package/dist/src/commands/workspace.d.ts +1 -1
  80. package/dist/src/commands.d.ts +0 -16
  81. package/dist/src/commands.js +16657 -12250
  82. package/dist/src/index.js +16528 -12497
  83. package/dist/src/launcher.js +4 -0
  84. package/dist/src/operator-cli.d.ts +2 -0
  85. package/dist/src/operator-cli.js +17837 -0
  86. package/dist/src/operator-entry.d.ts +1 -0
  87. package/dist/src/operator-entry.js +3 -0
  88. package/package.json +18 -12
  89. package/dist/src/app/board.d.ts +0 -23
  90. package/dist/src/app/board.js +0 -1786
  91. package/dist/src/app/theme.d.ts +0 -47
  92. package/dist/src/app/theme.js +0 -150
  93. package/dist/src/commands/_authority-runs.d.ts +0 -22
  94. package/dist/src/commands/_authority-runs.js +0 -110
  95. package/dist/src/commands/_operator-surface.d.ts +0 -34
  96. package/dist/src/commands/_operator-surface.js +0 -220
  97. package/dist/src/commands/_operator-view.d.ts +0 -30
  98. package/dist/src/commands/_operator-view.js +0 -1070
  99. package/dist/src/commands/_preflight.d.ts +0 -22
  100. package/dist/src/commands/_preflight.js +0 -540
  101. package/dist/src/commands/_run-replay.d.ts +0 -24
  102. package/dist/src/commands/_run-replay.js +0 -142
  103. package/dist/src/commands/_server-client.d.ts +0 -186
  104. package/dist/src/commands/_server-client.js +0 -681
  105. package/dist/src/commands/_snapshot-upload.d.ts +0 -39
  106. package/dist/src/commands/_snapshot-upload.js +0 -455
  107. package/dist/src/commands/_task-picker.d.ts +0 -9
  108. package/dist/src/commands/_task-picker.js +0 -201
  109. package/dist/src/commands/browser.d.ts +0 -65
  110. package/dist/src/commands/browser.js +0 -1173
  111. package/dist/src/commands/connect.d.ts +0 -7
  112. package/dist/src/commands/connect.js +0 -419
  113. package/dist/src/commands/inspector.d.ts +0 -3
  114. package/dist/src/commands/inspector.js +0 -263
  115. package/dist/src/commands/task-report-bug.d.ts +0 -19
  116. package/dist/src/commands/task-report-bug.js +0 -1281
  117. package/dist/src/report-bug.d.ts +0 -44
  118. package/dist/src/report-bug.js +0 -260
@@ -1,142 +0,0 @@
1
- // @bun
2
- // packages/cli/src/commands/_run-replay.ts
3
- import { existsSync, readdirSync } from "fs";
4
- import { join, resolve } from "path";
5
- import {
6
- readAuthorityRun,
7
- readJsonlFile,
8
- runJournalPath
9
- } from "@rig/runtime/control-plane/authority-files";
10
- function asRecord(value) {
11
- return value && typeof value === "object" && !Array.isArray(value) ? value : null;
12
- }
13
- function text(value) {
14
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
15
- }
16
- function snippet(value, max = 120) {
17
- const raw = text(value);
18
- if (!raw)
19
- return null;
20
- const flat = raw.replace(/\s+/g, " ");
21
- return flat.length > max ? `${flat.slice(0, max - 1)}\u2026` : flat;
22
- }
23
- function summarizeLifecycleEntry(entry) {
24
- const type = text(entry.type) ?? "event";
25
- switch (type) {
26
- case "status": {
27
- const anchor = text(entry.sessionId);
28
- return [
29
- `status \u2192 ${text(entry.status) ?? "(unknown)"}`,
30
- snippet(entry.detail) ? `\u2014 ${snippet(entry.detail)}` : null,
31
- anchor ? `[session ${anchor}]` : null
32
- ].filter(Boolean).join(" ");
33
- }
34
- case "timeline-entry": {
35
- const payload = asRecord(entry.payload) ?? {};
36
- const kind = text(payload.type) ?? "entry";
37
- const body = snippet(payload.title) ?? snippet(payload.text) ?? snippet(payload.detail);
38
- const state = text(payload.state);
39
- return [`timeline ${kind}`, body ? `\u2014 ${body}` : null, state ? `(${state})` : null].filter(Boolean).join(" ");
40
- }
41
- case "log-entry": {
42
- const payload = asRecord(entry.payload) ?? {};
43
- const title = snippet(payload.title) ?? "log";
44
- const detail = snippet(payload.detail);
45
- return [`log ${title}`, detail ? `\u2014 ${detail}` : null].filter(Boolean).join(" ");
46
- }
47
- case "record-patch": {
48
- const patch = asRecord(entry.patch) ?? {};
49
- const keys = Object.keys(patch);
50
- const shown = keys.slice(0, 8).join(", ");
51
- return `record-patch {${shown}${keys.length > 8 ? `, +${keys.length - 8} more` : ""}}`;
52
- }
53
- case "timeline":
54
- return "timeline updated (signal)";
55
- case "log":
56
- return `log signal${snippet(entry.title) ? ` \u2014 ${snippet(entry.title)}` : ""}`;
57
- case "completed":
58
- return "run completed";
59
- case "failed":
60
- return `run failed${snippet(entry.error) ? ` \u2014 ${snippet(entry.error)}` : ""}`;
61
- default:
62
- return type;
63
- }
64
- }
65
- function summarizeSessionEntry(entry) {
66
- const type = text(entry.type) ?? "entry";
67
- const message = asRecord(entry.message);
68
- const role = text(message?.role);
69
- const content = message?.content;
70
- let body = null;
71
- if (typeof content === "string") {
72
- body = snippet(content);
73
- } else if (Array.isArray(content)) {
74
- body = snippet(content.map((part) => text(asRecord(part)?.text) ?? "").filter(Boolean).join(" "));
75
- }
76
- return [
77
- `pi ${type}`,
78
- role ? `(${role})` : null,
79
- body ? `\u2014 ${body}` : null
80
- ].filter(Boolean).join(" ");
81
- }
82
- function sessionEntryTimestamp(entry) {
83
- return text(entry.timestamp) ?? text(entry.at) ?? text(entry.createdAt) ?? null;
84
- }
85
- function resolveRunSessionFile(record) {
86
- const piSession = record?.piSession ?? null;
87
- if (!piSession)
88
- return null;
89
- const recorded = text(piSession.sessionFile);
90
- if (recorded && existsSync(recorded)) {
91
- return recorded;
92
- }
93
- const cwd = text(piSession.cwd);
94
- const sessionId = text(piSession.sessionId);
95
- if (!cwd || !sessionId)
96
- return null;
97
- const sessionDir = resolve(cwd, ".rig", "session");
98
- try {
99
- const match = readdirSync(sessionDir).find((name) => name.endsWith(`_${sessionId}.jsonl`));
100
- return match ? join(sessionDir, match) : null;
101
- } catch {
102
- return null;
103
- }
104
- }
105
- function buildRunReplay(projectRoot, runId, options = {}) {
106
- const logPath = runJournalPath(projectRoot, runId);
107
- const record = readAuthorityRun(projectRoot, runId);
108
- const lifecycleEntries = readJsonlFile(logPath).map((entry) => asRecord(entry)).filter((entry) => entry !== null);
109
- const merged = lifecycleEntries.map((entry) => ({
110
- at: text(entry.at),
111
- source: "run",
112
- summary: summarizeLifecycleEntry(entry)
113
- }));
114
- let sessionFile = null;
115
- let sessionEntryCount = 0;
116
- if (options.withSession) {
117
- sessionFile = resolveRunSessionFile(record);
118
- if (sessionFile) {
119
- let lastSeenAt = null;
120
- const sessionLines = readJsonlFile(sessionFile).map((entry) => asRecord(entry)).filter((entry) => entry !== null).map((entry) => {
121
- lastSeenAt = sessionEntryTimestamp(entry) ?? lastSeenAt;
122
- return { at: lastSeenAt, source: "session", summary: summarizeSessionEntry(entry) };
123
- });
124
- sessionEntryCount = sessionLines.length;
125
- merged.push(...sessionLines);
126
- merged.sort((left, right) => (left.at ?? "").localeCompare(right.at ?? ""));
127
- }
128
- }
129
- const lines = merged.map((line) => `${line.at ?? "(no timestamp) "} ${line.source === "run" ? "run " : "session"} ${line.summary}`);
130
- return {
131
- runId,
132
- logPath,
133
- sessionFile,
134
- entryCount: lifecycleEntries.length,
135
- sessionEntryCount,
136
- lines
137
- };
138
- }
139
- export {
140
- resolveRunSessionFile,
141
- buildRunReplay
142
- };
@@ -1,186 +0,0 @@
1
- type ServerPhaseListener = (label: string) => void;
2
- /** Returns the previously registered listener so scopes can restore it. */
3
- export declare function setServerPhaseListener(listener: ServerPhaseListener | null): ServerPhaseListener | null;
4
- export declare function setGitHubBearerTokenForCurrentProcess(token: string | null, projectRoot?: string): void;
5
- export declare function ensureServerForCli(projectRoot: string): Promise<{
6
- baseUrl: string;
7
- authToken: string | null;
8
- connectionKind: "local" | "remote";
9
- serverProjectRoot: string | null;
10
- }>;
11
- export interface WorkspaceTaskFilters {
12
- readonly assignee?: string;
13
- readonly state?: string;
14
- readonly status?: string;
15
- readonly limit?: number;
16
- }
17
- export type WorkspaceTaskRecord = Record<string, unknown> & {
18
- readonly id?: unknown;
19
- readonly title?: unknown;
20
- readonly status?: unknown;
21
- };
22
- export type SubmitTaskRunInput = {
23
- runId: string;
24
- taskId?: string;
25
- title?: string;
26
- runtimeAdapter: "claude-code" | "codex" | "pi";
27
- model?: string;
28
- runtimeMode: string;
29
- interactionMode: string;
30
- initialPrompt?: string;
31
- baselineMode?: "head" | "dirty-snapshot";
32
- prMode?: "auto" | "ask" | "off";
33
- };
34
- export declare function requestServerJson(context: {
35
- projectRoot: string;
36
- }, pathname: string, init?: RequestInit): Promise<unknown>;
37
- export declare function listWorkspaceTasksViaServer(context: {
38
- projectRoot: string;
39
- }, filters?: WorkspaceTaskFilters): Promise<WorkspaceTaskRecord[]>;
40
- export declare function getWorkspaceTaskViaServer(context: {
41
- projectRoot: string;
42
- }, taskId: string): Promise<WorkspaceTaskRecord | null>;
43
- export declare function selectNextWorkspaceTaskViaServer(context: {
44
- projectRoot: string;
45
- }, filters?: WorkspaceTaskFilters): Promise<{
46
- task: WorkspaceTaskRecord | null;
47
- count: number;
48
- }>;
49
- /**
50
- * Submit a run (task or ad-hoc) to the local rig server. Routes to
51
- * /api/runs/task vs /api/runs/adhoc based on whether a taskId is provided.
52
- *
53
- * Caller is responsible for any pre-flight (e.g. project sync). This helper
54
- * only performs the POST and surfaces server errors as CliError.
55
- */
56
- export declare function getGitHubAuthStatusViaServer(context: {
57
- projectRoot: string;
58
- }): Promise<Record<string, unknown>>;
59
- export declare function postGitHubTokenViaServer(context: {
60
- projectRoot: string;
61
- }, token: string, options?: {
62
- readonly selectedRepo?: string;
63
- readonly projectRoot?: string;
64
- }): Promise<Record<string, unknown>>;
65
- export declare function prepareRemoteCheckoutViaServer(context: {
66
- projectRoot: string;
67
- }, input: {
68
- repoSlug: string;
69
- checkout: Record<string, unknown>;
70
- repoUrl?: string;
71
- baseDir?: string;
72
- }): Promise<Record<string, unknown>>;
73
- export declare function registerProjectViaServer(context: {
74
- projectRoot: string;
75
- }, input: {
76
- repoSlug: string;
77
- checkout?: Record<string, unknown>;
78
- }): Promise<Record<string, unknown>>;
79
- export declare function switchServerProjectRootViaServer(context: {
80
- projectRoot: string;
81
- }, projectRoot: string, options?: {
82
- timeoutMs?: number;
83
- pollMs?: number;
84
- }): Promise<Record<string, unknown>>;
85
- export declare function listRunsViaServer(context: {
86
- projectRoot: string;
87
- }, options?: {
88
- limit?: number;
89
- }): Promise<Record<string, unknown>[]>;
90
- export declare function getRunDetailsViaServer(context: {
91
- projectRoot: string;
92
- }, runId: string): Promise<Record<string, unknown>>;
93
- export declare function getRunLogsViaServer(context: {
94
- projectRoot: string;
95
- }, runId: string, options?: {
96
- limit?: number;
97
- cursor?: string;
98
- }): Promise<Record<string, unknown>>;
99
- export declare function getRunTimelineViaServer(context: {
100
- projectRoot: string;
101
- }, runId: string, options?: {
102
- limit?: number;
103
- cursor?: string;
104
- }): Promise<Record<string, unknown>>;
105
- export declare function ensureTaskLabelsViaServer(context: {
106
- projectRoot: string;
107
- }): Promise<Record<string, unknown>>;
108
- export declare function listGitHubProjectsViaServer(context: {
109
- projectRoot: string;
110
- }, owner: string): Promise<Record<string, unknown>>;
111
- export declare function getGitHubProjectStatusFieldViaServer(context: {
112
- projectRoot: string;
113
- }, projectId: string): Promise<Record<string, unknown>>;
114
- export declare function updateWorkspaceTaskViaServer(context: {
115
- projectRoot: string;
116
- }, input: {
117
- id: string;
118
- status?: string;
119
- comment?: string;
120
- title?: string;
121
- body?: string;
122
- issueNodeId?: string | null;
123
- }): Promise<Record<string, unknown>>;
124
- /**
125
- * Resume (or restart) a run through the selected server — works against the
126
- * auto-started local daemon AND a remote connection, unlike the old
127
- * runtime-side path that could only spawn a local engine-checkout server.
128
- * Without an explicit run id, targets the most recently updated resumable
129
- * run known to the server.
130
- */
131
- export declare function resumeRunViaServer(context: {
132
- projectRoot: string;
133
- }, runId: string | null, options: {
134
- restart: boolean;
135
- }): Promise<Record<string, unknown>>;
136
- /** Short human label for the selected server — board/header decoration. */
137
- export declare function resolveServerConnectionLabel(projectRoot: string): Promise<string>;
138
- export declare function stopRunViaServer(context: {
139
- projectRoot: string;
140
- }, runId: string): Promise<Record<string, unknown>>;
141
- export declare function steerRunViaServer(context: {
142
- projectRoot: string;
143
- }, runId: string, message: string): Promise<Record<string, unknown>>;
144
- export declare function getRunPiSessionViaServer(context: {
145
- projectRoot: string;
146
- }, runId: string): Promise<Record<string, unknown>>;
147
- export declare function getRunPiMessagesViaServer(context: {
148
- projectRoot: string;
149
- }, runId: string): Promise<Record<string, unknown>>;
150
- export declare function getRunPiStatusViaServer(context: {
151
- projectRoot: string;
152
- }, runId: string): Promise<Record<string, unknown>>;
153
- export declare function getRunPiCommandsViaServer(context: {
154
- projectRoot: string;
155
- }, runId: string): Promise<Record<string, unknown>>;
156
- export declare function getRunPiCapabilitiesViaServer(context: {
157
- projectRoot: string;
158
- }, runId: string): Promise<Record<string, unknown>>;
159
- export declare function sendRunPiPromptViaServer(context: {
160
- projectRoot: string;
161
- }, runId: string, text: string, streamingBehavior?: "steer" | "followUp"): Promise<Record<string, unknown>>;
162
- export declare function sendRunPiShellViaServer(context: {
163
- projectRoot: string;
164
- }, runId: string, text: string): Promise<Record<string, unknown>>;
165
- export declare function runRunPiCommandViaServer(context: {
166
- projectRoot: string;
167
- }, runId: string, text: string): Promise<Record<string, unknown>>;
168
- export declare function respondRunPiExtensionUiViaServer(context: {
169
- projectRoot: string;
170
- }, runId: string, requestId: string, valueOrCancel: {
171
- value?: unknown;
172
- confirmed?: boolean;
173
- cancelled?: boolean;
174
- }): Promise<Record<string, unknown>>;
175
- export declare function abortRunPiViaServer(context: {
176
- projectRoot: string;
177
- }, runId: string): Promise<Record<string, unknown>>;
178
- export declare function buildRunPiEventsWebSocketUrl(context: {
179
- projectRoot: string;
180
- }, runId: string): Promise<string>;
181
- export declare function submitTaskRunViaServer(context: {
182
- projectRoot: string;
183
- }, input: SubmitTaskRunInput): Promise<{
184
- runId: string;
185
- }>;
186
- export {};