@h-rig/cli 0.0.6-alpha.83 → 0.0.6-alpha.84

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 (163) hide show
  1. package/dist/bin/rig.js +22085 -14618
  2. package/dist/src/app/board.js +155 -28
  3. package/dist/src/app-opentui/adapters/doctor.d.ts +0 -2
  4. package/dist/src/app-opentui/adapters/doctor.js +1 -25
  5. package/dist/src/app-opentui/adapters/family.d.ts +62 -0
  6. package/dist/src/app-opentui/adapters/family.js +14305 -0
  7. package/dist/src/app-opentui/adapters/fleet.d.ts +0 -2
  8. package/dist/src/app-opentui/adapters/fleet.js +6 -40
  9. package/dist/src/app-opentui/adapters/inbox.d.ts +12 -2
  10. package/dist/src/app-opentui/adapters/inbox.js +54 -59
  11. package/dist/src/app-opentui/adapters/init.d.ts +0 -2
  12. package/dist/src/app-opentui/adapters/init.js +0 -26
  13. package/dist/src/app-opentui/adapters/inspect.d.ts +52 -0
  14. package/dist/src/app-opentui/adapters/inspect.js +1024 -0
  15. package/dist/src/app-opentui/adapters/pi-attach.d.ts +15 -6
  16. package/dist/src/app-opentui/adapters/pi-attach.js +348 -93
  17. package/dist/src/app-opentui/adapters/pi.d.ts +23 -0
  18. package/dist/src/app-opentui/adapters/pi.js +363 -0
  19. package/dist/src/app-opentui/adapters/plugin.d.ts +84 -0
  20. package/dist/src/app-opentui/adapters/plugin.js +544 -0
  21. package/dist/src/app-opentui/adapters/repo.d.ts +37 -0
  22. package/dist/src/app-opentui/adapters/repo.js +186 -0
  23. package/dist/src/app-opentui/adapters/run-detail.d.ts +9 -2
  24. package/dist/src/app-opentui/adapters/run-detail.js +97 -44
  25. package/dist/src/app-opentui/adapters/server.d.ts +10 -2
  26. package/dist/src/app-opentui/adapters/server.js +96 -27
  27. package/dist/src/app-opentui/adapters/tasks.d.ts +0 -2
  28. package/dist/src/app-opentui/adapters/tasks.js +437 -105
  29. package/dist/src/app-opentui/adapters/workspace.d.ts +49 -0
  30. package/dist/src/app-opentui/adapters/workspace.js +333 -0
  31. package/dist/src/app-opentui/autocomplete.d.ts +20 -0
  32. package/dist/src/app-opentui/autocomplete.js +576 -0
  33. package/dist/src/app-opentui/bootstrap.js +24296 -16919
  34. package/dist/src/app-opentui/command-palette.d.ts +3 -0
  35. package/dist/src/app-opentui/command-palette.js +1010 -0
  36. package/dist/src/app-opentui/drone.js +8 -6
  37. package/dist/src/app-opentui/fleet-stats.d.ts +32 -0
  38. package/dist/src/app-opentui/fleet-stats.js +114 -0
  39. package/dist/src/app-opentui/index.js +3438 -1724
  40. package/dist/src/app-opentui/intent.js +71 -48
  41. package/dist/src/app-opentui/keymap.d.ts +6 -5
  42. package/dist/src/app-opentui/keymap.js +1064 -23
  43. package/dist/src/app-opentui/layout.d.ts +7 -0
  44. package/dist/src/app-opentui/layout.js +13 -6
  45. package/dist/src/app-opentui/list-search.d.ts +24 -0
  46. package/dist/src/app-opentui/list-search.js +88 -1
  47. package/dist/src/app-opentui/pi-host-child.js +33 -1
  48. package/dist/src/app-opentui/pi-pty-host.d.ts +5 -0
  49. package/dist/src/app-opentui/pi-pty-host.js +21 -3
  50. package/dist/src/app-opentui/react/App.d.ts +9 -0
  51. package/dist/src/app-opentui/react/App.js +5144 -0
  52. package/dist/src/app-opentui/react/Backdrop.d.ts +5 -0
  53. package/dist/src/app-opentui/react/Backdrop.js +1834 -0
  54. package/dist/src/app-opentui/react/ChromeHost.d.ts +5 -0
  55. package/dist/src/app-opentui/react/ChromeHost.js +2942 -0
  56. package/dist/src/app-opentui/react/SceneFrameView.d.ts +7 -0
  57. package/dist/src/app-opentui/react/SceneFrameView.js +529 -0
  58. package/dist/src/app-opentui/react/context.d.ts +17 -0
  59. package/dist/src/app-opentui/react/context.js +37 -0
  60. package/dist/src/app-opentui/react/launch.d.ts +2 -0
  61. package/dist/src/app-opentui/react/launch.js +5743 -0
  62. package/dist/src/app-opentui/react/nav.d.ts +18 -0
  63. package/dist/src/app-opentui/react/nav.js +54 -0
  64. package/dist/src/app-opentui/react/scroll.d.ts +12 -0
  65. package/dist/src/app-opentui/react/scroll.js +21 -0
  66. package/dist/src/app-opentui/react/syntax.d.ts +2 -0
  67. package/dist/src/app-opentui/react/syntax.js +64 -0
  68. package/dist/src/app-opentui/registry.js +19923 -5151
  69. package/dist/src/app-opentui/render/constants.d.ts +31 -0
  70. package/dist/src/app-opentui/render/constants.js +66 -0
  71. package/dist/src/app-opentui/render/graphics.d.ts +2 -1
  72. package/dist/src/app-opentui/render/graphics.js +106 -39
  73. package/dist/src/app-opentui/render/image-visual-layer-worker.js +108 -20
  74. package/dist/src/app-opentui/render/image-visual-layer.d.ts +7 -0
  75. package/dist/src/app-opentui/render/image-visual-layer.js +109 -20
  76. package/dist/src/app-opentui/render/native-host.d.ts +37 -0
  77. package/dist/src/app-opentui/render/native-host.js +179 -0
  78. package/dist/src/app-opentui/render/panels.js +18 -11
  79. package/dist/src/app-opentui/render/preloader.js +8 -6
  80. package/dist/src/app-opentui/render/scene.d.ts +50 -1
  81. package/dist/src/app-opentui/render/scene.js +183 -6
  82. package/dist/src/app-opentui/render/text.d.ts +7 -1
  83. package/dist/src/app-opentui/render/text.js +10 -7
  84. package/dist/src/app-opentui/render/type-bar.js +69 -30
  85. package/dist/src/app-opentui/runtime.d.ts +44 -1
  86. package/dist/src/app-opentui/runtime.js +3231 -1363
  87. package/dist/src/app-opentui/scenes/command.js +20 -6
  88. package/dist/src/app-opentui/scenes/doctor.js +176 -11
  89. package/dist/src/app-opentui/scenes/error.js +20 -10
  90. package/dist/src/app-opentui/scenes/family-domains/agent.d.ts +2 -0
  91. package/dist/src/app-opentui/scenes/family-domains/agent.js +348 -0
  92. package/dist/src/app-opentui/scenes/family-domains/browser.d.ts +2 -0
  93. package/dist/src/app-opentui/scenes/family-domains/browser.js +195 -0
  94. package/dist/src/app-opentui/scenes/family-domains/dist.d.ts +2 -0
  95. package/dist/src/app-opentui/scenes/family-domains/dist.js +243 -0
  96. package/dist/src/app-opentui/scenes/family-domains/git.d.ts +2 -0
  97. package/dist/src/app-opentui/scenes/family-domains/git.js +195 -0
  98. package/dist/src/app-opentui/scenes/family-domains/github.d.ts +2 -0
  99. package/dist/src/app-opentui/scenes/family-domains/github.js +274 -0
  100. package/dist/src/app-opentui/scenes/family-domains/harness.d.ts +2 -0
  101. package/dist/src/app-opentui/scenes/family-domains/harness.js +152 -0
  102. package/dist/src/app-opentui/scenes/family-domains/index.d.ts +4 -0
  103. package/dist/src/app-opentui/scenes/family-domains/index.js +1679 -0
  104. package/dist/src/app-opentui/scenes/family-domains/kit.d.ts +76 -0
  105. package/dist/src/app-opentui/scenes/family-domains/kit.js +305 -0
  106. package/dist/src/app-opentui/scenes/family-domains/profile.d.ts +2 -0
  107. package/dist/src/app-opentui/scenes/family-domains/profile.js +212 -0
  108. package/dist/src/app-opentui/scenes/family-domains/queue.d.ts +2 -0
  109. package/dist/src/app-opentui/scenes/family-domains/queue.js +146 -0
  110. package/dist/src/app-opentui/scenes/family-domains/remote.d.ts +2 -0
  111. package/dist/src/app-opentui/scenes/family-domains/remote.js +518 -0
  112. package/dist/src/app-opentui/scenes/family-domains/review.d.ts +2 -0
  113. package/dist/src/app-opentui/scenes/family-domains/review.js +280 -0
  114. package/dist/src/app-opentui/scenes/family-domains/setup.d.ts +2 -0
  115. package/dist/src/app-opentui/scenes/family-domains/setup.js +267 -0
  116. package/dist/src/app-opentui/scenes/family-domains/stats.d.ts +2 -0
  117. package/dist/src/app-opentui/scenes/family-domains/stats.js +370 -0
  118. package/dist/src/app-opentui/scenes/family.d.ts +3 -0
  119. package/dist/src/app-opentui/scenes/family.js +2144 -0
  120. package/dist/src/app-opentui/scenes/fleet.js +521 -31
  121. package/dist/src/app-opentui/scenes/handoff.js +204 -12
  122. package/dist/src/app-opentui/scenes/help.js +609 -40
  123. package/dist/src/app-opentui/scenes/inbox.js +278 -17
  124. package/dist/src/app-opentui/scenes/init.js +84 -39
  125. package/dist/src/app-opentui/scenes/inspect.d.ts +3 -0
  126. package/dist/src/app-opentui/scenes/inspect.js +793 -0
  127. package/dist/src/app-opentui/scenes/main.js +218 -39
  128. package/dist/src/app-opentui/scenes/pi.d.ts +3 -0
  129. package/dist/src/app-opentui/scenes/pi.js +508 -0
  130. package/dist/src/app-opentui/scenes/plugin.d.ts +3 -0
  131. package/dist/src/app-opentui/scenes/plugin.js +486 -0
  132. package/dist/src/app-opentui/scenes/repo.d.ts +3 -0
  133. package/dist/src/app-opentui/scenes/repo.js +424 -0
  134. package/dist/src/app-opentui/scenes/run-detail.js +333 -20
  135. package/dist/src/app-opentui/scenes/server.js +181 -15
  136. package/dist/src/app-opentui/scenes/tasks.js +486 -31
  137. package/dist/src/app-opentui/scenes/workspace.d.ts +3 -0
  138. package/dist/src/app-opentui/scenes/workspace.js +426 -0
  139. package/dist/src/app-opentui/selectable.d.ts +19 -0
  140. package/dist/src/app-opentui/selectable.js +79 -0
  141. package/dist/src/app-opentui/state.js +83 -30
  142. package/dist/src/app-opentui/surface-catalog.d.ts +20 -0
  143. package/dist/src/app-opentui/surface-catalog.js +540 -0
  144. package/dist/src/app-opentui/theme.d.ts +28 -6
  145. package/dist/src/app-opentui/theme.js +61 -8
  146. package/dist/src/app-opentui/types.d.ts +121 -4
  147. package/dist/src/commands/_authority-runs.d.ts +1 -1
  148. package/dist/src/commands/_authority-runs.js +2 -12
  149. package/dist/src/commands/_help-catalog.js +95 -15
  150. package/dist/src/commands/_operator-view.js +34 -2
  151. package/dist/src/commands/_pi-frontend.d.ts +2 -0
  152. package/dist/src/commands/_pi-frontend.js +34 -0
  153. package/dist/src/commands/_server-events.d.ts +26 -0
  154. package/dist/src/commands/_server-events.js +310 -0
  155. package/dist/src/commands/agent.js +2 -12
  156. package/dist/src/commands/run.js +34 -2
  157. package/dist/src/commands/server.js +2 -12
  158. package/dist/src/commands/stats.js +95 -15
  159. package/dist/src/commands/task-run-driver.js +2 -12
  160. package/dist/src/commands/task.js +131 -29
  161. package/dist/src/commands.js +192 -31
  162. package/dist/src/index.js +192 -31
  163. package/package.json +11 -9
@@ -0,0 +1,363 @@
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
+
18
+ // packages/cli/src/runner.ts
19
+ import { EventBus } from "@rig/runtime/control-plane/runtime/events";
20
+ import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
21
+ import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
22
+ import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
23
+ function requireNoExtraArgs(args, usage) {
24
+ if (args.length > 0) {
25
+ throw new CliError(`Unexpected arguments: ${args.join(" ")}
26
+ Usage: ${usage}`);
27
+ }
28
+ }
29
+ var CliError;
30
+ var init_runner = __esm(() => {
31
+ CliError = class CliError extends RuntimeCliError {
32
+ hint;
33
+ constructor(message, exitCode = 1, options = {}) {
34
+ super(message, exitCode);
35
+ if (options.hint?.trim()) {
36
+ this.hint = options.hint.trim();
37
+ }
38
+ }
39
+ };
40
+ });
41
+
42
+ // packages/cli/src/commands/pi.ts
43
+ var exports_pi = {};
44
+ __export(exports_pi, {
45
+ executePi: () => executePi
46
+ });
47
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
48
+ import { homedir } from "os";
49
+ import { dirname, resolve } from "path";
50
+ function settingsPath(root) {
51
+ return resolve(root, ".pi", "settings.json");
52
+ }
53
+ function userSettingsPath() {
54
+ return resolve(homedir(), ".pi", "agent", "settings.json");
55
+ }
56
+ function readJson(path, fallback) {
57
+ if (!existsSync(path))
58
+ return fallback;
59
+ try {
60
+ return JSON.parse(readFileSync(path, "utf-8"));
61
+ } catch {
62
+ return fallback;
63
+ }
64
+ }
65
+ function packageKey(entry) {
66
+ if (typeof entry === "string")
67
+ return entry;
68
+ if (entry && typeof entry === "object" && typeof entry.source === "string") {
69
+ return entry.source;
70
+ }
71
+ return JSON.stringify(entry);
72
+ }
73
+ function writeSettings(path, settings) {
74
+ mkdirSync(dirname(path), { recursive: true });
75
+ writeFileSync(path, `${JSON.stringify(settings, null, 2)}
76
+ `, "utf-8");
77
+ }
78
+ async function searchNpmForPiExtensions(term) {
79
+ const query = encodeURIComponent(term ? `${term} pi extension` : "pi extension");
80
+ const url = `https://registry.npmjs.org/-/v1/search?text=${query}&size=20`;
81
+ const response = await fetch(url);
82
+ if (!response.ok) {
83
+ throw new CliError(`npm registry search failed (${response.status}).`, 2, { hint: "Check network access to registry.npmjs.org, then retry `rig pi search <term>`." });
84
+ }
85
+ const payload = await response.json();
86
+ const results = [];
87
+ for (const entry of payload.objects ?? []) {
88
+ const pkg = entry.package;
89
+ if (!pkg?.name)
90
+ continue;
91
+ const keywords = (pkg.keywords ?? []).map((k) => k.toLowerCase());
92
+ const piLike = pkg.name.startsWith("pi-") || pkg.name.includes("-pi") || keywords.includes("pi") || keywords.includes("pi-extension") || (pkg.description ?? "").toLowerCase().includes("pi extension") || (pkg.description ?? "").toLowerCase().includes("pi coding agent");
93
+ if (!piLike)
94
+ continue;
95
+ results.push({ name: pkg.name, version: pkg.version ?? "", description: pkg.description ?? "" });
96
+ }
97
+ return results;
98
+ }
99
+ async function executePi(context, args) {
100
+ const [command = "list", ...rest] = args;
101
+ const projectSettingsPath = settingsPath(context.projectRoot);
102
+ const managedRecordPath = resolve(context.projectRoot, ".rig", "state", "pi-managed-packages.json");
103
+ switch (command) {
104
+ case "list": {
105
+ requireNoExtraArgs(rest, "rig pi list");
106
+ const project = readJson(projectSettingsPath, {});
107
+ const managed = new Set(readJson(managedRecordPath, []));
108
+ const user = readJson(userSettingsPath(), {});
109
+ const projectPackages = (Array.isArray(project.packages) ? project.packages : []).map((entry) => ({
110
+ source: packageKey(entry),
111
+ managedByRigConfig: managed.has(packageKey(entry))
112
+ }));
113
+ const userPackages = (Array.isArray(user.packages) ? user.packages : []).map(packageKey);
114
+ if (context.outputMode === "text") {
115
+ console.log("Project Pi packages (.pi/settings.json):");
116
+ if (projectPackages.length === 0)
117
+ console.log(" (none)");
118
+ for (const pkg of projectPackages) {
119
+ console.log(` ${pkg.source}${pkg.managedByRigConfig ? " [from rig.config runtime.pi.packages]" : ""}`);
120
+ }
121
+ console.log("User Pi packages (~/.pi/agent/settings.json):");
122
+ if (userPackages.length === 0)
123
+ console.log(" (none)");
124
+ for (const pkg of userPackages)
125
+ console.log(` ${pkg}`);
126
+ console.log("Add more: `rig pi add <npm-package>` \xB7 discover: `rig pi search <term>`");
127
+ }
128
+ return { ok: true, group: "pi", command, details: { projectPackages, userPackages } };
129
+ }
130
+ case "add": {
131
+ const [source, ...extra] = rest;
132
+ requireNoExtraArgs(extra, "rig pi add <package-source>");
133
+ if (!source) {
134
+ throw new CliError("Usage: rig pi add <package-source> (npm name, name@version, or git URL)", 2);
135
+ }
136
+ const settings = readJson(projectSettingsPath, {});
137
+ const packages = Array.isArray(settings.packages) ? settings.packages : [];
138
+ if (packages.some((entry) => packageKey(entry) === source)) {
139
+ throw new CliError(`"${source}" is already in ${projectSettingsPath}.`, 2, { hint: "Run `rig pi list` to see installed extensions." });
140
+ }
141
+ writeSettings(projectSettingsPath, { ...settings, packages: [...packages, source] });
142
+ if (context.outputMode === "text") {
143
+ console.log(`Added ${source} to ${projectSettingsPath}.`);
144
+ console.log("Pi installs missing packages automatically at the next session start (local and worker).");
145
+ }
146
+ return { ok: true, group: "pi", command, details: { source, settingsPath: projectSettingsPath } };
147
+ }
148
+ case "remove": {
149
+ const [source, ...extra] = rest;
150
+ requireNoExtraArgs(extra, "rig pi remove <package-source>");
151
+ if (!source) {
152
+ throw new CliError("Usage: rig pi remove <package-source>", 2);
153
+ }
154
+ const managed = new Set(readJson(managedRecordPath, []));
155
+ if (managed.has(source)) {
156
+ throw new CliError(`"${source}" is managed by rig.config.ts (runtime.pi.packages); remove it there instead.`, 2);
157
+ }
158
+ const settings = readJson(projectSettingsPath, {});
159
+ const packages = Array.isArray(settings.packages) ? settings.packages : [];
160
+ const next = packages.filter((entry) => packageKey(entry) !== source);
161
+ if (next.length === packages.length) {
162
+ throw new CliError(`"${source}" is not in ${projectSettingsPath}.`, 2, { hint: "Run `rig pi list` to see what is installed, then `rig pi remove <source>` with an exact entry." });
163
+ }
164
+ const nextSettings = { ...settings };
165
+ if (next.length > 0)
166
+ nextSettings.packages = next;
167
+ else
168
+ delete nextSettings.packages;
169
+ writeSettings(projectSettingsPath, nextSettings);
170
+ if (context.outputMode === "text") {
171
+ console.log(`Removed ${source} from ${projectSettingsPath}.`);
172
+ }
173
+ return { ok: true, group: "pi", command, details: { source } };
174
+ }
175
+ case "search": {
176
+ const term = rest.join(" ").trim();
177
+ const results = await searchNpmForPiExtensions(term);
178
+ if (context.outputMode === "text") {
179
+ if (results.length === 0) {
180
+ console.log(`No Pi extension packages found on npm${term ? ` for "${term}"` : ""}.`);
181
+ } else {
182
+ console.log(`Pi extension packages on npm${term ? ` matching "${term}"` : ""}:`);
183
+ for (const pkg of results) {
184
+ console.log(` ${pkg.name}@${pkg.version} ${pkg.description.slice(0, 80)}`);
185
+ }
186
+ console.log("Install one: `rig pi add <name>`");
187
+ }
188
+ }
189
+ return { ok: true, group: "pi", command, details: { term, results } };
190
+ }
191
+ default:
192
+ throw new CliError(`Unknown pi command: ${command}. Use list|add|remove|search.`, 1, { hint: "Run `rig pi --help` for usage." });
193
+ }
194
+ }
195
+ var init_pi = __esm(() => {
196
+ init_runner();
197
+ });
198
+
199
+ // packages/cli/src/app-opentui/adapters/common.ts
200
+ async function runtimeOf(ctx) {
201
+ if (ctx.rig && "runId" in ctx.rig && ctx.ensureRuntime === undefined) {
202
+ return ctx.rig;
203
+ }
204
+ if (ctx.ensureRuntime)
205
+ return ctx.ensureRuntime();
206
+ throw new Error("App adapter requires ensureRuntime() before this action can run.");
207
+ }
208
+ function normalizeAppError(error) {
209
+ const message = error instanceof Error ? error.message : String(error);
210
+ const rawHint = error instanceof Error ? error.hint : undefined;
211
+ return {
212
+ message,
213
+ ...typeof rawHint === "string" && rawHint.trim() ? { hint: rawHint.trim() } : {}
214
+ };
215
+ }
216
+ function emitStarted(ctx, label, optimistic) {
217
+ ctx.emit({ type: "action.started", label, ...optimistic ? { optimistic } : {} });
218
+ }
219
+ function emitProgress(ctx, label, detail, data) {
220
+ ctx.emit({ type: "action.progress", label, ...detail ? { detail } : {}, ...data ? { data } : {} });
221
+ }
222
+ function emitCompleted(ctx, label, data) {
223
+ ctx.emit({ type: "action.completed", label, ...data ? { data } : {} });
224
+ }
225
+ function emitFailed(ctx, label, error, data) {
226
+ if (data)
227
+ patchData(ctx, data);
228
+ const normalized = normalizeAppError(error);
229
+ ctx.emit({
230
+ type: "action.failed",
231
+ label,
232
+ message: normalized.message,
233
+ ...normalized.hint ? { hint: normalized.hint } : {},
234
+ cause: error
235
+ });
236
+ }
237
+ function patchData(ctx, data) {
238
+ ctx.emit({ type: "data.patch", data });
239
+ }
240
+ function patchFooter(ctx, footer) {
241
+ ctx.emit({ type: "footer.patch", footer });
242
+ }
243
+ async function captureConsole(fn) {
244
+ const output = [];
245
+ const original = {
246
+ log: console.log,
247
+ info: console.info,
248
+ warn: console.warn,
249
+ error: console.error
250
+ };
251
+ const capture = (...parts) => {
252
+ output.push(parts.map((part) => typeof part === "string" ? part : JSON.stringify(part)).join(" "));
253
+ };
254
+ console.log = capture;
255
+ console.info = capture;
256
+ console.warn = capture;
257
+ console.error = capture;
258
+ try {
259
+ const result = await fn();
260
+ return { result, output };
261
+ } finally {
262
+ console.log = original.log;
263
+ console.info = original.info;
264
+ console.warn = original.warn;
265
+ console.error = original.error;
266
+ }
267
+ }
268
+
269
+ // packages/cli/src/app-opentui/adapters/pi.ts
270
+ function asProjectPackages(value) {
271
+ if (!Array.isArray(value))
272
+ return [];
273
+ return value.flatMap((entry) => {
274
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
275
+ return [];
276
+ const record = entry;
277
+ const source = typeof record.source === "string" ? record.source : undefined;
278
+ if (!source)
279
+ return [];
280
+ return [{ source, managedByRigConfig: record.managedByRigConfig === true }];
281
+ });
282
+ }
283
+ function asUserPackages(value) {
284
+ if (!Array.isArray(value))
285
+ return [];
286
+ return value.filter((entry) => typeof entry === "string");
287
+ }
288
+ function asSearchResults(value) {
289
+ if (!Array.isArray(value))
290
+ return [];
291
+ return value.flatMap((entry) => {
292
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
293
+ return [];
294
+ const record = entry;
295
+ const name = typeof record.name === "string" ? record.name : undefined;
296
+ if (!name)
297
+ return [];
298
+ return [{
299
+ name,
300
+ version: typeof record.version === "string" ? record.version : "",
301
+ description: typeof record.description === "string" ? record.description : ""
302
+ }];
303
+ });
304
+ }
305
+ function priorSnapshot(ctx) {
306
+ const value = ctx.getState().data?.pi;
307
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
308
+ }
309
+ function searchRequest(ctx) {
310
+ const state = ctx.getState();
311
+ const intent = state.intent;
312
+ const payload = intent?.action?.payload;
313
+ if (!payload || !("piSearch" in payload))
314
+ return { kind: "none" };
315
+ const value = payload.piSearch;
316
+ if (typeof value === "string" && value.trim())
317
+ return { kind: "search", term: value.trim() };
318
+ return { kind: "clear" };
319
+ }
320
+ async function refreshPi(ctx) {
321
+ const request = searchRequest(ctx);
322
+ const label = request.kind === "search" ? `Searching Pi extensions for "${request.term}"` : "Loading Pi extensions";
323
+ emitStarted(ctx, label);
324
+ try {
325
+ const runtime = await runtimeOf(ctx);
326
+ const { executePi: executePi2 } = await Promise.resolve().then(() => (init_pi(), exports_pi));
327
+ emitProgress(ctx, label, "reading project + user Pi settings");
328
+ const { result: listResult } = await captureConsole(() => executePi2(runtime, ["list"]));
329
+ const listDetails = listResult.details ?? {};
330
+ const prior = priorSnapshot(ctx);
331
+ let searchResults = request.kind === "clear" ? [] : prior?.searchResults ?? [];
332
+ let resolvedTerm = request.kind === "clear" ? undefined : prior?.searchTerm;
333
+ if (request.kind === "search") {
334
+ emitProgress(ctx, label, "searching npm for Pi extensions");
335
+ const { result: searchResult } = await captureConsole(() => executePi2(runtime, ["search", request.term]));
336
+ const searchDetails = searchResult.details ?? {};
337
+ searchResults = asSearchResults(searchDetails.results);
338
+ resolvedTerm = typeof searchDetails.term === "string" && searchDetails.term.trim() ? searchDetails.term.trim() : request.term;
339
+ }
340
+ const snapshot = {
341
+ projectPackages: asProjectPackages(listDetails.projectPackages),
342
+ userPackages: asUserPackages(listDetails.userPackages),
343
+ ...resolvedTerm !== undefined ? { searchTerm: resolvedTerm } : {},
344
+ searchResults,
345
+ refreshedAt: Date.now()
346
+ };
347
+ patchData(ctx, { pi: snapshot, lastRefreshError: undefined });
348
+ const footerSuffix = searchResults.length > 0 ? ` \xB7 ${searchResults.length} search hits` : "";
349
+ patchFooter(ctx, { message: `${snapshot.projectPackages.length} project \xB7 ${snapshot.userPackages.length} user Pi packages${footerSuffix}` });
350
+ emitCompleted(ctx, label, {
351
+ project: snapshot.projectPackages.length,
352
+ user: snapshot.userPackages.length,
353
+ ...request.kind === "search" ? { searchHits: searchResults.length } : {}
354
+ });
355
+ return snapshot;
356
+ } catch (error) {
357
+ emitFailed(ctx, label, error);
358
+ throw error;
359
+ }
360
+ }
361
+ export {
362
+ refreshPi
363
+ };
@@ -0,0 +1,84 @@
1
+ import { type AppAdapterContext } from "./common";
2
+ export type AppPluginRecord = {
3
+ readonly name: string;
4
+ readonly version: string;
5
+ readonly validators: readonly string[];
6
+ readonly hooks: readonly string[];
7
+ readonly agentRoles: readonly string[];
8
+ readonly repoSources: readonly string[];
9
+ readonly taskSources: readonly string[];
10
+ readonly skills: readonly string[];
11
+ readonly taskFieldExtensions: readonly string[];
12
+ readonly cliCommands: readonly string[];
13
+ };
14
+ /** A validator's static registration metadata (id + category + optional
15
+ * description), harvested from the live validator registry so the scene can
16
+ * enrich the otherwise-bare contribution ids with category/scope/description. */
17
+ export type AppValidatorMeta = {
18
+ readonly id: string;
19
+ readonly category: string;
20
+ readonly description?: string;
21
+ };
22
+ /** Enrichment for ONE contribution id, harvested from the live plugin host.
23
+ * `tag` is the scope-/kind-bearing label (validator category, hook event ·
24
+ * matcher, agent-role model, task-source kind, etc.); `description` is the
25
+ * optional registration description. The declarative `plugin list` slice only
26
+ * carries bare ids — these come from `pluginHost.list*()`. */
27
+ export type AppContributionMeta = {
28
+ readonly id: string;
29
+ readonly tag?: string;
30
+ readonly description?: string;
31
+ };
32
+ /** Registry-resolved metadata for every contribution group, keyed by id within
33
+ * each group, so the detail view can enrich every row (not just validators). */
34
+ export type AppPluginContributionMeta = {
35
+ readonly validators: readonly AppContributionMeta[];
36
+ readonly hooks: readonly AppContributionMeta[];
37
+ readonly agentRoles: readonly AppContributionMeta[];
38
+ readonly repoSources: readonly AppContributionMeta[];
39
+ readonly taskSources: readonly AppContributionMeta[];
40
+ readonly skills: readonly AppContributionMeta[];
41
+ readonly taskFieldExtensions: readonly AppContributionMeta[];
42
+ readonly cliCommands: readonly AppContributionMeta[];
43
+ };
44
+ export type AppPluginSnapshot = {
45
+ readonly plugins: readonly AppPluginRecord[];
46
+ /** Registry-resolved validator metadata, keyed by validator id. Empty when the
47
+ * project has no rig.config (validators only resolve through the plugin host). */
48
+ readonly validatorMeta: readonly AppValidatorMeta[];
49
+ /** Registry-resolved metadata for EVERY contribution group. Empty groups when
50
+ * the project has no rig.config. */
51
+ readonly contributionMeta: AppPluginContributionMeta;
52
+ readonly refreshedAt: number;
53
+ };
54
+ /** One row of a validate run: the structured result the validator registry
55
+ * produced (`details.results[]` shape) for a single validator. */
56
+ export type AppValidatorResult = {
57
+ readonly id: string;
58
+ readonly passed: boolean;
59
+ readonly summary: string;
60
+ readonly details?: string;
61
+ };
62
+ /** A captured `rig plugin validate --task <id>` run, rendered in-app as a
63
+ * pass/fail board (NOT a PTY). Populated by {@link validatePluginTask}. */
64
+ export type AppPluginValidation = {
65
+ readonly taskId: string;
66
+ readonly passed: number;
67
+ readonly failed: number;
68
+ readonly results: readonly AppValidatorResult[];
69
+ readonly ranAt: number;
70
+ };
71
+ export declare function refreshPlugin(ctx: AppAdapterContext): Promise<AppPluginSnapshot>;
72
+ /**
73
+ * Run plugin validators against a task id IN-PROCESS and capture the structured
74
+ * `results[]` (`{id, passed, summary, details}`) into `state.data.pluginValidation`
75
+ * so the scene renders an in-app pass/fail board — NOT a PTY.
76
+ *
77
+ * Why the registry walk and not `executePlugin(runtime, ["validate", ...])`:
78
+ * the command computes `details.results` but, on any failure, throws a CliError
79
+ * *before* returning — so the structured results never surface to a caller on
80
+ * the failure path, which is exactly the case the board most needs to render.
81
+ * We reuse the same validator registry the command uses (identical code path,
82
+ * identical results), collecting every validator's result regardless of pass/fail.
83
+ */
84
+ export declare function validatePluginTask(ctx: AppAdapterContext, taskId: string): Promise<AppPluginValidation>;