@h-rig/cli 0.0.6-alpha.24 → 0.0.6-alpha.241

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 (51) hide show
  1. package/README.md +6 -28
  2. package/package.json +13 -28
  3. package/dist/bin/build-rig-binaries.js +0 -107
  4. package/dist/bin/rig.js +0 -11112
  5. package/dist/src/commands/_authority-runs.js +0 -111
  6. package/dist/src/commands/_cli-format.js +0 -106
  7. package/dist/src/commands/_connection-state.js +0 -123
  8. package/dist/src/commands/_doctor-checks.js +0 -507
  9. package/dist/src/commands/_operator-surface.js +0 -204
  10. package/dist/src/commands/_operator-view.js +0 -1147
  11. package/dist/src/commands/_parsers.js +0 -107
  12. package/dist/src/commands/_paths.js +0 -50
  13. package/dist/src/commands/_pi-frontend.js +0 -843
  14. package/dist/src/commands/_pi-install.js +0 -185
  15. package/dist/src/commands/_pi-worker-bridge-extension.js +0 -761
  16. package/dist/src/commands/_policy.js +0 -79
  17. package/dist/src/commands/_preflight.js +0 -403
  18. package/dist/src/commands/_probes.js +0 -13
  19. package/dist/src/commands/_run-driver-helpers.js +0 -289
  20. package/dist/src/commands/_server-client.js +0 -514
  21. package/dist/src/commands/_snapshot-upload.js +0 -318
  22. package/dist/src/commands/_task-picker.js +0 -76
  23. package/dist/src/commands/agent.js +0 -499
  24. package/dist/src/commands/browser.js +0 -890
  25. package/dist/src/commands/connect.js +0 -180
  26. package/dist/src/commands/dist.js +0 -402
  27. package/dist/src/commands/doctor.js +0 -517
  28. package/dist/src/commands/github.js +0 -281
  29. package/dist/src/commands/inbox.js +0 -160
  30. package/dist/src/commands/init.js +0 -1563
  31. package/dist/src/commands/inspect.js +0 -174
  32. package/dist/src/commands/inspector.js +0 -256
  33. package/dist/src/commands/plugin.js +0 -167
  34. package/dist/src/commands/profile-and-review.js +0 -178
  35. package/dist/src/commands/queue.js +0 -198
  36. package/dist/src/commands/remote.js +0 -507
  37. package/dist/src/commands/repo-git-harness.js +0 -221
  38. package/dist/src/commands/run.js +0 -1674
  39. package/dist/src/commands/server.js +0 -373
  40. package/dist/src/commands/setup.js +0 -687
  41. package/dist/src/commands/task-report-bug.js +0 -1083
  42. package/dist/src/commands/task-run-driver.js +0 -2600
  43. package/dist/src/commands/task.js +0 -2178
  44. package/dist/src/commands/test.js +0 -39
  45. package/dist/src/commands/workspace.js +0 -123
  46. package/dist/src/commands.js +0 -10791
  47. package/dist/src/index.js +0 -11130
  48. package/dist/src/launcher.js +0 -133
  49. package/dist/src/report-bug.js +0 -260
  50. package/dist/src/runner.js +0 -273
  51. package/dist/src/withMutedConsole.js +0 -42
@@ -1,178 +0,0 @@
1
- // @bun
2
- // packages/cli/src/runner.ts
3
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
4
- import { CliError } from "@rig/runtime/control-plane/errors";
5
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
6
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
7
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
8
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
9
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
10
- function takeOption(args, option) {
11
- const rest = [];
12
- let value;
13
- for (let index = 0;index < args.length; index += 1) {
14
- const current = args[index];
15
- if (current === option) {
16
- const next = args[index + 1];
17
- if (!next || next.startsWith("-")) {
18
- throw new CliError(`Missing value for ${option}`);
19
- }
20
- value = next;
21
- index += 1;
22
- continue;
23
- }
24
- if (current !== undefined) {
25
- rest.push(current);
26
- }
27
- }
28
- return { value, rest };
29
- }
30
- function requireNoExtraArgs(args, usage) {
31
- if (args.length > 0) {
32
- throw new CliError(`Unexpected arguments: ${args.join(" ")}
33
- Usage: ${usage}`);
34
- }
35
- }
36
-
37
- // packages/cli/src/commands/profile-and-review.ts
38
- import {
39
- setProfile,
40
- setReviewProfile,
41
- showProfile,
42
- showReviewProfile
43
- } from "@rig/runtime/control-plane/native/profile-ops";
44
-
45
- // packages/cli/src/withMutedConsole.ts
46
- function isPromise(value) {
47
- if (typeof value !== "object" && typeof value !== "function") {
48
- return false;
49
- }
50
- return value !== null && typeof value.then === "function";
51
- }
52
- function withMutedConsole(mute, fn) {
53
- if (!mute) {
54
- return fn();
55
- }
56
- const originalLog = console.log;
57
- const originalWarn = console.warn;
58
- const originalInfo = console.info;
59
- const restore = () => {
60
- console.log = originalLog;
61
- console.warn = originalWarn;
62
- console.info = originalInfo;
63
- };
64
- console.log = () => {};
65
- console.warn = () => {};
66
- console.info = () => {};
67
- try {
68
- const result = fn();
69
- if (isPromise(result)) {
70
- return result.finally(restore);
71
- }
72
- restore();
73
- return result;
74
- } catch (error) {
75
- restore();
76
- throw error;
77
- } finally {
78
- if (console.log === originalLog) {
79
- restore();
80
- }
81
- }
82
- }
83
-
84
- // packages/cli/src/commands/profile-and-review.ts
85
- async function executeProfile(context, args) {
86
- const [command = "show", ...rest] = args;
87
- switch (command) {
88
- case "show":
89
- requireNoExtraArgs(rest, "bun run rig profile show");
90
- await withMutedConsole(context.outputMode === "json", () => showProfile(context.projectRoot));
91
- return { ok: true, group: "profile", command };
92
- case "set": {
93
- if (rest.length === 0) {
94
- throw new CliError2("Usage: bun run rig profile set <claude-code|codex-cli|pi> or set [--model ...] [--runtime ...] [--plugin ...]");
95
- }
96
- const preset = rest[0];
97
- if (preset && !preset.startsWith("-")) {
98
- if (rest.length !== 1) {
99
- throw new CliError2("Usage: bun run rig profile set <claude-code|codex-cli|pi>");
100
- }
101
- try {
102
- await withMutedConsole(context.outputMode === "json", () => setProfile(context.projectRoot, { preset }));
103
- } catch (error) {
104
- throw new CliError2(error instanceof Error ? error.message : String(error), 2);
105
- }
106
- return { ok: true, group: "profile", command, details: { preset } };
107
- }
108
- let pending = rest;
109
- const modelResult = takeOption(pending, "--model");
110
- pending = modelResult.rest;
111
- const runtimeResult = takeOption(pending, "--runtime");
112
- pending = runtimeResult.rest;
113
- const pluginResult = takeOption(pending, "--plugin");
114
- pending = pluginResult.rest;
115
- requireNoExtraArgs(pending, "bun run rig profile set [--model ...] [--runtime ...] [--plugin ...]");
116
- if (!modelResult.value && !runtimeResult.value && !pluginResult.value) {
117
- throw new CliError2("Provide at least one of --model, --runtime, or --plugin.");
118
- }
119
- try {
120
- await withMutedConsole(context.outputMode === "json", () => setProfile(context.projectRoot, {
121
- model: modelResult.value,
122
- runtime: runtimeResult.value,
123
- plugin: pluginResult.value
124
- }));
125
- } catch (error) {
126
- throw new CliError2(error instanceof Error ? error.message : String(error), 2);
127
- }
128
- return {
129
- ok: true,
130
- group: "profile",
131
- command,
132
- details: {
133
- model: modelResult.value || null,
134
- runtime: runtimeResult.value || null,
135
- plugin: pluginResult.value || null
136
- }
137
- };
138
- }
139
- default:
140
- throw new CliError2(`Unknown profile command: ${command}`);
141
- }
142
- }
143
- async function executeReview(context, args) {
144
- const [command = "show", ...rest] = args;
145
- switch (command) {
146
- case "show":
147
- requireNoExtraArgs(rest, "bun run rig review show");
148
- await withMutedConsole(context.outputMode === "json", () => showReviewProfile(context.projectRoot));
149
- return { ok: true, group: "review", command };
150
- case "set": {
151
- if (rest.length === 0) {
152
- throw new CliError2("Usage: bun run rig review set <off|advisory|required> [--provider greptile]");
153
- }
154
- const mode = rest[0];
155
- if (!mode) {
156
- throw new CliError2("Usage: bun run rig review set <off|advisory|required> [--provider greptile]");
157
- }
158
- let pending = rest.slice(1);
159
- const providerResult = takeOption(pending, "--provider");
160
- pending = providerResult.rest;
161
- requireNoExtraArgs(pending, "bun run rig review set <off|advisory|required> [--provider greptile]");
162
- try {
163
- await withMutedConsole(context.outputMode === "json", () => {
164
- return setReviewProfile(context.projectRoot, mode, providerResult.value);
165
- });
166
- } catch (error) {
167
- throw new CliError2(error instanceof Error ? error.message : String(error), 2);
168
- }
169
- return { ok: true, group: "review", command, details: { mode, provider: providerResult.value || null } };
170
- }
171
- default:
172
- throw new CliError2(`Unknown review command: ${command}`);
173
- }
174
- }
175
- export {
176
- executeReview,
177
- executeProfile
178
- };
@@ -1,198 +0,0 @@
1
- // @bun
2
- // packages/cli/src/runner.ts
3
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
4
- import { CliError } from "@rig/runtime/control-plane/errors";
5
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
6
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
7
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
8
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
9
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
10
- function takeFlag(args, flag) {
11
- const rest = [];
12
- let value = false;
13
- for (const arg of args) {
14
- if (arg === flag) {
15
- value = true;
16
- continue;
17
- }
18
- rest.push(arg);
19
- }
20
- return { value, rest };
21
- }
22
- function takeOption(args, option) {
23
- const rest = [];
24
- let value;
25
- for (let index = 0;index < args.length; index += 1) {
26
- const current = args[index];
27
- if (current === option) {
28
- const next = args[index + 1];
29
- if (!next || next.startsWith("-")) {
30
- throw new CliError(`Missing value for ${option}`);
31
- }
32
- value = next;
33
- index += 1;
34
- continue;
35
- }
36
- if (current !== undefined) {
37
- rest.push(current);
38
- }
39
- }
40
- return { value, rest };
41
- }
42
- function requireNoExtraArgs(args, usage) {
43
- if (args.length > 0) {
44
- throw new CliError(`Unexpected arguments: ${args.join(" ")}
45
- Usage: ${usage}`);
46
- }
47
- }
48
-
49
- // packages/cli/src/commands/queue.ts
50
- import { runPriorityQueue } from "@rig/runtime/control-plane/runtime/queue";
51
-
52
- // packages/cli/src/commands/_parsers.ts
53
- function parsePositiveInt(value, option, fallback) {
54
- if (!value) {
55
- return fallback;
56
- }
57
- const parsed = Number.parseInt(value, 10);
58
- if (!Number.isFinite(parsed) || parsed <= 0) {
59
- throw new CliError2(`Invalid ${option} value: ${value}`);
60
- }
61
- return parsed;
62
- }
63
- function parseAction(value) {
64
- if (!value || value === "validate") {
65
- return "validate";
66
- }
67
- if (value === "verify") {
68
- return "verify";
69
- }
70
- if (value === "pipeline") {
71
- return "pipeline";
72
- }
73
- throw new CliError2(`Invalid --action value: ${value}. Use validate, verify, or pipeline.`);
74
- }
75
- function parseIsolationMode(value, allowOff) {
76
- if (!value) {
77
- return "worktree";
78
- }
79
- if (value === "worktree") {
80
- return value;
81
- }
82
- if (allowOff && value === "off") {
83
- return value;
84
- }
85
- throw new CliError2(`Invalid isolation mode: ${value}. Use ${allowOff ? "off|" : ""}worktree.`);
86
- }
87
-
88
- // packages/cli/src/commands/_preflight.ts
89
- import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/project-main-pre-run-sync";
90
-
91
- // packages/cli/src/commands/_server-client.ts
92
- import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
93
- var scopedGitHubBearerTokens = new Map;
94
-
95
- // packages/cli/src/commands/_preflight.ts
96
- async function runProjectMainSyncPreflight(context, options) {
97
- if (context.dryRun) {
98
- if (context.outputMode === "text" && !options.disabled) {
99
- console.log("[dry-run] project-rig pre-run sync check");
100
- }
101
- return;
102
- }
103
- const result = await ensureProjectMainFreshBeforeRun({
104
- projectRoot: context.projectRoot,
105
- disabled: options.disabled,
106
- runBootstrap: async () => {
107
- const bootstrap = await context.runCommand(["bun", "run", "bootstrap"]);
108
- if (bootstrap.exitCode !== 0) {
109
- throw new CliError2(bootstrap.stderr || bootstrap.stdout || "bun run bootstrap failed during project pre-run sync", bootstrap.exitCode || 1);
110
- }
111
- }
112
- });
113
- if (context.outputMode !== "text") {
114
- return;
115
- }
116
- switch (result.status) {
117
- case "disabled":
118
- console.log("Project pre-run sync skipped (--skip-project-sync).");
119
- break;
120
- case "skipped_not_main":
121
- console.log(`Project pre-run sync skipped (current branch: ${result.branch}).`);
122
- break;
123
- case "up_to_date":
124
- break;
125
- case "local_ahead":
126
- console.log(`Project pre-run sync skipped (local main ahead by ${result.localAhead} commit(s)).`);
127
- break;
128
- case "updated":
129
- console.log(`Project pre-run sync updated local main from origin/main (+${result.remoteAhead}) and bootstrapped.`);
130
- break;
131
- }
132
- }
133
-
134
- // packages/cli/src/commands/queue.ts
135
- async function executeQueue(context, args) {
136
- const [command = "run", ...rest] = args;
137
- switch (command) {
138
- case "run": {
139
- let pending = rest;
140
- const workersResult = takeOption(pending, "--workers");
141
- pending = workersResult.rest;
142
- const maxTasksResult = takeOption(pending, "--max-tasks");
143
- pending = maxTasksResult.rest;
144
- const actionResult = takeOption(pending, "--action");
145
- pending = actionResult.rest;
146
- const isolationResult = takeOption(pending, "--isolation");
147
- pending = isolationResult.rest;
148
- const noRuntimeReuseResult = takeFlag(pending, "--no-runtime-reuse");
149
- pending = noRuntimeReuseResult.rest;
150
- const failFastResult = takeFlag(pending, "--fail-fast");
151
- pending = failFastResult.rest;
152
- const skipProjectSyncResult = takeFlag(pending, "--skip-project-sync");
153
- pending = skipProjectSyncResult.rest;
154
- requireNoExtraArgs(pending, "bun run rig queue run [--workers <n>] [--max-tasks <n>] [--action validate|verify|pipeline] [--isolation off|worktree] [--no-runtime-reuse] [--fail-fast] [--skip-project-sync]");
155
- const workers = parsePositiveInt(workersResult.value, "--workers", 2);
156
- const maxTasks = parsePositiveInt(maxTasksResult.value, "--max-tasks", 10);
157
- const action = parseAction(actionResult.value);
158
- const isolation = parseIsolationMode(isolationResult.value, true);
159
- const reuseRuntime = !noRuntimeReuseResult.value;
160
- await runProjectMainSyncPreflight(context, { disabled: skipProjectSyncResult.value });
161
- const summary = await runPriorityQueue(context, {
162
- workers,
163
- maxTasks,
164
- action,
165
- isolation,
166
- reuseRuntime,
167
- failFast: failFastResult.value
168
- });
169
- if (context.outputMode === "text") {
170
- console.log(`Processed: ${summary.processed}`);
171
- console.log(`Succeeded: ${summary.succeeded}`);
172
- console.log(`Failed: ${summary.failed}`);
173
- }
174
- if (summary.failed > 0) {
175
- throw new CliError2(`Queue finished with ${summary.failed} failed task(s).`, 3);
176
- }
177
- return {
178
- ok: true,
179
- group: "queue",
180
- command,
181
- details: {
182
- workers,
183
- maxTasks,
184
- action,
185
- isolation,
186
- reuseRuntime,
187
- failFast: failFastResult.value,
188
- summary
189
- }
190
- };
191
- }
192
- default:
193
- throw new CliError2(`Unknown queue command: ${command}`);
194
- }
195
- }
196
- export {
197
- executeQueue
198
- };