@h-rig/cli 0.0.6-alpha.100 → 0.0.6-alpha.101

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 (112) hide show
  1. package/README.md +6 -27
  2. package/bin/rig.js +16 -0
  3. package/package.json +14 -40
  4. package/dist/bin/build-rig-binaries.d.ts +0 -2
  5. package/dist/bin/build-rig-binaries.js +0 -119
  6. package/dist/bin/rig.d.ts +0 -72
  7. package/dist/bin/rig.js +0 -17875
  8. package/dist/config/rig-default-config.yml +0 -5
  9. package/dist/src/app/drone-ui.d.ts +0 -34
  10. package/dist/src/app/drone-ui.js +0 -278
  11. package/dist/src/commands/_async-ui.d.ts +0 -10
  12. package/dist/src/commands/_async-ui.js +0 -121
  13. package/dist/src/commands/_cli-format.d.ts +0 -56
  14. package/dist/src/commands/_cli-format.js +0 -319
  15. package/dist/src/commands/_config-env.d.ts +0 -18
  16. package/dist/src/commands/_config-env.js +0 -22
  17. package/dist/src/commands/_connection-state.d.ts +0 -54
  18. package/dist/src/commands/_connection-state.js +0 -187
  19. package/dist/src/commands/_doctor-checks.d.ts +0 -46
  20. package/dist/src/commands/_doctor-checks.js +0 -352
  21. package/dist/src/commands/_help-catalog.d.ts +0 -29
  22. package/dist/src/commands/_help-catalog.js +0 -146
  23. package/dist/src/commands/_inprocess-services.d.ts +0 -33
  24. package/dist/src/commands/_inprocess-services.js +0 -102
  25. package/dist/src/commands/_json-output.d.ts +0 -11
  26. package/dist/src/commands/_json-output.js +0 -60
  27. package/dist/src/commands/_lazy-reconcile.d.ts +0 -34
  28. package/dist/src/commands/_lazy-reconcile.js +0 -102
  29. package/dist/src/commands/_parsers.d.ts +0 -15
  30. package/dist/src/commands/_parsers.js +0 -114
  31. package/dist/src/commands/_paths.d.ts +0 -11
  32. package/dist/src/commands/_paths.js +0 -50
  33. package/dist/src/commands/_pi-frontend.d.ts +0 -35
  34. package/dist/src/commands/_pi-frontend.js +0 -64
  35. package/dist/src/commands/_pi-install.d.ts +0 -42
  36. package/dist/src/commands/_pi-install.js +0 -167
  37. package/dist/src/commands/_policy.d.ts +0 -8
  38. package/dist/src/commands/_policy.js +0 -127
  39. package/dist/src/commands/_probes.d.ts +0 -1
  40. package/dist/src/commands/_probes.js +0 -13
  41. package/dist/src/commands/_run-bridge.d.ts +0 -114
  42. package/dist/src/commands/_run-bridge.js +0 -387
  43. package/dist/src/commands/_run-diagnostics.d.ts +0 -9
  44. package/dist/src/commands/_run-diagnostics.js +0 -51
  45. package/dist/src/commands/_run-driver-helpers.d.ts +0 -26
  46. package/dist/src/commands/_run-driver-helpers.js +0 -138
  47. package/dist/src/commands/_run-projection.d.ts +0 -50
  48. package/dist/src/commands/_run-projection.js +0 -349
  49. package/dist/src/commands/_run-subcommands.d.ts +0 -3
  50. package/dist/src/commands/_run-subcommands.js +0 -31
  51. package/dist/src/commands/_spinner.d.ts +0 -25
  52. package/dist/src/commands/_spinner.js +0 -65
  53. package/dist/src/commands/agent.d.ts +0 -3
  54. package/dist/src/commands/agent.js +0 -8952
  55. package/dist/src/commands/config.d.ts +0 -3
  56. package/dist/src/commands/config.js +0 -181
  57. package/dist/src/commands/dist.d.ts +0 -28
  58. package/dist/src/commands/dist.js +0 -417
  59. package/dist/src/commands/doctor.d.ts +0 -3
  60. package/dist/src/commands/doctor.js +0 -480
  61. package/dist/src/commands/github.d.ts +0 -3
  62. package/dist/src/commands/github.js +0 -342
  63. package/dist/src/commands/inbox.d.ts +0 -28
  64. package/dist/src/commands/inbox.js +0 -579
  65. package/dist/src/commands/init.d.ts +0 -64
  66. package/dist/src/commands/init.js +0 -1541
  67. package/dist/src/commands/inspect.d.ts +0 -20
  68. package/dist/src/commands/inspect.js +0 -764
  69. package/dist/src/commands/pi.d.ts +0 -3
  70. package/dist/src/commands/pi.js +0 -177
  71. package/dist/src/commands/plugin.d.ts +0 -16
  72. package/dist/src/commands/plugin.js +0 -714
  73. package/dist/src/commands/profile-and-review.d.ts +0 -4
  74. package/dist/src/commands/profile-and-review.js +0 -223
  75. package/dist/src/commands/queue.d.ts +0 -3
  76. package/dist/src/commands/queue.js +0 -197
  77. package/dist/src/commands/remote.d.ts +0 -3
  78. package/dist/src/commands/remote.js +0 -1340
  79. package/dist/src/commands/repo-git-harness.d.ts +0 -5
  80. package/dist/src/commands/repo-git-harness.js +0 -271
  81. package/dist/src/commands/run.d.ts +0 -21
  82. package/dist/src/commands/run.js +0 -17867
  83. package/dist/src/commands/server.d.ts +0 -3
  84. package/dist/src/commands/server.js +0 -249
  85. package/dist/src/commands/setup.d.ts +0 -16
  86. package/dist/src/commands/setup.js +0 -644
  87. package/dist/src/commands/stats.d.ts +0 -15
  88. package/dist/src/commands/stats.js +0 -632
  89. package/dist/src/commands/task-run-driver.d.ts +0 -94
  90. package/dist/src/commands/task-run-driver.js +0 -203
  91. package/dist/src/commands/task.d.ts +0 -35
  92. package/dist/src/commands/task.js +0 -818
  93. package/dist/src/commands/test.d.ts +0 -3
  94. package/dist/src/commands/test.js +0 -46
  95. package/dist/src/commands/triage.d.ts +0 -11
  96. package/dist/src/commands/triage.js +0 -227
  97. package/dist/src/commands/workspace.d.ts +0 -3
  98. package/dist/src/commands/workspace.js +0 -130
  99. package/dist/src/commands.d.ts +0 -13
  100. package/dist/src/commands.js +0 -17999
  101. package/dist/src/index.d.ts +0 -4
  102. package/dist/src/index.js +0 -18011
  103. package/dist/src/launcher.d.ts +0 -61
  104. package/dist/src/launcher.js +0 -199
  105. package/dist/src/operator-cli.d.ts +0 -2
  106. package/dist/src/operator-cli.js +0 -17867
  107. package/dist/src/operator-entry.d.ts +0 -1
  108. package/dist/src/operator-entry.js +0 -3
  109. package/dist/src/runner.d.ts +0 -47
  110. package/dist/src/runner.js +0 -267
  111. package/dist/src/withMutedConsole.d.ts +0 -2
  112. package/dist/src/withMutedConsole.js +0 -42
@@ -1,3 +0,0 @@
1
- import { type RunnerContext } from "../runner";
2
- import type { CommandOutcome } from "@rig/runtime";
3
- export declare function executeServer(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
@@ -1,249 +0,0 @@
1
- // @bun
2
- // packages/cli/src/runner.ts
3
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
4
- import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
5
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
6
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
7
-
8
- class CliError extends RuntimeCliError {
9
- hint;
10
- constructor(message, exitCode = 1, options = {}) {
11
- super(message, exitCode);
12
- if (options.hint?.trim()) {
13
- this.hint = options.hint.trim();
14
- }
15
- }
16
- }
17
- function takeOption(args, option) {
18
- const rest = [];
19
- let value;
20
- for (let index = 0;index < args.length; index += 1) {
21
- const current = args[index];
22
- if (current === option) {
23
- const next = args[index + 1];
24
- if (!next || next.startsWith("-")) {
25
- throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
26
- }
27
- value = next;
28
- index += 1;
29
- continue;
30
- }
31
- if (current !== undefined) {
32
- rest.push(current);
33
- }
34
- }
35
- return { value, rest };
36
- }
37
- function requireNoExtraArgs(args, usage) {
38
- if (args.length > 0) {
39
- throw new CliError(`Unexpected arguments: ${args.join(" ")}
40
- Usage: ${usage}`);
41
- }
42
- }
43
-
44
- // packages/cli/src/commands/server.ts
45
- import {
46
- listManagedRemoteEndpoints,
47
- removeManagedRemoteEndpoint,
48
- resolveSelectedRemote as resolveSelectedRemote2,
49
- upsertManagedRemoteEndpoint
50
- } from "@rig/runtime/control-plane/remote";
51
-
52
- // packages/cli/src/commands/_connection-state.ts
53
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
54
- import { dirname, resolve } from "path";
55
- function resolveRepoConnectionPath(projectRoot) {
56
- return resolve(projectRoot, ".rig", "state", "connection.json");
57
- }
58
- function readJsonFile(path) {
59
- if (!existsSync(path))
60
- return null;
61
- try {
62
- return JSON.parse(readFileSync(path, "utf8"));
63
- } catch (error) {
64
- throw new CliError(`Invalid Rig connection state at ${path}: ${error instanceof Error ? error.message : String(error)}`, 1, { hint: "Fix or delete that file, then re-select a server with `rig server use <alias|local>`." });
65
- }
66
- }
67
- function writeJsonFile(path, value) {
68
- mkdirSync(dirname(path), { recursive: true });
69
- writeFileSync(path, `${JSON.stringify(value, null, 2)}
70
- `, "utf8");
71
- }
72
- function readRepoConnection(projectRoot) {
73
- const payload = readJsonFile(resolveRepoConnectionPath(projectRoot));
74
- if (!payload || typeof payload !== "object" || Array.isArray(payload))
75
- return null;
76
- const record = payload;
77
- const selected = typeof record.selected === "string" ? record.selected.trim() : "";
78
- if (!selected)
79
- return null;
80
- return {
81
- selected,
82
- project: typeof record.project === "string" ? record.project : undefined,
83
- linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined,
84
- serverProjectRoot: typeof record.serverProjectRoot === "string" && record.serverProjectRoot.trim() ? record.serverProjectRoot.trim() : undefined,
85
- serverProjectRootAlias: typeof record.serverProjectRootAlias === "string" && record.serverProjectRootAlias.trim() ? record.serverProjectRootAlias.trim() : undefined,
86
- serverProjectRootBaseUrl: typeof record.serverProjectRootBaseUrl === "string" && record.serverProjectRootBaseUrl.trim() ? record.serverProjectRootBaseUrl.trim().replace(/\/+$/, "") : undefined
87
- };
88
- }
89
- function writeRepoConnection(projectRoot, state) {
90
- writeJsonFile(resolveRepoConnectionPath(projectRoot), state);
91
- }
92
-
93
- // packages/cli/src/commands/_run-bridge.ts
94
- import { dirname as dirname2, resolve as resolve2 } from "path";
95
- import { CUSTOM_TYPE_FOR, sessionIdFromSessionFile } from "@rig/contracts";
96
- import { createPluginHost } from "@rig/core";
97
- import { loadConfig } from "@rig/core/load-config";
98
- import { resolveOwnerNamespaceKey, resolveRegistryBaseUrl, resolveRegistrySecret, resolveSelectedRemote } from "@rig/runtime/control-plane/remote";
99
- import { listAgentRuntimes } from "@rig/runtime/control-plane/runtime/isolation";
100
- import { createRegistryClient } from "@rig/relay-registry";
101
- import {
102
- listActiveCollabSessions as ompListActiveCollabSessions
103
- } from "@oh-my-pi/pi-coding-agent/collab/api";
104
- async function readSelectedTarget(projectRoot, env = process.env) {
105
- const config = await loadConfig(resolve2(projectRoot));
106
- const selected = resolveSelectedRemote(projectRoot, env);
107
- return {
108
- alias: selected?.alias ?? "local",
109
- kind: selected ? "remote" : "local",
110
- projectRoot,
111
- status: "ready",
112
- taskSource: config.taskSource.kind
113
- };
114
- }
115
-
116
- // packages/cli/src/commands/_cli-format.ts
117
- import pc from "picocolors";
118
- var dim = pc.dim;
119
- var faintBar = pc.dim("\u2502");
120
- var accent = pc.cyan;
121
- function printFormattedOutput(message) {
122
- console.log(message);
123
- }
124
-
125
- // packages/cli/src/commands/server.ts
126
- var DEFAULT_REMOTE_PORT = 22;
127
- async function executeServer(context, args) {
128
- const [command = "status", ...rest] = args;
129
- const text = context.outputMode === "text";
130
- const projectRoot = context.projectRoot;
131
- switch (command) {
132
- case "status": {
133
- requireNoExtraArgs(rest, "rig server status");
134
- const target = await readSelectedTarget(projectRoot);
135
- const remote = resolveSelectedRemote2(projectRoot);
136
- if (text) {
137
- printFormattedOutput(target.kind === "local" ? "Placement: local (runs execute on this machine)." : `Placement: remote \u2192 ${target.alias}${remote ? ` (${remote.host}:${remote.port})` : ""}`);
138
- printFormattedOutput(`Task source: ${target.taskSource}`);
139
- }
140
- return {
141
- ok: true,
142
- group: "server",
143
- command,
144
- details: {
145
- placement: target.kind,
146
- alias: target.alias,
147
- taskSource: target.taskSource,
148
- ...remote ? { host: remote.host, port: remote.port } : {}
149
- }
150
- };
151
- }
152
- case "list": {
153
- requireNoExtraArgs(rest, "rig server list");
154
- const endpoints = listManagedRemoteEndpoints(undefined, projectRoot);
155
- const selected = readRepoConnection(projectRoot)?.selected ?? "local";
156
- if (text) {
157
- printFormattedOutput(`${selected === "local" ? "* " : " "}local \u2014 runs execute on this machine`);
158
- if (endpoints.length === 0) {
159
- printFormattedOutput(" (no remote endpoints; add one with `rig server add --alias <a> --host <h>`)");
160
- }
161
- for (const endpoint of endpoints) {
162
- printFormattedOutput(`${selected === endpoint.alias ? "* " : " "}${endpoint.alias} \u2014 ${endpoint.host}:${endpoint.port}`);
163
- }
164
- }
165
- return {
166
- ok: true,
167
- group: "server",
168
- command,
169
- details: { selected, endpoints: endpoints.map((e) => ({ alias: e.alias, host: e.host, port: e.port })) }
170
- };
171
- }
172
- case "use": {
173
- const [aliasArg, ...extra] = rest;
174
- requireNoExtraArgs(extra, "rig server use <local|alias>");
175
- const alias = (aliasArg ?? "").trim();
176
- if (!alias) {
177
- throw new CliError("rig server use requires a target.", 2, { hint: "rig server use local | rig server use <alias>" });
178
- }
179
- if (alias !== "local") {
180
- const known = listManagedRemoteEndpoints(undefined, projectRoot).some((endpoint) => endpoint.alias === alias);
181
- if (!known) {
182
- throw new CliError(`Unknown remote endpoint: ${alias}`, 2, {
183
- hint: "Run `rig server list`, or add it with `rig server add --alias <a> --host <h>`."
184
- });
185
- }
186
- }
187
- if (context.dryRun)
188
- return { ok: true, group: "server", command, details: { selected: alias, dryRun: true } };
189
- const prev = readRepoConnection(projectRoot);
190
- writeRepoConnection(projectRoot, { ...prev ?? { selected: "local" }, selected: alias });
191
- if (text)
192
- printFormattedOutput(alias === "local" ? "Placement set to local." : `Placement set to remote \u2192 ${alias}.`);
193
- return { ok: true, group: "server", command, details: { selected: alias } };
194
- }
195
- case "add": {
196
- const aliasOpt = takeOption(rest, "--alias");
197
- const hostOpt = takeOption(aliasOpt.rest, "--host");
198
- const portOpt = takeOption(hostOpt.rest, "--port");
199
- const tokenOpt = takeOption(portOpt.rest, "--token");
200
- const positional = tokenOpt.rest.filter((arg) => !arg.startsWith("-"));
201
- const alias = (aliasOpt.value ?? positional[0] ?? "").trim();
202
- const host = (hostOpt.value ?? positional[1] ?? "").trim();
203
- const portRaw = portOpt.value ?? positional[2];
204
- if (!alias || !host) {
205
- throw new CliError("rig server add requires --alias <a> and --host <h>.", 2, {
206
- hint: "rig server add --alias prod --host prod.example.com --port 22"
207
- });
208
- }
209
- const port = portRaw ? Number(portRaw) : DEFAULT_REMOTE_PORT;
210
- if (!Number.isFinite(port))
211
- throw new CliError(`Invalid --port: ${portRaw}`, 2);
212
- if (context.dryRun)
213
- return { ok: true, group: "server", command, details: { alias, host, port, dryRun: true } };
214
- const saved = upsertManagedRemoteEndpoint({ alias, host, port, ...tokenOpt.value ? { token: tokenOpt.value } : {} }, undefined, projectRoot);
215
- if (text) {
216
- printFormattedOutput(`Saved remote endpoint ${saved.alias} \u2192 ${saved.host}:${saved.port}. Select it with \`rig server use ${saved.alias}\`.`);
217
- }
218
- return { ok: true, group: "server", command, details: { alias: saved.alias, host: saved.host, port: saved.port } };
219
- }
220
- case "remove": {
221
- const [aliasArg, ...extra] = rest;
222
- requireNoExtraArgs(extra, "rig server remove <alias>");
223
- const alias = (aliasArg ?? "").trim();
224
- if (!alias)
225
- throw new CliError("rig server remove requires an alias.", 2);
226
- if (context.dryRun)
227
- return { ok: true, group: "server", command, details: { alias, dryRun: true } };
228
- const removed = removeManagedRemoteEndpoint(alias, undefined, projectRoot);
229
- if (text)
230
- printFormattedOutput(removed ? `Removed remote endpoint ${alias}.` : `No remote endpoint named ${alias}.`);
231
- return { ok: removed, group: "server", command, details: { alias, removed } };
232
- }
233
- case "start":
234
- throw new CliError("rig server start is retired: there is no standalone Rig server process after the OMP migration.", 2, {
235
- hint: "Runs execute locally (tmux) or on a selected remote \u2014 pick one with `rig server use local|<alias>`."
236
- });
237
- case "repair-link":
238
- throw new CliError("rig server repair-link is retired with the standalone server.", 2, {
239
- hint: "Select placement with `rig server use local|<alias>`."
240
- });
241
- default:
242
- throw new CliError(`Unknown server command: ${command}`, 1, {
243
- hint: "Run `rig server --help` \u2014 commands are status|list|use|add|remove."
244
- });
245
- }
246
- }
247
- export {
248
- executeServer
249
- };
@@ -1,16 +0,0 @@
1
- import { type RunnerContext } from "../runner";
2
- import { type RigPluginWithRuntime } from "@rig/core";
3
- import type { TaskSourceConfig } from "@rig/contracts";
4
- import type { CommandOutcome } from "@rig/runtime";
5
- export declare function executeSetup(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
6
- type SetupCheck = {
7
- ok: boolean;
8
- label: string;
9
- hint?: string;
10
- };
11
- type SetupRigConfig = {
12
- plugins?: readonly RigPluginWithRuntime[];
13
- taskSource?: TaskSourceConfig;
14
- };
15
- export declare function buildTaskSourceKindSetupCheck(config: SetupRigConfig): SetupCheck | null;
16
- export {};