@h-rig/cli 0.0.6-alpha.22 → 0.0.6-alpha.220

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 (49) hide show
  1. package/README.md +6 -28
  2. package/package.json +9 -29
  3. package/dist/bin/build-rig-binaries.js +0 -107
  4. package/dist/bin/rig.js +0 -10655
  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 -731
  11. package/dist/src/commands/_parsers.js +0 -107
  12. package/dist/src/commands/_paths.js +0 -50
  13. package/dist/src/commands/_pi-install.js +0 -185
  14. package/dist/src/commands/_policy.js +0 -79
  15. package/dist/src/commands/_preflight.js +0 -483
  16. package/dist/src/commands/_probes.js +0 -13
  17. package/dist/src/commands/_run-driver-helpers.js +0 -289
  18. package/dist/src/commands/_server-client.js +0 -435
  19. package/dist/src/commands/_snapshot-upload.js +0 -318
  20. package/dist/src/commands/_task-picker.js +0 -76
  21. package/dist/src/commands/agent.js +0 -499
  22. package/dist/src/commands/browser.js +0 -890
  23. package/dist/src/commands/connect.js +0 -180
  24. package/dist/src/commands/dist.js +0 -402
  25. package/dist/src/commands/doctor.js +0 -517
  26. package/dist/src/commands/github.js +0 -281
  27. package/dist/src/commands/inbox.js +0 -160
  28. package/dist/src/commands/init.js +0 -1563
  29. package/dist/src/commands/inspect.js +0 -174
  30. package/dist/src/commands/inspector.js +0 -256
  31. package/dist/src/commands/plugin.js +0 -167
  32. package/dist/src/commands/profile-and-review.js +0 -178
  33. package/dist/src/commands/queue.js +0 -198
  34. package/dist/src/commands/remote.js +0 -507
  35. package/dist/src/commands/repo-git-harness.js +0 -221
  36. package/dist/src/commands/run.js +0 -1258
  37. package/dist/src/commands/server.js +0 -373
  38. package/dist/src/commands/setup.js +0 -687
  39. package/dist/src/commands/task-report-bug.js +0 -1083
  40. package/dist/src/commands/task-run-driver.js +0 -2554
  41. package/dist/src/commands/task.js +0 -1842
  42. package/dist/src/commands/test.js +0 -39
  43. package/dist/src/commands/workspace.js +0 -123
  44. package/dist/src/commands.js +0 -10334
  45. package/dist/src/index.js +0 -10673
  46. package/dist/src/launcher.js +0 -133
  47. package/dist/src/report-bug.js +0 -260
  48. package/dist/src/runner.js +0 -273
  49. package/dist/src/withMutedConsole.js +0 -42
@@ -1,221 +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 formatCommand(parts) {
11
- return parts.map((part) => /[^a-zA-Z0-9_./:-]/.test(part) ? JSON.stringify(part) : part).join(" ");
12
- }
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/repo-git-harness.ts
53
- import { executeHarnessCommand } from "@rig/runtime/control-plane/native/harness-cli";
54
- import { repoEnsure, resetBaseline } from "@rig/runtime/control-plane/native/repo-ops";
55
-
56
- // packages/cli/src/withMutedConsole.ts
57
- function isPromise(value) {
58
- if (typeof value !== "object" && typeof value !== "function") {
59
- return false;
60
- }
61
- return value !== null && typeof value.then === "function";
62
- }
63
- function withMutedConsole(mute, fn) {
64
- if (!mute) {
65
- return fn();
66
- }
67
- const originalLog = console.log;
68
- const originalWarn = console.warn;
69
- const originalInfo = console.info;
70
- const restore = () => {
71
- console.log = originalLog;
72
- console.warn = originalWarn;
73
- console.info = originalInfo;
74
- };
75
- console.log = () => {};
76
- console.warn = () => {};
77
- console.info = () => {};
78
- try {
79
- const result = fn();
80
- if (isPromise(result)) {
81
- return result.finally(restore);
82
- }
83
- restore();
84
- return result;
85
- } catch (error) {
86
- restore();
87
- throw error;
88
- } finally {
89
- if (console.log === originalLog) {
90
- restore();
91
- }
92
- }
93
- }
94
-
95
- // packages/cli/src/commands/_policy.ts
96
- import { appendFileSync, mkdirSync } from "fs";
97
- import { resolve } from "path";
98
- import { evaluate as evaluate2, loadPolicy as loadPolicy2, resolveAction as resolveAction2 } from "@rig/runtime/control-plane/runtime/guard";
99
- import { resolveHarnessPaths } from "@rig/runtime/control-plane/native/utils";
100
- function resolveEffectivePolicyMode(context) {
101
- const envMode = process.env.RIG_BASH_MODE;
102
- if (envMode === "off" || envMode === "observe" || envMode === "enforce") {
103
- return envMode;
104
- }
105
- return context.policyMode || loadPolicy2(context.projectRoot).mode;
106
- }
107
- function appendControlledBashAudit(context, mode, command, args, matchedRuleIds, action) {
108
- if (mode === "off") {
109
- return;
110
- }
111
- const logsDir = resolveHarnessPaths(context.projectRoot).logsDir;
112
- const logFile = resolve(logsDir, "controlled-bash.jsonl");
113
- mkdirSync(logsDir, { recursive: true });
114
- const payload = {
115
- timestamp: new Date().toISOString(),
116
- mode,
117
- cwd: process.cwd(),
118
- pid: process.pid,
119
- ppid: process.ppid,
120
- argv: args,
121
- command,
122
- matchedRuleIds
123
- };
124
- if (action) {
125
- payload.action = action;
126
- }
127
- appendFileSync(logFile, `${JSON.stringify(payload)}
128
- `, "utf-8");
129
- }
130
- async function enforceNativeCommandPolicy(context, args, options) {
131
- const mode = resolveEffectivePolicyMode(context);
132
- const command = formatCommand([options.commandPrefix, ...args]);
133
- const decision = evaluate2({
134
- projectRoot: context.projectRoot,
135
- evaluation: { type: "command", command }
136
- });
137
- const action = resolveAction2(mode, decision.matchedRules);
138
- const matchedRuleIds = decision.matchedRules.map((rule) => rule.id);
139
- await context.emitEvent("policy.decision", {
140
- target: "command",
141
- command,
142
- mode,
143
- allowed: action !== "block",
144
- matchedRuleIds,
145
- reasons: decision.matchedRules.map((rule) => rule.reason)
146
- });
147
- if (options.writeAuditLog) {
148
- appendControlledBashAudit(context, mode, command, args, matchedRuleIds, action === "block" ? "blocked" : action === "warn" ? "warn" : undefined);
149
- }
150
- if (action === "block") {
151
- throw new CliError2(`Policy blocked command: ${command}`, 126);
152
- }
153
- }
154
-
155
- // packages/cli/src/commands/repo-git-harness.ts
156
- async function executeRepo(context, args) {
157
- const [command = "sync", ...rest] = args;
158
- switch (command) {
159
- case "sync": {
160
- const { value: task, rest: remaining } = takeOption(rest, "--task");
161
- requireNoExtraArgs(remaining, "bun run rig repo sync [--task <beads-id>]");
162
- withMutedConsole(context.outputMode === "json", () => repoEnsure(context.projectRoot, task || undefined));
163
- return { ok: true, group: "repo", command, details: { task: task || null } };
164
- }
165
- case "reset-baseline": {
166
- const { value: keepTaskStatusFlag, rest: remaining } = takeFlag(rest, "--keep-task-status");
167
- requireNoExtraArgs(remaining, "bun run rig repo reset-baseline [--keep-task-status]");
168
- withMutedConsole(context.outputMode === "json", () => resetBaseline(context.projectRoot, keepTaskStatusFlag));
169
- return { ok: true, group: "repo", command, details: { keepTaskStatus: keepTaskStatusFlag } };
170
- }
171
- default:
172
- throw new CliError2(`Unknown repo command: ${command}`);
173
- }
174
- }
175
- async function executeGit(context, args) {
176
- if (args.length === 0) {
177
- throw new CliError2("Usage: bun run rig git <git-flow args...>");
178
- }
179
- await enforceNativeCommandPolicy(context, args, {
180
- commandPrefix: "rig-agent git",
181
- writeAuditLog: false
182
- });
183
- if (context.dryRun) {
184
- if (context.outputMode === "text") {
185
- console.log(`[dry-run] rig git ${args.join(" ")}`);
186
- }
187
- return { ok: true, group: "git", command: args[0] ?? "git" };
188
- }
189
- try {
190
- await executeHarnessCommand(context.projectRoot, context.plugins, ["git", ...args]);
191
- } catch (error) {
192
- throw new CliError2(error instanceof Error ? error.message : String(error), 2);
193
- }
194
- return { ok: true, group: "git", command: args[0] ?? "git" };
195
- }
196
- async function executeHarness(context, args) {
197
- if (args.length === 0) {
198
- throw new CliError2("Usage: bun run rig harness <harness args...>");
199
- }
200
- await enforceNativeCommandPolicy(context, args, {
201
- commandPrefix: "rig-agent",
202
- writeAuditLog: true
203
- });
204
- if (context.dryRun) {
205
- if (context.outputMode === "text") {
206
- console.log(`[dry-run] rig harness ${args.join(" ")}`);
207
- }
208
- return { ok: true, group: "harness", command: args[0] ?? "harness" };
209
- }
210
- try {
211
- await executeHarnessCommand(context.projectRoot, context.plugins, args);
212
- } catch (error) {
213
- throw new CliError2(error instanceof Error ? error.message : String(error), 2);
214
- }
215
- return { ok: true, group: "harness", command: args[0] ?? "harness" };
216
- }
217
- export {
218
- executeRepo,
219
- executeHarness,
220
- executeGit
221
- };