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

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 (231) hide show
  1. package/dist/bin/build-rig-binaries.js +8 -40
  2. package/dist/bin/rig.js +12519 -26675
  3. package/dist/src/app/board.js +74 -693
  4. package/dist/src/app/drone-ui.js +1 -1
  5. package/dist/src/app/theme.js +0 -1
  6. package/dist/src/commands/_async-ui.js +1 -1
  7. package/dist/src/commands/_authority-runs.d.ts +1 -1
  8. package/dist/src/commands/_authority-runs.js +12 -2
  9. package/dist/src/commands/_cli-format.d.ts +1 -10
  10. package/dist/src/commands/_cli-format.js +2 -5
  11. package/dist/src/commands/_connection-state.d.ts +1 -11
  12. package/dist/src/commands/_connection-state.js +5 -50
  13. package/dist/src/commands/_doctor-checks.js +40 -501
  14. package/dist/src/commands/_help-catalog.js +17 -99
  15. package/dist/src/commands/_json-output.js +0 -4
  16. package/dist/src/commands/_operator-view.js +54 -575
  17. package/dist/src/commands/_pi-frontend.d.ts +0 -27
  18. package/dist/src/commands/_pi-frontend.js +52 -576
  19. package/dist/src/commands/_preflight.js +66 -553
  20. package/dist/src/commands/_server-client.d.ts +0 -33
  21. package/dist/src/commands/_server-client.js +46 -541
  22. package/dist/src/commands/_snapshot-upload.js +42 -503
  23. package/dist/src/commands/_spinner.js +1 -1
  24. package/dist/src/commands/agent.js +12 -2
  25. package/dist/src/commands/browser.js +1 -1
  26. package/dist/src/commands/connect.js +15 -626
  27. package/dist/src/commands/doctor.js +41 -502
  28. package/dist/src/commands/github.js +51 -584
  29. package/dist/src/commands/inbox.js +41 -502
  30. package/dist/src/commands/init.js +74 -561
  31. package/dist/src/commands/inspect.js +41 -502
  32. package/dist/src/commands/run.js +54 -578
  33. package/dist/src/commands/server.js +163 -692
  34. package/dist/src/commands/setup.js +46 -507
  35. package/dist/src/commands/stats.js +58 -601
  36. package/dist/src/commands/task-run-driver.js +58 -509
  37. package/dist/src/commands/task.js +110 -729
  38. package/dist/src/commands.js +237 -1112
  39. package/dist/src/index.js +244 -1123
  40. package/dist/src/launcher.js +0 -4
  41. package/package.json +9 -13
  42. package/dist/src/app-opentui/adapters/command.d.ts +0 -2
  43. package/dist/src/app-opentui/adapters/command.js +0 -329
  44. package/dist/src/app-opentui/adapters/common.d.ts +0 -56
  45. package/dist/src/app-opentui/adapters/common.js +0 -153
  46. package/dist/src/app-opentui/adapters/doctor.d.ts +0 -9
  47. package/dist/src/app-opentui/adapters/doctor.js +0 -1217
  48. package/dist/src/app-opentui/adapters/family.d.ts +0 -62
  49. package/dist/src/app-opentui/adapters/family.js +0 -14855
  50. package/dist/src/app-opentui/adapters/fleet.d.ts +0 -14
  51. package/dist/src/app-opentui/adapters/fleet.js +0 -1335
  52. package/dist/src/app-opentui/adapters/inbox.d.ts +0 -43
  53. package/dist/src/app-opentui/adapters/inbox.js +0 -1944
  54. package/dist/src/app-opentui/adapters/init.d.ts +0 -11
  55. package/dist/src/app-opentui/adapters/init.js +0 -2818
  56. package/dist/src/app-opentui/adapters/inspect.d.ts +0 -52
  57. package/dist/src/app-opentui/adapters/inspect.js +0 -1455
  58. package/dist/src/app-opentui/adapters/pi-attach.d.ts +0 -32
  59. package/dist/src/app-opentui/adapters/pi-attach.js +0 -2101
  60. package/dist/src/app-opentui/adapters/pi.d.ts +0 -23
  61. package/dist/src/app-opentui/adapters/pi.js +0 -363
  62. package/dist/src/app-opentui/adapters/plugin.d.ts +0 -84
  63. package/dist/src/app-opentui/adapters/plugin.js +0 -544
  64. package/dist/src/app-opentui/adapters/repo.d.ts +0 -37
  65. package/dist/src/app-opentui/adapters/repo.js +0 -186
  66. package/dist/src/app-opentui/adapters/run-detail.d.ts +0 -27
  67. package/dist/src/app-opentui/adapters/run-detail.js +0 -1441
  68. package/dist/src/app-opentui/adapters/server.d.ts +0 -48
  69. package/dist/src/app-opentui/adapters/server.js +0 -1561
  70. package/dist/src/app-opentui/adapters/tasks.d.ts +0 -64
  71. package/dist/src/app-opentui/adapters/tasks.js +0 -4524
  72. package/dist/src/app-opentui/adapters/workspace.d.ts +0 -49
  73. package/dist/src/app-opentui/adapters/workspace.js +0 -333
  74. package/dist/src/app-opentui/autocomplete.d.ts +0 -20
  75. package/dist/src/app-opentui/autocomplete.js +0 -578
  76. package/dist/src/app-opentui/bootstrap.d.ts +0 -11
  77. package/dist/src/app-opentui/bootstrap.js +0 -27833
  78. package/dist/src/app-opentui/command-palette.d.ts +0 -3
  79. package/dist/src/app-opentui/command-palette.js +0 -1038
  80. package/dist/src/app-opentui/command-pty-host.d.ts +0 -62
  81. package/dist/src/app-opentui/command-pty-host.js +0 -248
  82. package/dist/src/app-opentui/drone.d.ts +0 -12
  83. package/dist/src/app-opentui/drone.js +0 -230
  84. package/dist/src/app-opentui/events.d.ts +0 -7
  85. package/dist/src/app-opentui/events.js +0 -28
  86. package/dist/src/app-opentui/fleet-stats.d.ts +0 -32
  87. package/dist/src/app-opentui/fleet-stats.js +0 -114
  88. package/dist/src/app-opentui/focus-manager.d.ts +0 -14
  89. package/dist/src/app-opentui/focus-manager.js +0 -24
  90. package/dist/src/app-opentui/index.d.ts +0 -8
  91. package/dist/src/app-opentui/index.js +0 -5260
  92. package/dist/src/app-opentui/intent.d.ts +0 -3
  93. package/dist/src/app-opentui/intent.js +0 -365
  94. package/dist/src/app-opentui/keymap.d.ts +0 -21
  95. package/dist/src/app-opentui/keymap.js +0 -1377
  96. package/dist/src/app-opentui/launch-routing.d.ts +0 -16
  97. package/dist/src/app-opentui/launch-routing.js +0 -55
  98. package/dist/src/app-opentui/layout.d.ts +0 -22
  99. package/dist/src/app-opentui/layout.js +0 -51
  100. package/dist/src/app-opentui/list-search.d.ts +0 -36
  101. package/dist/src/app-opentui/list-search.js +0 -130
  102. package/dist/src/app-opentui/pi-host-child.d.ts +0 -2
  103. package/dist/src/app-opentui/pi-host-child.js +0 -1299
  104. package/dist/src/app-opentui/pi-pty-host.d.ts +0 -28
  105. package/dist/src/app-opentui/pi-pty-host.js +0 -10
  106. package/dist/src/app-opentui/react/App.d.ts +0 -9
  107. package/dist/src/app-opentui/react/App.js +0 -3866
  108. package/dist/src/app-opentui/react/Backdrop.d.ts +0 -5
  109. package/dist/src/app-opentui/react/Backdrop.js +0 -823
  110. package/dist/src/app-opentui/react/ChromeHost.d.ts +0 -5
  111. package/dist/src/app-opentui/react/ChromeHost.js +0 -1539
  112. package/dist/src/app-opentui/react/SceneFrameView.d.ts +0 -7
  113. package/dist/src/app-opentui/react/SceneFrameView.js +0 -579
  114. package/dist/src/app-opentui/react/context.d.ts +0 -17
  115. package/dist/src/app-opentui/react/context.js +0 -37
  116. package/dist/src/app-opentui/react/launch.d.ts +0 -2
  117. package/dist/src/app-opentui/react/launch.js +0 -4897
  118. package/dist/src/app-opentui/react/nav.d.ts +0 -18
  119. package/dist/src/app-opentui/react/nav.js +0 -54
  120. package/dist/src/app-opentui/react/scroll.d.ts +0 -12
  121. package/dist/src/app-opentui/react/scroll.js +0 -21
  122. package/dist/src/app-opentui/react/syntax.d.ts +0 -2
  123. package/dist/src/app-opentui/react/syntax.js +0 -65
  124. package/dist/src/app-opentui/registry.d.ts +0 -4
  125. package/dist/src/app-opentui/registry.js +0 -22876
  126. package/dist/src/app-opentui/remote-link.d.ts +0 -10
  127. package/dist/src/app-opentui/remote-link.js +0 -47
  128. package/dist/src/app-opentui/render/ascii-fleet.d.ts +0 -15
  129. package/dist/src/app-opentui/render/ascii-fleet.js +0 -82
  130. package/dist/src/app-opentui/render/constants.d.ts +0 -30
  131. package/dist/src/app-opentui/render/constants.js +0 -64
  132. package/dist/src/app-opentui/render/graphics.d.ts +0 -40
  133. package/dist/src/app-opentui/render/graphics.js +0 -713
  134. package/dist/src/app-opentui/render/hover.d.ts +0 -11
  135. package/dist/src/app-opentui/render/hover.js +0 -34
  136. package/dist/src/app-opentui/render/native-host.d.ts +0 -37
  137. package/dist/src/app-opentui/render/native-host.js +0 -180
  138. package/dist/src/app-opentui/render/panel-layout.d.ts +0 -38
  139. package/dist/src/app-opentui/render/panel-layout.js +0 -48
  140. package/dist/src/app-opentui/render/panels.d.ts +0 -12
  141. package/dist/src/app-opentui/render/panels.js +0 -288
  142. package/dist/src/app-opentui/render/preloader.d.ts +0 -10
  143. package/dist/src/app-opentui/render/preloader.js +0 -166
  144. package/dist/src/app-opentui/render/scene.d.ts +0 -68
  145. package/dist/src/app-opentui/render/scene.js +0 -300
  146. package/dist/src/app-opentui/render/terminal-handoff.d.ts +0 -16
  147. package/dist/src/app-opentui/render/terminal-handoff.js +0 -14
  148. package/dist/src/app-opentui/render/text.d.ts +0 -29
  149. package/dist/src/app-opentui/render/text.js +0 -177
  150. package/dist/src/app-opentui/render/type-bar.d.ts +0 -15
  151. package/dist/src/app-opentui/render/type-bar.js +0 -212
  152. package/dist/src/app-opentui/runtime-resources.d.ts +0 -16
  153. package/dist/src/app-opentui/runtime-resources.js +0 -62
  154. package/dist/src/app-opentui/runtime.d.ts +0 -45
  155. package/dist/src/app-opentui/runtime.js +0 -5232
  156. package/dist/src/app-opentui/scenes/command.d.ts +0 -3
  157. package/dist/src/app-opentui/scenes/command.js +0 -118
  158. package/dist/src/app-opentui/scenes/doctor.d.ts +0 -3
  159. package/dist/src/app-opentui/scenes/doctor.js +0 -296
  160. package/dist/src/app-opentui/scenes/error.d.ts +0 -2
  161. package/dist/src/app-opentui/scenes/error.js +0 -277
  162. package/dist/src/app-opentui/scenes/family-domains/agent.d.ts +0 -2
  163. package/dist/src/app-opentui/scenes/family-domains/agent.js +0 -349
  164. package/dist/src/app-opentui/scenes/family-domains/browser.d.ts +0 -2
  165. package/dist/src/app-opentui/scenes/family-domains/browser.js +0 -196
  166. package/dist/src/app-opentui/scenes/family-domains/dist.d.ts +0 -2
  167. package/dist/src/app-opentui/scenes/family-domains/dist.js +0 -244
  168. package/dist/src/app-opentui/scenes/family-domains/git.d.ts +0 -2
  169. package/dist/src/app-opentui/scenes/family-domains/git.js +0 -196
  170. package/dist/src/app-opentui/scenes/family-domains/github.d.ts +0 -2
  171. package/dist/src/app-opentui/scenes/family-domains/github.js +0 -275
  172. package/dist/src/app-opentui/scenes/family-domains/harness.d.ts +0 -2
  173. package/dist/src/app-opentui/scenes/family-domains/harness.js +0 -153
  174. package/dist/src/app-opentui/scenes/family-domains/index.d.ts +0 -4
  175. package/dist/src/app-opentui/scenes/family-domains/index.js +0 -1680
  176. package/dist/src/app-opentui/scenes/family-domains/kit.d.ts +0 -76
  177. package/dist/src/app-opentui/scenes/family-domains/kit.js +0 -306
  178. package/dist/src/app-opentui/scenes/family-domains/profile.d.ts +0 -2
  179. package/dist/src/app-opentui/scenes/family-domains/profile.js +0 -213
  180. package/dist/src/app-opentui/scenes/family-domains/queue.d.ts +0 -2
  181. package/dist/src/app-opentui/scenes/family-domains/queue.js +0 -147
  182. package/dist/src/app-opentui/scenes/family-domains/remote.d.ts +0 -2
  183. package/dist/src/app-opentui/scenes/family-domains/remote.js +0 -519
  184. package/dist/src/app-opentui/scenes/family-domains/review.d.ts +0 -2
  185. package/dist/src/app-opentui/scenes/family-domains/review.js +0 -281
  186. package/dist/src/app-opentui/scenes/family-domains/setup.d.ts +0 -2
  187. package/dist/src/app-opentui/scenes/family-domains/setup.js +0 -268
  188. package/dist/src/app-opentui/scenes/family-domains/stats.d.ts +0 -2
  189. package/dist/src/app-opentui/scenes/family-domains/stats.js +0 -371
  190. package/dist/src/app-opentui/scenes/family.d.ts +0 -3
  191. package/dist/src/app-opentui/scenes/family.js +0 -2199
  192. package/dist/src/app-opentui/scenes/fleet.d.ts +0 -3
  193. package/dist/src/app-opentui/scenes/fleet.js +0 -766
  194. package/dist/src/app-opentui/scenes/handoff.d.ts +0 -2
  195. package/dist/src/app-opentui/scenes/handoff.js +0 -455
  196. package/dist/src/app-opentui/scenes/help.d.ts +0 -3
  197. package/dist/src/app-opentui/scenes/help.js +0 -725
  198. package/dist/src/app-opentui/scenes/inbox.d.ts +0 -3
  199. package/dist/src/app-opentui/scenes/inbox.js +0 -427
  200. package/dist/src/app-opentui/scenes/init.d.ts +0 -3
  201. package/dist/src/app-opentui/scenes/init.js +0 -181
  202. package/dist/src/app-opentui/scenes/inspect.d.ts +0 -3
  203. package/dist/src/app-opentui/scenes/inspect.js +0 -794
  204. package/dist/src/app-opentui/scenes/main.d.ts +0 -3
  205. package/dist/src/app-opentui/scenes/main.js +0 -332
  206. package/dist/src/app-opentui/scenes/pi.d.ts +0 -3
  207. package/dist/src/app-opentui/scenes/pi.js +0 -509
  208. package/dist/src/app-opentui/scenes/plugin.d.ts +0 -3
  209. package/dist/src/app-opentui/scenes/plugin.js +0 -487
  210. package/dist/src/app-opentui/scenes/repo.d.ts +0 -3
  211. package/dist/src/app-opentui/scenes/repo.js +0 -425
  212. package/dist/src/app-opentui/scenes/run-detail.d.ts +0 -3
  213. package/dist/src/app-opentui/scenes/run-detail.js +0 -467
  214. package/dist/src/app-opentui/scenes/server.d.ts +0 -3
  215. package/dist/src/app-opentui/scenes/server.js +0 -378
  216. package/dist/src/app-opentui/scenes/tasks.d.ts +0 -3
  217. package/dist/src/app-opentui/scenes/tasks.js +0 -768
  218. package/dist/src/app-opentui/scenes/workspace.d.ts +0 -3
  219. package/dist/src/app-opentui/scenes/workspace.js +0 -427
  220. package/dist/src/app-opentui/selectable.d.ts +0 -19
  221. package/dist/src/app-opentui/selectable.js +0 -80
  222. package/dist/src/app-opentui/state.d.ts +0 -4
  223. package/dist/src/app-opentui/state.js +0 -399
  224. package/dist/src/app-opentui/surface-catalog.d.ts +0 -20
  225. package/dist/src/app-opentui/surface-catalog.js +0 -542
  226. package/dist/src/app-opentui/theme.d.ts +0 -59
  227. package/dist/src/app-opentui/theme.js +0 -142
  228. package/dist/src/app-opentui/types.d.ts +0 -313
  229. package/dist/src/app-opentui/types.js +0 -1
  230. package/dist/src/commands/_server-events.d.ts +0 -26
  231. package/dist/src/commands/_server-events.js +0 -715
@@ -1,544 +0,0 @@
1
- // @bun
2
- var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, {
10
- get: all[name],
11
- enumerable: true,
12
- configurable: true,
13
- set: __exportSetter.bind(all, name)
14
- });
15
- };
16
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
- var __require = import.meta.require;
18
-
19
- // packages/cli/src/runner.ts
20
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
21
- import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
22
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
23
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
24
- function takeOption(args, option) {
25
- const rest = [];
26
- let value;
27
- for (let index = 0;index < args.length; index += 1) {
28
- const current = args[index];
29
- if (current === option) {
30
- const next = args[index + 1];
31
- if (!next || next.startsWith("-")) {
32
- throw new CliError(`Missing value for ${option}`, 1, { hint: `Provide a value after ${option}, e.g. \`${option} <value>\`.` });
33
- }
34
- value = next;
35
- index += 1;
36
- continue;
37
- }
38
- if (current !== undefined) {
39
- rest.push(current);
40
- }
41
- }
42
- return { value, rest };
43
- }
44
- function requireNoExtraArgs(args, usage) {
45
- if (args.length > 0) {
46
- throw new CliError(`Unexpected arguments: ${args.join(" ")}
47
- Usage: ${usage}`);
48
- }
49
- }
50
- function requireTask(taskId, usage) {
51
- if (!taskId) {
52
- throw new CliError(`Missing --task option.
53
- Usage: ${usage}`);
54
- }
55
- return taskId;
56
- }
57
- var CliError;
58
- var init_runner = __esm(() => {
59
- CliError = class CliError extends RuntimeCliError {
60
- hint;
61
- constructor(message, exitCode = 1, options = {}) {
62
- super(message, exitCode);
63
- if (options.hint?.trim()) {
64
- this.hint = options.hint.trim();
65
- }
66
- }
67
- };
68
- });
69
-
70
- // packages/cli/src/commands/_parsers.ts
71
- async function loadRigConfigOrNull(projectRoot) {
72
- try {
73
- const { loadConfig } = await import("@rig/core/load-config");
74
- return await loadConfig(projectRoot);
75
- } catch {
76
- return null;
77
- }
78
- }
79
- var init__parsers = __esm(() => {
80
- init_runner();
81
- });
82
-
83
- // packages/cli/src/commands/plugin.ts
84
- var exports_plugin = {};
85
- __export(exports_plugin, {
86
- resolvePluginCliCommand: () => resolvePluginCliCommand,
87
- executePlugin: () => executePlugin
88
- });
89
- import { existsSync } from "fs";
90
- import { resolve } from "path";
91
- import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
92
- async function executePlugin(context, args) {
93
- const [command = "list", ...rest] = args;
94
- switch (command) {
95
- case "list": {
96
- requireNoExtraArgs(rest, "rig plugin list");
97
- const declarative = [];
98
- const config = await loadRigConfigOrNull(context.projectRoot);
99
- if (config && Array.isArray(config.plugins)) {
100
- for (const plugin of config.plugins) {
101
- const c = plugin.contributes ?? {};
102
- declarative.push({
103
- name: plugin.name,
104
- version: plugin.version,
105
- validators: (c.validators ?? []).map((v) => v.id),
106
- hooks: (c.hooks ?? []).map((h) => h.id),
107
- agentRoles: (c.agentRoles ?? []).map((r) => r.id),
108
- repoSources: (c.repoSources ?? []).map((r) => r.id),
109
- taskSources: (c.taskSources ?? []).map((s) => s.id),
110
- skills: (c.skills ?? []).map((s) => s.id),
111
- taskFieldExtensions: (c.taskFieldSchemas ?? []).map((f) => f.id),
112
- cliCommands: (c.cliCommands ?? []).map((entry) => entry.id)
113
- });
114
- }
115
- }
116
- if (context.outputMode === "text") {
117
- if (declarative.length === 0) {
118
- const configExists = ["rig.config.ts", "rig.config.mts", "rig.config.json"].some((name) => existsSync(resolve(context.projectRoot, name)));
119
- console.log(configExists ? "rig.config found but no plugins could be loaded. If the config imports @rig/* packages, run `bun install` in this project first." : "No plugins loaded. Declare plugins in rig.config.ts.");
120
- } else {
121
- console.log("Plugins (rig.config.ts):");
122
- for (const p of declarative) {
123
- console.log(` ${p.name}@${p.version}`);
124
- const lines = [];
125
- if (p.validators.length)
126
- lines.push(` validators: ${p.validators.join(", ")}`);
127
- if (p.hooks.length)
128
- lines.push(` hooks: ${p.hooks.join(", ")}`);
129
- if (p.agentRoles.length)
130
- lines.push(` agent-roles: ${p.agentRoles.join(", ")}`);
131
- if (p.repoSources.length)
132
- lines.push(` repo-sources: ${p.repoSources.join(", ")}`);
133
- if (p.taskSources.length)
134
- lines.push(` task-sources: ${p.taskSources.join(", ")}`);
135
- if (p.skills.length)
136
- lines.push(` skills: ${p.skills.join(", ")}`);
137
- if (p.taskFieldExtensions.length)
138
- lines.push(` task-fields: ${p.taskFieldExtensions.join(", ")}`);
139
- if (p.cliCommands.length)
140
- lines.push(` cli-commands: ${p.cliCommands.join(", ")} (run with \`rig plugin run <id>\`)`);
141
- for (const line of lines)
142
- console.log(line);
143
- }
144
- }
145
- }
146
- return {
147
- ok: true,
148
- group: "plugin",
149
- command,
150
- details: { declarative }
151
- };
152
- }
153
- case "validate": {
154
- const { value: task, rest: remaining } = takeOption(rest, "--task");
155
- requireNoExtraArgs(remaining, "rig plugin validate --task <task-id>");
156
- const taskId = requireTask(task, "rig plugin validate --task <task-id>");
157
- const hostCtx = await buildPluginHostContext(context.projectRoot);
158
- if (!hostCtx) {
159
- throw new CliError(`No rig.config found at ${context.projectRoot}. Run \`rig init\` to set up plugins.`, 2);
160
- }
161
- const validators = hostCtx.validatorRegistry.list();
162
- const results = [];
163
- for (const validator of validators) {
164
- try {
165
- results.push(await validator.run({
166
- taskId,
167
- workspaceRoot: context.projectRoot,
168
- scope: []
169
- }));
170
- } catch (error) {
171
- results.push({
172
- id: validator.id,
173
- passed: false,
174
- summary: `${validator.id} failed unexpectedly`,
175
- details: `${error}`
176
- });
177
- }
178
- }
179
- const passed = results.filter((result) => result.passed).length;
180
- const failed = results.length - passed;
181
- if (context.outputMode === "text") {
182
- if (results.length === 0) {
183
- console.log("No plugin validators registered.");
184
- } else {
185
- for (const result of results) {
186
- const icon = result.passed ? "PASS" : "FAIL";
187
- console.log(`[${icon}] ${result.id}: ${result.summary}`);
188
- if (result.details && !result.passed) {
189
- console.log(result.details);
190
- }
191
- }
192
- }
193
- }
194
- if (failed > 0) {
195
- throw new CliError(`Plugin validation failed for ${failed} validator(s).`, 2, { hint: "Fix the reported validators, then re-run `rig plugin validate --task <id>`." });
196
- }
197
- return {
198
- ok: true,
199
- group: "plugin",
200
- command,
201
- details: {
202
- taskId,
203
- passed,
204
- failed,
205
- results
206
- }
207
- };
208
- }
209
- case "run": {
210
- const [commandId, ...commandArgs] = rest;
211
- if (!commandId) {
212
- throw new CliError("Usage: rig plugin run <command-id> [args...]", 1, { hint: "Run `rig plugin list` to see plugin-contributed command ids." });
213
- }
214
- const hostCtx = await buildPluginHostContext(context.projectRoot);
215
- if (!hostCtx) {
216
- throw new CliError(`No rig.config found at ${context.projectRoot}. Run \`rig init\` to set up plugins.`, 2);
217
- }
218
- const registration = resolvePluginCliCommand(hostCtx.pluginHost.listCliCommands(), commandId);
219
- if (!registration) {
220
- const available = hostCtx.pluginHost.listCliCommands().map((entry) => entry.id);
221
- throw new CliError(available.length > 0 ? `Unknown plugin command "${commandId}". Available: ${available.join(", ")}` : `No plugin CLI commands are registered. Plugins contribute them via contributes.cliCommands.`, 2);
222
- }
223
- if (context.dryRun) {
224
- if (context.outputMode === "text") {
225
- console.log(`[dry-run] ${registration.command}${commandArgs.length ? ` ${commandArgs.join(" ")}` : ""}`);
226
- }
227
- return { ok: true, group: "plugin", command, details: { id: registration.id, dryRun: true } };
228
- }
229
- const proc = Bun.spawn(["bash", "-c", `${registration.command} "$@"`, registration.id, ...commandArgs], {
230
- cwd: context.projectRoot,
231
- env: process.env,
232
- stdin: "inherit",
233
- stdout: "inherit",
234
- stderr: "inherit"
235
- });
236
- const exitCode = await proc.exited;
237
- if (exitCode !== 0) {
238
- throw new CliError(`Plugin command "${registration.id}" exited with code ${exitCode}.`, exitCode, { hint: "Run `rig plugin list` to inspect the contributing plugin, or re-run with --json for details." });
239
- }
240
- return { ok: true, group: "plugin", command, details: { id: registration.id, exitCode } };
241
- }
242
- default:
243
- throw new CliError(`Unknown plugin command: ${command}`, 1, { hint: "Run `rig plugin --help` \u2014 commands are list|validate|run." });
244
- }
245
- }
246
- function resolvePluginCliCommand(commands, requested) {
247
- const exact = commands.find((entry) => entry.id === requested);
248
- if (exact)
249
- return exact;
250
- const byLocalPart = commands.filter((entry) => entry.id.split(":").slice(1).join(":") === requested);
251
- return byLocalPart.length === 1 ? byLocalPart[0] : undefined;
252
- }
253
- var init_plugin = __esm(() => {
254
- init_runner();
255
- init__parsers();
256
- });
257
-
258
- // packages/cli/src/app-opentui/adapters/common.ts
259
- function projectRootOf(ctx) {
260
- const root = ctx.rig?.projectRoot ?? ctx.projectRoot ?? ctx.getState().projectRoot;
261
- if (typeof root === "string" && root.trim())
262
- return root;
263
- throw new Error("App adapter requires a projectRoot.");
264
- }
265
- async function runtimeOf(ctx) {
266
- if (ctx.rig && "runId" in ctx.rig && ctx.ensureRuntime === undefined) {
267
- return ctx.rig;
268
- }
269
- if (ctx.ensureRuntime)
270
- return ctx.ensureRuntime();
271
- throw new Error("App adapter requires ensureRuntime() before this action can run.");
272
- }
273
- function normalizeAppError(error) {
274
- const message = error instanceof Error ? error.message : String(error);
275
- const rawHint = error instanceof Error ? error.hint : undefined;
276
- return {
277
- message,
278
- ...typeof rawHint === "string" && rawHint.trim() ? { hint: rawHint.trim() } : {}
279
- };
280
- }
281
- function emitStarted(ctx, label, optimistic) {
282
- ctx.emit({ type: "action.started", label, ...optimistic ? { optimistic } : {} });
283
- }
284
- function emitProgress(ctx, label, detail, data) {
285
- ctx.emit({ type: "action.progress", label, ...detail ? { detail } : {}, ...data ? { data } : {} });
286
- }
287
- function emitCompleted(ctx, label, data) {
288
- ctx.emit({ type: "action.completed", label, ...data ? { data } : {} });
289
- }
290
- function emitFailed(ctx, label, error, data) {
291
- if (data)
292
- patchData(ctx, data);
293
- const normalized = normalizeAppError(error);
294
- ctx.emit({
295
- type: "action.failed",
296
- label,
297
- message: normalized.message,
298
- ...normalized.hint ? { hint: normalized.hint } : {},
299
- cause: error
300
- });
301
- }
302
- function patchData(ctx, data) {
303
- ctx.emit({ type: "data.patch", data });
304
- }
305
- function patchFooter(ctx, footer) {
306
- ctx.emit({ type: "footer.patch", footer });
307
- }
308
- async function captureConsole(fn) {
309
- const output = [];
310
- const original = {
311
- log: console.log,
312
- info: console.info,
313
- warn: console.warn,
314
- error: console.error
315
- };
316
- const capture = (...parts) => {
317
- output.push(parts.map((part) => typeof part === "string" ? part : JSON.stringify(part)).join(" "));
318
- };
319
- console.log = capture;
320
- console.info = capture;
321
- console.warn = capture;
322
- console.error = capture;
323
- try {
324
- const result = await fn();
325
- return { result, output };
326
- } finally {
327
- console.log = original.log;
328
- console.info = original.info;
329
- console.warn = original.warn;
330
- console.error = original.error;
331
- }
332
- }
333
-
334
- // packages/cli/src/app-opentui/adapters/plugin.ts
335
- function stringArray(value) {
336
- return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
337
- }
338
- function asValidatorMeta(value) {
339
- if (!Array.isArray(value))
340
- return [];
341
- return value.flatMap((entry) => {
342
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
343
- return [];
344
- const record = entry;
345
- const id = typeof record.id === "string" ? record.id : undefined;
346
- if (!id)
347
- return [];
348
- return [{
349
- id,
350
- category: typeof record.category === "string" ? record.category : "custom",
351
- ...typeof record.description === "string" && record.description.trim() ? { description: record.description.trim() } : {}
352
- }];
353
- });
354
- }
355
- function asValidatorResults(value) {
356
- if (!Array.isArray(value))
357
- return [];
358
- return value.flatMap((entry) => {
359
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
360
- return [];
361
- const record = entry;
362
- const id = typeof record.id === "string" ? record.id : undefined;
363
- if (!id)
364
- return [];
365
- return [{
366
- id,
367
- passed: record.passed === true,
368
- summary: typeof record.summary === "string" ? record.summary : "",
369
- ...typeof record.details === "string" && record.details.trim() ? { details: record.details.trim() } : {}
370
- }];
371
- });
372
- }
373
- function asPluginRecords(value) {
374
- if (!Array.isArray(value))
375
- return [];
376
- return value.flatMap((entry) => {
377
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
378
- return [];
379
- const record = entry;
380
- const name = typeof record.name === "string" ? record.name : undefined;
381
- if (!name)
382
- return [];
383
- return [{
384
- name,
385
- version: typeof record.version === "string" ? record.version : "0.0.0",
386
- validators: stringArray(record.validators),
387
- hooks: stringArray(record.hooks),
388
- agentRoles: stringArray(record.agentRoles),
389
- repoSources: stringArray(record.repoSources),
390
- taskSources: stringArray(record.taskSources),
391
- skills: stringArray(record.skills),
392
- taskFieldExtensions: stringArray(record.taskFieldExtensions),
393
- cliCommands: stringArray(record.cliCommands)
394
- }];
395
- });
396
- }
397
- var EMPTY_CONTRIBUTION_META = {
398
- validators: [],
399
- hooks: [],
400
- agentRoles: [],
401
- repoSources: [],
402
- taskSources: [],
403
- skills: [],
404
- taskFieldExtensions: [],
405
- cliCommands: []
406
- };
407
- function metaRow(id, tag, description) {
408
- return {
409
- id,
410
- ...tag && tag.trim() ? { tag: tag.trim() } : {},
411
- ...typeof description === "string" && description.trim() ? { description: description.trim() } : {}
412
- };
413
- }
414
- function hookMatcherLabel(matcher) {
415
- if (matcher.kind === "tool" && matcher.name)
416
- return `tool:${matcher.name}`;
417
- if (matcher.kind === "glob" && matcher.pattern)
418
- return `glob:${matcher.pattern}`;
419
- return "all";
420
- }
421
- async function harvestContributionMeta(projectRoot) {
422
- try {
423
- const { buildPluginHostContext: buildPluginHostContext2 } = await import("@rig/runtime/control-plane/plugin-host-context");
424
- const hostCtx = await buildPluginHostContext2(projectRoot);
425
- if (!hostCtx)
426
- return { validators: [], contributions: EMPTY_CONTRIBUTION_META };
427
- const host = hostCtx.pluginHost;
428
- const validators = asValidatorMeta(hostCtx.validatorRegistry.list().map((validator) => ({
429
- id: validator.id,
430
- category: validator.category,
431
- ...validator.description ? { description: validator.description } : {}
432
- })));
433
- const contributions = {
434
- validators: host.listValidators().map((v) => metaRow(v.id, v.category, v.description)),
435
- hooks: host.listHooks().map((h) => metaRow(h.id, `${h.event} \xB7 ${hookMatcherLabel(h.matcher)}`, h.description)),
436
- agentRoles: host.listAgentRoles().map((r) => metaRow(r.id, r.defaultModel ? `model:${r.defaultModel}` : undefined, r.description)),
437
- repoSources: host.listRepoSources().map((r) => metaRow(r.id, r.defaultBranch ? `managed \xB7 ${r.defaultBranch}` : "listing", r.description ?? r.url)),
438
- taskSources: host.listTaskSources().map((s) => metaRow(s.id, `kind:${s.kind}`, s.description)),
439
- skills: host.listSkills().map((s) => metaRow(s.id, s.path, s.description)),
440
- taskFieldExtensions: host.listTaskFieldExtensions().map((f) => metaRow(f.id, `field:${f.fieldName}`, undefined)),
441
- cliCommands: host.listCliCommands().map((c) => metaRow(c.id, c.command, c.description))
442
- };
443
- return { validators, contributions };
444
- } catch {
445
- return { validators: [], contributions: EMPTY_CONTRIBUTION_META };
446
- }
447
- }
448
- function pendingValidateTask(ctx) {
449
- const intent = ctx.getState().intent;
450
- if (!intent || typeof intent !== "object")
451
- return;
452
- const action = intent.action;
453
- const task = action?.payload?.task;
454
- return typeof task === "string" && task.trim() ? task.trim() : undefined;
455
- }
456
- async function refreshPlugin(ctx) {
457
- const validateTask = pendingValidateTask(ctx);
458
- if (validateTask) {
459
- await validatePluginTask(ctx, validateTask);
460
- const existing = ctx.getState().data?.plugin;
461
- if (existing && typeof existing === "object" && !Array.isArray(existing)) {
462
- return existing;
463
- }
464
- }
465
- const label = "Loading plugins";
466
- emitStarted(ctx, label);
467
- try {
468
- const runtime = await runtimeOf(ctx);
469
- emitProgress(ctx, label, "loading rig.config plugin contributions");
470
- const { executePlugin: executePlugin2 } = await Promise.resolve().then(() => (init_plugin(), exports_plugin));
471
- const { result } = await captureConsole(() => executePlugin2(runtime, ["list"]));
472
- const details = result.details ?? {};
473
- const { validators: validatorMeta, contributions: contributionMeta } = await harvestContributionMeta(projectRootOf(ctx));
474
- const snapshot = {
475
- plugins: asPluginRecords(details.declarative),
476
- validatorMeta,
477
- contributionMeta,
478
- refreshedAt: Date.now()
479
- };
480
- patchData(ctx, { plugin: snapshot, lastRefreshError: undefined });
481
- patchFooter(ctx, { message: `${snapshot.plugins.length} plugins` });
482
- emitCompleted(ctx, label, { plugins: snapshot.plugins.length });
483
- return snapshot;
484
- } catch (error) {
485
- emitFailed(ctx, label, error);
486
- throw error;
487
- }
488
- }
489
- async function validatePluginTask(ctx, taskId) {
490
- const trimmed = taskId.trim();
491
- const label = `Validate ${trimmed || "task"}`;
492
- emitStarted(ctx, label);
493
- try {
494
- if (!trimmed)
495
- throw new Error("A task id is required to run plugin validators.");
496
- const projectRoot = projectRootOf(ctx);
497
- emitProgress(ctx, label, "running plugin validators in-process");
498
- const { buildPluginHostContext: buildPluginHostContext2 } = await import("@rig/runtime/control-plane/plugin-host-context");
499
- const hostCtx = await buildPluginHostContext2(projectRoot);
500
- if (!hostCtx) {
501
- throw new Error(`No rig.config found at ${projectRoot}. Run \`rig init\` to set up plugins.`);
502
- }
503
- const validators = hostCtx.validatorRegistry.list();
504
- const rawResults = [];
505
- for (const validator of validators) {
506
- try {
507
- const result = await validator.run({ taskId: trimmed, workspaceRoot: projectRoot, scope: [] });
508
- rawResults.push({
509
- id: result.id,
510
- passed: result.passed === true,
511
- summary: result.summary,
512
- ...result.details ? { details: result.details } : {}
513
- });
514
- } catch (error) {
515
- rawResults.push({
516
- id: validator.id,
517
- passed: false,
518
- summary: `${validator.id} failed unexpectedly`,
519
- details: `${error}`
520
- });
521
- }
522
- }
523
- const results = asValidatorResults(rawResults);
524
- const passed = results.filter((result) => result.passed).length;
525
- const validation = {
526
- taskId: trimmed,
527
- passed,
528
- failed: results.length - passed,
529
- results,
530
- ranAt: Date.now()
531
- };
532
- patchData(ctx, { pluginValidation: validation, lastRefreshError: undefined });
533
- patchFooter(ctx, { message: `validate ${trimmed} \u2014 ${passed}/${results.length} passed` });
534
- emitCompleted(ctx, label, { passed, failed: validation.failed });
535
- return validation;
536
- } catch (error) {
537
- emitFailed(ctx, label, error);
538
- throw error;
539
- }
540
- }
541
- export {
542
- validatePluginTask,
543
- refreshPlugin
544
- };
@@ -1,37 +0,0 @@
1
- import { type AppAdapterContext } from "./common";
2
- export type AppRepoPin = {
3
- readonly alias: string;
4
- readonly commit: string;
5
- };
6
- /** Per-managed-repo git working-tree status, read safely (no network, no
7
- * mutation) off the repo's local checkout. `available` is false when the
8
- * checkout doesn't exist yet (nothing cloned) — the row then renders "not
9
- * checked out" instead of a false clean/dirty. `ahead`/`behind` count commits
10
- * of the local HEAD relative to the recorded baseline pin (when one exists). */
11
- export type AppRepoGitStatus = {
12
- readonly available: boolean;
13
- readonly clean: boolean;
14
- readonly dirtyCount: number;
15
- readonly head: string;
16
- readonly branch: string;
17
- /** Commits HEAD is ahead of the pinned baseline commit (0 when no pin). */
18
- readonly ahead: number;
19
- /** Commits HEAD is behind the pinned baseline commit (0 when no pin). */
20
- readonly behind: number;
21
- };
22
- export type AppRepoManagedEntry = {
23
- readonly id: string;
24
- readonly alias: string;
25
- readonly defaultBranch: string;
26
- readonly defaultRemoteUrl: string;
27
- /** Per-repo working-tree status, present when a local checkout exists. */
28
- readonly git?: AppRepoGitStatus;
29
- };
30
- export type AppRepoSnapshot = {
31
- readonly activeTaskId: string | null;
32
- readonly baselinePins: readonly AppRepoPin[];
33
- readonly managedRepos: readonly AppRepoManagedEntry[];
34
- readonly flatLayout: boolean;
35
- readonly refreshedAt: number;
36
- };
37
- export declare function refreshRepo(ctx: AppAdapterContext): Promise<AppRepoSnapshot>;