@h-rig/cli 0.0.6-alpha.9 → 0.0.6-alpha.91
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 +18 -19
- package/dist/bin/build-rig-binaries.d.ts +2 -0
- package/dist/bin/build-rig-binaries.js +22 -10
- package/dist/bin/rig.d.ts +72 -0
- package/dist/bin/rig.js +15637 -7344
- package/dist/config/rig-default-config.yml +5 -0
- package/dist/src/app/drone-ui.d.ts +34 -0
- package/dist/src/app/drone-ui.js +278 -0
- package/dist/src/commands/_async-ui.d.ts +10 -0
- package/dist/src/commands/_async-ui.js +121 -0
- package/dist/src/commands/_cli-format.d.ts +56 -0
- package/dist/src/commands/_cli-format.js +319 -0
- package/dist/src/commands/_connection-state.d.ts +54 -0
- package/dist/src/commands/_connection-state.js +75 -11
- package/dist/src/commands/_doctor-checks.d.ts +46 -0
- package/dist/src/commands/_doctor-checks.js +100 -267
- package/dist/src/commands/_help-catalog.d.ts +51 -0
- package/dist/src/commands/_help-catalog.js +502 -0
- package/dist/src/commands/_inprocess-services.d.ts +33 -0
- package/dist/src/commands/_inprocess-services.js +102 -0
- package/dist/src/commands/_json-output.d.ts +11 -0
- package/dist/src/commands/_json-output.js +60 -0
- package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
- package/dist/src/commands/_lazy-reconcile.js +102 -0
- package/dist/src/commands/_parsers.d.ts +15 -0
- package/dist/src/commands/_parsers.js +18 -11
- package/dist/src/commands/_paths.d.ts +11 -0
- package/dist/src/commands/_paths.js +1 -1
- package/dist/src/commands/_pi-frontend.d.ts +35 -0
- package/dist/src/commands/_pi-frontend.js +64 -0
- package/dist/src/commands/_pi-install.d.ts +42 -0
- package/dist/src/commands/_pi-install.js +19 -36
- package/dist/src/commands/_policy.d.ts +8 -0
- package/dist/src/commands/_policy.js +67 -19
- package/dist/src/commands/_probes.d.ts +1 -0
- package/dist/src/commands/_run-bridge.d.ts +114 -0
- package/dist/src/commands/_run-bridge.js +387 -0
- package/dist/src/commands/_run-diagnostics.d.ts +9 -0
- package/dist/src/commands/_run-diagnostics.js +51 -0
- package/dist/src/commands/_run-driver-helpers.d.ts +26 -0
- package/dist/src/commands/_run-driver-helpers.js +79 -230
- package/dist/src/commands/_run-projection.d.ts +50 -0
- package/dist/src/commands/_run-projection.js +349 -0
- package/dist/src/commands/_run-subcommands.d.ts +3 -0
- package/dist/src/commands/_run-subcommands.js +31 -0
- package/dist/src/commands/_spinner.d.ts +25 -0
- package/dist/src/commands/_spinner.js +65 -0
- package/dist/src/commands/agent.d.ts +3 -0
- package/dist/src/commands/agent.js +8575 -236
- package/dist/src/commands/dist.d.ts +28 -0
- package/dist/src/commands/dist.js +44 -29
- package/dist/src/commands/doctor.d.ts +3 -0
- package/dist/src/commands/doctor.js +219 -268
- package/dist/src/commands/github.d.ts +3 -0
- package/dist/src/commands/github.js +236 -188
- package/dist/src/commands/inbox.d.ts +28 -0
- package/dist/src/commands/inbox.js +530 -111
- package/dist/src/commands/init.d.ts +64 -0
- package/dist/src/commands/init.js +912 -705
- package/dist/src/commands/inspect.d.ts +20 -0
- package/dist/src/commands/inspect.js +709 -119
- package/dist/src/commands/pi.d.ts +3 -0
- package/dist/src/commands/pi.js +177 -0
- package/dist/src/commands/plugin.d.ts +16 -0
- package/dist/src/commands/plugin.js +576 -29
- package/dist/src/commands/profile-and-review.d.ts +4 -0
- package/dist/src/commands/profile-and-review.js +112 -67
- package/dist/src/commands/queue.d.ts +3 -0
- package/dist/src/commands/queue.js +20 -20
- package/dist/src/commands/remote.d.ts +3 -0
- package/dist/src/commands/remote.js +880 -50
- package/dist/src/commands/repo-git-harness.d.ts +5 -0
- package/dist/src/commands/repo-git-harness.js +78 -28
- package/dist/src/commands/run.d.ts +21 -0
- package/dist/src/commands/run.js +17701 -661
- package/dist/src/commands/server.d.ts +3 -0
- package/dist/src/commands/server.js +166 -303
- package/dist/src/commands/setup.d.ts +16 -0
- package/dist/src/commands/setup.js +244 -299
- package/dist/src/commands/stats.d.ts +15 -0
- package/dist/src/commands/stats.js +979 -0
- package/dist/src/commands/task-run-driver.d.ts +94 -0
- package/dist/src/commands/task-run-driver.js +116 -1961
- package/dist/src/commands/task.d.ts +35 -0
- package/dist/src/commands/task.js +676 -1201
- package/dist/src/commands/test.d.ts +3 -0
- package/dist/src/commands/test.js +15 -8
- package/dist/src/commands/triage.d.ts +11 -0
- package/dist/src/commands/triage.js +227 -0
- package/dist/src/commands/workspace.d.ts +3 -0
- package/dist/src/commands/workspace.js +18 -11
- package/dist/src/commands.d.ts +13 -0
- package/dist/src/commands.js +16792 -8055
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +16862 -8450
- package/dist/src/launcher.d.ts +61 -0
- package/dist/src/launcher.js +81 -13
- package/dist/src/operator-cli.d.ts +2 -0
- package/dist/src/operator-cli.js +17837 -0
- package/dist/src/operator-entry.d.ts +1 -0
- package/dist/src/operator-entry.js +3 -0
- package/dist/src/runner.d.ts +47 -0
- package/dist/src/runner.js +16 -22
- package/dist/src/withMutedConsole.d.ts +2 -0
- package/package.json +21 -8
- package/dist/src/commands/_authority-runs.js +0 -111
- package/dist/src/commands/_operator-view.js +0 -340
- package/dist/src/commands/_preflight.js +0 -478
- package/dist/src/commands/_server-client.js +0 -382
- package/dist/src/commands/_snapshot-upload.js +0 -331
- package/dist/src/commands/_task-picker.js +0 -48
- package/dist/src/commands/browser.js +0 -890
- package/dist/src/commands/connect.js +0 -180
- package/dist/src/commands/inspector.js +0 -256
- package/dist/src/commands/task-report-bug.js +0 -1083
- package/dist/src/report-bug.js +0 -260
|
@@ -2,34 +2,31 @@
|
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
4
|
// packages/cli/src/commands/_doctor-checks.ts
|
|
5
|
-
import { existsSync as
|
|
6
|
-
import { resolve as
|
|
5
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
6
|
+
import { resolve as resolve3 } from "path";
|
|
7
7
|
|
|
8
8
|
// packages/cli/src/runner.ts
|
|
9
9
|
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
10
|
-
import { CliError } from "@rig/runtime/control-plane/errors";
|
|
10
|
+
import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
|
|
11
11
|
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
12
|
-
import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
|
|
13
|
-
import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
|
|
14
12
|
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
class CliError extends RuntimeCliError {
|
|
15
|
+
hint;
|
|
16
|
+
constructor(message, exitCode = 1, options = {}) {
|
|
17
|
+
super(message, exitCode);
|
|
18
|
+
if (options.hint?.trim()) {
|
|
19
|
+
this.hint = options.hint.trim();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
16
23
|
|
|
17
24
|
// packages/cli/src/commands/_doctor-checks.ts
|
|
18
25
|
import { isSupportedBunVersion, MIN_SUPPORTED_BUN_VERSION } from "@rig/runtime/control-plane/setup-version";
|
|
19
26
|
|
|
20
27
|
// packages/cli/src/commands/_connection-state.ts
|
|
21
28
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
22
|
-
import { homedir } from "os";
|
|
23
29
|
import { dirname, resolve } from "path";
|
|
24
|
-
function resolveGlobalConnectionsPath(env = process.env) {
|
|
25
|
-
const explicit = env.RIG_CONNECTIONS_FILE?.trim();
|
|
26
|
-
if (explicit)
|
|
27
|
-
return resolve(explicit);
|
|
28
|
-
const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
|
|
29
|
-
if (stateDir)
|
|
30
|
-
return resolve(stateDir, "connections.json");
|
|
31
|
-
return resolve(homedir(), ".rig", "connections.json");
|
|
32
|
-
}
|
|
33
30
|
function resolveRepoConnectionPath(projectRoot) {
|
|
34
31
|
return resolve(projectRoot, ".rig", "state", "connection.json");
|
|
35
32
|
}
|
|
@@ -39,37 +36,8 @@ function readJsonFile(path) {
|
|
|
39
36
|
try {
|
|
40
37
|
return JSON.parse(readFileSync(path, "utf8"));
|
|
41
38
|
} catch (error) {
|
|
42
|
-
throw new
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function normalizeConnection(value) {
|
|
46
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
47
|
-
return null;
|
|
48
|
-
const record = value;
|
|
49
|
-
if (record.kind === "local")
|
|
50
|
-
return { kind: "local", mode: "auto" };
|
|
51
|
-
if (record.kind === "remote" && typeof record.baseUrl === "string" && record.baseUrl.trim()) {
|
|
52
|
-
const baseUrl = record.baseUrl.trim().replace(/\/+$/, "");
|
|
53
|
-
return { kind: "remote", baseUrl };
|
|
39
|
+
throw new CliError(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1, { hint: "Fix or delete that file, then re-select a server with `rig server use <alias|local>`." });
|
|
54
40
|
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
function readGlobalConnections(options = {}) {
|
|
58
|
-
const path = resolveGlobalConnectionsPath(options.env ?? process.env);
|
|
59
|
-
const payload = readJsonFile(path);
|
|
60
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
61
|
-
return { connections: {} };
|
|
62
|
-
}
|
|
63
|
-
const rawConnections = payload.connections;
|
|
64
|
-
const connections = {};
|
|
65
|
-
if (rawConnections && typeof rawConnections === "object" && !Array.isArray(rawConnections)) {
|
|
66
|
-
for (const [alias, raw] of Object.entries(rawConnections)) {
|
|
67
|
-
const connection = normalizeConnection(raw);
|
|
68
|
-
if (connection)
|
|
69
|
-
connections[alias] = connection;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return { connections };
|
|
73
41
|
}
|
|
74
42
|
function readRepoConnection(projectRoot) {
|
|
75
43
|
const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
|
|
@@ -82,130 +50,68 @@ function readRepoConnection(projectRoot) {
|
|
|
82
50
|
return {
|
|
83
51
|
selected,
|
|
84
52
|
project: typeof record.project === "string" ? record.project : undefined,
|
|
85
|
-
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined
|
|
53
|
+
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined,
|
|
54
|
+
serverProjectRoot: typeof record.serverProjectRoot === "string" && record.serverProjectRoot.trim() ? record.serverProjectRoot.trim() : undefined,
|
|
55
|
+
serverProjectRootAlias: typeof record.serverProjectRootAlias === "string" && record.serverProjectRootAlias.trim() ? record.serverProjectRootAlias.trim() : undefined,
|
|
56
|
+
serverProjectRootBaseUrl: typeof record.serverProjectRootBaseUrl === "string" && record.serverProjectRootBaseUrl.trim() ? record.serverProjectRootBaseUrl.trim().replace(/\/+$/, "") : undefined
|
|
86
57
|
};
|
|
87
58
|
}
|
|
88
|
-
function resolveSelectedConnection(projectRoot, options = {}) {
|
|
89
|
-
const repo = readRepoConnection(projectRoot);
|
|
90
|
-
if (!repo)
|
|
91
|
-
return null;
|
|
92
|
-
if (repo.selected === "local")
|
|
93
|
-
return { alias: "local", connection: { kind: "local", mode: "auto" } };
|
|
94
|
-
const global = readGlobalConnections(options);
|
|
95
|
-
const connection = global.connections[repo.selected];
|
|
96
|
-
if (!connection) {
|
|
97
|
-
throw new CliError2(`Selected Rig connection "${repo.selected}" was not found. Run \`rig connect list\` or \`rig connect use local\`.`, 1);
|
|
98
|
-
}
|
|
99
|
-
return { alias: repo.selected, connection };
|
|
100
|
-
}
|
|
101
59
|
|
|
102
|
-
// packages/cli/src/commands/
|
|
103
|
-
import {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
60
|
+
// packages/cli/src/commands/_inprocess-services.ts
|
|
61
|
+
import {
|
|
62
|
+
beginGitHubDeviceFlow,
|
|
63
|
+
checkGitHubRepoPermissions,
|
|
64
|
+
createGitHubAuthStore,
|
|
65
|
+
listGitHubProjects,
|
|
66
|
+
pollGitHubDeviceFlow,
|
|
67
|
+
resolveGitHubAuthStatus,
|
|
68
|
+
resolveProjectStatusField,
|
|
69
|
+
saveGitHubTokenForProject
|
|
70
|
+
} from "@rig/runtime/control-plane/github/index";
|
|
71
|
+
var scopedGitHubBearerTokens = new Map;
|
|
108
72
|
function cleanToken(value) {
|
|
109
73
|
const trimmed = value?.trim();
|
|
110
74
|
return trimmed ? trimmed : null;
|
|
111
75
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
if (!existsSync2(path))
|
|
115
|
-
return null;
|
|
116
|
-
try {
|
|
117
|
-
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
118
|
-
return cleanToken(typeof parsed.apiSessionToken === "string" ? parsed.apiSessionToken : typeof parsed.sessionToken === "string" ? parsed.sessionToken : undefined);
|
|
119
|
-
} catch {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
76
|
+
function cleanString(value) {
|
|
77
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
122
78
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
return cachedGitHubBearerToken;
|
|
126
|
-
const privateSession = readPrivateRemoteSessionToken(projectRoot);
|
|
127
|
-
if (privateSession) {
|
|
128
|
-
cachedGitHubBearerToken = privateSession;
|
|
129
|
-
return cachedGitHubBearerToken;
|
|
130
|
-
}
|
|
131
|
-
const envToken = cleanToken(process.env.RIG_GITHUB_TOKEN) ?? cleanToken(process.env.GITHUB_TOKEN) ?? cleanToken(process.env.GH_TOKEN);
|
|
132
|
-
if (envToken) {
|
|
133
|
-
cachedGitHubBearerToken = envToken;
|
|
134
|
-
return cachedGitHubBearerToken;
|
|
135
|
-
}
|
|
136
|
-
const result = spawnSync("gh", ["auth", "token"], {
|
|
137
|
-
encoding: "utf8",
|
|
138
|
-
timeout: 5000,
|
|
139
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
140
|
-
});
|
|
141
|
-
cachedGitHubBearerToken = result.status === 0 ? cleanToken(result.stdout) : null;
|
|
142
|
-
return cachedGitHubBearerToken;
|
|
79
|
+
function oauthClientId() {
|
|
80
|
+
return cleanToken(process.env.RIG_GITHUB_OAUTH_CLIENT_ID);
|
|
143
81
|
}
|
|
144
|
-
async function
|
|
145
|
-
|
|
146
|
-
const selected = resolveSelectedConnection(projectRoot);
|
|
147
|
-
if (selected?.connection.kind === "remote") {
|
|
148
|
-
return {
|
|
149
|
-
baseUrl: selected.connection.baseUrl,
|
|
150
|
-
authToken: readGitHubBearerTokenForRemote(projectRoot),
|
|
151
|
-
connectionKind: "remote"
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
const connection = await ensureLocalRigServerConnection(projectRoot);
|
|
155
|
-
return {
|
|
156
|
-
baseUrl: connection.baseUrl,
|
|
157
|
-
authToken: connection.authToken,
|
|
158
|
-
connectionKind: "local"
|
|
159
|
-
};
|
|
160
|
-
} catch (error) {
|
|
161
|
-
if (error instanceof Error) {
|
|
162
|
-
throw new CliError2(error.message, 1);
|
|
163
|
-
}
|
|
164
|
-
throw error;
|
|
165
|
-
}
|
|
82
|
+
async function getGitHubAuthStatusInProcess(context) {
|
|
83
|
+
return { ok: true, ...resolveGitHubAuthStatus({ projectRoot: context.projectRoot, oauthConfigured: Boolean(oauthClientId()) }) };
|
|
166
84
|
}
|
|
167
|
-
function
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
|
|
85
|
+
async function requestGitHubAuthJsonInProcess(context, pathname, init = {}) {
|
|
86
|
+
const method = (init.method ?? "GET").toUpperCase();
|
|
87
|
+
if (pathname === "/api/github/auth/status")
|
|
88
|
+
return getGitHubAuthStatusInProcess(context);
|
|
89
|
+
if (pathname === "/api/github/repo/permissions") {
|
|
90
|
+
return checkGitHubRepoPermissions({ projectRoot: context.projectRoot, oauthConfigured: Boolean(oauthClientId()) });
|
|
171
91
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
headers: mergeHeaders(init.headers, server.authToken)
|
|
194
|
-
});
|
|
195
|
-
const text = await response.text();
|
|
196
|
-
const payload = text.trim().length > 0 ? (() => {
|
|
197
|
-
try {
|
|
198
|
-
return JSON.parse(text);
|
|
199
|
-
} catch {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
})() : null;
|
|
203
|
-
if (!response.ok) {
|
|
204
|
-
const diagnostics = diagnosticMessage(payload);
|
|
205
|
-
const detail = diagnostics ?? (text || response.statusText);
|
|
206
|
-
throw new CliError2(`Rig server request failed (${response.status}): ${detail}`, 1);
|
|
92
|
+
if (pathname === "/api/github/auth/device/start" && method === "POST") {
|
|
93
|
+
const clientId = oauthClientId();
|
|
94
|
+
if (!clientId)
|
|
95
|
+
return { ok: false, oauthConfigured: false, error: "RIG_GITHUB_OAUTH_CLIENT_ID is not configured." };
|
|
96
|
+
const body = init.body ? JSON.parse(String(init.body)) : {};
|
|
97
|
+
return beginGitHubDeviceFlow({
|
|
98
|
+
projectRoot: context.projectRoot,
|
|
99
|
+
clientId,
|
|
100
|
+
scope: cleanString(body.scope) ?? undefined,
|
|
101
|
+
selectedRepo: cleanString(body.repoSlug)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (pathname === "/api/github/auth/device/poll" && method === "POST") {
|
|
105
|
+
const clientId = oauthClientId();
|
|
106
|
+
if (!clientId)
|
|
107
|
+
return { ok: false, oauthConfigured: false, error: "RIG_GITHUB_OAUTH_CLIENT_ID is not configured." };
|
|
108
|
+
const body = init.body ? JSON.parse(String(init.body)) : {};
|
|
109
|
+
const pollId = cleanString(body.pollId);
|
|
110
|
+
if (!pollId)
|
|
111
|
+
return { ok: false, status: "error", error: "pollId is required" };
|
|
112
|
+
return pollGitHubDeviceFlow({ projectRoot: context.projectRoot, clientId, pollId, selectedRepo: cleanString(body.repoSlug) });
|
|
207
113
|
}
|
|
208
|
-
|
|
114
|
+
throw new Error(`No in-process GitHub auth API for ${method} ${pathname}`);
|
|
209
115
|
}
|
|
210
116
|
|
|
211
117
|
// packages/cli/src/commands/_parsers.ts
|
|
@@ -219,10 +125,10 @@ async function loadRigConfigOrNull(projectRoot) {
|
|
|
219
125
|
}
|
|
220
126
|
|
|
221
127
|
// packages/cli/src/commands/_pi-install.ts
|
|
222
|
-
import { existsSync as
|
|
223
|
-
import { homedir
|
|
224
|
-
import { resolve as
|
|
225
|
-
var PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
|
|
128
|
+
import { existsSync as existsSync2 } from "fs";
|
|
129
|
+
import { homedir } from "os";
|
|
130
|
+
import { resolve as resolve2 } from "path";
|
|
131
|
+
var PI_RIG_PACKAGE_NAME = "@h-rig/pi-rig";
|
|
226
132
|
async function defaultCommandRunner(command, options = {}) {
|
|
227
133
|
const proc = Bun.spawn(command, { cwd: options.cwd, stdout: "pipe", stderr: "pipe" });
|
|
228
134
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
@@ -233,10 +139,10 @@ async function defaultCommandRunner(command, options = {}) {
|
|
|
233
139
|
return { exitCode, stdout, stderr };
|
|
234
140
|
}
|
|
235
141
|
function resolvePiRigExtensionPath(homeDir) {
|
|
236
|
-
return
|
|
142
|
+
return resolve2(homeDir, ".pi", "agent", "extensions", "pi-rig");
|
|
237
143
|
}
|
|
238
144
|
function resolvePiHomeDir(inputHomeDir) {
|
|
239
|
-
return inputHomeDir ?? process.env.RIG_PI_HOME_DIR?.trim() ??
|
|
145
|
+
return inputHomeDir ?? process.env.RIG_PI_HOME_DIR?.trim() ?? homedir();
|
|
240
146
|
}
|
|
241
147
|
function piListContainsPiRig(output) {
|
|
242
148
|
return output.split(/\r?\n/).some((line) => {
|
|
@@ -261,27 +167,25 @@ async function checkPiRigInstall(input = {}) {
|
|
|
261
167
|
piRig: { ok: true, label: "pi-rig global extension", detail: extensionPath }
|
|
262
168
|
};
|
|
263
169
|
}
|
|
264
|
-
const exists = input.exists ?? existsSync3;
|
|
265
170
|
const runner = input.commandRunner ?? defaultCommandRunner;
|
|
266
171
|
const piResult = await safeRun(runner, ["pi", "--version"]);
|
|
267
172
|
const piListResult = piResult.exitCode === 0 ? await safeRun(runner, ["pi", "list"]) : { exitCode: 1, stdout: "", stderr: "" };
|
|
268
|
-
const
|
|
173
|
+
const hasPiRig = piListResult.exitCode === 0 && piListContainsPiRig(`${piListResult.stdout}
|
|
269
174
|
${piListResult.stderr}`);
|
|
270
|
-
const
|
|
271
|
-
const hasPiRig = listedPiRig;
|
|
175
|
+
const hasLegacyBridgeScaffold = !hasPiRig && (input.exists ?? existsSync2)(extensionPath);
|
|
272
176
|
return {
|
|
273
177
|
extensionPath,
|
|
274
178
|
pi: {
|
|
275
179
|
ok: piResult.exitCode === 0,
|
|
276
180
|
label: "pi",
|
|
277
181
|
detail: (piResult.stdout || piResult.stderr).trim() || undefined,
|
|
278
|
-
hint: piResult.exitCode === 0 ? undefined : "Install Pi or
|
|
182
|
+
hint: piResult.exitCode === 0 ? undefined : "Install Pi/OMP manually or set RIG_PI_INSTALL_COMMAND before verifying with bare `rig` / Cockpit \u2192 Doctor."
|
|
279
183
|
},
|
|
280
184
|
piRig: {
|
|
281
185
|
ok: hasPiRig,
|
|
282
186
|
label: "pi-rig global extension",
|
|
283
|
-
detail: hasPiRig ? piListResult.stdout.trim() || PI_RIG_PACKAGE_NAME :
|
|
284
|
-
hint: hasPiRig ? undefined :
|
|
187
|
+
detail: hasPiRig ? piListResult.stdout.trim() || PI_RIG_PACKAGE_NAME : hasLegacyBridgeScaffold ? `legacy bridge scaffold at ${extensionPath}` : undefined,
|
|
188
|
+
hint: hasPiRig ? undefined : `Install the Rig OMP extension with \`pi install ${PI_RIG_PACKAGE_NAME}\`, then verify with bare \`rig\` / Cockpit \u2192 Doctor.`
|
|
285
189
|
}
|
|
286
190
|
};
|
|
287
191
|
}
|
|
@@ -309,31 +213,14 @@ function isAuthenticated(payload) {
|
|
|
309
213
|
const record = payload;
|
|
310
214
|
return record.signedIn === true || record.authenticated === true || record.status === "authenticated" || record.ok === true && typeof record.login === "string" && record.login.trim().length > 0;
|
|
311
215
|
}
|
|
312
|
-
function repoSlugFromConfig(config) {
|
|
313
|
-
const project = config?.project;
|
|
314
|
-
if (project && typeof project === "object" && !Array.isArray(project)) {
|
|
315
|
-
const record = project;
|
|
316
|
-
if (typeof record.repo === "string" && /^([^/\s]+)\/([^/\s]+)$/.test(record.repo))
|
|
317
|
-
return record.repo;
|
|
318
|
-
if (typeof record.name === "string" && /^([^/\s]+)\/([^/\s]+)$/.test(record.name))
|
|
319
|
-
return record.name;
|
|
320
|
-
}
|
|
321
|
-
const taskSource = config?.taskSource;
|
|
322
|
-
if (taskSource && typeof taskSource === "object" && !Array.isArray(taskSource)) {
|
|
323
|
-
const source = taskSource;
|
|
324
|
-
if (typeof source.owner === "string" && typeof source.repo === "string")
|
|
325
|
-
return `${source.owner}/${source.repo}`;
|
|
326
|
-
}
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
216
|
function loadFallbackConfig(projectRoot) {
|
|
330
217
|
const candidates = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
331
218
|
for (const name of candidates) {
|
|
332
|
-
const path =
|
|
333
|
-
if (!
|
|
219
|
+
const path = resolve3(projectRoot, name);
|
|
220
|
+
if (!existsSync3(path))
|
|
334
221
|
continue;
|
|
335
222
|
try {
|
|
336
|
-
const source =
|
|
223
|
+
const source = readFileSync2(path, "utf8");
|
|
337
224
|
if (name.endsWith(".json"))
|
|
338
225
|
return JSON.parse(source);
|
|
339
226
|
const owner = source.match(/owner\s*:\s*["']([^"']+)["']/)?.[1];
|
|
@@ -352,14 +239,11 @@ function loadFallbackConfig(projectRoot) {
|
|
|
352
239
|
}
|
|
353
240
|
return null;
|
|
354
241
|
}
|
|
355
|
-
function projectStatusSlug(projectRoot, config) {
|
|
356
|
-
return readRepoConnection(projectRoot)?.project ?? repoSlugFromConfig(config);
|
|
357
|
-
}
|
|
358
242
|
function githubProjectsCheck(config) {
|
|
359
243
|
const github = config?.github;
|
|
360
244
|
const projects = github?.projects;
|
|
361
245
|
if (!projects?.enabled) {
|
|
362
|
-
return check("github-projects", "GitHub Projects status sync", "warn", "disabled or not configured", "
|
|
246
|
+
return check("github-projects", "GitHub Projects status sync", "warn", "disabled or not configured", "Current OMP flow does not require GitHub Projects status sync; configure github.projects manually when Project status sync should be authoritative.");
|
|
363
247
|
}
|
|
364
248
|
if (projects.projectId && projects.statusFieldId) {
|
|
365
249
|
return check("github-projects", "GitHub Projects status sync", "pass", `project ${projects.projectId}`);
|
|
@@ -384,16 +268,6 @@ function permissionAllowsPr(payload) {
|
|
|
384
268
|
}
|
|
385
269
|
return null;
|
|
386
270
|
}
|
|
387
|
-
function labelsReady(payload) {
|
|
388
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
389
|
-
return null;
|
|
390
|
-
const record = payload;
|
|
391
|
-
if (record.ok === true || record.ready === true || record.labelsReady === true)
|
|
392
|
-
return true;
|
|
393
|
-
if (record.ok === false || record.ready === false || record.labelsReady === false)
|
|
394
|
-
return false;
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
271
|
function prMergeCheck(config) {
|
|
398
272
|
const pr = config?.pr;
|
|
399
273
|
const merge = config?.merge;
|
|
@@ -407,89 +281,48 @@ async function runRigDoctorChecks(options) {
|
|
|
407
281
|
const checks = [];
|
|
408
282
|
const which = options.which ?? ((binary) => Bun.which(binary));
|
|
409
283
|
const bunVersion = options.bunVersion ?? Bun.version;
|
|
410
|
-
const request = options.requestJson ?? ((pathname, init) =>
|
|
284
|
+
const request = options.requestJson ?? ((pathname, init) => requestGitHubAuthJsonInProcess({ projectRoot }, pathname, init));
|
|
411
285
|
const loadConfig = options.loadConfig ?? loadRigConfigOrNull;
|
|
286
|
+
const progress = options.onProgress ?? (() => {});
|
|
287
|
+
progress("Checking local toolchain\u2026");
|
|
412
288
|
checks.push(check("bun", `bun >= ${MIN_SUPPORTED_BUN_VERSION}`, isSupportedBunVersion(bunVersion) ? "pass" : "fail", `found ${bunVersion}`, `Install Bun ${MIN_SUPPORTED_BUN_VERSION} or newer.`), check("git", "git", which("git") ? "pass" : "fail", which("git") ?? undefined, "Install git and ensure it is on PATH."), check("jq", "jq", which("jq") ? "pass" : "warn", which("jq") ?? undefined, "Install jq (for example `brew install jq`)."));
|
|
289
|
+
progress("Loading rig.config\u2026");
|
|
413
290
|
const loadedConfig = await loadConfig(projectRoot).catch(() => null);
|
|
414
291
|
const config = loadedConfig ?? loadFallbackConfig(projectRoot);
|
|
415
|
-
const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) =>
|
|
416
|
-
checks.push(config ? check("config", "rig.config loadable", "pass") : check("config", "rig.config loadable", hasConfigFile ? "fail" : "fail", hasConfigFile ? "config file exists but failed to load" : "missing rig.config.ts/json", "
|
|
292
|
+
const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync3(resolve3(projectRoot, name)));
|
|
293
|
+
checks.push(config ? check("config", "rig.config loadable", "pass") : check("config", "rig.config loadable", hasConfigFile ? "fail" : "fail", hasConfigFile ? "config file exists but failed to load" : "missing rig.config.ts/json", "Create/fix rig.config.ts or use the OMP cockpit Start tab to scaffold one."));
|
|
417
294
|
const taskSourceKind = config?.taskSource?.kind;
|
|
418
295
|
checks.push(taskSourceKind ? check("task-source", "task source configured", "pass", taskSourceKind) : check("task-source", "task source configured", "fail", "missing taskSource", "Configure taskSource in rig.config.ts."));
|
|
419
296
|
const repo = readRepoConnection(projectRoot);
|
|
420
|
-
checks.push(repo ? check("project-link", "repo selected
|
|
421
|
-
const selected = (() => {
|
|
422
|
-
try {
|
|
423
|
-
return resolveSelectedConnection(projectRoot);
|
|
424
|
-
} catch {
|
|
425
|
-
return null;
|
|
426
|
-
}
|
|
427
|
-
})();
|
|
428
|
-
checks.push(selected ? check("connection", "selected server connection", "pass", selected.connection.kind === "remote" ? selected.connection.baseUrl : "local auto") : check("connection", "selected server connection", repo ? "fail" : "warn", repo ? "selected alias is missing" : "will auto-start local server", repo ? "Run `rig connect list` and `rig connect use <alias|local>`." : undefined));
|
|
429
|
-
let server = null;
|
|
297
|
+
checks.push(repo ? check("project-link", "repo selected for local setup", repo.project ? "pass" : "warn", `${repo.selected}${repo.project ? ` -> ${repo.project}` : ""}`, "Run `rig init --repo owner/repo` if this project should use GitHub Issues.") : check("project-link", "repo selected for local setup", "warn", "missing .rig/state/connection.json", "Current UX can run without this compatibility file; `rig init` recreates it for GitHub-backed projects."));
|
|
430
298
|
try {
|
|
431
|
-
|
|
432
|
-
|
|
299
|
+
progress("Checking GitHub auth\u2026");
|
|
300
|
+
const auth = await request("/api/github/auth/status");
|
|
301
|
+
checks.push(isAuthenticated(auth) ? check("github-auth", "GitHub auth", "pass") : check("github-auth", "GitHub auth", "fail", "not authenticated", "Run `rig github auth import-gh` or `rig github auth token --token <token>`."));
|
|
433
302
|
} catch (error) {
|
|
434
|
-
checks.push(check("
|
|
303
|
+
checks.push(check("github-auth", "GitHub auth", "fail", errorMessage(error), "Authenticate GitHub through Rig."));
|
|
435
304
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
try {
|
|
444
|
-
const auth = await request("/api/github/auth/status");
|
|
445
|
-
checks.push(isAuthenticated(auth) ? check("github-auth", "GitHub auth", "pass") : check("github-auth", "GitHub auth", "fail", "not authenticated", "Run `rig github auth import-gh` or `rig github auth token --token <token>`."));
|
|
446
|
-
} catch (error) {
|
|
447
|
-
checks.push(check("github-auth", "GitHub auth", "fail", errorMessage(error), "Authenticate GitHub through Rig and ensure the server exposes auth status."));
|
|
448
|
-
}
|
|
449
|
-
try {
|
|
450
|
-
const permissions = await request("/api/github/repo/permissions");
|
|
451
|
-
const allowed = permissionAllowsPr(permissions);
|
|
452
|
-
checks.push(allowed === true ? check("github-repo-permissions", "GitHub repo PR permissions", "pass", JSON.stringify(permissions).slice(0, 180)) : allowed === false ? check("github-repo-permissions", "GitHub repo PR permissions", "fail", JSON.stringify(permissions).slice(0, 180), "Grant the selected GitHub token permission to push branches, open PRs, and merge according to repo rules.") : check("github-repo-permissions", "GitHub repo PR permissions", "warn", JSON.stringify(permissions).slice(0, 180), "Confirm the selected token can push branches and open PRs."));
|
|
453
|
-
} catch (error) {
|
|
454
|
-
checks.push(check("github-repo-permissions", "GitHub repo PR permissions", "warn", errorMessage(error), "Ensure the server exposes repo permission checks and the token can open PRs."));
|
|
455
|
-
}
|
|
456
|
-
try {
|
|
457
|
-
const labels = await request("/api/workspace/task-labels");
|
|
458
|
-
const ready = labelsReady(labels);
|
|
459
|
-
checks.push(ready === false ? check("task-labels", "GitHub issue labels", "fail", JSON.stringify(labels).slice(0, 180), "Let Rig create required labels or create the configured lifecycle labels manually.") : check("task-labels", "GitHub issue labels", ready === true ? "pass" : "warn", JSON.stringify(labels).slice(0, 180), "Confirm required Rig lifecycle labels exist."));
|
|
460
|
-
} catch (error) {
|
|
461
|
-
checks.push(check("task-labels", "GitHub issue labels", "warn", errorMessage(error), "Run `rig init`/`rig doctor` after label setup is wired on the server."));
|
|
462
|
-
}
|
|
463
|
-
try {
|
|
464
|
-
const projection = await request("/api/workspace/task-projection");
|
|
465
|
-
checks.push(check("task-projection", "task projection", "pass", JSON.stringify(projection).slice(0, 180)));
|
|
466
|
-
} catch (error) {
|
|
467
|
-
checks.push(check("task-projection", "task projection", "warn", errorMessage(error), "Refresh task projection with `rig task list` or fix the task source."));
|
|
468
|
-
}
|
|
469
|
-
const slug = projectStatusSlug(projectRoot, config);
|
|
470
|
-
if (slug) {
|
|
471
|
-
try {
|
|
472
|
-
const project = await request(`/api/projects/${encodeURIComponent(slug)}`);
|
|
473
|
-
checks.push(check("remote-checkout", "server project checkout", "pass", JSON.stringify(project).slice(0, 180)));
|
|
474
|
-
} catch (error) {
|
|
475
|
-
checks.push(check("remote-checkout", "server project checkout", "warn", errorMessage(error), "Run `rig init --yes --repo owner/repo` to register/link the server project checkout."));
|
|
476
|
-
}
|
|
477
|
-
} else {
|
|
478
|
-
checks.push(check("remote-checkout", "server project checkout", "warn", "repo slug unknown", "Set project.repo or run `rig init --repo owner/repo`."));
|
|
479
|
-
}
|
|
305
|
+
try {
|
|
306
|
+
progress("Checking GitHub repo permissions\u2026");
|
|
307
|
+
const permissions = await request("/api/github/repo/permissions");
|
|
308
|
+
const allowed = permissionAllowsPr(permissions);
|
|
309
|
+
checks.push(allowed === true ? check("github-repo-permissions", "GitHub repo PR permissions", "pass", JSON.stringify(permissions).slice(0, 180)) : allowed === false ? check("github-repo-permissions", "GitHub repo PR permissions", "fail", JSON.stringify(permissions).slice(0, 180), "Grant the selected GitHub token permission to push branches, open PRs, and merge according to repo rules.") : check("github-repo-permissions", "GitHub repo PR permissions", "warn", JSON.stringify(permissions).slice(0, 180), "Confirm the selected token can push branches and open PRs."));
|
|
310
|
+
} catch (error) {
|
|
311
|
+
checks.push(check("github-repo-permissions", "GitHub repo PR permissions", "warn", errorMessage(error), "Ensure the token can open PRs."));
|
|
480
312
|
}
|
|
481
313
|
if (taskSourceKind === "github-issues") {
|
|
482
314
|
checks.push(check("gh", "gh CLI fallback", which("gh") ? "pass" : "warn", which("gh") ?? undefined, "Install gh for local/dev GitHub fallback operations."));
|
|
483
315
|
}
|
|
484
316
|
checks.push(githubProjectsCheck(config));
|
|
485
317
|
checks.push(prMergeCheck(config));
|
|
318
|
+
progress("Checking Pi installation\u2026");
|
|
486
319
|
const piChecks = await (options.piChecks ?? (() => buildPiSetupChecks()))().catch((error) => [{
|
|
487
320
|
ok: false,
|
|
488
321
|
label: "pi/pi-rig checks",
|
|
489
322
|
hint: errorMessage(error)
|
|
490
323
|
}]);
|
|
491
324
|
for (const pi of piChecks) {
|
|
492
|
-
checks.push(check(pi.label === "pi" ? "pi" : "pi-rig", pi.label, pi.ok ? "pass" : "warn", pi.detail, pi.hint ?? (pi.ok ? undefined : "
|
|
325
|
+
checks.push(check(pi.label === "pi" ? "pi" : "pi-rig", pi.label, pi.ok ? "pass" : "warn", pi.detail, pi.hint ?? (pi.ok ? undefined : "Install Pi/OMP and the Rig extension, then use bare `rig` or Cockpit \u2192 Doctor to verify.")));
|
|
493
326
|
}
|
|
494
327
|
return checks;
|
|
495
328
|
}
|
|
@@ -508,7 +341,7 @@ function countDoctorFailures(checks) {
|
|
|
508
341
|
function throwIfDoctorFailed(checks) {
|
|
509
342
|
const failures = countDoctorFailures(checks);
|
|
510
343
|
if (failures > 0) {
|
|
511
|
-
throw new
|
|
344
|
+
throw new CliError(`Doctor failed (${failures} failing check${failures === 1 ? "" : "s"}).`, 1);
|
|
512
345
|
}
|
|
513
346
|
}
|
|
514
347
|
export {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type HelpCommand = {
|
|
2
|
+
command: string;
|
|
3
|
+
description: string;
|
|
4
|
+
primary?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type HelpGroup = {
|
|
7
|
+
name: string;
|
|
8
|
+
summary: string;
|
|
9
|
+
usage: string[];
|
|
10
|
+
commands: HelpCommand[];
|
|
11
|
+
examples?: string[];
|
|
12
|
+
next?: string[];
|
|
13
|
+
advanced?: string[];
|
|
14
|
+
};
|
|
15
|
+
export type TopLevelSection = {
|
|
16
|
+
title: string;
|
|
17
|
+
subtitle: string;
|
|
18
|
+
commands: HelpCommand[];
|
|
19
|
+
};
|
|
20
|
+
/** Catalog DATA for the app's help view — the view builds its own layout
|
|
21
|
+
* from these; the render* functions below remain for plain/script output. */
|
|
22
|
+
export declare function helpCatalog(): {
|
|
23
|
+
sections: readonly TopLevelSection[];
|
|
24
|
+
groups: readonly HelpGroup[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Night City boot screen. Rendered only on interactive TTY launches — plain
|
|
28
|
+
* mode and --json never see it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function renderRigBanner(version?: string): string;
|
|
31
|
+
export declare function renderTopLevelHelp(): string;
|
|
32
|
+
export declare function renderAdvancedHelp(): string;
|
|
33
|
+
export declare function renderGroupHelp(groupName: string): string | null;
|
|
34
|
+
export declare function listHelpGroups(): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Fuzzy-match a bare word against known group subcommand names so the
|
|
37
|
+
* unknown-command error can suggest the canonical `rig <group> <cmd>`
|
|
38
|
+
* spelling. Primary groups win ties (ALL_GROUPS is primary-first).
|
|
39
|
+
*/
|
|
40
|
+
export declare function suggestGroupCommandForWord(word: string, liveGroups?: ReadonlySet<string>): string | null;
|
|
41
|
+
export type TopLevelLaunchState = {
|
|
42
|
+
/** True when the cwd resolves to an initialized Rig project. */
|
|
43
|
+
projectInitialized?: boolean;
|
|
44
|
+
/** Short description of the selected server connection, if known. */
|
|
45
|
+
selectedServer?: string | null;
|
|
46
|
+
/** CLI version for the banner footer. */
|
|
47
|
+
version?: string;
|
|
48
|
+
};
|
|
49
|
+
export declare function printTopLevelHelp(state?: TopLevelLaunchState): void;
|
|
50
|
+
export declare function printAdvancedHelp(): void;
|
|
51
|
+
export declare function printGroupHelpDocument(groupName: string): void;
|