@h-rig/cli 0.0.6-alpha.28 → 0.0.6-alpha.29
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 +421 -241
- package/dist/src/commands/_connection-state.js +0 -2
- package/dist/src/commands/_doctor-checks.js +0 -2
- package/dist/src/commands/_help-catalog.js +27 -3
- package/dist/src/commands/_operator-view.js +0 -2
- package/dist/src/commands/_parsers.js +0 -2
- package/dist/src/commands/_pi-frontend.js +0 -2
- package/dist/src/commands/_pi-worker-bridge-extension.js +0 -2
- package/dist/src/commands/_policy.js +0 -2
- package/dist/src/commands/_preflight.js +0 -2
- package/dist/src/commands/_run-driver-helpers.js +0 -2
- package/dist/src/commands/_server-client.js +0 -2
- package/dist/src/commands/_snapshot-upload.js +0 -2
- package/dist/src/commands/agent.js +0 -2
- package/dist/src/commands/browser.js +0 -2
- package/dist/src/commands/connect.js +0 -2
- package/dist/src/commands/dist.js +0 -2
- package/dist/src/commands/doctor.js +0 -2
- package/dist/src/commands/github.js +0 -2
- package/dist/src/commands/inbox.js +0 -2
- package/dist/src/commands/init.js +0 -2
- package/dist/src/commands/inspect.js +0 -2
- package/dist/src/commands/inspector.js +0 -2
- package/dist/src/commands/plugin.js +73 -19
- package/dist/src/commands/profile-and-review.js +0 -2
- package/dist/src/commands/queue.js +0 -2
- package/dist/src/commands/remote.js +0 -2
- package/dist/src/commands/repo-git-harness.js +2 -4
- package/dist/src/commands/run.js +2 -4
- package/dist/src/commands/server.js +0 -2
- package/dist/src/commands/setup.js +0 -8
- package/dist/src/commands/task-report-bug.js +0 -2
- package/dist/src/commands/task-run-driver.js +0 -2
- package/dist/src/commands/task.js +34 -7
- package/dist/src/commands/test.js +0 -2
- package/dist/src/commands/workspace.js +0 -2
- package/dist/src/commands.js +403 -214
- package/dist/src/index.js +415 -238
- package/dist/src/runner.js +2 -17
- package/package.json +6 -6
package/dist/bin/rig.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __returnValue = (v) => v;
|
|
5
|
+
function __exportSetter(name, newValue) {
|
|
6
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
7
|
+
}
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
set: __exportSetter.bind(all, name)
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
3
18
|
var __require = import.meta.require;
|
|
4
19
|
|
|
5
|
-
// packages/cli/bin/rig.ts
|
|
6
|
-
import { loadPolicy as loadPolicy3 } from "@rig/runtime/control-plane/runtime/guard";
|
|
7
|
-
|
|
8
20
|
// packages/cli/src/runner.ts
|
|
9
21
|
var {$ } = globalThis.Bun;
|
|
10
22
|
import { existsSync, mkdirSync } from "fs";
|
|
@@ -12,8 +24,6 @@ import { resolve } from "path";
|
|
|
12
24
|
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
13
25
|
import { CliError } from "@rig/runtime/control-plane/errors";
|
|
14
26
|
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
15
|
-
import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
|
|
16
|
-
import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
|
|
17
27
|
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
18
28
|
import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
|
|
19
29
|
function withProjectRoot(projectRoot) {
|
|
@@ -22,7 +32,6 @@ function withProjectRoot(projectRoot) {
|
|
|
22
32
|
function formatCommand(parts) {
|
|
23
33
|
return parts.map((part) => /[^a-zA-Z0-9_./:-]/.test(part) ? JSON.stringify(part) : part).join(" ");
|
|
24
34
|
}
|
|
25
|
-
var AGENT_DISPATCH_SOURCE = "packages/runtime/bin/rig-agent-dispatch.ts";
|
|
26
35
|
function hasAgentDispatchSource(root) {
|
|
27
36
|
return existsSync(resolve(root, AGENT_DISPATCH_SOURCE));
|
|
28
37
|
}
|
|
@@ -67,13 +76,6 @@ async function ensureAgentShellBinary(projectRoot, options = {}) {
|
|
|
67
76
|
}
|
|
68
77
|
async function initializeRuntime(options) {
|
|
69
78
|
const eventBus = new EventBus({ projectRoot: options.projectRoot, runId: options.runId });
|
|
70
|
-
const runtimeContext = loadRuntimeContextFromEnv() ?? undefined;
|
|
71
|
-
const plugins = await PluginManager.load({
|
|
72
|
-
projectRoot: options.projectRoot,
|
|
73
|
-
runId: eventBus.getRunId(),
|
|
74
|
-
eventBus,
|
|
75
|
-
runtimeContext
|
|
76
|
-
});
|
|
77
79
|
const context = {
|
|
78
80
|
projectRoot: options.projectRoot,
|
|
79
81
|
dryRun: options.dryRun,
|
|
@@ -81,10 +83,8 @@ async function initializeRuntime(options) {
|
|
|
81
83
|
runId: eventBus.getRunId(),
|
|
82
84
|
policyMode: options.policyMode,
|
|
83
85
|
eventBus,
|
|
84
|
-
plugins,
|
|
85
86
|
emitEvent: async (type, payload) => {
|
|
86
|
-
|
|
87
|
-
await plugins.onEvent(event);
|
|
87
|
+
await eventBus.emit(type, payload);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
context.runCommand = async (parts) => runCommand(context, parts);
|
|
@@ -93,8 +93,7 @@ async function initializeRuntime(options) {
|
|
|
93
93
|
outputMode: context.outputMode,
|
|
94
94
|
dryRun: context.dryRun,
|
|
95
95
|
policyMode: context.policyMode ?? loadPolicy(options.projectRoot).mode,
|
|
96
|
-
policyFile: resolve(options.projectRoot, "rig/policy/policy.json")
|
|
97
|
-
plugins: context.plugins.list()
|
|
96
|
+
policyFile: resolve(options.projectRoot, "rig/policy/policy.json")
|
|
98
97
|
});
|
|
99
98
|
return context;
|
|
100
99
|
}
|
|
@@ -145,7 +144,6 @@ async function runCommand(context, parts) {
|
|
|
145
144
|
});
|
|
146
145
|
throw new CliError(`Policy blocked command: ${formatted}`, 126);
|
|
147
146
|
}
|
|
148
|
-
await context.plugins.beforeCommand({ command: commandWithEnv, formattedCommand: formatted });
|
|
149
147
|
const startedAt = new Date;
|
|
150
148
|
await context.emitEvent("command.started", {
|
|
151
149
|
command: commandWithEnv,
|
|
@@ -165,7 +163,6 @@ async function runCommand(context, parts) {
|
|
|
165
163
|
if (context.outputMode === "text") {
|
|
166
164
|
console.log(`$ ${formatted}`);
|
|
167
165
|
}
|
|
168
|
-
await context.plugins.afterCommand(dryResult);
|
|
169
166
|
await context.emitEvent("command.finished", {
|
|
170
167
|
...dryResult,
|
|
171
168
|
dryRun: true
|
|
@@ -205,7 +202,6 @@ async function runCommand(context, parts) {
|
|
|
205
202
|
stdout: context.outputMode === "json" ? stdout : undefined,
|
|
206
203
|
stderr: context.outputMode === "json" ? stderr : undefined
|
|
207
204
|
};
|
|
208
|
-
await context.plugins.afterCommand(result);
|
|
209
205
|
if (exitCode !== 0) {
|
|
210
206
|
await context.emitEvent("command.failed", {
|
|
211
207
|
...result
|
|
@@ -264,11 +260,281 @@ Usage: ${usage}`);
|
|
|
264
260
|
}
|
|
265
261
|
return taskId;
|
|
266
262
|
}
|
|
263
|
+
var AGENT_DISPATCH_SOURCE = "packages/runtime/bin/rig-agent-dispatch.ts";
|
|
264
|
+
var init_runner = () => {};
|
|
265
|
+
|
|
266
|
+
// packages/cli/src/commands/_parsers.ts
|
|
267
|
+
import { homedir } from "os";
|
|
268
|
+
import { resolve as resolve7 } from "path";
|
|
269
|
+
function parsePositiveInt(value, option, fallback) {
|
|
270
|
+
if (!value) {
|
|
271
|
+
return fallback;
|
|
272
|
+
}
|
|
273
|
+
const parsed = Number.parseInt(value, 10);
|
|
274
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
275
|
+
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
276
|
+
}
|
|
277
|
+
return parsed;
|
|
278
|
+
}
|
|
279
|
+
function parseOptionalPositiveInt(value, option) {
|
|
280
|
+
if (!value) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const parsed = Number.parseInt(value, 10);
|
|
284
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
285
|
+
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
286
|
+
}
|
|
287
|
+
return parsed;
|
|
288
|
+
}
|
|
289
|
+
function parseRequiredPositiveInt(value, option) {
|
|
290
|
+
if (!value) {
|
|
291
|
+
throw new CliError2(`Missing value for ${option}.`);
|
|
292
|
+
}
|
|
293
|
+
const parsed = Number.parseInt(value, 10);
|
|
294
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
295
|
+
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
296
|
+
}
|
|
297
|
+
return parsed;
|
|
298
|
+
}
|
|
299
|
+
function parseAction(value) {
|
|
300
|
+
if (!value || value === "validate") {
|
|
301
|
+
return "validate";
|
|
302
|
+
}
|
|
303
|
+
if (value === "verify") {
|
|
304
|
+
return "verify";
|
|
305
|
+
}
|
|
306
|
+
if (value === "pipeline") {
|
|
307
|
+
return "pipeline";
|
|
308
|
+
}
|
|
309
|
+
throw new CliError2(`Invalid --action value: ${value}. Use validate, verify, or pipeline.`);
|
|
310
|
+
}
|
|
311
|
+
function parseIsolationMode(value, allowOff) {
|
|
312
|
+
if (!value) {
|
|
313
|
+
return "worktree";
|
|
314
|
+
}
|
|
315
|
+
if (value === "worktree") {
|
|
316
|
+
return value;
|
|
317
|
+
}
|
|
318
|
+
if (allowOff && value === "off") {
|
|
319
|
+
return value;
|
|
320
|
+
}
|
|
321
|
+
throw new CliError2(`Invalid isolation mode: ${value}. Use ${allowOff ? "off|" : ""}worktree.`);
|
|
322
|
+
}
|
|
323
|
+
function parseInstallScope(value) {
|
|
324
|
+
if (!value || value === "user") {
|
|
325
|
+
return "user";
|
|
326
|
+
}
|
|
327
|
+
if (value === "system") {
|
|
328
|
+
return "system";
|
|
329
|
+
}
|
|
330
|
+
throw new CliError2(`Invalid --scope value: ${value}. Use user|system.`);
|
|
331
|
+
}
|
|
332
|
+
function resolveInstallDir(scope, explicitPath) {
|
|
333
|
+
if (explicitPath) {
|
|
334
|
+
return resolve7(explicitPath);
|
|
335
|
+
}
|
|
336
|
+
if (scope === "system") {
|
|
337
|
+
return "/usr/local/bin";
|
|
338
|
+
}
|
|
339
|
+
return resolve7(homedir(), ".local/bin");
|
|
340
|
+
}
|
|
341
|
+
async function loadRigConfigOrNull(projectRoot) {
|
|
342
|
+
try {
|
|
343
|
+
const { loadConfig } = await import("@rig/core/load-config");
|
|
344
|
+
return await loadConfig(projectRoot);
|
|
345
|
+
} catch {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
var init__parsers = __esm(() => {
|
|
350
|
+
init_runner();
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// packages/cli/src/commands/plugin.ts
|
|
354
|
+
var exports_plugin = {};
|
|
355
|
+
__export(exports_plugin, {
|
|
356
|
+
resolvePluginCliCommand: () => resolvePluginCliCommand,
|
|
357
|
+
executePlugin: () => executePlugin
|
|
358
|
+
});
|
|
359
|
+
import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
|
|
360
|
+
async function executePlugin(context, args) {
|
|
361
|
+
const [command = "list", ...rest] = args;
|
|
362
|
+
switch (command) {
|
|
363
|
+
case "list": {
|
|
364
|
+
requireNoExtraArgs(rest, "rig plugin list");
|
|
365
|
+
const declarative = [];
|
|
366
|
+
const config = await loadRigConfigOrNull(context.projectRoot);
|
|
367
|
+
if (config && Array.isArray(config.plugins)) {
|
|
368
|
+
for (const plugin of config.plugins) {
|
|
369
|
+
const c = plugin.contributes ?? {};
|
|
370
|
+
declarative.push({
|
|
371
|
+
name: plugin.name,
|
|
372
|
+
version: plugin.version,
|
|
373
|
+
validators: (c.validators ?? []).map((v) => v.id),
|
|
374
|
+
hooks: (c.hooks ?? []).map((h) => h.id),
|
|
375
|
+
agentRoles: (c.agentRoles ?? []).map((r) => r.id),
|
|
376
|
+
repoSources: (c.repoSources ?? []).map((r) => r.id),
|
|
377
|
+
taskSources: (c.taskSources ?? []).map((s) => s.id),
|
|
378
|
+
skills: (c.skills ?? []).map((s) => s.id),
|
|
379
|
+
taskFieldExtensions: (c.taskFieldSchemas ?? []).map((f) => f.id),
|
|
380
|
+
cliCommands: (c.cliCommands ?? []).map((entry) => entry.id)
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (context.outputMode === "text") {
|
|
385
|
+
if (declarative.length === 0) {
|
|
386
|
+
console.log("No plugins loaded. Declare plugins in rig.config.ts.");
|
|
387
|
+
} else {
|
|
388
|
+
console.log("Plugins (rig.config.ts):");
|
|
389
|
+
for (const p of declarative) {
|
|
390
|
+
console.log(` ${p.name}@${p.version}`);
|
|
391
|
+
const lines = [];
|
|
392
|
+
if (p.validators.length)
|
|
393
|
+
lines.push(` validators: ${p.validators.join(", ")}`);
|
|
394
|
+
if (p.hooks.length)
|
|
395
|
+
lines.push(` hooks: ${p.hooks.join(", ")}`);
|
|
396
|
+
if (p.agentRoles.length)
|
|
397
|
+
lines.push(` agent-roles: ${p.agentRoles.join(", ")}`);
|
|
398
|
+
if (p.repoSources.length)
|
|
399
|
+
lines.push(` repo-sources: ${p.repoSources.join(", ")}`);
|
|
400
|
+
if (p.taskSources.length)
|
|
401
|
+
lines.push(` task-sources: ${p.taskSources.join(", ")}`);
|
|
402
|
+
if (p.skills.length)
|
|
403
|
+
lines.push(` skills: ${p.skills.join(", ")}`);
|
|
404
|
+
if (p.taskFieldExtensions.length)
|
|
405
|
+
lines.push(` task-fields: ${p.taskFieldExtensions.join(", ")}`);
|
|
406
|
+
if (p.cliCommands.length)
|
|
407
|
+
lines.push(` cli-commands: ${p.cliCommands.join(", ")} (run with \`rig plugin run <id>\`)`);
|
|
408
|
+
for (const line of lines)
|
|
409
|
+
console.log(line);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
ok: true,
|
|
415
|
+
group: "plugin",
|
|
416
|
+
command,
|
|
417
|
+
details: { declarative }
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
case "validate": {
|
|
421
|
+
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
422
|
+
requireNoExtraArgs(remaining, "rig plugin validate --task <task-id>");
|
|
423
|
+
const taskId = requireTask(task, "rig plugin validate --task <task-id>");
|
|
424
|
+
const hostCtx = await buildPluginHostContext(context.projectRoot);
|
|
425
|
+
if (!hostCtx) {
|
|
426
|
+
throw new CliError2(`No rig.config found at ${context.projectRoot}. Run \`rig init\` to set up plugins.`, 2);
|
|
427
|
+
}
|
|
428
|
+
const validators = hostCtx.validatorRegistry.list();
|
|
429
|
+
const results = [];
|
|
430
|
+
for (const validator of validators) {
|
|
431
|
+
try {
|
|
432
|
+
results.push(await validator.run({
|
|
433
|
+
taskId,
|
|
434
|
+
workspaceRoot: context.projectRoot,
|
|
435
|
+
scope: []
|
|
436
|
+
}));
|
|
437
|
+
} catch (error) {
|
|
438
|
+
results.push({
|
|
439
|
+
id: validator.id,
|
|
440
|
+
passed: false,
|
|
441
|
+
summary: `${validator.id} failed unexpectedly`,
|
|
442
|
+
details: `${error}`
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const passed = results.filter((result) => result.passed).length;
|
|
447
|
+
const failed = results.length - passed;
|
|
448
|
+
if (context.outputMode === "text") {
|
|
449
|
+
if (results.length === 0) {
|
|
450
|
+
console.log("No plugin validators registered.");
|
|
451
|
+
} else {
|
|
452
|
+
for (const result of results) {
|
|
453
|
+
const icon = result.passed ? "PASS" : "FAIL";
|
|
454
|
+
console.log(`[${icon}] ${result.id}: ${result.summary}`);
|
|
455
|
+
if (result.details && !result.passed) {
|
|
456
|
+
console.log(result.details);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (failed > 0) {
|
|
462
|
+
throw new CliError2(`Plugin validation failed for ${failed} validator(s).`, 2);
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
ok: true,
|
|
466
|
+
group: "plugin",
|
|
467
|
+
command,
|
|
468
|
+
details: {
|
|
469
|
+
taskId,
|
|
470
|
+
passed,
|
|
471
|
+
failed,
|
|
472
|
+
results
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
case "run": {
|
|
477
|
+
const [commandId, ...commandArgs] = rest;
|
|
478
|
+
if (!commandId) {
|
|
479
|
+
throw new CliError2("Usage: rig plugin run <command-id> [args...]");
|
|
480
|
+
}
|
|
481
|
+
const hostCtx = await buildPluginHostContext(context.projectRoot);
|
|
482
|
+
if (!hostCtx) {
|
|
483
|
+
throw new CliError2(`No rig.config found at ${context.projectRoot}. Run \`rig init\` to set up plugins.`, 2);
|
|
484
|
+
}
|
|
485
|
+
const registration = resolvePluginCliCommand(hostCtx.pluginHost.listCliCommands(), commandId);
|
|
486
|
+
if (!registration) {
|
|
487
|
+
const available = hostCtx.pluginHost.listCliCommands().map((entry) => entry.id);
|
|
488
|
+
throw new CliError2(available.length > 0 ? `Unknown plugin command "${commandId}". Available: ${available.join(", ")}` : `No plugin CLI commands are registered. Plugins contribute them via contributes.cliCommands.`, 2);
|
|
489
|
+
}
|
|
490
|
+
if (context.dryRun) {
|
|
491
|
+
if (context.outputMode === "text") {
|
|
492
|
+
console.log(`[dry-run] ${registration.command}${commandArgs.length ? ` ${commandArgs.join(" ")}` : ""}`);
|
|
493
|
+
}
|
|
494
|
+
return { ok: true, group: "plugin", command, details: { id: registration.id, dryRun: true } };
|
|
495
|
+
}
|
|
496
|
+
const proc = Bun.spawn(["bash", "-c", `${registration.command} "$@"`, registration.id, ...commandArgs], {
|
|
497
|
+
cwd: context.projectRoot,
|
|
498
|
+
env: process.env,
|
|
499
|
+
stdin: "inherit",
|
|
500
|
+
stdout: "inherit",
|
|
501
|
+
stderr: "inherit"
|
|
502
|
+
});
|
|
503
|
+
const exitCode = await proc.exited;
|
|
504
|
+
if (exitCode !== 0) {
|
|
505
|
+
throw new CliError2(`Plugin command "${registration.id}" exited with code ${exitCode}.`, exitCode);
|
|
506
|
+
}
|
|
507
|
+
return { ok: true, group: "plugin", command, details: { id: registration.id, exitCode } };
|
|
508
|
+
}
|
|
509
|
+
default:
|
|
510
|
+
throw new CliError2(`Unknown plugin command: ${command}`);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function resolvePluginCliCommand(commands, requested) {
|
|
514
|
+
const exact = commands.find((entry) => entry.id === requested);
|
|
515
|
+
if (exact)
|
|
516
|
+
return exact;
|
|
517
|
+
const byLocalPart = commands.filter((entry) => entry.id.split(":").slice(1).join(":") === requested);
|
|
518
|
+
return byLocalPart.length === 1 ? byLocalPart[0] : undefined;
|
|
519
|
+
}
|
|
520
|
+
var init_plugin = __esm(() => {
|
|
521
|
+
init_runner();
|
|
522
|
+
init__parsers();
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// packages/cli/bin/rig.ts
|
|
526
|
+
import { loadPolicy as loadPolicy3 } from "@rig/runtime/control-plane/runtime/guard";
|
|
267
527
|
|
|
268
528
|
// packages/cli/src/commands.ts
|
|
529
|
+
init_runner();
|
|
530
|
+
import {
|
|
531
|
+
existsSync as existsSync14
|
|
532
|
+
} from "fs";
|
|
533
|
+
import { resolve as resolve23 } from "path";
|
|
269
534
|
import { readBuildConfig } from "@rig/runtime/build-time-config";
|
|
270
535
|
|
|
271
536
|
// packages/cli/src/commands/browser.ts
|
|
537
|
+
init_runner();
|
|
272
538
|
import { mkdirSync as mkdirSync3, rmSync as rmSync2 } from "fs";
|
|
273
539
|
import { resolve as resolve5 } from "path";
|
|
274
540
|
import { spawn } from "child_process";
|
|
@@ -279,6 +545,7 @@ import pc2 from "picocolors";
|
|
|
279
545
|
import { runCapture as runCapture2 } from "@rig/runtime/control-plane/native/utils";
|
|
280
546
|
|
|
281
547
|
// packages/cli/src/commands/task-report-bug.ts
|
|
548
|
+
init_runner();
|
|
282
549
|
import { existsSync as existsSync3, readFileSync, writeFileSync as writeFileSync2 } from "fs";
|
|
283
550
|
import { resolve as resolve4 } from "path";
|
|
284
551
|
import * as clack from "@clack/prompts";
|
|
@@ -2103,6 +2370,7 @@ async function stopBrowserDemo(child) {
|
|
|
2103
2370
|
}
|
|
2104
2371
|
|
|
2105
2372
|
// packages/cli/src/commands/profile-and-review.ts
|
|
2373
|
+
init_runner();
|
|
2106
2374
|
import {
|
|
2107
2375
|
setProfile,
|
|
2108
2376
|
setReviewProfile,
|
|
@@ -2242,10 +2510,12 @@ async function executeReview(context, args) {
|
|
|
2242
2510
|
}
|
|
2243
2511
|
|
|
2244
2512
|
// packages/cli/src/commands/repo-git-harness.ts
|
|
2513
|
+
init_runner();
|
|
2245
2514
|
import { executeHarnessCommand } from "@rig/runtime/control-plane/native/harness-cli";
|
|
2246
2515
|
import { repoEnsure, resetBaseline } from "@rig/runtime/control-plane/native/repo-ops";
|
|
2247
2516
|
|
|
2248
2517
|
// packages/cli/src/commands/_policy.ts
|
|
2518
|
+
init_runner();
|
|
2249
2519
|
import { appendFileSync, mkdirSync as mkdirSync4 } from "fs";
|
|
2250
2520
|
import { resolve as resolve6 } from "path";
|
|
2251
2521
|
import { evaluate as evaluate2, loadPolicy as loadPolicy2, resolveAction as resolveAction2 } from "@rig/runtime/control-plane/runtime/guard";
|
|
@@ -2340,7 +2610,7 @@ async function executeGit(context, args) {
|
|
|
2340
2610
|
return { ok: true, group: "git", command: args[0] ?? "git" };
|
|
2341
2611
|
}
|
|
2342
2612
|
try {
|
|
2343
|
-
await executeHarnessCommand(context.projectRoot,
|
|
2613
|
+
await executeHarnessCommand(context.projectRoot, ["git", ...args]);
|
|
2344
2614
|
} catch (error) {
|
|
2345
2615
|
throw new CliError2(error instanceof Error ? error.message : String(error), 2);
|
|
2346
2616
|
}
|
|
@@ -2361,214 +2631,27 @@ async function executeHarness(context, args) {
|
|
|
2361
2631
|
return { ok: true, group: "harness", command: args[0] ?? "harness" };
|
|
2362
2632
|
}
|
|
2363
2633
|
try {
|
|
2364
|
-
await executeHarnessCommand(context.projectRoot,
|
|
2634
|
+
await executeHarnessCommand(context.projectRoot, args);
|
|
2365
2635
|
} catch (error) {
|
|
2366
2636
|
throw new CliError2(error instanceof Error ? error.message : String(error), 2);
|
|
2367
2637
|
}
|
|
2368
2638
|
return { ok: true, group: "harness", command: args[0] ?? "harness" };
|
|
2369
2639
|
}
|
|
2370
2640
|
|
|
2371
|
-
// packages/cli/src/commands
|
|
2372
|
-
|
|
2373
|
-
import { resolve as resolve7 } from "path";
|
|
2374
|
-
function parsePositiveInt(value, option, fallback) {
|
|
2375
|
-
if (!value) {
|
|
2376
|
-
return fallback;
|
|
2377
|
-
}
|
|
2378
|
-
const parsed = Number.parseInt(value, 10);
|
|
2379
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
2380
|
-
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
2381
|
-
}
|
|
2382
|
-
return parsed;
|
|
2383
|
-
}
|
|
2384
|
-
function parseOptionalPositiveInt(value, option) {
|
|
2385
|
-
if (!value) {
|
|
2386
|
-
return;
|
|
2387
|
-
}
|
|
2388
|
-
const parsed = Number.parseInt(value, 10);
|
|
2389
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
2390
|
-
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
2391
|
-
}
|
|
2392
|
-
return parsed;
|
|
2393
|
-
}
|
|
2394
|
-
function parseRequiredPositiveInt(value, option) {
|
|
2395
|
-
if (!value) {
|
|
2396
|
-
throw new CliError2(`Missing value for ${option}.`);
|
|
2397
|
-
}
|
|
2398
|
-
const parsed = Number.parseInt(value, 10);
|
|
2399
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
2400
|
-
throw new CliError2(`Invalid ${option} value: ${value}`);
|
|
2401
|
-
}
|
|
2402
|
-
return parsed;
|
|
2403
|
-
}
|
|
2404
|
-
function parseAction(value) {
|
|
2405
|
-
if (!value || value === "validate") {
|
|
2406
|
-
return "validate";
|
|
2407
|
-
}
|
|
2408
|
-
if (value === "verify") {
|
|
2409
|
-
return "verify";
|
|
2410
|
-
}
|
|
2411
|
-
if (value === "pipeline") {
|
|
2412
|
-
return "pipeline";
|
|
2413
|
-
}
|
|
2414
|
-
throw new CliError2(`Invalid --action value: ${value}. Use validate, verify, or pipeline.`);
|
|
2415
|
-
}
|
|
2416
|
-
function parseIsolationMode(value, allowOff) {
|
|
2417
|
-
if (!value) {
|
|
2418
|
-
return "worktree";
|
|
2419
|
-
}
|
|
2420
|
-
if (value === "worktree") {
|
|
2421
|
-
return value;
|
|
2422
|
-
}
|
|
2423
|
-
if (allowOff && value === "off") {
|
|
2424
|
-
return value;
|
|
2425
|
-
}
|
|
2426
|
-
throw new CliError2(`Invalid isolation mode: ${value}. Use ${allowOff ? "off|" : ""}worktree.`);
|
|
2427
|
-
}
|
|
2428
|
-
function parseInstallScope(value) {
|
|
2429
|
-
if (!value || value === "user") {
|
|
2430
|
-
return "user";
|
|
2431
|
-
}
|
|
2432
|
-
if (value === "system") {
|
|
2433
|
-
return "system";
|
|
2434
|
-
}
|
|
2435
|
-
throw new CliError2(`Invalid --scope value: ${value}. Use user|system.`);
|
|
2436
|
-
}
|
|
2437
|
-
function resolveInstallDir(scope, explicitPath) {
|
|
2438
|
-
if (explicitPath) {
|
|
2439
|
-
return resolve7(explicitPath);
|
|
2440
|
-
}
|
|
2441
|
-
if (scope === "system") {
|
|
2442
|
-
return "/usr/local/bin";
|
|
2443
|
-
}
|
|
2444
|
-
return resolve7(homedir(), ".local/bin");
|
|
2445
|
-
}
|
|
2446
|
-
async function loadRigConfigOrNull(projectRoot) {
|
|
2447
|
-
try {
|
|
2448
|
-
const { loadConfig } = await import("@rig/core/load-config");
|
|
2449
|
-
return await loadConfig(projectRoot);
|
|
2450
|
-
} catch {
|
|
2451
|
-
return null;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
|
|
2455
|
-
// packages/cli/src/commands/plugin.ts
|
|
2456
|
-
async function executePlugin(context, args) {
|
|
2457
|
-
const [command = "list", ...rest] = args;
|
|
2458
|
-
switch (command) {
|
|
2459
|
-
case "list": {
|
|
2460
|
-
requireNoExtraArgs(rest, "rig plugin list");
|
|
2461
|
-
const legacyPlugins = context.plugins.list();
|
|
2462
|
-
const declarative = [];
|
|
2463
|
-
const config = await loadRigConfigOrNull(context.projectRoot);
|
|
2464
|
-
if (config && Array.isArray(config.plugins)) {
|
|
2465
|
-
for (const plugin of config.plugins) {
|
|
2466
|
-
const c = plugin.contributes ?? {};
|
|
2467
|
-
declarative.push({
|
|
2468
|
-
name: plugin.name,
|
|
2469
|
-
version: plugin.version,
|
|
2470
|
-
validators: (c.validators ?? []).map((v) => v.id),
|
|
2471
|
-
hooks: (c.hooks ?? []).map((h) => h.id),
|
|
2472
|
-
agentRoles: (c.agentRoles ?? []).map((r) => r.id),
|
|
2473
|
-
repoSources: (c.repoSources ?? []).map((r) => r.id),
|
|
2474
|
-
taskSources: (c.taskSources ?? []).map((s) => s.id),
|
|
2475
|
-
skills: (c.skills ?? []).map((s) => s.id),
|
|
2476
|
-
taskFieldExtensions: (c.taskFieldSchemas ?? []).map((f) => f.id),
|
|
2477
|
-
cliCommands: (c.cliCommands ?? []).map((c2) => c2.id)
|
|
2478
|
-
});
|
|
2479
|
-
}
|
|
2480
|
-
}
|
|
2481
|
-
if (context.outputMode === "text") {
|
|
2482
|
-
if (legacyPlugins.length === 0 && declarative.length === 0) {
|
|
2483
|
-
console.log("No plugins loaded.");
|
|
2484
|
-
}
|
|
2485
|
-
if (declarative.length > 0) {
|
|
2486
|
-
console.log("Declarative plugins (rig.config.ts):");
|
|
2487
|
-
for (const p of declarative) {
|
|
2488
|
-
console.log(` ${p.name}@${p.version}`);
|
|
2489
|
-
const lines = [];
|
|
2490
|
-
if (p.validators.length)
|
|
2491
|
-
lines.push(` validators: ${p.validators.join(", ")}`);
|
|
2492
|
-
if (p.hooks.length)
|
|
2493
|
-
lines.push(` hooks: ${p.hooks.join(", ")}`);
|
|
2494
|
-
if (p.agentRoles.length)
|
|
2495
|
-
lines.push(` agent-roles: ${p.agentRoles.join(", ")}`);
|
|
2496
|
-
if (p.repoSources.length)
|
|
2497
|
-
lines.push(` repo-sources: ${p.repoSources.join(", ")}`);
|
|
2498
|
-
if (p.taskSources.length)
|
|
2499
|
-
lines.push(` task-sources: ${p.taskSources.join(", ")}`);
|
|
2500
|
-
if (p.skills.length)
|
|
2501
|
-
lines.push(` skills: ${p.skills.join(", ")}`);
|
|
2502
|
-
if (p.taskFieldExtensions.length)
|
|
2503
|
-
lines.push(` task-fields: ${p.taskFieldExtensions.join(", ")}`);
|
|
2504
|
-
if (p.cliCommands.length)
|
|
2505
|
-
lines.push(` cli-commands: ${p.cliCommands.join(", ")}`);
|
|
2506
|
-
for (const line of lines)
|
|
2507
|
-
console.log(line);
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
if (legacyPlugins.length > 0) {
|
|
2511
|
-
console.log("Legacy disk-scan plugins (rig/plugins/):");
|
|
2512
|
-
for (const plugin of legacyPlugins) {
|
|
2513
|
-
const validators = plugin.validators.length > 0 ? plugin.validators.join(", ") : "none";
|
|
2514
|
-
console.log(` ${plugin.name} (validators: ${validators})`);
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
return {
|
|
2519
|
-
ok: true,
|
|
2520
|
-
group: "plugin",
|
|
2521
|
-
command,
|
|
2522
|
-
details: { declarative, legacy: legacyPlugins }
|
|
2523
|
-
};
|
|
2524
|
-
}
|
|
2525
|
-
case "validate": {
|
|
2526
|
-
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
2527
|
-
requireNoExtraArgs(remaining, "rig plugin validate --task <task-id>");
|
|
2528
|
-
const taskId = requireTask(task, "rig plugin validate --task <task-id>");
|
|
2529
|
-
const results = await context.plugins.runValidators(taskId);
|
|
2530
|
-
const passed = results.filter((result) => result.passed).length;
|
|
2531
|
-
const failed = results.length - passed;
|
|
2532
|
-
if (context.outputMode === "text") {
|
|
2533
|
-
if (results.length === 0) {
|
|
2534
|
-
console.log("No plugin validators registered.");
|
|
2535
|
-
} else {
|
|
2536
|
-
for (const result of results) {
|
|
2537
|
-
const icon = result.passed ? "PASS" : "FAIL";
|
|
2538
|
-
console.log(`[${icon}] ${result.id}: ${result.summary}`);
|
|
2539
|
-
if (result.details && !result.passed) {
|
|
2540
|
-
console.log(result.details);
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
|
-
if (failed > 0) {
|
|
2546
|
-
throw new CliError2(`Plugin validation failed for ${failed} validator(s).`, 2);
|
|
2547
|
-
}
|
|
2548
|
-
return {
|
|
2549
|
-
ok: true,
|
|
2550
|
-
group: "plugin",
|
|
2551
|
-
command,
|
|
2552
|
-
details: {
|
|
2553
|
-
taskId,
|
|
2554
|
-
passed,
|
|
2555
|
-
failed,
|
|
2556
|
-
results
|
|
2557
|
-
}
|
|
2558
|
-
};
|
|
2559
|
-
}
|
|
2560
|
-
default:
|
|
2561
|
-
throw new CliError2(`Unknown plugin command: ${command}`);
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2641
|
+
// packages/cli/src/commands.ts
|
|
2642
|
+
init_plugin();
|
|
2564
2643
|
|
|
2565
2644
|
// packages/cli/src/commands/queue.ts
|
|
2645
|
+
init_runner();
|
|
2646
|
+
init__parsers();
|
|
2566
2647
|
import { runPriorityQueue } from "@rig/runtime/control-plane/runtime/queue";
|
|
2567
2648
|
|
|
2568
2649
|
// packages/cli/src/commands/_preflight.ts
|
|
2650
|
+
init_runner();
|
|
2569
2651
|
import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/project-main-pre-run-sync";
|
|
2570
2652
|
|
|
2571
2653
|
// packages/cli/src/commands/_connection-state.ts
|
|
2654
|
+
init_runner();
|
|
2572
2655
|
import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
2573
2656
|
import { homedir as homedir2 } from "os";
|
|
2574
2657
|
import { dirname, resolve as resolve8 } from "path";
|
|
@@ -2671,6 +2754,7 @@ function resolveSelectedConnection(projectRoot, options = {}) {
|
|
|
2671
2754
|
}
|
|
2672
2755
|
|
|
2673
2756
|
// packages/cli/src/commands/_server-client.ts
|
|
2757
|
+
init_runner();
|
|
2674
2758
|
import { existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
|
|
2675
2759
|
import { resolve as resolve9 } from "path";
|
|
2676
2760
|
import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
|
|
@@ -3319,6 +3403,7 @@ async function executeQueue(context, args) {
|
|
|
3319
3403
|
}
|
|
3320
3404
|
|
|
3321
3405
|
// packages/cli/src/commands/agent.ts
|
|
3406
|
+
init_runner();
|
|
3322
3407
|
import { resolve as resolve11 } from "path";
|
|
3323
3408
|
import {
|
|
3324
3409
|
agentId,
|
|
@@ -3426,6 +3511,7 @@ function upsertAgentAuthorityRun(projectRoot, input) {
|
|
|
3426
3511
|
}
|
|
3427
3512
|
|
|
3428
3513
|
// packages/cli/src/commands/agent.ts
|
|
3514
|
+
init__parsers();
|
|
3429
3515
|
function splitAtDoubleDash(args) {
|
|
3430
3516
|
const separatorIndex = args.indexOf("--");
|
|
3431
3517
|
if (separatorIndex === -1) {
|
|
@@ -3659,6 +3745,8 @@ ${result.stderr.trim()}` : ""}`, result.exitCode);
|
|
|
3659
3745
|
}
|
|
3660
3746
|
|
|
3661
3747
|
// packages/cli/src/commands/dist.ts
|
|
3748
|
+
init_runner();
|
|
3749
|
+
init__parsers();
|
|
3662
3750
|
import {
|
|
3663
3751
|
chmodSync,
|
|
3664
3752
|
copyFileSync as copyFileSync2,
|
|
@@ -3976,6 +4064,7 @@ async function executeDist(context, args) {
|
|
|
3976
4064
|
}
|
|
3977
4065
|
|
|
3978
4066
|
// packages/cli/src/commands/inbox.ts
|
|
4067
|
+
init_runner();
|
|
3979
4068
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
3980
4069
|
import { resolve as resolve13 } from "path";
|
|
3981
4070
|
import {
|
|
@@ -4498,6 +4587,7 @@ async function executeInbox(context, args) {
|
|
|
4498
4587
|
}
|
|
4499
4588
|
|
|
4500
4589
|
// packages/cli/src/commands/init.ts
|
|
4590
|
+
init_runner();
|
|
4501
4591
|
import { appendFileSync as appendFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
4502
4592
|
import { spawnSync } from "child_process";
|
|
4503
4593
|
import { resolve as resolve17 } from "path";
|
|
@@ -4773,9 +4863,11 @@ async function uploadSnapshotArchiveViaServer(context, input) {
|
|
|
4773
4863
|
}
|
|
4774
4864
|
|
|
4775
4865
|
// packages/cli/src/commands/_doctor-checks.ts
|
|
4866
|
+
init_runner();
|
|
4776
4867
|
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "fs";
|
|
4777
4868
|
import { resolve as resolve16 } from "path";
|
|
4778
4869
|
import { isSupportedBunVersion, MIN_SUPPORTED_BUN_VERSION } from "@rig/runtime/control-plane/setup-version";
|
|
4870
|
+
init__parsers();
|
|
4779
4871
|
function check(id, label, status, detail, remediation) {
|
|
4780
4872
|
return {
|
|
4781
4873
|
id,
|
|
@@ -5718,6 +5810,7 @@ Usage: rig init`, 1);
|
|
|
5718
5810
|
}
|
|
5719
5811
|
|
|
5720
5812
|
// packages/cli/src/commands/connect.ts
|
|
5813
|
+
init_runner();
|
|
5721
5814
|
import { cancel as cancel2, isCancel as isCancel2, select as select2 } from "@clack/prompts";
|
|
5722
5815
|
function usageName(options) {
|
|
5723
5816
|
return `rig ${options.group}`;
|
|
@@ -5830,6 +5923,7 @@ async function executeConnect(context, args) {
|
|
|
5830
5923
|
}
|
|
5831
5924
|
|
|
5832
5925
|
// packages/cli/src/commands/github.ts
|
|
5926
|
+
init_runner();
|
|
5833
5927
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
5834
5928
|
function printPayload(context, payload, fallback) {
|
|
5835
5929
|
if (context.outputMode === "json")
|
|
@@ -5885,6 +5979,7 @@ async function executeGithub(context, args) {
|
|
|
5885
5979
|
}
|
|
5886
5980
|
|
|
5887
5981
|
// packages/cli/src/commands/doctor.ts
|
|
5982
|
+
init_runner();
|
|
5888
5983
|
async function executeDoctor(context, args) {
|
|
5889
5984
|
requireNoExtraArgs(args, "rig doctor");
|
|
5890
5985
|
const checks = await runRigDoctorChecks({ projectRoot: context.projectRoot });
|
|
@@ -5900,6 +5995,7 @@ async function executeDoctor(context, args) {
|
|
|
5900
5995
|
}
|
|
5901
5996
|
|
|
5902
5997
|
// packages/cli/src/commands/_run-driver-helpers.ts
|
|
5998
|
+
init_runner();
|
|
5903
5999
|
import { readFileSync as readFileSync7 } from "fs";
|
|
5904
6000
|
import { resolve as resolve18 } from "path";
|
|
5905
6001
|
import {
|
|
@@ -6127,6 +6223,7 @@ function renderSourceScopeValidation(task, validation) {
|
|
|
6127
6223
|
}
|
|
6128
6224
|
|
|
6129
6225
|
// packages/cli/src/commands/inspect.ts
|
|
6226
|
+
init_runner();
|
|
6130
6227
|
import { existsSync as existsSync11, readFileSync as readFileSync8 } from "fs";
|
|
6131
6228
|
import { resolve as resolve19 } from "path";
|
|
6132
6229
|
import {
|
|
@@ -6254,6 +6351,8 @@ async function executeInspect(context, args) {
|
|
|
6254
6351
|
}
|
|
6255
6352
|
|
|
6256
6353
|
// packages/cli/src/commands/inspector.ts
|
|
6354
|
+
init_runner();
|
|
6355
|
+
init__parsers();
|
|
6257
6356
|
import { iterateServerSentEvents } from "@rig/client";
|
|
6258
6357
|
import { ensureLocalRigServerConnection as ensureLocalRigServerConnection2 } from "@rig/runtime/local-server";
|
|
6259
6358
|
function formatInspectorStreamLine(payload) {
|
|
@@ -6444,6 +6543,8 @@ async function executeInspector(context, args) {
|
|
|
6444
6543
|
}
|
|
6445
6544
|
|
|
6446
6545
|
// packages/cli/src/commands/remote.ts
|
|
6546
|
+
init_runner();
|
|
6547
|
+
init__parsers();
|
|
6447
6548
|
import {
|
|
6448
6549
|
doctorManagedRemoteEndpoints,
|
|
6449
6550
|
listManagedRemoteEndpoints,
|
|
@@ -6870,6 +6971,8 @@ async function executeRemote(context, args) {
|
|
|
6870
6971
|
}
|
|
6871
6972
|
|
|
6872
6973
|
// packages/cli/src/commands/run.ts
|
|
6974
|
+
init_runner();
|
|
6975
|
+
init__parsers();
|
|
6873
6976
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
6874
6977
|
import {
|
|
6875
6978
|
listAuthorityRuns as listAuthorityRuns3,
|
|
@@ -6887,7 +6990,7 @@ import {
|
|
|
6887
6990
|
startRun,
|
|
6888
6991
|
defaultStartRunOptions
|
|
6889
6992
|
} from "@rig/runtime/control-plane/native/run-ops";
|
|
6890
|
-
import { loadRuntimeContextFromEnv
|
|
6993
|
+
import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
|
|
6891
6994
|
|
|
6892
6995
|
// packages/cli/src/commands/_operator-surface.ts
|
|
6893
6996
|
import { createInterface } from "readline";
|
|
@@ -7854,7 +7957,7 @@ async function promptForEpicSelection(projectRoot, command) {
|
|
|
7854
7957
|
}
|
|
7855
7958
|
async function executeRun(context, args) {
|
|
7856
7959
|
const [command = "status", ...rest] = args;
|
|
7857
|
-
const runtimeContext =
|
|
7960
|
+
const runtimeContext = loadRuntimeContextFromEnv() ?? undefined;
|
|
7858
7961
|
switch (command) {
|
|
7859
7962
|
case "list": {
|
|
7860
7963
|
requireNoExtraArgs(rest, "rig run list");
|
|
@@ -8155,6 +8258,7 @@ async function executeRun(context, args) {
|
|
|
8155
8258
|
}
|
|
8156
8259
|
|
|
8157
8260
|
// packages/cli/src/commands/server.ts
|
|
8261
|
+
init_runner();
|
|
8158
8262
|
async function executeServer(context, args, options) {
|
|
8159
8263
|
const [command = "status", ...rest] = args;
|
|
8160
8264
|
if (["status", "list", "add", "use"].includes(command)) {
|
|
@@ -8256,6 +8360,7 @@ async function executeServer(context, args, options) {
|
|
|
8256
8360
|
}
|
|
8257
8361
|
|
|
8258
8362
|
// packages/cli/src/commands/task.ts
|
|
8363
|
+
init_runner();
|
|
8259
8364
|
import { readFileSync as readFileSync9 } from "fs";
|
|
8260
8365
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
8261
8366
|
import { resolve as resolve20 } from "path";
|
|
@@ -8410,6 +8515,9 @@ var PRIMARY_GROUPS = [
|
|
|
8410
8515
|
{ command: "show <id>|--task <id> [--raw]", description: "Show a human task summary; --raw prints the full payload.", primary: true },
|
|
8411
8516
|
{ command: "run [#<issue>|<task-id>|--next|--task <id>]", description: "Submit a task run; interactive follows with bundled Pi.", primary: true },
|
|
8412
8517
|
{ command: "validate|verify [--task <id>]", description: "Run configured task checks/review gates." },
|
|
8518
|
+
{ command: "details --task <id>", description: "Show full task info from the configured source." },
|
|
8519
|
+
{ command: "reopen [--task <id> | --all] [--reason <text>]", description: "Reopen closed task(s) in the configured source." },
|
|
8520
|
+
{ command: "reset --task <id>", description: "Compatibility spelling of `reopen --task <id>`." },
|
|
8413
8521
|
{ command: "artifacts|artifact-dir|artifact-write", description: "Inspect or write task artifacts." },
|
|
8414
8522
|
{ command: "report-bug", description: "Create a structured bug report/task." }
|
|
8415
8523
|
],
|
|
@@ -8434,6 +8542,8 @@ var PRIMARY_GROUPS = [
|
|
|
8434
8542
|
{ command: "attach <run-id>|--run <id> [--follow]", description: "Attach to the run; --follow launches native bundled Pi for live Pi runs.", primary: true },
|
|
8435
8543
|
{ command: "stop [<run-id>|--run <id>]", description: "Request stop for one run or local active runs.", primary: true },
|
|
8436
8544
|
{ command: "timeline --run <id> [--follow]", description: "Stream raw run timeline events." },
|
|
8545
|
+
{ command: "resume", description: "Resume the most recent interrupted local run." },
|
|
8546
|
+
{ command: "restart", description: "Restart the most recent local run from a clean runtime." },
|
|
8437
8547
|
{ command: "delete|cleanup", description: "Remove completed run records/artifacts." }
|
|
8438
8548
|
],
|
|
8439
8549
|
examples: [
|
|
@@ -8520,8 +8630,28 @@ var ADVANCED_GROUPS = [
|
|
|
8520
8630
|
{ name: "inspect", summary: "Inspect logs, artifacts, graphs, failures.", usage: ["rig inspect <logs|artifacts|failures|graph|audit|diff>"], commands: [{ command: "logs --task <id>", description: "Inspect task logs." }] },
|
|
8521
8631
|
{ name: "repo", summary: "Repository sync/baseline helpers.", usage: ["rig repo <sync|reset-baseline>"], commands: [{ command: "sync", description: "Sync project repository state." }] },
|
|
8522
8632
|
{ name: "profile", summary: "Runtime profile/model defaults.", usage: ["rig profile <show|set>"], commands: [{ command: "show", description: "Show active profile." }] },
|
|
8523
|
-
{
|
|
8524
|
-
|
|
8633
|
+
{
|
|
8634
|
+
name: "browser",
|
|
8635
|
+
summary: "Browser/app diagnostics for browser-required tasks.",
|
|
8636
|
+
usage: ["rig browser <help|explain|demo|app|hp-next> [options]"],
|
|
8637
|
+
commands: [
|
|
8638
|
+
{ command: "help", description: "Rich browser command help (canonical: `rig browser help`)." },
|
|
8639
|
+
{ command: "explain", description: "Explain the browser-required task contract." },
|
|
8640
|
+
{ command: "demo", description: "Run browser demo flows against a local page." },
|
|
8641
|
+
{ command: "app", description: "Launch the Rig Browser workstation app." },
|
|
8642
|
+
{ command: "hp-next <dev|check|e2e|reset>", description: "Drive the hp-next browser test harness." }
|
|
8643
|
+
]
|
|
8644
|
+
},
|
|
8645
|
+
{
|
|
8646
|
+
name: "plugin",
|
|
8647
|
+
summary: "Plugin listing, validation, and plugin-contributed commands.",
|
|
8648
|
+
usage: ["rig plugin <list|validate|run> [options]"],
|
|
8649
|
+
commands: [
|
|
8650
|
+
{ command: "list", description: "List plugins declared in rig.config.ts and their contributions." },
|
|
8651
|
+
{ command: "validate --task <id>", description: "Run plugin-contributed validators for a task." },
|
|
8652
|
+
{ command: "run <command-id> [args...]", description: "Execute a plugin-contributed CLI command (also callable as `rig <command-id>`)." }
|
|
8653
|
+
]
|
|
8654
|
+
},
|
|
8525
8655
|
{ name: "queue", summary: "Run task queues locally.", usage: ["rig queue run [options]"], commands: [{ command: "run", description: "Process queue work." }] },
|
|
8526
8656
|
{ name: "agent", summary: "Runtime agent workspace helpers.", usage: ["rig agent <list|prepare|run|cleanup>"], commands: [{ command: "list", description: "List prepared agents." }] },
|
|
8527
8657
|
{ name: "inspector", summary: "Event stream and drift scanners.", usage: ["rig inspector <stream|scan-upstream-drift>"], commands: [{ command: "stream", description: "Stream events." }] },
|
|
@@ -8536,7 +8666,6 @@ var ADVANCED_COMMANDS = [
|
|
|
8536
8666
|
{ command: "rig server task-run ...", description: "Internal server-owned task execution entry point." },
|
|
8537
8667
|
{ command: "rig server notify-test [--event <type>]", description: "Internal event notification smoke command." },
|
|
8538
8668
|
{ command: "rig run start|start-serial|start-parallel", description: "Compatibility local run starters; prefer `rig task run ...`." },
|
|
8539
|
-
{ command: "rig setup install-agent-shell", description: "Development helper for materializing the agent shell." },
|
|
8540
8669
|
{ command: "rig remote orchestrate-*", description: "Compatibility remote orchestration commands." }
|
|
8541
8670
|
];
|
|
8542
8671
|
var ALL_GROUPS = [...PRIMARY_GROUPS, ...ADVANCED_GROUPS];
|
|
@@ -8676,7 +8805,7 @@ function printGroupHelpDocument(groupName) {
|
|
|
8676
8805
|
}
|
|
8677
8806
|
|
|
8678
8807
|
// packages/cli/src/commands/task.ts
|
|
8679
|
-
import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
|
|
8808
|
+
import { buildPluginHostContext as buildPluginHostContext2 } from "@rig/runtime/control-plane/plugin-host-context";
|
|
8680
8809
|
import { loadConfig } from "@rig/core/load-config";
|
|
8681
8810
|
async function readStdin() {
|
|
8682
8811
|
const chunks = [];
|
|
@@ -8827,7 +8956,7 @@ function summarizeTask(task, options = {}) {
|
|
|
8827
8956
|
};
|
|
8828
8957
|
}
|
|
8829
8958
|
async function validatorRegistryForTaskCommands(projectRoot) {
|
|
8830
|
-
return
|
|
8959
|
+
return buildPluginHostContext2(projectRoot).then((ctx) => ctx?.validatorRegistry ?? undefined).catch(() => {
|
|
8831
8960
|
return;
|
|
8832
8961
|
});
|
|
8833
8962
|
}
|
|
@@ -9131,7 +9260,7 @@ async function executeTask(context, args, options) {
|
|
|
9131
9260
|
await context.runCommand(["rig", "task", "verify", ...task ? ["--task", task] : []]);
|
|
9132
9261
|
return { ok: true, group: "task", command, details: { task: task || "active" } };
|
|
9133
9262
|
}
|
|
9134
|
-
const ok = await withMutedConsole(context.outputMode === "json", () => taskVerify(context.projectRoot,
|
|
9263
|
+
const ok = await withMutedConsole(context.outputMode === "json", () => taskVerify(context.projectRoot, task || undefined));
|
|
9135
9264
|
if (!ok) {
|
|
9136
9265
|
throw new CliError2(`Verification rejected for ${task || "active task"}.`, 2);
|
|
9137
9266
|
}
|
|
@@ -9141,8 +9270,12 @@ async function executeTask(context, args, options) {
|
|
|
9141
9270
|
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
9142
9271
|
requireNoExtraArgs(remaining, "rig task reset --task <task-id>");
|
|
9143
9272
|
const requiredTask = requireTask(task, "rig task reset --task <task-id>");
|
|
9144
|
-
|
|
9145
|
-
|
|
9273
|
+
const summary = withMutedConsole(context.outputMode === "json", () => taskReopen(context.projectRoot, {
|
|
9274
|
+
all: false,
|
|
9275
|
+
taskId: requiredTask,
|
|
9276
|
+
dryRun: false
|
|
9277
|
+
}));
|
|
9278
|
+
return { ok: true, group: "task", command, details: summary };
|
|
9146
9279
|
}
|
|
9147
9280
|
case "details": {
|
|
9148
9281
|
const { value: task, rest: remaining } = takeOption(rest, "--task");
|
|
@@ -9172,6 +9305,7 @@ async function executeTask(context, args, options) {
|
|
|
9172
9305
|
}
|
|
9173
9306
|
|
|
9174
9307
|
// packages/cli/src/commands/task-run-driver.ts
|
|
9308
|
+
init_runner();
|
|
9175
9309
|
import { copyFileSync as copyFileSync3, existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync10, statSync as statSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
9176
9310
|
import { resolve as resolve21 } from "path";
|
|
9177
9311
|
import { spawn as spawn2, spawnSync as spawnSync4 } from "child_process";
|
|
@@ -11188,6 +11322,7 @@ Failed to update task source for ${input.taskId ?? runtimeTaskId} to failed: ${e
|
|
|
11188
11322
|
}
|
|
11189
11323
|
|
|
11190
11324
|
// packages/cli/src/commands/test.ts
|
|
11325
|
+
init_runner();
|
|
11191
11326
|
async function executeTest(context, args) {
|
|
11192
11327
|
const [command = "unit", ...rest] = args;
|
|
11193
11328
|
switch (command) {
|
|
@@ -11209,6 +11344,7 @@ async function executeTest(context, args) {
|
|
|
11209
11344
|
}
|
|
11210
11345
|
|
|
11211
11346
|
// packages/cli/src/commands/setup.ts
|
|
11347
|
+
init_runner();
|
|
11212
11348
|
import { existsSync as existsSync13, mkdirSync as mkdirSync9, readdirSync as readdirSync2, writeFileSync as writeFileSync7 } from "fs";
|
|
11213
11349
|
import { resolve as resolve22 } from "path";
|
|
11214
11350
|
import { createPluginHost } from "@rig/core";
|
|
@@ -11216,6 +11352,7 @@ import {
|
|
|
11216
11352
|
isSupportedBunVersion as isSupportedBunVersion2,
|
|
11217
11353
|
MIN_SUPPORTED_BUN_VERSION as MIN_SUPPORTED_BUN_VERSION2
|
|
11218
11354
|
} from "@rig/runtime/control-plane/setup-version";
|
|
11355
|
+
init__parsers();
|
|
11219
11356
|
async function executeSetup(context, args) {
|
|
11220
11357
|
const [command = "check", ...rest] = args;
|
|
11221
11358
|
switch (command) {
|
|
@@ -11256,12 +11393,6 @@ async function executeSetup(context, args) {
|
|
|
11256
11393
|
requireNoExtraArgs(rest, "rig setup preflight");
|
|
11257
11394
|
await withMutedConsole(context.outputMode === "json", () => runSetupPreflight(context.projectRoot));
|
|
11258
11395
|
return { ok: true, group: "setup", command };
|
|
11259
|
-
case "install-agent-shell":
|
|
11260
|
-
requireNoExtraArgs(rest, "rig setup install-agent-shell");
|
|
11261
|
-
if (context.outputMode === "text") {
|
|
11262
|
-
console.log("install-agent-shell is deprecated. Runtime shells now use compiled rig-agent directly.");
|
|
11263
|
-
}
|
|
11264
|
-
return { ok: true, group: "setup", command };
|
|
11265
11396
|
default:
|
|
11266
11397
|
throw new CliError2(`Unknown setup command: ${command}`);
|
|
11267
11398
|
}
|
|
@@ -11312,6 +11443,7 @@ async function runSetupPreflight(projectRoot) {
|
|
|
11312
11443
|
}
|
|
11313
11444
|
|
|
11314
11445
|
// packages/cli/src/commands/workspace.ts
|
|
11446
|
+
init_runner();
|
|
11315
11447
|
import {
|
|
11316
11448
|
mutateWorkspaceServiceFabric,
|
|
11317
11449
|
readWorkspaceRemoteFleet,
|
|
@@ -11403,7 +11535,6 @@ var TOP_LEVEL_ALIASES = {
|
|
|
11403
11535
|
check: ["setup", "check"],
|
|
11404
11536
|
preflight: ["setup", "preflight"],
|
|
11405
11537
|
install: ["dist", "install"],
|
|
11406
|
-
"install-shell": ["setup", "install-agent-shell"],
|
|
11407
11538
|
status: ["run", "status"],
|
|
11408
11539
|
start: ["task", "run", "--next"],
|
|
11409
11540
|
"start-parallel": ["run", "start-parallel"],
|
|
@@ -11436,6 +11567,30 @@ var TOP_LEVEL_ALIASES = {
|
|
|
11436
11567
|
"remote-watch": ["remote", "watch"],
|
|
11437
11568
|
doctor: ["doctor", "check"]
|
|
11438
11569
|
};
|
|
11570
|
+
var PROJECT_REQUIRED_GROUPS = new Set([
|
|
11571
|
+
"task",
|
|
11572
|
+
"run",
|
|
11573
|
+
"inbox",
|
|
11574
|
+
"review",
|
|
11575
|
+
"queue",
|
|
11576
|
+
"agent",
|
|
11577
|
+
"repo",
|
|
11578
|
+
"inspect"
|
|
11579
|
+
]);
|
|
11580
|
+
var RIG_CONFIG_FILENAMES = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
11581
|
+
function hasInitializedRigProject(projectRoot) {
|
|
11582
|
+
return RIG_CONFIG_FILENAMES.some((name) => existsSync14(resolve23(projectRoot, name))) || existsSync14(resolve23(projectRoot, ".rig"));
|
|
11583
|
+
}
|
|
11584
|
+
function requireInitializedRigProject(context, group) {
|
|
11585
|
+
if (hasInitializedRigProject(context.projectRoot)) {
|
|
11586
|
+
return;
|
|
11587
|
+
}
|
|
11588
|
+
throw new CliError2([
|
|
11589
|
+
`No Rig project found at ${context.projectRoot} (expected rig.config.ts or a .rig/ state directory).`,
|
|
11590
|
+
"Run `rig init` to set up this repo, or pass --project <path> to point at an existing Rig project."
|
|
11591
|
+
].join(`
|
|
11592
|
+
`), 2);
|
|
11593
|
+
}
|
|
11439
11594
|
var GROUPS = new Set([
|
|
11440
11595
|
"init",
|
|
11441
11596
|
"setup",
|
|
@@ -11533,10 +11688,28 @@ ${helpText()}`);
|
|
|
11533
11688
|
}
|
|
11534
11689
|
return executeGroup(context, group, [command, ...aliasArgs, ...rest]);
|
|
11535
11690
|
}
|
|
11691
|
+
if (await matchesPluginCliCommand(context, first)) {
|
|
11692
|
+
return executeGroup(context, "plugin", ["run", first, ...rest]);
|
|
11693
|
+
}
|
|
11536
11694
|
throw new CliError2(`Unknown group or command: ${first}
|
|
11537
11695
|
|
|
11538
11696
|
${helpText()}`);
|
|
11539
11697
|
}
|
|
11698
|
+
async function matchesPluginCliCommand(context, requested) {
|
|
11699
|
+
if (!hasInitializedRigProject(context.projectRoot)) {
|
|
11700
|
+
return false;
|
|
11701
|
+
}
|
|
11702
|
+
try {
|
|
11703
|
+
const { buildPluginHostContext: buildPluginHostContext3 } = await import("@rig/runtime/control-plane/plugin-host-context");
|
|
11704
|
+
const hostCtx = await buildPluginHostContext3(context.projectRoot);
|
|
11705
|
+
if (!hostCtx)
|
|
11706
|
+
return false;
|
|
11707
|
+
const { resolvePluginCliCommand: resolvePluginCliCommand2 } = await Promise.resolve().then(() => (init_plugin(), exports_plugin));
|
|
11708
|
+
return Boolean(resolvePluginCliCommand2(hostCtx.pluginHost.listCliCommands(), requested));
|
|
11709
|
+
} catch {
|
|
11710
|
+
return false;
|
|
11711
|
+
}
|
|
11712
|
+
}
|
|
11540
11713
|
var GROUPS_WITH_CUSTOM_HELP = new Set(["browser"]);
|
|
11541
11714
|
async function executeGroup(context, group, args) {
|
|
11542
11715
|
if (isHelpArg(args[0]) && !GROUPS_WITH_CUSTOM_HELP.has(group)) {
|
|
@@ -11545,6 +11718,9 @@ async function executeGroup(context, group, args) {
|
|
|
11545
11718
|
}
|
|
11546
11719
|
return { ok: true, group, command: "help" };
|
|
11547
11720
|
}
|
|
11721
|
+
if (PROJECT_REQUIRED_GROUPS.has(group)) {
|
|
11722
|
+
requireInitializedRigProject(context, group);
|
|
11723
|
+
}
|
|
11548
11724
|
switch (group) {
|
|
11549
11725
|
case "setup":
|
|
11550
11726
|
return executeSetup(context, args);
|
|
@@ -11599,8 +11775,8 @@ async function executeGroup(context, group, args) {
|
|
|
11599
11775
|
}
|
|
11600
11776
|
}
|
|
11601
11777
|
// packages/cli/src/launcher.ts
|
|
11602
|
-
import { existsSync as
|
|
11603
|
-
import { basename as basename2, resolve as
|
|
11778
|
+
import { existsSync as existsSync15 } from "fs";
|
|
11779
|
+
import { basename as basename2, resolve as resolve24 } from "path";
|
|
11604
11780
|
import { loadDotEnvSecrets } from "@rig/runtime/baked-secrets";
|
|
11605
11781
|
import { RIG_DEFINITION_DIRNAME, RIG_STATE_DIRNAME, resolveNearestRigProjectRoot } from "@rig/runtime/layout";
|
|
11606
11782
|
function parsePolicyMode(value) {
|
|
@@ -11613,7 +11789,7 @@ function parsePolicyMode(value) {
|
|
|
11613
11789
|
throw new Error(`Invalid --policy-mode value: ${value}. Use off|observe|enforce.`);
|
|
11614
11790
|
}
|
|
11615
11791
|
function hasRigProjectMarker(candidate) {
|
|
11616
|
-
return
|
|
11792
|
+
return existsSync15(resolve24(candidate, RIG_DEFINITION_DIRNAME)) || existsSync15(resolve24(candidate, RIG_STATE_DIRNAME)) || existsSync15(resolve24(candidate, "rig.config.ts")) || existsSync15(resolve24(candidate, "rig.config.json")) || existsSync15(resolve24(candidate, ".git"));
|
|
11617
11793
|
}
|
|
11618
11794
|
function resolveProjectRoot({
|
|
11619
11795
|
envProjectRoot,
|
|
@@ -11622,19 +11798,19 @@ function resolveProjectRoot({
|
|
|
11622
11798
|
cwd = process.cwd()
|
|
11623
11799
|
}) {
|
|
11624
11800
|
if (envProjectRoot) {
|
|
11625
|
-
return
|
|
11801
|
+
return resolve24(cwd, envProjectRoot);
|
|
11626
11802
|
}
|
|
11627
11803
|
const fallbackImportDir = importDir ?? cwd;
|
|
11628
11804
|
const execName = basename2(execPath).toLowerCase();
|
|
11629
|
-
const execCandidates = execName === "rig" || execName === "rig.exe" ? [
|
|
11630
|
-
const candidates = [cwd, ...execCandidates,
|
|
11805
|
+
const execCandidates = execName === "rig" || execName === "rig.exe" ? [resolve24(execPath, "..", "..")] : [];
|
|
11806
|
+
const candidates = [cwd, ...execCandidates, resolve24(fallbackImportDir, "..")];
|
|
11631
11807
|
for (const candidate of candidates) {
|
|
11632
11808
|
const nearest = resolveNearestRigProjectRoot(candidate);
|
|
11633
11809
|
if (hasRigProjectMarker(nearest)) {
|
|
11634
11810
|
return nearest;
|
|
11635
11811
|
}
|
|
11636
11812
|
}
|
|
11637
|
-
return
|
|
11813
|
+
return resolve24(cwd);
|
|
11638
11814
|
}
|
|
11639
11815
|
function normalizeCliErrorCode(message2, isCliError) {
|
|
11640
11816
|
if (message2.startsWith("Invalid --policy-mode value:")) {
|
|
@@ -11701,7 +11877,7 @@ async function runRigCli(module, options = {}) {
|
|
|
11701
11877
|
runId: context.runId,
|
|
11702
11878
|
outcome,
|
|
11703
11879
|
eventsFile: context.eventBus.getEventsFile(),
|
|
11704
|
-
policyFile:
|
|
11880
|
+
policyFile: resolve24(projectRoot, "rig", "policy", "policy.json"),
|
|
11705
11881
|
policyMode: context.policyMode ?? policyMode ?? module.loadPolicy(projectRoot).mode
|
|
11706
11882
|
}, null, 2));
|
|
11707
11883
|
}
|
|
@@ -11723,6 +11899,10 @@ function hydrateProcessEnvFromDotEnv(projectRoot) {
|
|
|
11723
11899
|
}
|
|
11724
11900
|
}
|
|
11725
11901
|
}
|
|
11902
|
+
|
|
11903
|
+
// packages/cli/src/index.ts
|
|
11904
|
+
init_runner();
|
|
11905
|
+
|
|
11726
11906
|
// packages/cli/bin/rig.ts
|
|
11727
11907
|
var rigCliModule = {
|
|
11728
11908
|
CliError: CliError2,
|