@h-rig/cli 0.0.6-alpha.1 → 0.0.6-alpha.100
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 +15742 -7203
- 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/_config-env.d.ts +18 -0
- package/dist/src/commands/_config-env.js +22 -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 +95 -244
- package/dist/src/commands/_help-catalog.d.ts +29 -0
- package/dist/src/commands/_help-catalog.js +146 -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 +8690 -235
- package/dist/src/commands/config.d.ts +3 -0
- package/dist/src/commands/config.js +181 -0
- 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 +214 -245
- package/dist/src/commands/github.d.ts +3 -0
- package/dist/src/commands/github.js +237 -171
- 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 +941 -654
- 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 +883 -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 +17732 -618
- package/dist/src/commands/server.d.ts +3 -0
- package/dist/src/commands/server.js +166 -285
- package/dist/src/commands/setup.d.ts +16 -0
- package/dist/src/commands/setup.js +230 -267
- package/dist/src/commands/stats.d.ts +15 -0
- package/dist/src/commands/stats.js +632 -0
- package/dist/src/commands/task-run-driver.d.ts +94 -0
- package/dist/src/commands/task-run-driver.js +120 -1856
- package/dist/src/commands/task.d.ts +35 -0
- package/dist/src/commands/task.js +676 -1183
- 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 +16760 -7779
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +16880 -8223
- 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 +17867 -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 +19 -24
- package/dist/src/withMutedConsole.d.ts +2 -0
- package/package.json +21 -7
- package/dist/src/commands/_authority-runs.js +0 -110
- package/dist/src/commands/_operator-view.js +0 -322
- package/dist/src/commands/_preflight.js +0 -460
- package/dist/src/commands/_server-client.js +0 -364
- package/dist/src/commands/_snapshot-upload.js +0 -313
- 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 existsSync3, readFileSync as
|
|
5
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
6
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,112 +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
|
-
|
|
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;
|
|
106
72
|
function cleanToken(value) {
|
|
107
73
|
const trimmed = value?.trim();
|
|
108
74
|
return trimmed ? trimmed : null;
|
|
109
75
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
return cachedGitHubBearerToken;
|
|
113
|
-
const envToken = cleanToken(process.env.RIG_GITHUB_TOKEN) ?? cleanToken(process.env.GITHUB_TOKEN) ?? cleanToken(process.env.GH_TOKEN);
|
|
114
|
-
if (envToken) {
|
|
115
|
-
cachedGitHubBearerToken = envToken;
|
|
116
|
-
return cachedGitHubBearerToken;
|
|
117
|
-
}
|
|
118
|
-
const result = spawnSync("gh", ["auth", "token"], {
|
|
119
|
-
encoding: "utf8",
|
|
120
|
-
timeout: 5000,
|
|
121
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
122
|
-
});
|
|
123
|
-
cachedGitHubBearerToken = result.status === 0 ? cleanToken(result.stdout) : null;
|
|
124
|
-
return cachedGitHubBearerToken;
|
|
125
|
-
}
|
|
126
|
-
async function ensureServerForCli(projectRoot) {
|
|
127
|
-
try {
|
|
128
|
-
const selected = resolveSelectedConnection(projectRoot);
|
|
129
|
-
if (selected?.connection.kind === "remote") {
|
|
130
|
-
return {
|
|
131
|
-
baseUrl: selected.connection.baseUrl,
|
|
132
|
-
authToken: readGitHubBearerTokenForRemote(),
|
|
133
|
-
connectionKind: "remote"
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
const connection = await ensureLocalRigServerConnection(projectRoot);
|
|
137
|
-
return {
|
|
138
|
-
baseUrl: connection.baseUrl,
|
|
139
|
-
authToken: connection.authToken,
|
|
140
|
-
connectionKind: "local"
|
|
141
|
-
};
|
|
142
|
-
} catch (error) {
|
|
143
|
-
if (error instanceof Error) {
|
|
144
|
-
throw new CliError2(error.message, 1);
|
|
145
|
-
}
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
76
|
+
function cleanString(value) {
|
|
77
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
148
78
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
if (authToken) {
|
|
152
|
-
merged.set("authorization", `Bearer ${authToken}`);
|
|
153
|
-
}
|
|
154
|
-
return merged;
|
|
79
|
+
function oauthClientId() {
|
|
80
|
+
return cleanToken(process.env.RIG_GITHUB_OAUTH_CLIENT_ID);
|
|
155
81
|
}
|
|
156
|
-
function
|
|
157
|
-
|
|
158
|
-
return null;
|
|
159
|
-
const record = payload;
|
|
160
|
-
const diagnostics = Array.isArray(record.diagnostics) ? record.diagnostics : [];
|
|
161
|
-
const messages = diagnostics.flatMap((entry) => {
|
|
162
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
163
|
-
return [];
|
|
164
|
-
const diagnostic = entry;
|
|
165
|
-
const kind = typeof diagnostic.kind === "string" ? diagnostic.kind : "task-source";
|
|
166
|
-
const message = typeof diagnostic.message === "string" ? diagnostic.message : null;
|
|
167
|
-
return message ? [`${kind}: ${message}`] : [];
|
|
168
|
-
});
|
|
169
|
-
return messages.length > 0 ? messages.join("; ") : null;
|
|
82
|
+
async function getGitHubAuthStatusInProcess(context) {
|
|
83
|
+
return { ok: true, ...resolveGitHubAuthStatus({ projectRoot: context.projectRoot, oauthConfigured: Boolean(oauthClientId()) }) };
|
|
170
84
|
}
|
|
171
|
-
async function
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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()) });
|
|
91
|
+
}
|
|
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
|
+
});
|
|
189
103
|
}
|
|
190
|
-
|
|
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) });
|
|
113
|
+
}
|
|
114
|
+
throw new Error(`No in-process GitHub auth API for ${method} ${pathname}`);
|
|
191
115
|
}
|
|
192
116
|
|
|
193
117
|
// packages/cli/src/commands/_parsers.ts
|
|
@@ -201,10 +125,10 @@ async function loadRigConfigOrNull(projectRoot) {
|
|
|
201
125
|
}
|
|
202
126
|
|
|
203
127
|
// packages/cli/src/commands/_pi-install.ts
|
|
204
|
-
import { existsSync as existsSync2
|
|
205
|
-
import { homedir
|
|
128
|
+
import { existsSync as existsSync2 } from "fs";
|
|
129
|
+
import { homedir } from "os";
|
|
206
130
|
import { resolve as resolve2 } from "path";
|
|
207
|
-
var PI_RIG_PACKAGE_NAME = "@rig/pi-rig";
|
|
131
|
+
var PI_RIG_PACKAGE_NAME = "@h-rig/pi-rig";
|
|
208
132
|
async function defaultCommandRunner(command, options = {}) {
|
|
209
133
|
const proc = Bun.spawn(command, { cwd: options.cwd, stdout: "pipe", stderr: "pipe" });
|
|
210
134
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
@@ -218,7 +142,7 @@ function resolvePiRigExtensionPath(homeDir) {
|
|
|
218
142
|
return resolve2(homeDir, ".pi", "agent", "extensions", "pi-rig");
|
|
219
143
|
}
|
|
220
144
|
function resolvePiHomeDir(inputHomeDir) {
|
|
221
|
-
return inputHomeDir ?? process.env.RIG_PI_HOME_DIR?.trim() ??
|
|
145
|
+
return inputHomeDir ?? process.env.RIG_PI_HOME_DIR?.trim() ?? homedir();
|
|
222
146
|
}
|
|
223
147
|
function piListContainsPiRig(output) {
|
|
224
148
|
return output.split(/\r?\n/).some((line) => {
|
|
@@ -243,27 +167,25 @@ async function checkPiRigInstall(input = {}) {
|
|
|
243
167
|
piRig: { ok: true, label: "pi-rig global extension", detail: extensionPath }
|
|
244
168
|
};
|
|
245
169
|
}
|
|
246
|
-
const exists = input.exists ?? existsSync2;
|
|
247
170
|
const runner = input.commandRunner ?? defaultCommandRunner;
|
|
248
171
|
const piResult = await safeRun(runner, ["pi", "--version"]);
|
|
249
172
|
const piListResult = piResult.exitCode === 0 ? await safeRun(runner, ["pi", "list"]) : { exitCode: 1, stdout: "", stderr: "" };
|
|
250
|
-
const
|
|
173
|
+
const hasPiRig = piListResult.exitCode === 0 && piListContainsPiRig(`${piListResult.stdout}
|
|
251
174
|
${piListResult.stderr}`);
|
|
252
|
-
const
|
|
253
|
-
const hasPiRig = listedPiRig;
|
|
175
|
+
const hasLegacyBridgeScaffold = !hasPiRig && (input.exists ?? existsSync2)(extensionPath);
|
|
254
176
|
return {
|
|
255
177
|
extensionPath,
|
|
256
178
|
pi: {
|
|
257
179
|
ok: piResult.exitCode === 0,
|
|
258
180
|
label: "pi",
|
|
259
181
|
detail: (piResult.stdout || piResult.stderr).trim() || undefined,
|
|
260
|
-
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."
|
|
261
183
|
},
|
|
262
184
|
piRig: {
|
|
263
185
|
ok: hasPiRig,
|
|
264
186
|
label: "pi-rig global extension",
|
|
265
|
-
detail: hasPiRig ? piListResult.stdout.trim() || PI_RIG_PACKAGE_NAME :
|
|
266
|
-
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.`
|
|
267
189
|
}
|
|
268
190
|
};
|
|
269
191
|
}
|
|
@@ -291,23 +213,6 @@ function isAuthenticated(payload) {
|
|
|
291
213
|
const record = payload;
|
|
292
214
|
return record.signedIn === true || record.authenticated === true || record.status === "authenticated" || record.ok === true && typeof record.login === "string" && record.login.trim().length > 0;
|
|
293
215
|
}
|
|
294
|
-
function repoSlugFromConfig(config) {
|
|
295
|
-
const project = config?.project;
|
|
296
|
-
if (project && typeof project === "object" && !Array.isArray(project)) {
|
|
297
|
-
const record = project;
|
|
298
|
-
if (typeof record.repo === "string" && /^([^/\s]+)\/([^/\s]+)$/.test(record.repo))
|
|
299
|
-
return record.repo;
|
|
300
|
-
if (typeof record.name === "string" && /^([^/\s]+)\/([^/\s]+)$/.test(record.name))
|
|
301
|
-
return record.name;
|
|
302
|
-
}
|
|
303
|
-
const taskSource = config?.taskSource;
|
|
304
|
-
if (taskSource && typeof taskSource === "object" && !Array.isArray(taskSource)) {
|
|
305
|
-
const source = taskSource;
|
|
306
|
-
if (typeof source.owner === "string" && typeof source.repo === "string")
|
|
307
|
-
return `${source.owner}/${source.repo}`;
|
|
308
|
-
}
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
216
|
function loadFallbackConfig(projectRoot) {
|
|
312
217
|
const candidates = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
313
218
|
for (const name of candidates) {
|
|
@@ -315,7 +220,7 @@ function loadFallbackConfig(projectRoot) {
|
|
|
315
220
|
if (!existsSync3(path))
|
|
316
221
|
continue;
|
|
317
222
|
try {
|
|
318
|
-
const source =
|
|
223
|
+
const source = readFileSync2(path, "utf8");
|
|
319
224
|
if (name.endsWith(".json"))
|
|
320
225
|
return JSON.parse(source);
|
|
321
226
|
const owner = source.match(/owner\s*:\s*["']([^"']+)["']/)?.[1];
|
|
@@ -334,14 +239,11 @@ function loadFallbackConfig(projectRoot) {
|
|
|
334
239
|
}
|
|
335
240
|
return null;
|
|
336
241
|
}
|
|
337
|
-
function projectStatusSlug(projectRoot, config) {
|
|
338
|
-
return readRepoConnection(projectRoot)?.project ?? repoSlugFromConfig(config);
|
|
339
|
-
}
|
|
340
242
|
function githubProjectsCheck(config) {
|
|
341
243
|
const github = config?.github;
|
|
342
244
|
const projects = github?.projects;
|
|
343
245
|
if (!projects?.enabled) {
|
|
344
|
-
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.");
|
|
345
247
|
}
|
|
346
248
|
if (projects.projectId && projects.statusFieldId) {
|
|
347
249
|
return check("github-projects", "GitHub Projects status sync", "pass", `project ${projects.projectId}`);
|
|
@@ -366,16 +268,6 @@ function permissionAllowsPr(payload) {
|
|
|
366
268
|
}
|
|
367
269
|
return null;
|
|
368
270
|
}
|
|
369
|
-
function labelsReady(payload) {
|
|
370
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
371
|
-
return null;
|
|
372
|
-
const record = payload;
|
|
373
|
-
if (record.ok === true || record.ready === true || record.labelsReady === true)
|
|
374
|
-
return true;
|
|
375
|
-
if (record.ok === false || record.ready === false || record.labelsReady === false)
|
|
376
|
-
return false;
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
271
|
function prMergeCheck(config) {
|
|
380
272
|
const pr = config?.pr;
|
|
381
273
|
const merge = config?.merge;
|
|
@@ -389,89 +281,48 @@ async function runRigDoctorChecks(options) {
|
|
|
389
281
|
const checks = [];
|
|
390
282
|
const which = options.which ?? ((binary) => Bun.which(binary));
|
|
391
283
|
const bunVersion = options.bunVersion ?? Bun.version;
|
|
392
|
-
const request = options.requestJson ?? ((pathname, init) =>
|
|
284
|
+
const request = options.requestJson ?? ((pathname, init) => requestGitHubAuthJsonInProcess({ projectRoot }, pathname, init));
|
|
393
285
|
const loadConfig = options.loadConfig ?? loadRigConfigOrNull;
|
|
286
|
+
const progress = options.onProgress ?? (() => {});
|
|
287
|
+
progress("Checking local toolchain\u2026");
|
|
394
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");
|
|
395
290
|
const loadedConfig = await loadConfig(projectRoot).catch(() => null);
|
|
396
291
|
const config = loadedConfig ?? loadFallbackConfig(projectRoot);
|
|
397
292
|
const hasConfigFile = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync3(resolve3(projectRoot, name)));
|
|
398
|
-
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", "
|
|
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."));
|
|
399
294
|
const taskSourceKind = config?.taskSource?.kind;
|
|
400
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."));
|
|
401
296
|
const repo = readRepoConnection(projectRoot);
|
|
402
|
-
checks.push(repo ? check("project-link", "repo selected
|
|
403
|
-
const selected = (() => {
|
|
404
|
-
try {
|
|
405
|
-
return resolveSelectedConnection(projectRoot);
|
|
406
|
-
} catch {
|
|
407
|
-
return null;
|
|
408
|
-
}
|
|
409
|
-
})();
|
|
410
|
-
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));
|
|
411
|
-
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."));
|
|
412
298
|
try {
|
|
413
|
-
|
|
414
|
-
|
|
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>`."));
|
|
415
302
|
} catch (error) {
|
|
416
|
-
checks.push(check("
|
|
303
|
+
checks.push(check("github-auth", "GitHub auth", "fail", errorMessage(error), "Authenticate GitHub through Rig."));
|
|
417
304
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
try {
|
|
426
|
-
const auth = await request("/api/github/auth/status");
|
|
427
|
-
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>`."));
|
|
428
|
-
} catch (error) {
|
|
429
|
-
checks.push(check("github-auth", "GitHub auth", "fail", errorMessage(error), "Authenticate GitHub through Rig and ensure the server exposes auth status."));
|
|
430
|
-
}
|
|
431
|
-
try {
|
|
432
|
-
const permissions = await request("/api/github/repo/permissions");
|
|
433
|
-
const allowed = permissionAllowsPr(permissions);
|
|
434
|
-
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."));
|
|
435
|
-
} catch (error) {
|
|
436
|
-
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."));
|
|
437
|
-
}
|
|
438
|
-
try {
|
|
439
|
-
const labels = await request("/api/workspace/task-labels");
|
|
440
|
-
const ready = labelsReady(labels);
|
|
441
|
-
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."));
|
|
442
|
-
} catch (error) {
|
|
443
|
-
checks.push(check("task-labels", "GitHub issue labels", "warn", errorMessage(error), "Run `rig init`/`rig doctor` after label setup is wired on the server."));
|
|
444
|
-
}
|
|
445
|
-
try {
|
|
446
|
-
const projection = await request("/api/workspace/task-projection");
|
|
447
|
-
checks.push(check("task-projection", "task projection", "pass", JSON.stringify(projection).slice(0, 180)));
|
|
448
|
-
} catch (error) {
|
|
449
|
-
checks.push(check("task-projection", "task projection", "warn", errorMessage(error), "Refresh task projection with `rig task list` or fix the task source."));
|
|
450
|
-
}
|
|
451
|
-
const slug = projectStatusSlug(projectRoot, config);
|
|
452
|
-
if (slug) {
|
|
453
|
-
try {
|
|
454
|
-
const project = await request(`/api/projects/${encodeURIComponent(slug)}`);
|
|
455
|
-
checks.push(check("remote-checkout", "server project checkout", "pass", JSON.stringify(project).slice(0, 180)));
|
|
456
|
-
} catch (error) {
|
|
457
|
-
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."));
|
|
458
|
-
}
|
|
459
|
-
} else {
|
|
460
|
-
checks.push(check("remote-checkout", "server project checkout", "warn", "repo slug unknown", "Set project.repo or run `rig init --repo owner/repo`."));
|
|
461
|
-
}
|
|
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."));
|
|
462
312
|
}
|
|
463
313
|
if (taskSourceKind === "github-issues") {
|
|
464
314
|
checks.push(check("gh", "gh CLI fallback", which("gh") ? "pass" : "warn", which("gh") ?? undefined, "Install gh for local/dev GitHub fallback operations."));
|
|
465
315
|
}
|
|
466
316
|
checks.push(githubProjectsCheck(config));
|
|
467
317
|
checks.push(prMergeCheck(config));
|
|
318
|
+
progress("Checking Pi installation\u2026");
|
|
468
319
|
const piChecks = await (options.piChecks ?? (() => buildPiSetupChecks()))().catch((error) => [{
|
|
469
320
|
ok: false,
|
|
470
321
|
label: "pi/pi-rig checks",
|
|
471
322
|
hint: errorMessage(error)
|
|
472
323
|
}]);
|
|
473
324
|
for (const pi of piChecks) {
|
|
474
|
-
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.")));
|
|
475
326
|
}
|
|
476
327
|
return checks;
|
|
477
328
|
}
|
|
@@ -490,7 +341,7 @@ function countDoctorFailures(checks) {
|
|
|
490
341
|
function throwIfDoctorFailed(checks) {
|
|
491
342
|
const failures = countDoctorFailures(checks);
|
|
492
343
|
if (failures > 0) {
|
|
493
|
-
throw new
|
|
344
|
+
throw new CliError(`Doctor failed (${failures} failing check${failures === 1 ? "" : "s"}).`, 1);
|
|
494
345
|
}
|
|
495
346
|
}
|
|
496
347
|
export {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { helpCatalog, type HelpCommand, type HelpGroup, type TopLevelSection } from "@rig/contracts";
|
|
2
|
+
export { helpCatalog };
|
|
3
|
+
export type { HelpCommand, HelpGroup, TopLevelSection };
|
|
4
|
+
/**
|
|
5
|
+
* Night City boot screen. Rendered only on interactive TTY launches — plain
|
|
6
|
+
* mode and --json never see it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderRigBanner(version?: string): string;
|
|
9
|
+
export declare function renderTopLevelHelp(): string;
|
|
10
|
+
export declare function renderAdvancedHelp(): string;
|
|
11
|
+
export declare function renderGroupHelp(groupName: string): string | null;
|
|
12
|
+
export declare function listHelpGroups(): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Fuzzy-match a bare word against known group subcommand names so the
|
|
15
|
+
* unknown-command error can suggest the canonical `rig <group> <cmd>`
|
|
16
|
+
* spelling. Primary groups win ties (ALL_GROUPS is primary-first).
|
|
17
|
+
*/
|
|
18
|
+
export declare function suggestGroupCommandForWord(word: string, liveGroups?: ReadonlySet<string>): string | null;
|
|
19
|
+
export type TopLevelLaunchState = {
|
|
20
|
+
/** True when the cwd resolves to an initialized Rig project. */
|
|
21
|
+
projectInitialized?: boolean;
|
|
22
|
+
/** Short description of the selected server connection, if known. */
|
|
23
|
+
selectedServer?: string | null;
|
|
24
|
+
/** CLI version for the banner footer. */
|
|
25
|
+
version?: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function printTopLevelHelp(state?: TopLevelLaunchState): void;
|
|
28
|
+
export declare function printAdvancedHelp(): void;
|
|
29
|
+
export declare function printGroupHelpDocument(groupName: string): void;
|