@h-rig/cli 0.0.6-alpha.2 → 0.0.6-alpha.200

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.
Files changed (47) hide show
  1. package/README.md +6 -28
  2. package/package.json +9 -27
  3. package/dist/bin/build-rig-binaries.js +0 -107
  4. package/dist/bin/rig.js +0 -9470
  5. package/dist/src/commands/_authority-runs.js +0 -110
  6. package/dist/src/commands/_connection-state.js +0 -123
  7. package/dist/src/commands/_doctor-checks.js +0 -519
  8. package/dist/src/commands/_operator-view.js +0 -340
  9. package/dist/src/commands/_parsers.js +0 -107
  10. package/dist/src/commands/_paths.js +0 -50
  11. package/dist/src/commands/_pi-install.js +0 -184
  12. package/dist/src/commands/_policy.js +0 -79
  13. package/dist/src/commands/_preflight.js +0 -478
  14. package/dist/src/commands/_probes.js +0 -13
  15. package/dist/src/commands/_run-driver-helpers.js +0 -289
  16. package/dist/src/commands/_server-client.js +0 -382
  17. package/dist/src/commands/_snapshot-upload.js +0 -331
  18. package/dist/src/commands/_task-picker.js +0 -48
  19. package/dist/src/commands/agent.js +0 -497
  20. package/dist/src/commands/browser.js +0 -890
  21. package/dist/src/commands/connect.js +0 -180
  22. package/dist/src/commands/dist.js +0 -402
  23. package/dist/src/commands/doctor.js +0 -529
  24. package/dist/src/commands/github.js +0 -294
  25. package/dist/src/commands/inbox.js +0 -160
  26. package/dist/src/commands/init.js +0 -1334
  27. package/dist/src/commands/inspect.js +0 -174
  28. package/dist/src/commands/inspector.js +0 -256
  29. package/dist/src/commands/plugin.js +0 -167
  30. package/dist/src/commands/profile-and-review.js +0 -178
  31. package/dist/src/commands/queue.js +0 -197
  32. package/dist/src/commands/remote.js +0 -507
  33. package/dist/src/commands/repo-git-harness.js +0 -221
  34. package/dist/src/commands/run.js +0 -771
  35. package/dist/src/commands/server.js +0 -386
  36. package/dist/src/commands/setup.js +0 -699
  37. package/dist/src/commands/task-report-bug.js +0 -1083
  38. package/dist/src/commands/task-run-driver.js +0 -1994
  39. package/dist/src/commands/task.js +0 -1343
  40. package/dist/src/commands/test.js +0 -39
  41. package/dist/src/commands/workspace.js +0 -123
  42. package/dist/src/commands.js +0 -9152
  43. package/dist/src/index.js +0 -9488
  44. package/dist/src/launcher.js +0 -131
  45. package/dist/src/report-bug.js +0 -260
  46. package/dist/src/runner.js +0 -272
  47. package/dist/src/withMutedConsole.js +0 -42
@@ -1,174 +0,0 @@
1
- // @bun
2
- // packages/cli/src/commands/inspect.ts
3
- import { existsSync, readFileSync } from "fs";
4
- import { resolve } from "path";
5
-
6
- // packages/cli/src/runner.ts
7
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
8
- import { CliError } from "@rig/runtime/control-plane/errors";
9
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
10
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
11
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
12
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
13
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
14
- function takeOption(args, option) {
15
- const rest = [];
16
- let value;
17
- for (let index = 0;index < args.length; index += 1) {
18
- const current = args[index];
19
- if (current === option) {
20
- const next = args[index + 1];
21
- if (!next || next.startsWith("-")) {
22
- throw new CliError(`Missing value for ${option}`);
23
- }
24
- value = next;
25
- index += 1;
26
- continue;
27
- }
28
- if (current !== undefined) {
29
- rest.push(current);
30
- }
31
- }
32
- return { value, rest };
33
- }
34
- function requireNoExtraArgs(args, usage) {
35
- if (args.length > 0) {
36
- throw new CliError(`Unexpected arguments: ${args.join(" ")}
37
- Usage: ${usage}`);
38
- }
39
- }
40
- function requireTask(taskId, usage) {
41
- if (!taskId) {
42
- throw new CliError(`Missing --task option.
43
- Usage: ${usage}`);
44
- }
45
- return taskId;
46
- }
47
-
48
- // packages/cli/src/commands/inspect.ts
49
- import {
50
- listAuthorityRuns,
51
- readAuthorityRun,
52
- resolveAuthorityRunDir,
53
- resolveTaskArtifactDirs
54
- } from "@rig/runtime/control-plane/authority-files";
55
- import { changedFilesForTask } from "@rig/runtime/control-plane/native/task-ops";
56
- import { resolveHarnessPaths, resolveMonorepoRoot, runCapture } from "@rig/runtime/control-plane/native/utils";
57
- import { readTaskArtifactPreview } from "@rig/runtime/control-plane/native/workspace-ops";
58
- async function executeInspect(context, args) {
59
- const [command = "failures", ...rest] = args;
60
- switch (command) {
61
- case "logs": {
62
- const { value: task, rest: remaining } = takeOption(rest, "--task");
63
- requireNoExtraArgs(remaining, "bun run rig inspect logs --task <beads-id>");
64
- const requiredTask = requireTask(task, "bun run rig inspect logs --task <beads-id>");
65
- const latestRun = listAuthorityRuns(context.projectRoot).map((entry) => readAuthorityRun(context.projectRoot, entry.runId)).filter((run) => Boolean(run)).filter((run) => run.taskId === requiredTask).sort((left, right) => String(right.updatedAt ?? "").localeCompare(String(left.updatedAt ?? "")))[0];
66
- if (!latestRun) {
67
- throw new CliError2(`No runs found for ${requiredTask}.`);
68
- }
69
- const logsPath = resolve(resolveAuthorityRunDir(context.projectRoot, latestRun.runId), "logs.jsonl");
70
- if (!existsSync(logsPath)) {
71
- throw new CliError2(`No logs found for run ${latestRun.runId}.`);
72
- }
73
- await context.runCommand(["cat", logsPath]);
74
- return { ok: true, group: "inspect", command, details: { task: requiredTask, runId: latestRun.runId } };
75
- }
76
- case "artifacts": {
77
- const { value: task, rest: remaining } = takeOption(rest, "--task");
78
- requireNoExtraArgs(remaining, "bun run rig inspect artifacts --task <beads-id>");
79
- const requiredTask = requireTask(task, "bun run rig inspect artifacts --task <beads-id>");
80
- const artifactRoot = resolveTaskArtifactDirs(context.projectRoot, requiredTask).find((path) => existsSync(path));
81
- if (!artifactRoot) {
82
- throw new CliError2(`No artifacts found for ${requiredTask}.`);
83
- }
84
- await context.runCommand(["ls", "-la", artifactRoot]);
85
- return { ok: true, group: "inspect", command, details: { task: requiredTask } };
86
- }
87
- case "artifact": {
88
- let previewPending = rest;
89
- const task = takeOption(previewPending, "--task");
90
- previewPending = task.rest;
91
- const file = takeOption(previewPending, "--file");
92
- previewPending = file.rest;
93
- requireNoExtraArgs(previewPending, "bun run rig inspect artifact --task <beads-id> --file <name>");
94
- const requiredTask = requireTask(task.value, "bun run rig inspect artifact --task <beads-id> --file <name>");
95
- if (!file.value) {
96
- throw new CliError2("Missing --file for rig inspect artifact.");
97
- }
98
- const preview = readTaskArtifactPreview(context.projectRoot, requiredTask, file.value);
99
- if (context.outputMode === "text") {
100
- console.log(preview.contents);
101
- if (preview.truncated) {
102
- console.log(`
103
- [preview truncated at ${preview.maxBytes} bytes of ${preview.sizeBytes}]`);
104
- }
105
- }
106
- return {
107
- ok: true,
108
- group: "inspect",
109
- command,
110
- details: {
111
- task: requiredTask,
112
- fileName: file.value,
113
- path: preview.path,
114
- sizeBytes: preview.sizeBytes,
115
- truncated: preview.truncated,
116
- maxBytes: preview.maxBytes,
117
- contents: context.outputMode === "json" ? preview.contents : null
118
- }
119
- };
120
- }
121
- case "diff": {
122
- const { value: task, rest: remaining } = takeOption(rest, "--task");
123
- requireNoExtraArgs(remaining, "bun run rig inspect diff [--task <beads-id>]");
124
- if (task) {
125
- const files = changedFilesForTask(context.projectRoot, task, false);
126
- for (const file of files) {
127
- console.log(file);
128
- }
129
- } else {
130
- await context.runCommand(["git", "diff", "--stat"]);
131
- }
132
- return { ok: true, group: "inspect", command, details: { task: task || null } };
133
- }
134
- case "failures": {
135
- requireNoExtraArgs(rest, "bun run rig inspect failures");
136
- const failed = resolveHarnessPaths(context.projectRoot).failedApproachesPath;
137
- if (!existsSync(failed)) {
138
- console.log("No failures recorded.");
139
- } else {
140
- process.stdout.write(readFileSync(failed, "utf-8"));
141
- }
142
- return { ok: true, group: "inspect", command };
143
- }
144
- case "graph":
145
- requireNoExtraArgs(rest, "bun run rig inspect graph");
146
- {
147
- const monorepoRoot = resolveMonorepoRoot(context.projectRoot);
148
- const result = runCapture(["br", "--no-db", "list", "--pretty"], monorepoRoot);
149
- if (result.exitCode !== 0) {
150
- throw new CliError2(result.stderr || result.stdout || "Failed to inspect graph");
151
- }
152
- process.stdout.write(result.stdout);
153
- }
154
- return { ok: true, group: "inspect", command };
155
- case "audit": {
156
- requireNoExtraArgs(rest, "bun run rig inspect audit");
157
- const auditPath = resolve(resolveHarnessPaths(context.projectRoot).logsDir, "audit.jsonl");
158
- if (!existsSync(auditPath)) {
159
- console.log("No audit log found.");
160
- } else {
161
- const lines = readFileSync(auditPath, "utf-8").split(/\r?\n/).filter(Boolean).slice(-20);
162
- for (const line of lines) {
163
- console.log(line);
164
- }
165
- }
166
- return { ok: true, group: "inspect", command };
167
- }
168
- default:
169
- throw new CliError2(`Unknown inspect command: ${command}`);
170
- }
171
- }
172
- export {
173
- executeInspect
174
- };
@@ -1,256 +0,0 @@
1
- // @bun
2
- // packages/cli/src/commands/inspector.ts
3
- import { iterateServerSentEvents } from "@rig/client";
4
-
5
- // packages/cli/src/runner.ts
6
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
7
- import { CliError } from "@rig/runtime/control-plane/errors";
8
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
9
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
10
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
11
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
12
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
13
- function takeFlag(args, flag) {
14
- const rest = [];
15
- let value = false;
16
- for (const arg of args) {
17
- if (arg === flag) {
18
- value = true;
19
- continue;
20
- }
21
- rest.push(arg);
22
- }
23
- return { value, rest };
24
- }
25
- function takeOption(args, option) {
26
- const rest = [];
27
- let value;
28
- for (let index = 0;index < args.length; index += 1) {
29
- const current = args[index];
30
- if (current === option) {
31
- const next = args[index + 1];
32
- if (!next || next.startsWith("-")) {
33
- throw new CliError(`Missing value for ${option}`);
34
- }
35
- value = next;
36
- index += 1;
37
- continue;
38
- }
39
- if (current !== undefined) {
40
- rest.push(current);
41
- }
42
- }
43
- return { value, rest };
44
- }
45
- function requireNoExtraArgs(args, usage) {
46
- if (args.length > 0) {
47
- throw new CliError(`Unexpected arguments: ${args.join(" ")}
48
- Usage: ${usage}`);
49
- }
50
- }
51
-
52
- // packages/cli/src/commands/inspector.ts
53
- import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
54
-
55
- // packages/cli/src/commands/_parsers.ts
56
- function parseRequiredPositiveInt(value, option) {
57
- if (!value) {
58
- throw new CliError2(`Missing value for ${option}.`);
59
- }
60
- const parsed = Number.parseInt(value, 10);
61
- if (!Number.isFinite(parsed) || parsed <= 0) {
62
- throw new CliError2(`Invalid ${option} value: ${value}`);
63
- }
64
- return parsed;
65
- }
66
-
67
- // packages/cli/src/commands/inspector.ts
68
- function formatInspectorStreamLine(payload) {
69
- const emittedAt = payload.emittedAt ?? new Date().toISOString();
70
- const agentStatus = String(payload.agent?.status ?? "unknown");
71
- const queueDepth = Number(payload.agent?.queueDepth ?? 0);
72
- const activeRuns = Array.isArray(payload.snapshot?.activeRuns) ? payload.snapshot?.activeRuns.length : 0;
73
- const lines = [
74
- `[${emittedAt}] seq=${String(payload.sequence ?? "?")} agent=${agentStatus} queue=${queueDepth} activeRuns=${activeRuns}`
75
- ];
76
- const lastAssistantMessage = payload.agent?.lastAssistantMessage?.trim();
77
- if (lastAssistantMessage) {
78
- lines.push(` assistant: ${lastAssistantMessage.split(`
79
- `)[0].slice(0, 240)}`);
80
- }
81
- const recentProtocol = payload.agent?.recentProtocolEvents;
82
- const latestProtocol = Array.isArray(recentProtocol) && recentProtocol.length > 0 ? recentProtocol[recentProtocol.length - 1] : null;
83
- if (latestProtocol?.method) {
84
- lines.push(` protocol: ${String(latestProtocol.direction ?? "recv")} ${String(latestProtocol.kind ?? "notification")} ${latestProtocol.method}`);
85
- }
86
- const finding = Array.isArray(payload.journal?.recentFindings) && payload.journal?.recentFindings.length > 0 ? payload.journal?.recentFindings[0] : null;
87
- if (finding?.summary) {
88
- lines.push(` finding: ${String(finding.source ?? "journal")} \xB7 ${finding.summary}`);
89
- }
90
- const action = Array.isArray(payload.journal?.recentActions) && payload.journal?.recentActions.length > 0 ? payload.journal?.recentActions[0] : null;
91
- if (action?.actionType) {
92
- lines.push(` action: ${action.actionType} (${String(action.status ?? "unknown")})${action.target ? ` -> ${action.target}` : ""}`);
93
- }
94
- return lines;
95
- }
96
- async function executeInspector(context, args) {
97
- const [command = "stream", ...rest] = args;
98
- switch (command) {
99
- case "stream": {
100
- let pending = rest;
101
- const onceResult = takeFlag(pending, "--once");
102
- pending = onceResult.rest;
103
- const secondsResult = takeOption(pending, "--seconds");
104
- pending = secondsResult.rest;
105
- const pollMsResult = takeOption(pending, "--poll-ms");
106
- pending = pollMsResult.rest;
107
- requireNoExtraArgs(pending, "bun run rig inspector stream [--once] [--seconds <n>] [--poll-ms <n>]");
108
- const seconds = secondsResult.value ? parseRequiredPositiveInt(secondsResult.value, "--seconds") : null;
109
- const pollMs = pollMsResult.value ? parseRequiredPositiveInt(pollMsResult.value, "--poll-ms") : null;
110
- if (context.outputMode === "json" && !onceResult.value && !seconds) {
111
- throw new CliError2("--json inspector stream requires --once or --seconds <n>.", 2);
112
- }
113
- const connection = await ensureLocalRigServerConnection(context.projectRoot);
114
- const streamUrl = new URL("/api/inspector/stream", connection.baseUrl);
115
- if (onceResult.value) {
116
- streamUrl.searchParams.set("once", "1");
117
- }
118
- if (pollMs) {
119
- streamUrl.searchParams.set("pollMs", String(pollMs));
120
- }
121
- const controller = new AbortController;
122
- const deadline = seconds ? setTimeout(() => controller.abort(), seconds * 1000) : null;
123
- let interrupted = false;
124
- const onSignal = () => {
125
- interrupted = true;
126
- controller.abort();
127
- };
128
- if (!onceResult.value) {
129
- process.once("SIGINT", onSignal);
130
- process.once("SIGTERM", onSignal);
131
- }
132
- try {
133
- const response = await fetch(streamUrl, {
134
- headers: connection.authToken ? { authorization: `Bearer ${connection.authToken}` } : undefined,
135
- signal: controller.signal
136
- });
137
- if (!response.ok) {
138
- throw new CliError2(`Inspector stream request failed (${response.status}).`, response.status);
139
- }
140
- let received = 0;
141
- let lastEvent = null;
142
- for await (const event of iterateServerSentEvents(response)) {
143
- const payload = JSON.parse(event.data);
144
- lastEvent = { event: event.event, payload };
145
- received += 1;
146
- if (context.outputMode === "text" && event.event === "snapshot") {
147
- for (const line of formatInspectorStreamLine(payload)) {
148
- console.log(line);
149
- }
150
- } else if (context.outputMode === "text") {
151
- console.log(`[inspector:${event.event}] ${event.data}`);
152
- }
153
- if (onceResult.value) {
154
- break;
155
- }
156
- }
157
- return {
158
- ok: true,
159
- group: "inspector",
160
- command,
161
- details: {
162
- streamUrl: streamUrl.toString(),
163
- received,
164
- interrupted,
165
- once: onceResult.value,
166
- seconds,
167
- lastEvent
168
- }
169
- };
170
- } catch (error) {
171
- if (controller.signal.aborted && !onceResult.value) {
172
- return {
173
- ok: true,
174
- group: "inspector",
175
- command,
176
- details: {
177
- streamUrl: streamUrl.toString(),
178
- received: 0,
179
- interrupted: true,
180
- once: onceResult.value,
181
- seconds,
182
- lastEvent: null
183
- }
184
- };
185
- }
186
- throw error;
187
- } finally {
188
- if (deadline) {
189
- clearTimeout(deadline);
190
- }
191
- if (!onceResult.value) {
192
- process.off("SIGINT", onSignal);
193
- process.off("SIGTERM", onSignal);
194
- }
195
- }
196
- }
197
- case "scan-upstream-drift": {
198
- let pending = rest;
199
- const scanIdResult = takeOption(pending, "--scan-id");
200
- pending = scanIdResult.rest;
201
- requireNoExtraArgs(pending, "bun run rig inspector scan-upstream-drift [--scan-id <id>]");
202
- const connection = await ensureLocalRigServerConnection(context.projectRoot);
203
- const response = await fetch(new URL("/api/inspector/tools/invoke", connection.baseUrl), {
204
- method: "POST",
205
- headers: {
206
- "content-type": "application/json",
207
- ...connection.authToken ? { authorization: `Bearer ${connection.authToken}` } : {}
208
- },
209
- body: JSON.stringify({
210
- name: "scan_upstream_drift",
211
- input: scanIdResult.value ? { scanId: scanIdResult.value } : {}
212
- })
213
- });
214
- if (!response.ok) {
215
- throw new CliError2(`Upstream drift scan request failed (${response.status}).`, response.status);
216
- }
217
- const result = await response.json();
218
- if (context.outputMode === "text") {
219
- console.log(String(result.summary ?? "Upstream drift scan completed"));
220
- const details = result.details;
221
- if (details && typeof details === "object" && !Array.isArray(details)) {
222
- const record = details;
223
- if (typeof record.scannedCommitCount === "number") {
224
- console.log(` scanned commits: ${record.scannedCommitCount}`);
225
- }
226
- if (typeof record.ignoredCommitCount === "number") {
227
- console.log(` ignored commits: ${record.ignoredCommitCount}`);
228
- }
229
- if (typeof record.followupCount === "number") {
230
- console.log(` follow-up tasks: ${record.followupCount}`);
231
- }
232
- if (Array.isArray(record.createdTaskIds) && record.createdTaskIds.length > 0) {
233
- console.log(` created tasks: ${record.createdTaskIds.join(", ")}`);
234
- }
235
- if (typeof record.latestHeadSha === "string" && record.latestHeadSha.length > 0) {
236
- console.log(` latest upstream head: ${record.latestHeadSha}`);
237
- }
238
- }
239
- }
240
- return {
241
- ok: true,
242
- group: "inspector",
243
- command,
244
- details: {
245
- scanId: scanIdResult.value ?? null,
246
- result
247
- }
248
- };
249
- }
250
- default:
251
- throw new CliError2(`Unknown inspector command: ${command}`);
252
- }
253
- }
254
- export {
255
- executeInspector
256
- };
@@ -1,167 +0,0 @@
1
- // @bun
2
- var __require = import.meta.require;
3
-
4
- // packages/cli/src/runner.ts
5
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
6
- import { CliError } from "@rig/runtime/control-plane/errors";
7
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
8
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
9
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
10
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
11
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
12
- function takeOption(args, option) {
13
- const rest = [];
14
- let value;
15
- for (let index = 0;index < args.length; index += 1) {
16
- const current = args[index];
17
- if (current === option) {
18
- const next = args[index + 1];
19
- if (!next || next.startsWith("-")) {
20
- throw new CliError(`Missing value for ${option}`);
21
- }
22
- value = next;
23
- index += 1;
24
- continue;
25
- }
26
- if (current !== undefined) {
27
- rest.push(current);
28
- }
29
- }
30
- return { value, rest };
31
- }
32
- function requireNoExtraArgs(args, usage) {
33
- if (args.length > 0) {
34
- throw new CliError(`Unexpected arguments: ${args.join(" ")}
35
- Usage: ${usage}`);
36
- }
37
- }
38
- function requireTask(taskId, usage) {
39
- if (!taskId) {
40
- throw new CliError(`Missing --task option.
41
- Usage: ${usage}`);
42
- }
43
- return taskId;
44
- }
45
-
46
- // packages/cli/src/commands/_parsers.ts
47
- async function loadRigConfigOrNull(projectRoot) {
48
- try {
49
- const { loadConfig } = await import("@rig/core/load-config");
50
- return await loadConfig(projectRoot);
51
- } catch {
52
- return null;
53
- }
54
- }
55
-
56
- // packages/cli/src/commands/plugin.ts
57
- async function executePlugin(context, args) {
58
- const [command = "list", ...rest] = args;
59
- switch (command) {
60
- case "list": {
61
- requireNoExtraArgs(rest, "bun run rig plugin list");
62
- const legacyPlugins = context.plugins.list();
63
- const declarative = [];
64
- const config = await loadRigConfigOrNull(context.projectRoot);
65
- if (config && Array.isArray(config.plugins)) {
66
- for (const plugin of config.plugins) {
67
- const c = plugin.contributes ?? {};
68
- declarative.push({
69
- name: plugin.name,
70
- version: plugin.version,
71
- validators: (c.validators ?? []).map((v) => v.id),
72
- hooks: (c.hooks ?? []).map((h) => h.id),
73
- agentRoles: (c.agentRoles ?? []).map((r) => r.id),
74
- repoSources: (c.repoSources ?? []).map((r) => r.id),
75
- taskSources: (c.taskSources ?? []).map((s) => s.id),
76
- skills: (c.skills ?? []).map((s) => s.id),
77
- taskFieldExtensions: (c.taskFieldSchemas ?? []).map((f) => f.id),
78
- cliCommands: (c.cliCommands ?? []).map((c2) => c2.id)
79
- });
80
- }
81
- }
82
- if (context.outputMode === "text") {
83
- if (legacyPlugins.length === 0 && declarative.length === 0) {
84
- console.log("No plugins loaded.");
85
- }
86
- if (declarative.length > 0) {
87
- console.log("Declarative plugins (rig.config.ts):");
88
- for (const p of declarative) {
89
- console.log(` ${p.name}@${p.version}`);
90
- const lines = [];
91
- if (p.validators.length)
92
- lines.push(` validators: ${p.validators.join(", ")}`);
93
- if (p.hooks.length)
94
- lines.push(` hooks: ${p.hooks.join(", ")}`);
95
- if (p.agentRoles.length)
96
- lines.push(` agent-roles: ${p.agentRoles.join(", ")}`);
97
- if (p.repoSources.length)
98
- lines.push(` repo-sources: ${p.repoSources.join(", ")}`);
99
- if (p.taskSources.length)
100
- lines.push(` task-sources: ${p.taskSources.join(", ")}`);
101
- if (p.skills.length)
102
- lines.push(` skills: ${p.skills.join(", ")}`);
103
- if (p.taskFieldExtensions.length)
104
- lines.push(` task-fields: ${p.taskFieldExtensions.join(", ")}`);
105
- if (p.cliCommands.length)
106
- lines.push(` cli-commands: ${p.cliCommands.join(", ")}`);
107
- for (const line of lines)
108
- console.log(line);
109
- }
110
- }
111
- if (legacyPlugins.length > 0) {
112
- console.log("Legacy disk-scan plugins (rig/plugins/):");
113
- for (const plugin of legacyPlugins) {
114
- const validators = plugin.validators.length > 0 ? plugin.validators.join(", ") : "none";
115
- console.log(` ${plugin.name} (validators: ${validators})`);
116
- }
117
- }
118
- }
119
- return {
120
- ok: true,
121
- group: "plugin",
122
- command,
123
- details: { declarative, legacy: legacyPlugins }
124
- };
125
- }
126
- case "validate": {
127
- const { value: task, rest: remaining } = takeOption(rest, "--task");
128
- requireNoExtraArgs(remaining, "bun run rig plugin validate --task <beads-id>");
129
- const taskId = requireTask(task, "bun run rig plugin validate --task <beads-id>");
130
- const results = await context.plugins.runValidators(taskId);
131
- const passed = results.filter((result) => result.passed).length;
132
- const failed = results.length - passed;
133
- if (context.outputMode === "text") {
134
- if (results.length === 0) {
135
- console.log("No plugin validators registered.");
136
- } else {
137
- for (const result of results) {
138
- const icon = result.passed ? "PASS" : "FAIL";
139
- console.log(`[${icon}] ${result.id}: ${result.summary}`);
140
- if (result.details && !result.passed) {
141
- console.log(result.details);
142
- }
143
- }
144
- }
145
- }
146
- if (failed > 0) {
147
- throw new CliError2(`Plugin validation failed for ${failed} validator(s).`, 2);
148
- }
149
- return {
150
- ok: true,
151
- group: "plugin",
152
- command,
153
- details: {
154
- taskId,
155
- passed,
156
- failed,
157
- results
158
- }
159
- };
160
- }
161
- default:
162
- throw new CliError2(`Unknown plugin command: ${command}`);
163
- }
164
- }
165
- export {
166
- executePlugin
167
- };