@h-rig/cli 0.0.6-alpha.90 → 0.0.6-alpha.91

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 (118) hide show
  1. package/README.md +18 -19
  2. package/dist/bin/build-rig-binaries.js +22 -10
  3. package/dist/bin/rig.d.ts +71 -1
  4. package/dist/bin/rig.js +15078 -11169
  5. package/dist/config/rig-default-config.yml +5 -0
  6. package/dist/src/app/drone-ui.d.ts +11 -14
  7. package/dist/src/app/drone-ui.js +70 -86
  8. package/dist/src/commands/_async-ui.d.ts +1 -4
  9. package/dist/src/commands/_async-ui.js +9 -111
  10. package/dist/src/commands/_cli-format.d.ts +16 -9
  11. package/dist/src/commands/_cli-format.js +167 -295
  12. package/dist/src/commands/_connection-state.d.ts +11 -1
  13. package/dist/src/commands/_connection-state.js +50 -5
  14. package/dist/src/commands/_doctor-checks.d.ts +0 -6
  15. package/dist/src/commands/_doctor-checks.js +79 -382
  16. package/dist/src/commands/_help-catalog.d.ts +1 -1
  17. package/dist/src/commands/_help-catalog.js +217 -157
  18. package/dist/src/commands/_inprocess-services.d.ts +33 -0
  19. package/dist/src/commands/_inprocess-services.js +102 -0
  20. package/dist/src/commands/_json-output.js +4 -0
  21. package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
  22. package/dist/src/commands/_lazy-reconcile.js +102 -0
  23. package/dist/src/commands/_paths.js +1 -1
  24. package/dist/src/commands/_pi-frontend.d.ts +18 -10
  25. package/dist/src/commands/_pi-frontend.js +37 -715
  26. package/dist/src/commands/_pi-install.js +18 -36
  27. package/dist/src/commands/_policy.d.ts +1 -1
  28. package/dist/src/commands/_policy.js +56 -15
  29. package/dist/src/commands/_run-bridge.d.ts +114 -0
  30. package/dist/src/commands/_run-bridge.js +387 -0
  31. package/dist/src/commands/_run-diagnostics.d.ts +9 -0
  32. package/dist/src/commands/_run-diagnostics.js +51 -0
  33. package/dist/src/commands/_run-driver-helpers.d.ts +8 -81
  34. package/dist/src/commands/_run-driver-helpers.js +79 -283
  35. package/dist/src/commands/_run-projection.d.ts +50 -0
  36. package/dist/src/commands/_run-projection.js +349 -0
  37. package/dist/src/commands/_run-subcommands.d.ts +3 -0
  38. package/dist/src/commands/_run-subcommands.js +31 -0
  39. package/dist/src/commands/_spinner.js +1 -1
  40. package/dist/src/commands/agent.d.ts +1 -1
  41. package/dist/src/commands/agent.js +8559 -239
  42. package/dist/src/commands/dist.d.ts +1 -1
  43. package/dist/src/commands/dist.js +27 -19
  44. package/dist/src/commands/doctor.d.ts +1 -1
  45. package/dist/src/commands/doctor.js +93 -475
  46. package/dist/src/commands/github.d.ts +1 -1
  47. package/dist/src/commands/github.js +113 -387
  48. package/dist/src/commands/inbox.d.ts +22 -24
  49. package/dist/src/commands/inbox.js +420 -691
  50. package/dist/src/commands/init.d.ts +6 -16
  51. package/dist/src/commands/init.js +334 -971
  52. package/dist/src/commands/inspect.d.ts +19 -2
  53. package/dist/src/commands/inspect.js +644 -610
  54. package/dist/src/commands/pi.d.ts +1 -1
  55. package/dist/src/commands/plugin.d.ts +1 -1
  56. package/dist/src/commands/plugin.js +486 -7
  57. package/dist/src/commands/profile-and-review.d.ts +1 -1
  58. package/dist/src/commands/profile-and-review.js +94 -56
  59. package/dist/src/commands/queue.js +1 -21
  60. package/dist/src/commands/remote.d.ts +1 -1
  61. package/dist/src/commands/remote.js +837 -14
  62. package/dist/src/commands/repo-git-harness.d.ts +1 -1
  63. package/dist/src/commands/repo-git-harness.js +57 -14
  64. package/dist/src/commands/run.d.ts +20 -2
  65. package/dist/src/commands/run.js +17579 -1759
  66. package/dist/src/commands/server.d.ts +2 -6
  67. package/dist/src/commands/server.js +141 -723
  68. package/dist/src/commands/setup.d.ts +1 -1
  69. package/dist/src/commands/setup.js +102 -484
  70. package/dist/src/commands/stats.d.ts +13 -10
  71. package/dist/src/commands/stats.js +689 -761
  72. package/dist/src/commands/task-run-driver.d.ts +50 -88
  73. package/dist/src/commands/task-run-driver.js +116 -2717
  74. package/dist/src/commands/task.d.ts +34 -13
  75. package/dist/src/commands/task.js +668 -2523
  76. package/dist/src/commands/test.d.ts +1 -1
  77. package/dist/src/commands/triage.d.ts +11 -0
  78. package/dist/src/commands/triage.js +227 -0
  79. package/dist/src/commands/workspace.d.ts +1 -1
  80. package/dist/src/commands.d.ts +0 -16
  81. package/dist/src/commands.js +16657 -12250
  82. package/dist/src/index.js +16528 -12497
  83. package/dist/src/launcher.js +4 -0
  84. package/dist/src/operator-cli.d.ts +2 -0
  85. package/dist/src/operator-cli.js +17837 -0
  86. package/dist/src/operator-entry.d.ts +1 -0
  87. package/dist/src/operator-entry.js +3 -0
  88. package/package.json +18 -12
  89. package/dist/src/app/board.d.ts +0 -23
  90. package/dist/src/app/board.js +0 -1786
  91. package/dist/src/app/theme.d.ts +0 -47
  92. package/dist/src/app/theme.js +0 -150
  93. package/dist/src/commands/_authority-runs.d.ts +0 -22
  94. package/dist/src/commands/_authority-runs.js +0 -110
  95. package/dist/src/commands/_operator-surface.d.ts +0 -34
  96. package/dist/src/commands/_operator-surface.js +0 -220
  97. package/dist/src/commands/_operator-view.d.ts +0 -30
  98. package/dist/src/commands/_operator-view.js +0 -1070
  99. package/dist/src/commands/_preflight.d.ts +0 -22
  100. package/dist/src/commands/_preflight.js +0 -540
  101. package/dist/src/commands/_run-replay.d.ts +0 -24
  102. package/dist/src/commands/_run-replay.js +0 -142
  103. package/dist/src/commands/_server-client.d.ts +0 -186
  104. package/dist/src/commands/_server-client.js +0 -681
  105. package/dist/src/commands/_snapshot-upload.d.ts +0 -39
  106. package/dist/src/commands/_snapshot-upload.js +0 -455
  107. package/dist/src/commands/_task-picker.d.ts +0 -9
  108. package/dist/src/commands/_task-picker.js +0 -201
  109. package/dist/src/commands/browser.d.ts +0 -65
  110. package/dist/src/commands/browser.js +0 -1173
  111. package/dist/src/commands/connect.d.ts +0 -7
  112. package/dist/src/commands/connect.js +0 -419
  113. package/dist/src/commands/inspector.d.ts +0 -3
  114. package/dist/src/commands/inspector.js +0 -263
  115. package/dist/src/commands/task-report-bug.d.ts +0 -19
  116. package/dist/src/commands/task-report-bug.js +0 -1281
  117. package/dist/src/report-bug.d.ts +0 -44
  118. package/dist/src/report-bug.js +0 -260
@@ -1,4 +1,7 @@
1
1
  // @bun
2
+ // packages/cli/src/commands/profile-and-review.ts
3
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
4
+
2
5
  // packages/cli/src/runner.ts
3
6
  import { EventBus } from "@rig/runtime/control-plane/runtime/events";
4
7
  import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
@@ -41,14 +44,6 @@ Usage: ${usage}`);
41
44
  }
42
45
  }
43
46
 
44
- // packages/cli/src/commands/profile-and-review.ts
45
- import {
46
- setProfile,
47
- setReviewProfile,
48
- showProfile,
49
- showReviewProfile
50
- } from "@rig/runtime/control-plane/native/profile-ops";
51
-
52
47
  // packages/cli/src/withMutedConsole.ts
53
48
  function isPromise(value) {
54
49
  if (typeof value !== "object" && typeof value !== "function") {
@@ -88,7 +83,75 @@ function withMutedConsole(mute, fn) {
88
83
  }
89
84
  }
90
85
 
86
+ // packages/cli/src/commands/_paths.ts
87
+ import { resolve } from "path";
88
+ import { resolveMonorepoRoot } from "@rig/runtime/layout";
89
+ function resolveControlPlaneHostStateRoot(projectRoot) {
90
+ return resolve(projectRoot, ".rig");
91
+ }
92
+ function resolveControlPlaneHostStateDir(projectRoot) {
93
+ return resolve(resolveControlPlaneHostStateRoot(projectRoot), "state");
94
+ }
95
+
91
96
  // packages/cli/src/commands/profile-and-review.ts
97
+ var DEFAULT_AGENT_PROFILE = {
98
+ model: "pi",
99
+ runtime: "pi",
100
+ agent_plugin: "pi",
101
+ updated_at: new Date().toISOString()
102
+ };
103
+ function agentProfilePath(projectRoot) {
104
+ return `${resolveControlPlaneHostStateDir(projectRoot)}/agent-profile.json`;
105
+ }
106
+ function reviewProfilePath(projectRoot) {
107
+ return `${resolveControlPlaneHostStateDir(projectRoot)}/review-profile.json`;
108
+ }
109
+ function readJson(path) {
110
+ if (!existsSync(path))
111
+ return null;
112
+ try {
113
+ return JSON.parse(readFileSync(path, "utf8"));
114
+ } catch {
115
+ return null;
116
+ }
117
+ }
118
+ async function showProfile(projectRoot) {
119
+ const profile = { ...DEFAULT_AGENT_PROFILE, ...readJson(agentProfilePath(projectRoot)), model: "pi", runtime: "pi", agent_plugin: "pi" };
120
+ console.log("Execution Profile:");
121
+ console.log(` model: ${profile.model}`);
122
+ console.log(` runtime: ${profile.runtime}`);
123
+ console.log(` plugin: ${profile.agent_plugin}`);
124
+ }
125
+ async function setProfile(projectRoot) {
126
+ mkdirSync(resolveControlPlaneHostStateDir(projectRoot), { recursive: true });
127
+ writeFileSync(agentProfilePath(projectRoot), `${JSON.stringify({ ...DEFAULT_AGENT_PROFILE, updated_at: new Date().toISOString() }, null, 2)}
128
+ `, "utf8");
129
+ await showProfile(projectRoot);
130
+ }
131
+ async function showReviewProfile(projectRoot) {
132
+ const parsed = readJson(reviewProfilePath(projectRoot));
133
+ const profile = {
134
+ mode: parsed?.mode === "off" || parsed?.mode === "required" || parsed?.mode === "advisory" ? parsed.mode : "advisory",
135
+ provider: "greptile",
136
+ updated_at: typeof parsed?.updated_at === "string" ? parsed.updated_at : new Date().toISOString()
137
+ };
138
+ console.log("AI Review Profile:");
139
+ console.log(` mode: ${profile.mode}`);
140
+ console.log(` provider: ${profile.provider}`);
141
+ console.log(` file: ${reviewProfilePath(projectRoot)}`);
142
+ }
143
+ async function setReviewProfile(projectRoot, mode, provider) {
144
+ if (mode !== "off" && mode !== "advisory" && mode !== "required") {
145
+ throw new Error(`Invalid mode: ${mode}. Use off|advisory|required.`);
146
+ }
147
+ if (provider && provider !== "greptile") {
148
+ throw new Error(`Invalid provider: ${provider}. Supported: greptile.`);
149
+ }
150
+ mkdirSync(resolveControlPlaneHostStateDir(projectRoot), { recursive: true });
151
+ writeFileSync(reviewProfilePath(projectRoot), `${JSON.stringify({ mode, provider: "greptile", updated_at: new Date().toISOString() }, null, 2)}
152
+ `, "utf8");
153
+ await showReviewProfile(projectRoot);
154
+ }
92
155
  async function executeProfile(context, args) {
93
156
  const [command = "show", ...rest] = args;
94
157
  switch (command) {
@@ -97,22 +160,9 @@ async function executeProfile(context, args) {
97
160
  await withMutedConsole(context.outputMode === "json", () => showProfile(context.projectRoot));
98
161
  return { ok: true, group: "profile", command };
99
162
  case "set": {
100
- if (rest.length === 0) {
101
- throw new CliError("Usage: rig profile set <claude-code|codex-cli|pi> or set [--model ...] [--runtime ...] [--plugin ...]");
102
- }
103
- const preset = rest[0];
104
- if (preset && !preset.startsWith("-")) {
105
- if (rest.length !== 1) {
106
- throw new CliError("Usage: rig profile set <claude-code|codex-cli|pi>");
107
- }
108
- try {
109
- await withMutedConsole(context.outputMode === "json", () => setProfile(context.projectRoot, { preset }));
110
- } catch (error) {
111
- throw new CliError(error instanceof Error ? error.message : String(error), 2);
112
- }
113
- return { ok: true, group: "profile", command, details: { preset } };
114
- }
115
163
  let pending = rest;
164
+ const presetResult = takeOption(pending, "--preset");
165
+ pending = presetResult.rest;
116
166
  const modelResult = takeOption(pending, "--model");
117
167
  pending = modelResult.rest;
118
168
  const runtimeResult = takeOption(pending, "--runtime");
@@ -120,28 +170,13 @@ async function executeProfile(context, args) {
120
170
  const pluginResult = takeOption(pending, "--plugin");
121
171
  pending = pluginResult.rest;
122
172
  requireNoExtraArgs(pending, "rig profile set [--model ...] [--runtime ...] [--plugin ...]");
123
- if (!modelResult.value && !runtimeResult.value && !pluginResult.value) {
124
- throw new CliError("Provide at least one of --model, --runtime, or --plugin.", 1, { hint: "Example: `rig profile set --model claude-sonnet`. See current values with `rig profile show`." });
125
- }
126
- try {
127
- await withMutedConsole(context.outputMode === "json", () => setProfile(context.projectRoot, {
128
- model: modelResult.value,
129
- runtime: runtimeResult.value,
130
- plugin: pluginResult.value
131
- }));
132
- } catch (error) {
133
- throw new CliError(error instanceof Error ? error.message : String(error), 2);
173
+ if (!presetResult.value && !modelResult.value && !runtimeResult.value && !pluginResult.value && rest.length === 0) {
174
+ throw new CliError("Provide at least one of --model, --runtime, or --plugin.", 1, {
175
+ hint: "Example: `rig profile set --model pi`. See current values with `rig profile show`."
176
+ });
134
177
  }
135
- return {
136
- ok: true,
137
- group: "profile",
138
- command,
139
- details: {
140
- model: modelResult.value || null,
141
- runtime: runtimeResult.value || null,
142
- plugin: pluginResult.value || null
143
- }
144
- };
178
+ await withMutedConsole(context.outputMode === "json", () => setProfile(context.projectRoot));
179
+ return { ok: true, group: "profile", command, details: { lockedTo: "pi" } };
145
180
  }
146
181
  default:
147
182
  throw new CliError(`Unknown profile command: ${command}`, 1, { hint: "Run `rig profile --help` \u2014 commands are show|set." });
@@ -155,25 +190,28 @@ async function executeReview(context, args) {
155
190
  await withMutedConsole(context.outputMode === "json", () => showReviewProfile(context.projectRoot));
156
191
  return { ok: true, group: "review", command };
157
192
  case "set": {
158
- if (rest.length === 0) {
159
- throw new CliError("Usage: rig review set <off|advisory|required> [--provider greptile]");
193
+ let pending = rest;
194
+ const modeResult = takeOption(pending, "--mode");
195
+ pending = modeResult.rest;
196
+ const providerResult = takeOption(pending, "--provider");
197
+ pending = providerResult.rest;
198
+ const positionalMode = pending[0];
199
+ if (modeResult.value && positionalMode) {
200
+ throw new CliError("Usage: rig review set <off|advisory|required> [--provider greptile]", 1, {
201
+ hint: "Pass the mode positionally, or use --mode as a compatibility alias, but not both."
202
+ });
160
203
  }
161
- const mode = rest[0];
204
+ requireNoExtraArgs(positionalMode ? pending.slice(1) : pending, "rig review set <off|advisory|required> [--provider greptile]");
205
+ const mode = modeResult.value ?? positionalMode;
162
206
  if (!mode) {
163
- throw new CliError("Usage: rig review set <off|advisory|required> [--provider greptile]");
207
+ throw new CliError("Usage: rig review set <off|advisory|required> [--provider greptile]", 1);
164
208
  }
165
- let pending = rest.slice(1);
166
- const providerResult = takeOption(pending, "--provider");
167
- pending = providerResult.rest;
168
- requireNoExtraArgs(pending, "rig review set <off|advisory|required> [--provider greptile]");
169
209
  try {
170
- await withMutedConsole(context.outputMode === "json", () => {
171
- return setReviewProfile(context.projectRoot, mode, providerResult.value);
172
- });
210
+ await withMutedConsole(context.outputMode === "json", () => setReviewProfile(context.projectRoot, mode, providerResult.value));
173
211
  } catch (error) {
174
212
  throw new CliError(error instanceof Error ? error.message : String(error), 2);
175
213
  }
176
- return { ok: true, group: "review", command, details: { mode, provider: providerResult.value || null } };
214
+ return { ok: true, group: "review", command, details: { mode, provider: "greptile" } };
177
215
  }
178
216
  default:
179
217
  throw new CliError(`Unknown review command: ${command}`, 1, { hint: "Run `rig review --help` \u2014 commands are show|set." });
@@ -92,26 +92,8 @@ function parseIsolationMode(value, allowOff) {
92
92
  throw new CliError(`Invalid isolation mode: ${value}. Use ${allowOff ? "off|" : ""}worktree.`);
93
93
  }
94
94
 
95
- // packages/cli/src/commands/_preflight.ts
95
+ // packages/cli/src/commands/queue.ts
96
96
  import { ensureProjectMainFreshBeforeRun } from "@rig/runtime/control-plane/project-main-pre-run-sync";
97
-
98
- // packages/cli/src/commands/_server-client.ts
99
- import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
100
- var scopedGitHubBearerTokens = new Map;
101
- var serverReachabilityCache = new Map;
102
- var RESUMABLE_RUN_STATUSES = new Set([
103
- "created",
104
- "preparing",
105
- "running",
106
- "validating",
107
- "reviewing",
108
- "stopped",
109
- "failed",
110
- "needs-attention",
111
- "needs_attention"
112
- ]);
113
-
114
- // packages/cli/src/commands/_preflight.ts
115
97
  async function runProjectMainSyncPreflight(context, options) {
116
98
  if (context.dryRun) {
117
99
  if (context.outputMode === "text" && !options.disabled) {
@@ -149,8 +131,6 @@ async function runProjectMainSyncPreflight(context, options) {
149
131
  break;
150
132
  }
151
133
  }
152
-
153
- // packages/cli/src/commands/queue.ts
154
134
  async function executeQueue(context, args) {
155
135
  const [command = "run", ...rest] = args;
156
136
  switch (command) {
@@ -1,3 +1,3 @@
1
1
  import { type RunnerContext } from "../runner";
2
- import type { CommandOutcome } from "@rig/runtime/control-plane/runtime/types";
2
+ import type { CommandOutcome } from "@rig/runtime";
3
3
  export declare function executeRemote(context: RunnerContext, args: string[]): Promise<CommandOutcome>;