@h-rig/cli 0.0.6-alpha.94 → 0.0.6-alpha.96
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 +6 -27
- package/bin/rig.js +16 -0
- package/package.json +14 -40
- package/dist/bin/build-rig-binaries.d.ts +0 -2
- package/dist/bin/build-rig-binaries.js +0 -119
- package/dist/bin/rig.d.ts +0 -72
- package/dist/bin/rig.js +0 -17855
- package/dist/config/rig-default-config.yml +0 -5
- package/dist/src/app/drone-ui.d.ts +0 -34
- package/dist/src/app/drone-ui.js +0 -278
- package/dist/src/commands/_async-ui.d.ts +0 -10
- package/dist/src/commands/_async-ui.js +0 -121
- package/dist/src/commands/_cli-format.d.ts +0 -56
- package/dist/src/commands/_cli-format.js +0 -319
- package/dist/src/commands/_connection-state.d.ts +0 -54
- package/dist/src/commands/_connection-state.js +0 -187
- package/dist/src/commands/_doctor-checks.d.ts +0 -46
- package/dist/src/commands/_doctor-checks.js +0 -352
- package/dist/src/commands/_help-catalog.d.ts +0 -51
- package/dist/src/commands/_help-catalog.js +0 -502
- package/dist/src/commands/_inprocess-services.d.ts +0 -33
- package/dist/src/commands/_inprocess-services.js +0 -102
- package/dist/src/commands/_json-output.d.ts +0 -11
- package/dist/src/commands/_json-output.js +0 -60
- package/dist/src/commands/_lazy-reconcile.d.ts +0 -34
- package/dist/src/commands/_lazy-reconcile.js +0 -102
- package/dist/src/commands/_parsers.d.ts +0 -15
- package/dist/src/commands/_parsers.js +0 -114
- package/dist/src/commands/_paths.d.ts +0 -11
- package/dist/src/commands/_paths.js +0 -50
- package/dist/src/commands/_pi-frontend.d.ts +0 -35
- package/dist/src/commands/_pi-frontend.js +0 -64
- package/dist/src/commands/_pi-install.d.ts +0 -42
- package/dist/src/commands/_pi-install.js +0 -167
- package/dist/src/commands/_policy.d.ts +0 -8
- package/dist/src/commands/_policy.js +0 -127
- package/dist/src/commands/_probes.d.ts +0 -1
- package/dist/src/commands/_probes.js +0 -13
- package/dist/src/commands/_run-bridge.d.ts +0 -114
- package/dist/src/commands/_run-bridge.js +0 -387
- package/dist/src/commands/_run-diagnostics.d.ts +0 -9
- package/dist/src/commands/_run-diagnostics.js +0 -51
- package/dist/src/commands/_run-driver-helpers.d.ts +0 -26
- package/dist/src/commands/_run-driver-helpers.js +0 -138
- package/dist/src/commands/_run-projection.d.ts +0 -50
- package/dist/src/commands/_run-projection.js +0 -349
- package/dist/src/commands/_run-subcommands.d.ts +0 -3
- package/dist/src/commands/_run-subcommands.js +0 -31
- package/dist/src/commands/_spinner.d.ts +0 -25
- package/dist/src/commands/_spinner.js +0 -65
- package/dist/src/commands/agent.d.ts +0 -3
- package/dist/src/commands/agent.js +0 -8837
- package/dist/src/commands/dist.d.ts +0 -28
- package/dist/src/commands/dist.js +0 -417
- package/dist/src/commands/doctor.d.ts +0 -3
- package/dist/src/commands/doctor.js +0 -480
- package/dist/src/commands/github.d.ts +0 -3
- package/dist/src/commands/github.js +0 -342
- package/dist/src/commands/inbox.d.ts +0 -28
- package/dist/src/commands/inbox.js +0 -579
- package/dist/src/commands/init.d.ts +0 -64
- package/dist/src/commands/init.js +0 -1541
- package/dist/src/commands/inspect.d.ts +0 -20
- package/dist/src/commands/inspect.js +0 -764
- package/dist/src/commands/pi.d.ts +0 -3
- package/dist/src/commands/pi.js +0 -177
- package/dist/src/commands/plugin.d.ts +0 -16
- package/dist/src/commands/plugin.js +0 -714
- package/dist/src/commands/profile-and-review.d.ts +0 -4
- package/dist/src/commands/profile-and-review.js +0 -223
- package/dist/src/commands/queue.d.ts +0 -3
- package/dist/src/commands/queue.js +0 -197
- package/dist/src/commands/remote.d.ts +0 -3
- package/dist/src/commands/remote.js +0 -1337
- package/dist/src/commands/repo-git-harness.d.ts +0 -5
- package/dist/src/commands/repo-git-harness.js +0 -271
- package/dist/src/commands/run.d.ts +0 -21
- package/dist/src/commands/run.js +0 -17847
- package/dist/src/commands/server.d.ts +0 -3
- package/dist/src/commands/server.js +0 -249
- package/dist/src/commands/setup.d.ts +0 -16
- package/dist/src/commands/setup.js +0 -644
- package/dist/src/commands/stats.d.ts +0 -15
- package/dist/src/commands/stats.js +0 -979
- package/dist/src/commands/task-run-driver.d.ts +0 -94
- package/dist/src/commands/task-run-driver.js +0 -203
- package/dist/src/commands/task.d.ts +0 -35
- package/dist/src/commands/task.js +0 -818
- package/dist/src/commands/test.d.ts +0 -3
- package/dist/src/commands/test.js +0 -46
- package/dist/src/commands/triage.d.ts +0 -11
- package/dist/src/commands/triage.js +0 -227
- package/dist/src/commands/workspace.d.ts +0 -3
- package/dist/src/commands/workspace.js +0 -130
- package/dist/src/commands.d.ts +0 -13
- package/dist/src/commands.js +0 -17979
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -17991
- package/dist/src/launcher.d.ts +0 -61
- package/dist/src/launcher.js +0 -199
- package/dist/src/operator-cli.d.ts +0 -2
- package/dist/src/operator-cli.js +0 -17847
- package/dist/src/operator-entry.d.ts +0 -1
- package/dist/src/operator-entry.js +0 -3
- package/dist/src/runner.d.ts +0 -47
- package/dist/src/runner.js +0 -267
- package/dist/src/withMutedConsole.d.ts +0 -2
- package/dist/src/withMutedConsole.js +0 -42
package/dist/src/launcher.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { RunnerContext } from "./runner";
|
|
2
|
-
export type PolicyModeValue = "off" | "observe" | "enforce";
|
|
3
|
-
export interface ResolveProjectRootOptions {
|
|
4
|
-
readonly envProjectRoot?: string;
|
|
5
|
-
readonly execPath?: string;
|
|
6
|
-
readonly importDir?: string;
|
|
7
|
-
readonly cwd?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface CliIo {
|
|
10
|
-
readonly log: (message: string) => void;
|
|
11
|
-
readonly error: (message: string) => void;
|
|
12
|
-
}
|
|
13
|
-
export interface RigCliRunOptions {
|
|
14
|
-
readonly argv?: readonly string[];
|
|
15
|
-
readonly io?: CliIo;
|
|
16
|
-
readonly envProjectRoot?: string;
|
|
17
|
-
readonly execPath?: string;
|
|
18
|
-
readonly importDir?: string;
|
|
19
|
-
readonly cwd?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface RigCliModule {
|
|
22
|
-
readonly CliError: new (message: string, exitCode?: number) => Error & {
|
|
23
|
-
exitCode: number;
|
|
24
|
-
};
|
|
25
|
-
execute: (context: RunnerContext, args: string[]) => Promise<unknown>;
|
|
26
|
-
initializeRuntime: (options: {
|
|
27
|
-
projectRoot: string;
|
|
28
|
-
dryRun: boolean;
|
|
29
|
-
outputMode: "json" | "text";
|
|
30
|
-
runId?: string | undefined;
|
|
31
|
-
policyMode?: PolicyModeValue | undefined;
|
|
32
|
-
}) => Promise<RunnerContext>;
|
|
33
|
-
loadPolicy(projectRoot: string): {
|
|
34
|
-
mode: PolicyModeValue;
|
|
35
|
-
};
|
|
36
|
-
takeFlag(args: string[], flag: string): {
|
|
37
|
-
value: boolean;
|
|
38
|
-
rest: string[];
|
|
39
|
-
};
|
|
40
|
-
takeOption(args: string[], option: string): {
|
|
41
|
-
value?: string;
|
|
42
|
-
rest: string[];
|
|
43
|
-
};
|
|
44
|
-
withProjectRoot(projectRoot: string): void;
|
|
45
|
-
}
|
|
46
|
-
export declare function parsePolicyMode(value: string | undefined): PolicyModeValue | undefined;
|
|
47
|
-
export declare function resolveProjectRoot({ envProjectRoot, execPath, importDir, cwd, }: ResolveProjectRootOptions): string;
|
|
48
|
-
export interface CliErrorPayload {
|
|
49
|
-
readonly ok: false;
|
|
50
|
-
readonly code: string;
|
|
51
|
-
readonly message: string;
|
|
52
|
-
readonly exitCode: number;
|
|
53
|
-
/** Remediation hint (next command to run); rendered as `Next: <hint>`. */
|
|
54
|
-
readonly hint?: string;
|
|
55
|
-
readonly stack?: string;
|
|
56
|
-
}
|
|
57
|
-
export declare function normalizeCliErrorPayload(error: unknown, CliErrorClass: RigCliModule["CliError"], options?: {
|
|
58
|
-
readonly debug?: boolean;
|
|
59
|
-
}): CliErrorPayload;
|
|
60
|
-
export declare function runRigCli(module: RigCliModule, options?: RigCliRunOptions): Promise<void>;
|
|
61
|
-
export declare function hydrateProcessEnvFromDotEnv(projectRoot: string): void;
|
package/dist/src/launcher.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/launcher.ts
|
|
3
|
-
import { existsSync } from "fs";
|
|
4
|
-
import { basename, resolve } from "path";
|
|
5
|
-
import { loadDotEnvSecrets } from "@rig/runtime/baked-secrets";
|
|
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
|
-
RigServerRepairLinkOutput,
|
|
17
|
-
RigServerStatusOutput,
|
|
18
|
-
RigServerUseOutput,
|
|
19
|
-
RigStatsOutput,
|
|
20
|
-
RigTaskListOutput,
|
|
21
|
-
RigTaskShowOutput
|
|
22
|
-
} from "@rig/contracts";
|
|
23
|
-
var CLI_OUTPUT_SCHEMAS = {
|
|
24
|
-
"task list": RigTaskListOutput,
|
|
25
|
-
"task show": RigTaskShowOutput,
|
|
26
|
-
"run list": RigRunListOutput,
|
|
27
|
-
"run show": RigRunShowOutput,
|
|
28
|
-
"server use": RigServerUseOutput,
|
|
29
|
-
"server status": RigServerStatusOutput,
|
|
30
|
-
"server repair-link": RigServerRepairLinkOutput,
|
|
31
|
-
"inbox approvals": RigInboxApprovalsOutput,
|
|
32
|
-
"inbox inputs": RigInboxInputsOutput,
|
|
33
|
-
"doctor check": RigDoctorCheckOutput,
|
|
34
|
-
"stats show": RigStatsOutput
|
|
35
|
-
};
|
|
36
|
-
function isCommandOutcomeLike(value) {
|
|
37
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
38
|
-
return false;
|
|
39
|
-
const record = value;
|
|
40
|
-
return typeof record.group === "string" && typeof record.command === "string";
|
|
41
|
-
}
|
|
42
|
-
function buildCliJsonEnvelope(outcome, options = {}) {
|
|
43
|
-
if (!isCommandOutcomeLike(outcome))
|
|
44
|
-
return null;
|
|
45
|
-
const commandKey = `${outcome.group} ${outcome.command}`;
|
|
46
|
-
const schema = CLI_OUTPUT_SCHEMAS[commandKey];
|
|
47
|
-
if (!schema)
|
|
48
|
-
return null;
|
|
49
|
-
const warn = options.warn ?? ((message) => console.error(message));
|
|
50
|
-
const envelope = { v: 1, command: commandKey, data: outcome.details ?? {} };
|
|
51
|
-
try {
|
|
52
|
-
Schema.decodeUnknownSync(schema)(JSON.parse(JSON.stringify(envelope)));
|
|
53
|
-
return envelope;
|
|
54
|
-
} catch (error) {
|
|
55
|
-
warn(`[rig] --json output for "${commandKey}" failed schema validation; printing legacy payload. ` + `(${error instanceof Error ? error.message.split(`
|
|
56
|
-
`)[0] : String(error)})`);
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// packages/cli/src/launcher.ts
|
|
62
|
-
function parsePolicyMode(value) {
|
|
63
|
-
if (!value) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (value === "off" || value === "observe" || value === "enforce") {
|
|
67
|
-
return value;
|
|
68
|
-
}
|
|
69
|
-
throw new Error(`Invalid --policy-mode value: ${value}. Use off|observe|enforce.`);
|
|
70
|
-
}
|
|
71
|
-
function hasRigProjectMarker(candidate) {
|
|
72
|
-
return existsSync(resolve(candidate, RIG_DEFINITION_DIRNAME)) || existsSync(resolve(candidate, RIG_STATE_DIRNAME)) || existsSync(resolve(candidate, "rig.config.ts")) || existsSync(resolve(candidate, "rig.config.json")) || existsSync(resolve(candidate, ".git"));
|
|
73
|
-
}
|
|
74
|
-
function resolveProjectRoot({
|
|
75
|
-
envProjectRoot,
|
|
76
|
-
execPath = process.execPath,
|
|
77
|
-
importDir,
|
|
78
|
-
cwd = process.cwd()
|
|
79
|
-
}) {
|
|
80
|
-
if (envProjectRoot) {
|
|
81
|
-
return resolve(cwd, envProjectRoot);
|
|
82
|
-
}
|
|
83
|
-
const fallbackImportDir = importDir ?? cwd;
|
|
84
|
-
const execName = basename(execPath).toLowerCase();
|
|
85
|
-
const execCandidates = execName === "rig" || execName === "rig.exe" ? [resolve(execPath, "..", "..")] : [];
|
|
86
|
-
const candidates = [cwd, ...execCandidates, resolve(fallbackImportDir, "..")];
|
|
87
|
-
for (const candidate of candidates) {
|
|
88
|
-
const nearest = resolveNearestRigProjectRoot(candidate);
|
|
89
|
-
if (hasRigProjectMarker(nearest)) {
|
|
90
|
-
return nearest;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return resolve(cwd);
|
|
94
|
-
}
|
|
95
|
-
function normalizeCliErrorCode(message, isCliError) {
|
|
96
|
-
if (message.startsWith("Invalid --policy-mode value:")) {
|
|
97
|
-
return "INVALID_POLICY_MODE";
|
|
98
|
-
}
|
|
99
|
-
if (message.startsWith("Missing value for --")) {
|
|
100
|
-
return "MISSING_OPTION_VALUE";
|
|
101
|
-
}
|
|
102
|
-
return isCliError ? "CLI_ERROR" : "UNEXPECTED_ERROR";
|
|
103
|
-
}
|
|
104
|
-
function normalizeCliErrorPayload(error, CliErrorClass, options = {}) {
|
|
105
|
-
const isCliError = error instanceof CliErrorClass || error instanceof Error && error.name === "CliError" && typeof error.exitCode === "number";
|
|
106
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
107
|
-
const exitCode = isCliError ? error.exitCode : 1;
|
|
108
|
-
const rawHint = error instanceof Error ? error.hint : undefined;
|
|
109
|
-
const hint = typeof rawHint === "string" && rawHint.trim() ? rawHint.trim() : undefined;
|
|
110
|
-
const payload = {
|
|
111
|
-
ok: false,
|
|
112
|
-
code: normalizeCliErrorCode(message, isCliError),
|
|
113
|
-
message,
|
|
114
|
-
exitCode,
|
|
115
|
-
...hint ? { hint } : {}
|
|
116
|
-
};
|
|
117
|
-
if (options.debug && error instanceof Error && error.stack) {
|
|
118
|
-
return { ...payload, stack: error.stack };
|
|
119
|
-
}
|
|
120
|
-
return payload;
|
|
121
|
-
}
|
|
122
|
-
async function runRigCli(module, options = {}) {
|
|
123
|
-
const io = options.io ?? {
|
|
124
|
-
log: (message) => console.log(message),
|
|
125
|
-
error: (message) => console.error(message)
|
|
126
|
-
};
|
|
127
|
-
const args = [...options.argv ?? process.argv.slice(2)];
|
|
128
|
-
const debugErrors = process.env.RIG_DEBUG === "1" || process.env.RIG_CLI_DEBUG === "1";
|
|
129
|
-
let jsonOutput = args.includes("--json");
|
|
130
|
-
try {
|
|
131
|
-
const dryRunResult = module.takeFlag(args, "--dry-run");
|
|
132
|
-
const jsonResult = module.takeFlag(dryRunResult.rest, "--json");
|
|
133
|
-
jsonOutput = jsonResult.value;
|
|
134
|
-
const projectResult = module.takeOption(jsonResult.rest, "--project");
|
|
135
|
-
const cwd = options.cwd ?? process.cwd();
|
|
136
|
-
const projectRoot = resolveProjectRoot(Object.fromEntries(Object.entries({
|
|
137
|
-
envProjectRoot: projectResult.value ?? options.envProjectRoot ?? process.env.PROJECT_RIG_ROOT,
|
|
138
|
-
execPath: options.execPath ?? process.execPath,
|
|
139
|
-
importDir: options.importDir,
|
|
140
|
-
cwd
|
|
141
|
-
}).filter(([, value]) => value !== undefined)));
|
|
142
|
-
hydrateProcessEnvFromDotEnv(projectRoot);
|
|
143
|
-
module.withProjectRoot(projectRoot);
|
|
144
|
-
const policyModeResult = module.takeOption(projectResult.rest, "--policy-mode");
|
|
145
|
-
const runIdResult = module.takeOption(policyModeResult.rest, "--run-id");
|
|
146
|
-
const policyMode = parsePolicyMode(policyModeResult.value);
|
|
147
|
-
const outputMode = jsonResult.value ? "json" : "text";
|
|
148
|
-
const runtimeOptions = {
|
|
149
|
-
projectRoot,
|
|
150
|
-
dryRun: dryRunResult.value,
|
|
151
|
-
outputMode,
|
|
152
|
-
runId: runIdResult.value,
|
|
153
|
-
policyMode
|
|
154
|
-
};
|
|
155
|
-
const context = await module.initializeRuntime(runtimeOptions);
|
|
156
|
-
const outcome = await module.execute(context, runIdResult.rest);
|
|
157
|
-
if (outputMode === "json") {
|
|
158
|
-
const envelope = buildCliJsonEnvelope(outcome, { warn: io.error });
|
|
159
|
-
if (envelope) {
|
|
160
|
-
io.log(JSON.stringify(envelope, null, 2));
|
|
161
|
-
} else {
|
|
162
|
-
io.log(JSON.stringify({
|
|
163
|
-
ok: true,
|
|
164
|
-
runId: context.runId,
|
|
165
|
-
outcome,
|
|
166
|
-
eventsFile: context.eventBus.getEventsFile(),
|
|
167
|
-
policyFile: resolve(projectRoot, "rig", "policy", "policy.json"),
|
|
168
|
-
policyMode: context.policyMode ?? policyMode ?? module.loadPolicy(projectRoot).mode
|
|
169
|
-
}, null, 2));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
} catch (error) {
|
|
173
|
-
const payload = normalizeCliErrorPayload(error, module.CliError, { debug: debugErrors });
|
|
174
|
-
if (jsonOutput) {
|
|
175
|
-
io.error(JSON.stringify(payload, null, 2));
|
|
176
|
-
} else {
|
|
177
|
-
io.error(debugErrors && payload.stack ? payload.stack : payload.message);
|
|
178
|
-
if (payload.hint) {
|
|
179
|
-
io.error(`Next: ${payload.hint}`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
process.exit(payload.exitCode);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function hydrateProcessEnvFromDotEnv(projectRoot) {
|
|
186
|
-
const secrets = loadDotEnvSecrets(projectRoot, process.env);
|
|
187
|
-
for (const [key, value] of Object.entries(secrets)) {
|
|
188
|
-
if (value && !process.env[key]) {
|
|
189
|
-
process.env[key] = value;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
export {
|
|
194
|
-
runRigCli,
|
|
195
|
-
resolveProjectRoot,
|
|
196
|
-
parsePolicyMode,
|
|
197
|
-
normalizeCliErrorPayload,
|
|
198
|
-
hydrateProcessEnvFromDotEnv
|
|
199
|
-
};
|