@h-rig/cli 0.0.6-alpha.64 → 0.0.6-alpha.66
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/dist/bin/rig.js +1349 -1599
- package/dist/src/commands/_connection-state.js +14 -5
- package/dist/src/commands/_doctor-checks.js +71 -11
- package/dist/src/commands/_help-catalog.js +99 -60
- package/dist/src/commands/_json-output.js +56 -0
- package/dist/src/commands/_operator-view.js +97 -784
- package/dist/src/commands/_parsers.js +18 -9
- package/dist/src/commands/_pi-frontend.js +96 -788
- package/dist/src/commands/_policy.js +12 -3
- package/dist/src/commands/_preflight.js +73 -13
- package/dist/src/commands/_run-driver-helpers.js +31 -5
- package/dist/src/commands/_run-replay.js +2 -2
- package/dist/src/commands/_server-client.js +76 -16
- package/dist/src/commands/_snapshot-upload.js +70 -10
- package/dist/src/commands/agent.js +21 -11
- package/dist/src/commands/browser.js +24 -15
- package/dist/src/commands/connect.js +22 -17
- package/dist/src/commands/dist.js +15 -6
- package/dist/src/commands/doctor.js +70 -10
- package/dist/src/commands/github.js +79 -19
- package/dist/src/commands/inbox.js +215 -131
- package/dist/src/commands/init.js +202 -35
- package/dist/src/commands/inspect.js +77 -17
- package/dist/src/commands/inspector.js +18 -9
- package/dist/src/commands/pi.js +18 -9
- package/dist/src/commands/plugin.js +19 -10
- package/dist/src/commands/profile-and-review.js +22 -13
- package/dist/src/commands/queue.js +19 -9
- package/dist/src/commands/remote.js +25 -16
- package/dist/src/commands/repo-git-harness.js +18 -9
- package/dist/src/commands/run.js +158 -805
- package/dist/src/commands/server.js +85 -25
- package/dist/src/commands/setup.js +73 -13
- package/dist/src/commands/stats.js +681 -0
- package/dist/src/commands/task-report-bug.js +24 -15
- package/dist/src/commands/task-run-driver.js +121 -49
- package/dist/src/commands/task.js +254 -893
- package/dist/src/commands/test.js +12 -3
- package/dist/src/commands/workspace.js +14 -5
- package/dist/src/commands.js +1339 -1650
- package/dist/src/index.js +1349 -1599
- package/dist/src/launcher.js +72 -10
- package/dist/src/runner.js +14 -5
- package/package.json +10 -7
- package/dist/src/commands/_pi-remote-session.js +0 -771
- package/dist/src/commands/_pi-worker-bridge-extension.js +0 -834
package/dist/src/launcher.js
CHANGED
|
@@ -4,6 +4,57 @@ import { existsSync } from "fs";
|
|
|
4
4
|
import { basename, resolve } from "path";
|
|
5
5
|
import { loadDotEnvSecrets } from "@rig/runtime/baked-secrets";
|
|
6
6
|
import { RIG_DEFINITION_DIRNAME, RIG_STATE_DIRNAME, resolveNearestRigProjectRoot } from "@rig/runtime/layout";
|
|
7
|
+
|
|
8
|
+
// packages/cli/src/commands/_json-output.ts
|
|
9
|
+
import { Schema } from "effect";
|
|
10
|
+
import {
|
|
11
|
+
RigDoctorCheckOutput,
|
|
12
|
+
RigInboxApprovalsOutput,
|
|
13
|
+
RigInboxInputsOutput,
|
|
14
|
+
RigRunListOutput,
|
|
15
|
+
RigRunShowOutput,
|
|
16
|
+
RigServerStatusOutput,
|
|
17
|
+
RigStatsOutput,
|
|
18
|
+
RigTaskListOutput,
|
|
19
|
+
RigTaskShowOutput
|
|
20
|
+
} from "@rig/contracts";
|
|
21
|
+
var CLI_OUTPUT_SCHEMAS = {
|
|
22
|
+
"task list": RigTaskListOutput,
|
|
23
|
+
"task show": RigTaskShowOutput,
|
|
24
|
+
"run list": RigRunListOutput,
|
|
25
|
+
"run show": RigRunShowOutput,
|
|
26
|
+
"server status": RigServerStatusOutput,
|
|
27
|
+
"inbox approvals": RigInboxApprovalsOutput,
|
|
28
|
+
"inbox inputs": RigInboxInputsOutput,
|
|
29
|
+
"doctor check": RigDoctorCheckOutput,
|
|
30
|
+
"stats show": RigStatsOutput
|
|
31
|
+
};
|
|
32
|
+
function isCommandOutcomeLike(value) {
|
|
33
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
34
|
+
return false;
|
|
35
|
+
const record = value;
|
|
36
|
+
return typeof record.group === "string" && typeof record.command === "string";
|
|
37
|
+
}
|
|
38
|
+
function buildCliJsonEnvelope(outcome, options = {}) {
|
|
39
|
+
if (!isCommandOutcomeLike(outcome))
|
|
40
|
+
return null;
|
|
41
|
+
const commandKey = `${outcome.group} ${outcome.command}`;
|
|
42
|
+
const schema = CLI_OUTPUT_SCHEMAS[commandKey];
|
|
43
|
+
if (!schema)
|
|
44
|
+
return null;
|
|
45
|
+
const warn = options.warn ?? ((message) => console.error(message));
|
|
46
|
+
const envelope = { v: 1, command: commandKey, data: outcome.details ?? {} };
|
|
47
|
+
try {
|
|
48
|
+
Schema.decodeUnknownSync(schema)(JSON.parse(JSON.stringify(envelope)));
|
|
49
|
+
return envelope;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
warn(`[rig] --json output for "${commandKey}" failed schema validation; printing legacy payload. ` + `(${error instanceof Error ? error.message.split(`
|
|
52
|
+
`)[0] : String(error)})`);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// packages/cli/src/launcher.ts
|
|
7
58
|
function parsePolicyMode(value) {
|
|
8
59
|
if (!value) {
|
|
9
60
|
return;
|
|
@@ -47,14 +98,17 @@ function normalizeCliErrorCode(message, isCliError) {
|
|
|
47
98
|
return isCliError ? "CLI_ERROR" : "UNEXPECTED_ERROR";
|
|
48
99
|
}
|
|
49
100
|
function normalizeCliErrorPayload(error, CliErrorClass, options = {}) {
|
|
50
|
-
const isCliError = error instanceof CliErrorClass;
|
|
101
|
+
const isCliError = error instanceof CliErrorClass || error instanceof Error && error.name === "CliError" && typeof error.exitCode === "number";
|
|
51
102
|
const message = error instanceof Error ? error.message : String(error);
|
|
52
103
|
const exitCode = isCliError ? error.exitCode : 1;
|
|
104
|
+
const rawHint = error instanceof Error ? error.hint : undefined;
|
|
105
|
+
const hint = typeof rawHint === "string" && rawHint.trim() ? rawHint.trim() : undefined;
|
|
53
106
|
const payload = {
|
|
54
107
|
ok: false,
|
|
55
108
|
code: normalizeCliErrorCode(message, isCliError),
|
|
56
109
|
message,
|
|
57
|
-
exitCode
|
|
110
|
+
exitCode,
|
|
111
|
+
...hint ? { hint } : {}
|
|
58
112
|
};
|
|
59
113
|
if (options.debug && error instanceof Error && error.stack) {
|
|
60
114
|
return { ...payload, stack: error.stack };
|
|
@@ -97,14 +151,19 @@ async function runRigCli(module, options = {}) {
|
|
|
97
151
|
const context = await module.initializeRuntime(runtimeOptions);
|
|
98
152
|
const outcome = await module.execute(context, runIdResult.rest);
|
|
99
153
|
if (outputMode === "json") {
|
|
100
|
-
io.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
154
|
+
const envelope = buildCliJsonEnvelope(outcome, { warn: io.error });
|
|
155
|
+
if (envelope) {
|
|
156
|
+
io.log(JSON.stringify(envelope, null, 2));
|
|
157
|
+
} else {
|
|
158
|
+
io.log(JSON.stringify({
|
|
159
|
+
ok: true,
|
|
160
|
+
runId: context.runId,
|
|
161
|
+
outcome,
|
|
162
|
+
eventsFile: context.eventBus.getEventsFile(),
|
|
163
|
+
policyFile: resolve(projectRoot, "rig", "policy", "policy.json"),
|
|
164
|
+
policyMode: context.policyMode ?? policyMode ?? module.loadPolicy(projectRoot).mode
|
|
165
|
+
}, null, 2));
|
|
166
|
+
}
|
|
108
167
|
}
|
|
109
168
|
} catch (error) {
|
|
110
169
|
const payload = normalizeCliErrorPayload(error, module.CliError, { debug: debugErrors });
|
|
@@ -112,6 +171,9 @@ async function runRigCli(module, options = {}) {
|
|
|
112
171
|
io.error(JSON.stringify(payload, null, 2));
|
|
113
172
|
} else {
|
|
114
173
|
io.error(debugErrors && payload.stack ? payload.stack : payload.message);
|
|
174
|
+
if (payload.hint) {
|
|
175
|
+
io.error(`Next: ${payload.hint}`);
|
|
176
|
+
}
|
|
115
177
|
}
|
|
116
178
|
process.exit(payload.exitCode);
|
|
117
179
|
}
|
package/dist/src/runner.js
CHANGED
|
@@ -4,10 +4,19 @@ var {$ } = globalThis.Bun;
|
|
|
4
4
|
import { existsSync, mkdirSync } from "fs";
|
|
5
5
|
import { resolve } from "path";
|
|
6
6
|
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
7
|
-
import { CliError } from "@rig/runtime/control-plane/errors";
|
|
7
|
+
import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
|
|
8
8
|
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
9
9
|
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
class CliError extends RuntimeCliError {
|
|
12
|
+
hint;
|
|
13
|
+
constructor(message, exitCode = 1, options = {}) {
|
|
14
|
+
super(message, exitCode);
|
|
15
|
+
if (options.hint?.trim()) {
|
|
16
|
+
this.hint = options.hint.trim();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
function withProjectRoot(projectRoot) {
|
|
12
21
|
$.cwd(projectRoot);
|
|
13
22
|
}
|
|
@@ -125,7 +134,7 @@ async function runCommand(context, parts) {
|
|
|
125
134
|
matchedRuleIds: guardDecision.matchedRules.map((r) => r.id),
|
|
126
135
|
mode: effectiveMode
|
|
127
136
|
});
|
|
128
|
-
throw new CliError(`Policy blocked command: ${formatted}`, 126);
|
|
137
|
+
throw new CliError(`Policy blocked command: ${formatted}`, 126, { hint: "Review rig/policy/policy.json, or re-run with `--policy-mode observe` to log instead of block." });
|
|
129
138
|
}
|
|
130
139
|
const startedAt = new Date;
|
|
131
140
|
await context.emitEvent("command.started", {
|
|
@@ -218,7 +227,7 @@ function takeOption(args, option) {
|
|
|
218
227
|
if (current === option) {
|
|
219
228
|
const next = args[index + 1];
|
|
220
229
|
if (!next || next.startsWith("-")) {
|
|
221
|
-
throw new CliError(`Missing value for ${option}`);
|
|
230
|
+
throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
|
|
222
231
|
}
|
|
223
232
|
value = next;
|
|
224
233
|
index += 1;
|
|
@@ -254,5 +263,5 @@ export {
|
|
|
254
263
|
initializeRuntime,
|
|
255
264
|
formatCommand,
|
|
256
265
|
ensureAgentShellBinary,
|
|
257
|
-
|
|
266
|
+
CliError
|
|
258
267
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/cli",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.66",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rig package",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -23,12 +23,15 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@clack/prompts": "^1.2.0",
|
|
26
|
-
"@earendil-works/pi-coding-agent": "
|
|
27
|
-
"@rig/client": "npm:@h-rig/client@0.0.6-alpha.
|
|
28
|
-
"@rig/
|
|
29
|
-
"@rig/
|
|
30
|
-
"@rig/
|
|
31
|
-
"@rig/
|
|
26
|
+
"@earendil-works/pi-coding-agent": "0.79.0",
|
|
27
|
+
"@rig/client": "npm:@h-rig/client@0.0.6-alpha.66",
|
|
28
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.66",
|
|
29
|
+
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.66",
|
|
30
|
+
"@rig/pi-rig": "npm:@h-rig/pi-rig@0.0.6-alpha.66",
|
|
31
|
+
"@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.66",
|
|
32
|
+
"@rig/server": "npm:@h-rig/server@0.0.6-alpha.66",
|
|
33
|
+
"@rig/standard-plugin": "npm:@h-rig/standard-plugin@0.0.6-alpha.66",
|
|
34
|
+
"effect": "4.0.0-beta.78",
|
|
32
35
|
"picocolors": "^1.1.1"
|
|
33
36
|
}
|
|
34
37
|
}
|