@h-rig/cli 0.0.6-alpha.27 → 0.0.6-alpha.280

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 (52) hide show
  1. package/README.md +6 -28
  2. package/package.json +11 -28
  3. package/dist/bin/build-rig-binaries.js +0 -107
  4. package/dist/bin/rig.js +0 -11321
  5. package/dist/src/commands/_authority-runs.js +0 -111
  6. package/dist/src/commands/_cli-format.js +0 -164
  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/_help-catalog.js +0 -203
  10. package/dist/src/commands/_operator-surface.js +0 -204
  11. package/dist/src/commands/_operator-view.js +0 -1147
  12. package/dist/src/commands/_parsers.js +0 -107
  13. package/dist/src/commands/_paths.js +0 -50
  14. package/dist/src/commands/_pi-frontend.js +0 -843
  15. package/dist/src/commands/_pi-install.js +0 -185
  16. package/dist/src/commands/_pi-worker-bridge-extension.js +0 -761
  17. package/dist/src/commands/_policy.js +0 -79
  18. package/dist/src/commands/_preflight.js +0 -403
  19. package/dist/src/commands/_probes.js +0 -13
  20. package/dist/src/commands/_run-driver-helpers.js +0 -289
  21. package/dist/src/commands/_server-client.js +0 -514
  22. package/dist/src/commands/_snapshot-upload.js +0 -318
  23. package/dist/src/commands/_task-picker.js +0 -76
  24. package/dist/src/commands/agent.js +0 -499
  25. package/dist/src/commands/browser.js +0 -890
  26. package/dist/src/commands/connect.js +0 -288
  27. package/dist/src/commands/dist.js +0 -402
  28. package/dist/src/commands/doctor.js +0 -517
  29. package/dist/src/commands/github.js +0 -281
  30. package/dist/src/commands/inbox.js +0 -160
  31. package/dist/src/commands/init.js +0 -1563
  32. package/dist/src/commands/inspect.js +0 -174
  33. package/dist/src/commands/inspector.js +0 -256
  34. package/dist/src/commands/plugin.js +0 -167
  35. package/dist/src/commands/profile-and-review.js +0 -178
  36. package/dist/src/commands/queue.js +0 -198
  37. package/dist/src/commands/remote.js +0 -507
  38. package/dist/src/commands/repo-git-harness.js +0 -221
  39. package/dist/src/commands/run.js +0 -1688
  40. package/dist/src/commands/server.js +0 -571
  41. package/dist/src/commands/setup.js +0 -687
  42. package/dist/src/commands/task-report-bug.js +0 -1083
  43. package/dist/src/commands/task-run-driver.js +0 -2600
  44. package/dist/src/commands/task.js +0 -2200
  45. package/dist/src/commands/test.js +0 -39
  46. package/dist/src/commands/workspace.js +0 -123
  47. package/dist/src/commands.js +0 -11000
  48. package/dist/src/index.js +0 -11339
  49. package/dist/src/launcher.js +0 -133
  50. package/dist/src/report-bug.js +0 -260
  51. package/dist/src/runner.js +0 -273
  52. package/dist/src/withMutedConsole.js +0 -42
@@ -1,111 +0,0 @@
1
- // @bun
2
- // packages/cli/src/commands/_authority-runs.ts
3
- import { existsSync } from "fs";
4
- import { resolve } from "path";
5
- import {
6
- readAuthorityRun,
7
- readJsonlFile,
8
- resolveAuthorityRunDir,
9
- writeJsonFile
10
- } from "@rig/runtime/control-plane/authority-files";
11
-
12
- // packages/cli/src/commands/_paths.ts
13
- import { resolveMonorepoRoot } from "@rig/runtime/control-plane/native/utils";
14
- function resolveControlPlaneMonorepoRoot(projectRoot) {
15
- return resolveMonorepoRoot(projectRoot);
16
- }
17
-
18
- // packages/cli/src/commands/_authority-runs.ts
19
- var RIG_WORKSPACE_ID = "rig-local-workspace";
20
- function normalizeRuntimeAdapter(value) {
21
- const normalized = value?.trim().toLowerCase();
22
- if (!normalized) {
23
- return "pi";
24
- }
25
- if (normalized === "codex" || normalized === "codex-cli" || normalized === "codex-app-server" || normalized === "gpt-codex") {
26
- return "codex";
27
- }
28
- if (normalized === "pi" || normalized === "rig-pi" || normalized === "@rig/pi") {
29
- return "pi";
30
- }
31
- return "claude-code";
32
- }
33
- function readLatestBeadRecord(projectRoot, taskId) {
34
- const issuesPath = resolve(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
35
- if (!existsSync(issuesPath)) {
36
- return null;
37
- }
38
- let latest = null;
39
- for (const issue of readJsonlFile(issuesPath)) {
40
- if (!issue || typeof issue !== "object") {
41
- continue;
42
- }
43
- const record = issue;
44
- if (record.id === taskId) {
45
- latest = record;
46
- }
47
- }
48
- return latest;
49
- }
50
- function resolveTaskTitleForAuthorityRun(projectRoot, taskId) {
51
- try {
52
- const record = readLatestBeadRecord(projectRoot, taskId);
53
- const title = record && typeof record.title === "string" ? record.title.trim() : "";
54
- if (title) {
55
- return title;
56
- }
57
- } catch {}
58
- return null;
59
- }
60
- function upsertAgentAuthorityRun(projectRoot, input) {
61
- const current = readAuthorityRun(projectRoot, input.runId);
62
- const existing = current;
63
- const createdAt = existing?.createdAt ?? input.createdAt;
64
- const runtimeMode = typeof existing?.runtimeMode === "string" ? existing.runtimeMode : "full-access";
65
- const interactionMode = typeof existing?.interactionMode === "string" ? existing.interactionMode : "default";
66
- const runMode = typeof existing?.runMode === "string" ? existing.runMode : "autonomous";
67
- const runtimeAdapter = normalizeRuntimeAdapter(input.runtimeAdapter ?? existing?.runtimeAdapter ?? "claude-code");
68
- const title = resolveTaskTitleForAuthorityRun(projectRoot, input.taskId) ?? input.taskId;
69
- const next = {
70
- ...existing ?? {},
71
- runId: input.runId,
72
- projectRoot,
73
- workspaceId: existing?.workspaceId ?? RIG_WORKSPACE_ID,
74
- taskId: input.taskId,
75
- threadId: existing?.threadId ?? null,
76
- mode: "local",
77
- runtimeAdapter,
78
- status: input.status,
79
- createdAt,
80
- startedAt: input.startedAt ?? existing?.startedAt ?? null,
81
- completedAt: input.completedAt ?? existing?.completedAt ?? null,
82
- endpointId: existing?.endpointId ?? null,
83
- hostId: existing?.hostId ?? null,
84
- worktreePath: input.worktreePath ?? existing?.worktreePath ?? null,
85
- artifactRoot: input.artifactRoot ?? existing?.artifactRoot ?? null,
86
- logRoot: input.logRoot ?? existing?.logRoot ?? null,
87
- sessionPath: input.sessionPath ?? existing?.sessionPath ?? null,
88
- sessionLogPath: input.sessionLogPath ?? existing?.sessionLogPath ?? null,
89
- pid: input.pid ?? existing?.pid ?? null,
90
- updatedAt: input.createdAt,
91
- title,
92
- model: typeof existing?.model === "string" ? existing.model : null,
93
- runtimeMode,
94
- interactionMode,
95
- runMode,
96
- initialPrompt: typeof existing?.initialPrompt === "string" ? existing.initialPrompt : null
97
- };
98
- if (input.errorText !== undefined) {
99
- next.errorText = input.errorText;
100
- } else if ("errorText" in next) {
101
- delete next.errorText;
102
- }
103
- writeJsonFile(resolve(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
104
- return next;
105
- }
106
- export {
107
- upsertAgentAuthorityRun,
108
- readLatestBeadRecord,
109
- normalizeRuntimeAdapter,
110
- RIG_WORKSPACE_ID
111
- };
@@ -1,164 +0,0 @@
1
- // @bun
2
- // packages/cli/src/commands/_cli-format.ts
3
- import pc from "picocolors";
4
- function stringField(record, key, fallback = "") {
5
- const value = record[key];
6
- return typeof value === "string" && value.trim() ? value.trim() : fallback;
7
- }
8
- function arrayField(record, key) {
9
- const value = record[key];
10
- return Array.isArray(value) ? value.flatMap((entry) => typeof entry === "string" && entry.trim() ? [entry.trim()] : []) : [];
11
- }
12
- function rawObject(record) {
13
- const raw = record.raw;
14
- return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
15
- }
16
- function truncate(value, width) {
17
- if (value.length <= width)
18
- return value;
19
- if (width <= 1)
20
- return "\u2026";
21
- return `${value.slice(0, width - 1)}\u2026`;
22
- }
23
- function pad(value, width) {
24
- return value.length >= width ? value : `${value}${" ".repeat(width - value.length)}`;
25
- }
26
- function statusColor(status) {
27
- const normalized = status.toLowerCase();
28
- if (["completed", "merged", "closed", "done", "accepted", "pass", "selected"].includes(normalized))
29
- return pc.green;
30
- if (["failed", "needs_attention", "needs-attention", "blocked", "error"].includes(normalized))
31
- return pc.red;
32
- if (["running", "reviewing", "validating", "in_progress", "in-progress", "remote"].includes(normalized))
33
- return pc.cyan;
34
- if (["ready", "open", "queued", "created", "preparing", "local"].includes(normalized))
35
- return pc.yellow;
36
- return pc.dim;
37
- }
38
- function formatStatusPill(status) {
39
- const label = status || "unknown";
40
- return statusColor(label)(`\u25CF ${label}`);
41
- }
42
- function formatSection(title, subtitle) {
43
- return `${pc.bold(pc.cyan("\u25C6"))} ${pc.bold(title)}${subtitle ? pc.dim(` \u2014 ${subtitle}`) : ""}`;
44
- }
45
- function formatSuccessCard(title, rows = []) {
46
- const body = rows.filter(([, value]) => value !== undefined && value !== null && String(value).length > 0).map(([key, value]) => `${pc.dim("\u2502")} ${pc.dim(key.padEnd(9))} ${value}`);
47
- return [formatSection(title), ...body].join(`
48
- `);
49
- }
50
- function formatNextSteps(steps) {
51
- if (steps.length === 0)
52
- return [];
53
- return [pc.bold("Next"), ...steps.map((step) => `${pc.dim("\u203A")} ${step}`)];
54
- }
55
- function formatTaskList(tasks, options = {}) {
56
- if (options.raw)
57
- return tasks.map((task) => JSON.stringify(task)).join(`
58
- `);
59
- if (tasks.length === 0)
60
- return [formatSection("Tasks", "none found"), ...formatNextSteps(["Try `rig server status` to confirm the selected server.", "Relax filters or run `rig task run --title ... --initial-prompt ...` for ad hoc work."])].join(`
61
- `);
62
- const rows = tasks.map((task) => {
63
- const raw = rawObject(task);
64
- const id = stringField(task, "id", "<unknown>");
65
- const status = stringField(task, "status", "unknown");
66
- const title = stringField(task, "title", "Untitled task");
67
- const source = stringField(task, "source", stringField(raw, "source", ""));
68
- const labels = arrayField(task, "labels").length > 0 ? arrayField(task, "labels") : arrayField(raw, "labels");
69
- return { id, status, title, source, labels };
70
- });
71
- const idWidth = Math.min(18, Math.max(4, ...rows.map((row) => row.id.length)));
72
- const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
73
- const header = `${pc.bold(pad("TASK", idWidth))} ${pc.bold(pad("STATUS", statusWidth))} ${pc.bold("TITLE")}`;
74
- const body = rows.map((row) => {
75
- const labels = row.labels.length > 0 ? pc.dim(` ${row.labels.slice(0, 4).map((label) => `#${label}`).join(" ")}`) : "";
76
- const source = row.source ? pc.dim(` ${row.source}`) : "";
77
- return [
78
- pc.bold(pad(truncate(row.id, idWidth), idWidth)),
79
- statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
80
- `${row.title}${labels}${source}`
81
- ].join(" ");
82
- });
83
- return [formatSection("Tasks", `${rows.length} shown`), header, ...body, "", ...formatNextSteps(["Run one: `rig task run <id>` or `rig task run --next`", "Attach later: `rig run attach <run-id> --follow`"])].join(`
84
- `);
85
- }
86
- function formatRunList(runs, options = {}) {
87
- if (runs.length === 0) {
88
- return [
89
- formatSection("Runs", "none recorded"),
90
- options.source === "server" ? pc.dim("No runs recorded on the selected Rig server.") : pc.dim("No runs recorded in .rig/runs."),
91
- "",
92
- ...formatNextSteps(["Start one: `rig task run --next`", "Check server: `rig server status`"])
93
- ].join(`
94
- `);
95
- }
96
- const rows = runs.map((run) => {
97
- const runId = stringField(run, "runId", stringField(run, "id", "(unknown-run)"));
98
- const status = stringField(run, "status", "unknown");
99
- const taskId = stringField(run, "taskId", "");
100
- const title = stringField(run, "title", taskId || "(untitled)");
101
- const runtime = stringField(run, "runtimeAdapter", "");
102
- return { runId, status, title, runtime };
103
- });
104
- const idWidth = Math.min(36, Math.max(6, ...rows.map((row) => row.runId.length)));
105
- const statusWidth = Math.min(16, Math.max(6, ...rows.map((row) => row.status.length)));
106
- const header = `${pc.bold(pad("RUN", idWidth))} ${pc.bold(pad("STATUS", statusWidth))} ${pc.bold("TITLE")}`;
107
- const body = rows.map((row) => [
108
- pc.bold(pad(truncate(row.runId, idWidth), idWidth)),
109
- statusColor(row.status)(pad(truncate(row.status, statusWidth), statusWidth)),
110
- `${row.title}${row.runtime ? pc.dim(` ${row.runtime}`) : ""}`
111
- ].join(" "));
112
- return [formatSection("Runs", options.source === "server" ? "selected server" : "local state"), header, ...body, "", ...formatNextSteps(["Follow live: `rig run attach <run-id> --follow`", "Details: `rig run show --run <run-id>`"])].join(`
113
- `);
114
- }
115
- function formatSubmittedRun(input) {
116
- const rows = [["run", pc.bold(input.runId)]];
117
- if (input.task) {
118
- const id = stringField(input.task, "id", "<unknown>");
119
- const status = stringField(input.task, "status", "unknown");
120
- const title = stringField(input.task, "title", "Untitled task");
121
- rows.push(["task", `${pc.bold(id)} ${formatStatusPill(status)} ${title}`]);
122
- }
123
- return [
124
- formatSuccessCard("Run submitted", rows),
125
- "",
126
- ...formatNextSteps([`Attach: \`rig run attach ${input.runId} --follow\``, `Inspect: \`rig run show --run ${input.runId}\``])
127
- ].join(`
128
- `);
129
- }
130
- function formatConnectionList(connections) {
131
- const rows = [["local", { kind: "local", mode: "auto" }], ...Object.entries(connections)];
132
- const aliasWidth = Math.min(24, Math.max(5, ...rows.map(([alias]) => alias.length)));
133
- const lines = rows.map(([alias, connection]) => [
134
- pc.bold(pad(truncate(alias, aliasWidth), aliasWidth)),
135
- formatStatusPill(connection.kind),
136
- connection.kind === "remote" ? connection.baseUrl ?? "" : connection.mode ?? "local"
137
- ].join(" "));
138
- return [formatSection("Rig servers", `${rows.length} available`), `${pc.bold(pad("ALIAS", aliasWidth))} ${pc.bold("KIND")} ${pc.bold("TARGET")}`, ...lines, "", ...formatNextSteps(["Select one: `rig server use <alias|local>`"])].join(`
139
- `);
140
- }
141
- function formatConnectionStatus(selected, connections) {
142
- const connection = selected === "local" ? { kind: "local", mode: "auto" } : connections[selected];
143
- const target = !connection ? "not configured" : connection.kind === "remote" ? connection.baseUrl : "local";
144
- return [
145
- formatSection("Rig server", "selected for this repo"),
146
- `${pc.dim("\u2502")} ${pc.dim("selected ")} ${pc.bold(selected)}`,
147
- `${pc.dim("\u2502")} ${pc.dim("kind ")} ${formatStatusPill(connection?.kind ?? "unknown")}`,
148
- `${pc.dim("\u2502")} ${pc.dim("target ")} ${target ?? "not configured"}`,
149
- "",
150
- ...formatNextSteps(["Change: `rig server use <alias|local>`", "List saved servers: `rig server list`"])
151
- ].join(`
152
- `);
153
- }
154
- export {
155
- formatTaskList,
156
- formatSuccessCard,
157
- formatSubmittedRun,
158
- formatStatusPill,
159
- formatSection,
160
- formatRunList,
161
- formatNextSteps,
162
- formatConnectionStatus,
163
- formatConnectionList
164
- };
@@ -1,123 +0,0 @@
1
- // @bun
2
- // packages/cli/src/commands/_connection-state.ts
3
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
4
- import { homedir } from "os";
5
- import { dirname, resolve } from "path";
6
-
7
- // packages/cli/src/runner.ts
8
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
9
- import { CliError } from "@rig/runtime/control-plane/errors";
10
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
11
- import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
12
- import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
13
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
14
- import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
15
-
16
- // packages/cli/src/commands/_connection-state.ts
17
- function resolveGlobalConnectionsPath(env = process.env) {
18
- const explicit = env.RIG_CONNECTIONS_FILE?.trim();
19
- if (explicit)
20
- return resolve(explicit);
21
- const stateDir = env.RIG_GLOBAL_STATE_DIR?.trim();
22
- if (stateDir)
23
- return resolve(stateDir, "connections.json");
24
- return resolve(homedir(), ".rig", "connections.json");
25
- }
26
- function resolveRepoConnectionPath(projectRoot) {
27
- return resolve(projectRoot, ".rig", "state", "connection.json");
28
- }
29
- function readJsonFile(path) {
30
- if (!existsSync(path))
31
- return null;
32
- try {
33
- return JSON.parse(readFileSync(path, "utf8"));
34
- } catch (error) {
35
- throw new CliError2(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1);
36
- }
37
- }
38
- function writeJsonFile(path, value) {
39
- mkdirSync(dirname(path), { recursive: true });
40
- writeFileSync(path, `${JSON.stringify(value, null, 2)}
41
- `, "utf8");
42
- }
43
- function normalizeConnection(value) {
44
- if (!value || typeof value !== "object" || Array.isArray(value))
45
- return null;
46
- const record = value;
47
- if (record.kind === "local")
48
- return { kind: "local", mode: "auto" };
49
- if (record.kind === "remote" && typeof record.baseUrl === "string" && record.baseUrl.trim()) {
50
- const baseUrl = record.baseUrl.trim().replace(/\/+$/, "");
51
- return { kind: "remote", baseUrl };
52
- }
53
- return null;
54
- }
55
- function readGlobalConnections(options = {}) {
56
- const path = resolveGlobalConnectionsPath(options.env ?? process.env);
57
- const payload = readJsonFile(path);
58
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
59
- return { connections: {} };
60
- }
61
- const rawConnections = payload.connections;
62
- const connections = {};
63
- if (rawConnections && typeof rawConnections === "object" && !Array.isArray(rawConnections)) {
64
- for (const [alias, raw] of Object.entries(rawConnections)) {
65
- const connection = normalizeConnection(raw);
66
- if (connection)
67
- connections[alias] = connection;
68
- }
69
- }
70
- return { connections };
71
- }
72
- function writeGlobalConnections(state, options = {}) {
73
- writeJsonFile(resolveGlobalConnectionsPath(options.env ?? process.env), state);
74
- }
75
- function upsertGlobalConnection(alias, connection, options = {}) {
76
- const cleanAlias = alias.trim();
77
- if (!cleanAlias)
78
- throw new CliError2("Connection alias is required.", 1);
79
- const state = readGlobalConnections(options);
80
- state.connections[cleanAlias] = connection;
81
- writeGlobalConnections(state, options);
82
- return state;
83
- }
84
- function readRepoConnection(projectRoot) {
85
- const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
86
- if (!payload || typeof payload !== "object" || Array.isArray(payload))
87
- return null;
88
- const record = payload;
89
- const selected = typeof record.selected === "string" ? record.selected.trim() : "";
90
- if (!selected)
91
- return null;
92
- return {
93
- selected,
94
- project: typeof record.project === "string" ? record.project : undefined,
95
- linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined
96
- };
97
- }
98
- function writeRepoConnection(projectRoot, state) {
99
- writeJsonFile(resolveRepoConnectionPath(projectRoot), state);
100
- }
101
- function resolveSelectedConnection(projectRoot, options = {}) {
102
- const repo = readRepoConnection(projectRoot);
103
- if (!repo)
104
- return null;
105
- if (repo.selected === "local")
106
- return { alias: "local", connection: { kind: "local", mode: "auto" } };
107
- const global = readGlobalConnections(options);
108
- const connection = global.connections[repo.selected];
109
- if (!connection) {
110
- throw new CliError2(`Selected Rig connection "${repo.selected}" was not found. Run \`rig connect list\` or \`rig connect use local\`.`, 1);
111
- }
112
- return { alias: repo.selected, connection };
113
- }
114
- export {
115
- writeRepoConnection,
116
- writeGlobalConnections,
117
- upsertGlobalConnection,
118
- resolveSelectedConnection,
119
- resolveRepoConnectionPath,
120
- resolveGlobalConnectionsPath,
121
- readRepoConnection,
122
- readGlobalConnections
123
- };