@h-rig/cli-surface-plugin 0.0.6-alpha.146

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 (94) hide show
  1. package/README.md +1 -0
  2. package/dist/src/app/drone-ui.d.ts +34 -0
  3. package/dist/src/app/drone-ui.js +278 -0
  4. package/dist/src/commands/_async-ui.d.ts +10 -0
  5. package/dist/src/commands/_async-ui.js +121 -0
  6. package/dist/src/commands/_cli-format.d.ts +56 -0
  7. package/dist/src/commands/_cli-format.js +332 -0
  8. package/dist/src/commands/_connection-state.d.ts +54 -0
  9. package/dist/src/commands/_connection-state.js +187 -0
  10. package/dist/src/commands/_doctor-checks.d.ts +9 -0
  11. package/dist/src/commands/_doctor-checks.js +24 -0
  12. package/dist/src/commands/_help-catalog.d.ts +29 -0
  13. package/dist/src/commands/_help-catalog.js +157 -0
  14. package/dist/src/commands/_inprocess-services.d.ts +33 -0
  15. package/dist/src/commands/_inprocess-services.js +102 -0
  16. package/dist/src/commands/_json-output.d.ts +11 -0
  17. package/dist/src/commands/_json-output.js +54 -0
  18. package/dist/src/commands/_parsers.d.ts +15 -0
  19. package/dist/src/commands/_parsers.js +114 -0
  20. package/dist/src/commands/_paths.d.ts +11 -0
  21. package/dist/src/commands/_paths.js +50 -0
  22. package/dist/src/commands/_pi-frontend.d.ts +35 -0
  23. package/dist/src/commands/_pi-frontend.js +64 -0
  24. package/dist/src/commands/_pi-install.d.ts +42 -0
  25. package/dist/src/commands/_pi-install.js +167 -0
  26. package/dist/src/commands/_policy.d.ts +8 -0
  27. package/dist/src/commands/_policy.js +138 -0
  28. package/dist/src/commands/_probes.d.ts +1 -0
  29. package/dist/src/commands/_probes.js +13 -0
  30. package/dist/src/commands/_run-driver-helpers.d.ts +26 -0
  31. package/dist/src/commands/_run-driver-helpers.js +132 -0
  32. package/dist/src/commands/_run-subcommands.d.ts +3 -0
  33. package/dist/src/commands/_run-subcommands.js +31 -0
  34. package/dist/src/commands/_spinner.d.ts +25 -0
  35. package/dist/src/commands/_spinner.js +65 -0
  36. package/dist/src/commands/agent.d.ts +3 -0
  37. package/dist/src/commands/agent.js +322 -0
  38. package/dist/src/commands/config.d.ts +3 -0
  39. package/dist/src/commands/config.js +193 -0
  40. package/dist/src/commands/dist.d.ts +28 -0
  41. package/dist/src/commands/dist.js +435 -0
  42. package/dist/src/commands/doctor.d.ts +3 -0
  43. package/dist/src/commands/doctor.js +171 -0
  44. package/dist/src/commands/github.d.ts +3 -0
  45. package/dist/src/commands/github.js +342 -0
  46. package/dist/src/commands/inbox.d.ts +19 -0
  47. package/dist/src/commands/inbox.js +241 -0
  48. package/dist/src/commands/init.d.ts +64 -0
  49. package/dist/src/commands/init.js +1449 -0
  50. package/dist/src/commands/inspect.d.ts +20 -0
  51. package/dist/src/commands/inspect.js +337 -0
  52. package/dist/src/commands/pi.d.ts +3 -0
  53. package/dist/src/commands/pi.js +177 -0
  54. package/dist/src/commands/plugin.d.ts +20 -0
  55. package/dist/src/commands/plugin.js +238 -0
  56. package/dist/src/commands/profile-and-review.d.ts +4 -0
  57. package/dist/src/commands/profile-and-review.js +223 -0
  58. package/dist/src/commands/queue.d.ts +3 -0
  59. package/dist/src/commands/queue.js +197 -0
  60. package/dist/src/commands/remote.d.ts +3 -0
  61. package/dist/src/commands/remote.js +516 -0
  62. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  63. package/dist/src/commands/repo-git-harness.js +282 -0
  64. package/dist/src/commands/run.d.ts +22 -0
  65. package/dist/src/commands/run.js +645 -0
  66. package/dist/src/commands/server.d.ts +3 -0
  67. package/dist/src/commands/server.js +155 -0
  68. package/dist/src/commands/setup.d.ts +16 -0
  69. package/dist/src/commands/setup.js +356 -0
  70. package/dist/src/commands/stats.d.ts +11 -0
  71. package/dist/src/commands/stats.js +219 -0
  72. package/dist/src/commands/task-run-driver.d.ts +93 -0
  73. package/dist/src/commands/task-run-driver.js +136 -0
  74. package/dist/src/commands/task.d.ts +46 -0
  75. package/dist/src/commands/task.js +555 -0
  76. package/dist/src/commands/test.d.ts +3 -0
  77. package/dist/src/commands/test.js +46 -0
  78. package/dist/src/commands/triage.d.ts +11 -0
  79. package/dist/src/commands/triage.js +224 -0
  80. package/dist/src/commands/workspace.d.ts +3 -0
  81. package/dist/src/commands/workspace.js +130 -0
  82. package/dist/src/kernel-dispatch.d.ts +15 -0
  83. package/dist/src/kernel-dispatch.js +16 -0
  84. package/dist/src/plugin.d.ts +3 -0
  85. package/dist/src/plugin.js +5440 -0
  86. package/dist/src/rig-config-package-deps.d.ts +10 -0
  87. package/dist/src/rig-config-package-deps.js +272 -0
  88. package/dist/src/runner.d.ts +47 -0
  89. package/dist/src/runner.js +267 -0
  90. package/dist/src/version.d.ts +8 -0
  91. package/dist/src/version.js +47 -0
  92. package/dist/src/withMutedConsole.d.ts +2 -0
  93. package/dist/src/withMutedConsole.js +42 -0
  94. package/package.json +34 -0
@@ -0,0 +1,224 @@
1
+ // @bun
2
+ // packages/cli-surface-plugin/src/commands/triage.ts
3
+ import { runIssueAnalysisTriage } from "@rig/runtime/control-plane/github";
4
+
5
+ // packages/cli-surface-plugin/src/runner.ts
6
+ import { EventBus } from "@rig/runtime/control-plane/runtime/events";
7
+ import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
8
+ import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
9
+ import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
10
+
11
+ class CliError extends RuntimeCliError {
12
+ hint;
13
+ constructor(message, exitCode = 1, options = {}) {
14
+ super(message, exitCode);
15
+ if (options.hint?.trim()) {
16
+ this.hint = options.hint.trim();
17
+ }
18
+ }
19
+ }
20
+ function takeOption(args, option) {
21
+ const rest = [];
22
+ let value;
23
+ for (let index = 0;index < args.length; index += 1) {
24
+ const current = args[index];
25
+ if (current === option) {
26
+ const next = args[index + 1];
27
+ if (!next || next.startsWith("-")) {
28
+ throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
29
+ }
30
+ value = next;
31
+ index += 1;
32
+ continue;
33
+ }
34
+ if (current !== undefined) {
35
+ rest.push(current);
36
+ }
37
+ }
38
+ return { value, rest };
39
+ }
40
+ function requireNoExtraArgs(args, usage) {
41
+ if (args.length > 0) {
42
+ throw new CliError(`Unexpected arguments: ${args.join(" ")}
43
+ Usage: ${usage}`);
44
+ }
45
+ }
46
+
47
+ // packages/cli-surface-plugin/src/commands/_async-ui.ts
48
+ import pc from "picocolors";
49
+
50
+ // packages/cli-surface-plugin/src/commands/_spinner.ts
51
+ var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
52
+ function createTtySpinner(input) {
53
+ const output = input.output ?? process.stdout;
54
+ const isTty = output.isTTY === true;
55
+ const frames = input.frames && input.frames.length > 0 ? input.frames : SPINNER_FRAMES;
56
+ let label = input.label;
57
+ let frame = 0;
58
+ let paused = false;
59
+ let stopped = false;
60
+ let lastPrintedLabel = "";
61
+ const render = () => {
62
+ if (stopped || paused)
63
+ return;
64
+ if (!isTty) {
65
+ if (label !== lastPrintedLabel) {
66
+ output.write(`${label}
67
+ `);
68
+ lastPrintedLabel = label;
69
+ }
70
+ return;
71
+ }
72
+ frame = (frame + 1) % frames.length;
73
+ const glyph = frames[frame] ?? frames[0] ?? "";
74
+ output.write(`\r\x1B[2K${input.styleFrame ? input.styleFrame(glyph) : glyph} ${label}`);
75
+ };
76
+ const clearLine = () => {
77
+ if (isTty)
78
+ output.write("\r\x1B[2K");
79
+ };
80
+ render();
81
+ const timer = isTty ? setInterval(render, input.intervalMs ?? 16) : null;
82
+ return {
83
+ setLabel(next) {
84
+ label = next;
85
+ render();
86
+ },
87
+ pause() {
88
+ paused = true;
89
+ clearLine();
90
+ },
91
+ resume() {
92
+ if (stopped)
93
+ return;
94
+ paused = false;
95
+ render();
96
+ },
97
+ stop(finalLine) {
98
+ if (stopped)
99
+ return;
100
+ stopped = true;
101
+ if (timer)
102
+ clearInterval(timer);
103
+ clearLine();
104
+ if (finalLine)
105
+ output.write(`${finalLine}
106
+ `);
107
+ }
108
+ };
109
+ }
110
+
111
+ // packages/cli-surface-plugin/src/commands/_async-ui.ts
112
+ var FRAMES = ["\u25D0", "\u25D3", "\u25D1", "\u25D2"];
113
+ var DONE_SYMBOL = pc.green("\u25C7");
114
+ var FAIL_SYMBOL = pc.red("\u25A0");
115
+ var activeUpdate = null;
116
+ async function withSpinner(label, work, options = {}) {
117
+ if (options.outputMode === "json") {
118
+ return work(() => {
119
+ return;
120
+ });
121
+ }
122
+ if (activeUpdate) {
123
+ activeUpdate(label);
124
+ return work(activeUpdate);
125
+ }
126
+ const output = options.output ?? process.stderr;
127
+ const isTty = output.isTTY === true;
128
+ let lastLabel = label;
129
+ if (!isTty) {
130
+ output.write(`${label}
131
+ `);
132
+ const update2 = (next) => {
133
+ lastLabel = next;
134
+ };
135
+ activeUpdate = update2;
136
+ try {
137
+ return await work(update2);
138
+ } finally {
139
+ activeUpdate = null;
140
+ }
141
+ }
142
+ const spinner = createTtySpinner({
143
+ label,
144
+ output,
145
+ frames: FRAMES,
146
+ styleFrame: (frame) => pc.cyan(frame)
147
+ });
148
+ const update = (next) => {
149
+ lastLabel = next;
150
+ spinner.setLabel(next);
151
+ };
152
+ activeUpdate = update;
153
+ try {
154
+ const result = await work(update);
155
+ spinner.stop(options.doneLabel ? `${DONE_SYMBOL} ${options.doneLabel}` : undefined);
156
+ return result;
157
+ } catch (error) {
158
+ spinner.stop(`${FAIL_SYMBOL} ${lastLabel}`);
159
+ throw error;
160
+ } finally {
161
+ activeUpdate = null;
162
+ }
163
+ }
164
+
165
+ // packages/cli-surface-plugin/src/commands/triage.ts
166
+ function printTriageResult(context, result) {
167
+ if (context.outputMode !== "text")
168
+ return;
169
+ if (!result.enabled) {
170
+ const suffix = result.skippedReason === "no-config" ? "no rig.config task source was found" : "config.issueAnalysis is not enabled for continuous Pi analysis";
171
+ console.log(`Rig triage skipped: ${suffix}.`);
172
+ return;
173
+ }
174
+ console.log([
175
+ `Rig triage analyzed ${result.analyzedIssues} issue${result.analyzedIssues === 1 ? "" : "s"}.`,
176
+ `metadata patches: ${result.metadataPatches}`,
177
+ `labels added: ${result.labelsAdded}`,
178
+ `labels removed: ${result.labelsRemoved}`,
179
+ `generated issues: ${result.generatedIssues}`,
180
+ `snapshot refreshes: ${result.writeBackRefreshes}`
181
+ ].join(`
182
+ `));
183
+ }
184
+ async function executeTriage(context, args, deps = {}) {
185
+ if (args[0] === "--help" || args[0] === "-h" || args[0] === "help") {
186
+ if (context.outputMode === "text")
187
+ console.log(`Usage: rig triage [--reason <text>]
188
+
189
+ Runs the configured issueAnalysis pass once. Schedule this command externally for continuous triage.`);
190
+ return { ok: true, group: "triage", command: "help" };
191
+ }
192
+ const parsedReason = takeOption(args, "--reason");
193
+ requireNoExtraArgs(parsedReason.rest, "rig triage [--reason <text>]");
194
+ if (context.dryRun) {
195
+ const result2 = {
196
+ ok: true,
197
+ enabled: false,
198
+ reason: parsedReason.value?.trim() || "triage",
199
+ sourceId: null,
200
+ sourceKind: null,
201
+ analyzedIssues: 0,
202
+ metadataPatches: 0,
203
+ labelsAdded: 0,
204
+ labelsRemoved: 0,
205
+ generatedIssues: 0,
206
+ writeBackRefreshes: 0,
207
+ refreshedIssueCount: null,
208
+ skippedReason: "disabled",
209
+ dryRun: true
210
+ };
211
+ if (context.outputMode === "text")
212
+ console.log("[dry-run] rig triage would run the configured issueAnalysis pass once.");
213
+ return { ok: true, group: "triage", command: "run", details: result2 };
214
+ }
215
+ const result = await (deps.spinner ?? withSpinner)("Running Rig issue-analysis triage\u2026", () => (deps.runTriage ?? runIssueAnalysisTriage)({
216
+ projectRoot: context.projectRoot,
217
+ reason: parsedReason.value?.trim() || "triage"
218
+ }), { outputMode: context.outputMode });
219
+ printTriageResult(context, result);
220
+ return { ok: true, group: "triage", command: "run", details: result };
221
+ }
222
+ export {
223
+ executeTriage
224
+ };
@@ -0,0 +1,3 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import type { CommandOutcome } from "@rig/runtime";
3
+ export declare function executeWorkspace(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
@@ -0,0 +1,130 @@
1
+ // @bun
2
+ // packages/cli-surface-plugin/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-surface-plugin/src/commands/workspace.ts
45
+ import {
46
+ mutateWorkspaceServiceFabric,
47
+ readWorkspaceRemoteFleet,
48
+ readWorkspaceSummary,
49
+ readWorkspaceTopology
50
+ } from "@rig/runtime/control-plane/native/workspace-ops";
51
+ async function executeWorkspace(context, args) {
52
+ const [command = "summary", ...rest] = args;
53
+ switch (command) {
54
+ case "summary": {
55
+ requireNoExtraArgs(rest, "rig workspace summary");
56
+ const summary = await readWorkspaceSummary(context.projectRoot);
57
+ if (context.outputMode === "text") {
58
+ console.log("Workspace Summary");
59
+ console.log(` root: ${summary.rootPath}`);
60
+ console.log(` tasks: ${summary.taskCounts.total} total \xB7 ${summary.taskCounts.ready} ready \xB7 ${summary.taskCounts.running} running \xB7 ${summary.taskCounts.blocked} blocked \xB7 ${summary.taskCounts.completed} completed \xB7 ${summary.taskCounts.unknown} unknown`);
61
+ console.log(` runtimes: ${summary.runtimeCount}`);
62
+ console.log(` artifact tasks: ${summary.artifactTaskCount}`);
63
+ console.log(` topology: ${summary.topology.status} \xB7 ${summary.topology.serviceCount} services from ${summary.topology.manifestCount} manifests`);
64
+ console.log(` remote hosts: ${summary.remoteFleet.status} \xB7 ${summary.remoteFleet.onlineHostCount} online of ${summary.remoteFleet.hostCount}`);
65
+ if (summary.serviceFabric) {
66
+ console.log(` service fabric: ${String(summary.serviceFabric.status ?? "unknown")} \xB7 ${String(summary.serviceFabric.healthyServiceCount ?? 0)} healthy of ${String(summary.serviceFabric.serviceCount ?? 0)}`);
67
+ }
68
+ console.log(` failures log: ${summary.failedApproachesPresent ? "present" : "missing"}`);
69
+ if (summary.warnings.length > 0) {
70
+ console.log(`
71
+ Warnings:`);
72
+ for (const warning of summary.warnings) {
73
+ console.log(` - ${warning}`);
74
+ }
75
+ }
76
+ }
77
+ return { ok: true, group: "workspace", command, details: summary };
78
+ }
79
+ case "topology": {
80
+ requireNoExtraArgs(rest, "rig workspace topology");
81
+ const topology = readWorkspaceTopology(context.projectRoot);
82
+ if (context.outputMode === "text") {
83
+ console.log(`Topology: ${topology.status}`);
84
+ for (const service of topology.services) {
85
+ const suffix = [service.runtime, service.port != null ? `:${service.port}` : null, service.healthcheck].filter(Boolean).join(" \xB7 ");
86
+ console.log(`- ${service.name}${suffix ? ` (${suffix})` : ""}`);
87
+ console.log(` ${service.relativeRootPath}`);
88
+ }
89
+ }
90
+ return { ok: true, group: "workspace", command, details: topology };
91
+ }
92
+ case "remote-hosts": {
93
+ requireNoExtraArgs(rest, "rig workspace remote-hosts");
94
+ const fleet = readWorkspaceRemoteFleet(context.projectRoot);
95
+ if (context.outputMode === "text") {
96
+ console.log(`Remote Hosts: ${fleet.status}`);
97
+ for (const host of fleet.hosts) {
98
+ console.log(`- ${host.name} \xB7 ${host.status} \xB7 ${host.baseUrl}${host.workspacePath ? ` \xB7 ${host.workspacePath}` : ""}`);
99
+ }
100
+ }
101
+ return { ok: true, group: "workspace", command, details: fleet };
102
+ }
103
+ case "service-fabric": {
104
+ const [action = "status", ...serviceRest] = rest;
105
+ let pending = serviceRest;
106
+ const services = takeOption(pending, "--service");
107
+ pending = services.rest;
108
+ requireNoExtraArgs(pending, "rig workspace service-fabric <status|up|verify|down> [--service <name>]");
109
+ if (action !== "status" && action !== "up" && action !== "verify" && action !== "down") {
110
+ throw new CliError(`Unknown workspace service-fabric action: ${action}`, 1, { hint: "Use one of: `rig workspace service-fabric status|up|verify|down`." });
111
+ }
112
+ const selectedServices = services.value ? services.value.split(",").map((entry) => entry.trim()).filter(Boolean) : [];
113
+ const summary = action === "status" ? await mutateWorkspaceServiceFabric(context.projectRoot, "verify", selectedServices) : await mutateWorkspaceServiceFabric(context.projectRoot, action, selectedServices);
114
+ if (context.outputMode === "text") {
115
+ console.log(JSON.stringify(summary, null, 2));
116
+ }
117
+ return {
118
+ ok: true,
119
+ group: "workspace",
120
+ command: `service-fabric:${action}`,
121
+ details: summary
122
+ };
123
+ }
124
+ default:
125
+ throw new CliError(`Unknown workspace command: ${command}`, 1, { hint: "Run `rig workspace --help` \u2014 commands are summary|topology|remote-hosts|service-fabric." });
126
+ }
127
+ }
128
+ export {
129
+ executeWorkspace
130
+ };
@@ -0,0 +1,15 @@
1
+ export type KernelDispatchInput = {
2
+ readonly projectRoot: string;
3
+ readonly taskId: string;
4
+ readonly title?: string | null;
5
+ readonly model?: string | null;
6
+ readonly force?: boolean;
7
+ readonly prompt?: string | null;
8
+ };
9
+ export type KernelDispatchOptions = {
10
+ readonly placement?: unknown;
11
+ };
12
+ /** Dispatch a run through the resolved kernel transport capability. */
13
+ export declare function dispatchThroughKernel(input: KernelDispatchInput, options?: KernelDispatchOptions): Promise<{
14
+ readonly runId: string;
15
+ }>;
@@ -0,0 +1,16 @@
1
+ // @bun
2
+ var __require = import.meta.require;
3
+
4
+ // packages/cli-surface-plugin/src/kernel-dispatch.ts
5
+ async function dispatchThroughKernel(input, options) {
6
+ const { getProcessKernel } = await import("@rig/kernel/boot-default");
7
+ const kernel = getProcessKernel();
8
+ if (!kernel) {
9
+ throw new Error("Kernel not booted: cannot dispatch a run through the transport capability.");
10
+ }
11
+ const runId = await kernel.transport.dispatch(input, options);
12
+ return { runId };
13
+ }
14
+ export {
15
+ dispatchThroughKernel
16
+ };
@@ -0,0 +1,3 @@
1
+ export declare const STANDARD_CLI_SURFACE_PLUGIN_NAME = "@rig/cli-surface-plugin";
2
+ export declare function createStandardCliSurfacePlugin(): import("@rig/core").RigPluginWithRuntime;
3
+ export declare const standardCliSurfacePlugin: import("@rig/core").RigPluginWithRuntime;