@h-rig/cli 0.0.6-alpha.94 → 0.0.6-alpha.95

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 (108) 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 -17855
  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/_connection-state.d.ts +0 -54
  16. package/dist/src/commands/_connection-state.js +0 -187
  17. package/dist/src/commands/_doctor-checks.d.ts +0 -46
  18. package/dist/src/commands/_doctor-checks.js +0 -352
  19. package/dist/src/commands/_help-catalog.d.ts +0 -51
  20. package/dist/src/commands/_help-catalog.js +0 -502
  21. package/dist/src/commands/_inprocess-services.d.ts +0 -33
  22. package/dist/src/commands/_inprocess-services.js +0 -102
  23. package/dist/src/commands/_json-output.d.ts +0 -11
  24. package/dist/src/commands/_json-output.js +0 -60
  25. package/dist/src/commands/_lazy-reconcile.d.ts +0 -34
  26. package/dist/src/commands/_lazy-reconcile.js +0 -102
  27. package/dist/src/commands/_parsers.d.ts +0 -15
  28. package/dist/src/commands/_parsers.js +0 -114
  29. package/dist/src/commands/_paths.d.ts +0 -11
  30. package/dist/src/commands/_paths.js +0 -50
  31. package/dist/src/commands/_pi-frontend.d.ts +0 -35
  32. package/dist/src/commands/_pi-frontend.js +0 -64
  33. package/dist/src/commands/_pi-install.d.ts +0 -42
  34. package/dist/src/commands/_pi-install.js +0 -167
  35. package/dist/src/commands/_policy.d.ts +0 -8
  36. package/dist/src/commands/_policy.js +0 -127
  37. package/dist/src/commands/_probes.d.ts +0 -1
  38. package/dist/src/commands/_probes.js +0 -13
  39. package/dist/src/commands/_run-bridge.d.ts +0 -114
  40. package/dist/src/commands/_run-bridge.js +0 -387
  41. package/dist/src/commands/_run-diagnostics.d.ts +0 -9
  42. package/dist/src/commands/_run-diagnostics.js +0 -51
  43. package/dist/src/commands/_run-driver-helpers.d.ts +0 -26
  44. package/dist/src/commands/_run-driver-helpers.js +0 -138
  45. package/dist/src/commands/_run-projection.d.ts +0 -50
  46. package/dist/src/commands/_run-projection.js +0 -349
  47. package/dist/src/commands/_run-subcommands.d.ts +0 -3
  48. package/dist/src/commands/_run-subcommands.js +0 -31
  49. package/dist/src/commands/_spinner.d.ts +0 -25
  50. package/dist/src/commands/_spinner.js +0 -65
  51. package/dist/src/commands/agent.d.ts +0 -3
  52. package/dist/src/commands/agent.js +0 -8837
  53. package/dist/src/commands/dist.d.ts +0 -28
  54. package/dist/src/commands/dist.js +0 -417
  55. package/dist/src/commands/doctor.d.ts +0 -3
  56. package/dist/src/commands/doctor.js +0 -480
  57. package/dist/src/commands/github.d.ts +0 -3
  58. package/dist/src/commands/github.js +0 -342
  59. package/dist/src/commands/inbox.d.ts +0 -28
  60. package/dist/src/commands/inbox.js +0 -579
  61. package/dist/src/commands/init.d.ts +0 -64
  62. package/dist/src/commands/init.js +0 -1541
  63. package/dist/src/commands/inspect.d.ts +0 -20
  64. package/dist/src/commands/inspect.js +0 -764
  65. package/dist/src/commands/pi.d.ts +0 -3
  66. package/dist/src/commands/pi.js +0 -177
  67. package/dist/src/commands/plugin.d.ts +0 -16
  68. package/dist/src/commands/plugin.js +0 -714
  69. package/dist/src/commands/profile-and-review.d.ts +0 -4
  70. package/dist/src/commands/profile-and-review.js +0 -223
  71. package/dist/src/commands/queue.d.ts +0 -3
  72. package/dist/src/commands/queue.js +0 -197
  73. package/dist/src/commands/remote.d.ts +0 -3
  74. package/dist/src/commands/remote.js +0 -1337
  75. package/dist/src/commands/repo-git-harness.d.ts +0 -5
  76. package/dist/src/commands/repo-git-harness.js +0 -271
  77. package/dist/src/commands/run.d.ts +0 -21
  78. package/dist/src/commands/run.js +0 -17847
  79. package/dist/src/commands/server.d.ts +0 -3
  80. package/dist/src/commands/server.js +0 -249
  81. package/dist/src/commands/setup.d.ts +0 -16
  82. package/dist/src/commands/setup.js +0 -644
  83. package/dist/src/commands/stats.d.ts +0 -15
  84. package/dist/src/commands/stats.js +0 -979
  85. package/dist/src/commands/task-run-driver.d.ts +0 -94
  86. package/dist/src/commands/task-run-driver.js +0 -203
  87. package/dist/src/commands/task.d.ts +0 -35
  88. package/dist/src/commands/task.js +0 -818
  89. package/dist/src/commands/test.d.ts +0 -3
  90. package/dist/src/commands/test.js +0 -46
  91. package/dist/src/commands/triage.d.ts +0 -11
  92. package/dist/src/commands/triage.js +0 -227
  93. package/dist/src/commands/workspace.d.ts +0 -3
  94. package/dist/src/commands/workspace.js +0 -130
  95. package/dist/src/commands.d.ts +0 -13
  96. package/dist/src/commands.js +0 -17979
  97. package/dist/src/index.d.ts +0 -4
  98. package/dist/src/index.js +0 -17991
  99. package/dist/src/launcher.d.ts +0 -61
  100. package/dist/src/launcher.js +0 -199
  101. package/dist/src/operator-cli.d.ts +0 -2
  102. package/dist/src/operator-cli.js +0 -17847
  103. package/dist/src/operator-entry.d.ts +0 -1
  104. package/dist/src/operator-entry.js +0 -3
  105. package/dist/src/runner.d.ts +0 -47
  106. package/dist/src/runner.js +0 -267
  107. package/dist/src/withMutedConsole.d.ts +0 -2
  108. 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 executePi(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
@@ -1,177 +0,0 @@
1
- // @bun
2
- // packages/cli/src/commands/pi.ts
3
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
4
- import { homedir } from "os";
5
- import { dirname, resolve } from "path";
6
-
7
- // packages/cli/src/runner.ts
8
- import { EventBus } from "@rig/runtime/control-plane/runtime/events";
9
- import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
10
- import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
11
- import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
12
-
13
- class CliError extends RuntimeCliError {
14
- hint;
15
- constructor(message, exitCode = 1, options = {}) {
16
- super(message, exitCode);
17
- if (options.hint?.trim()) {
18
- this.hint = options.hint.trim();
19
- }
20
- }
21
- }
22
- function requireNoExtraArgs(args, usage) {
23
- if (args.length > 0) {
24
- throw new CliError(`Unexpected arguments: ${args.join(" ")}
25
- Usage: ${usage}`);
26
- }
27
- }
28
-
29
- // packages/cli/src/commands/pi.ts
30
- function settingsPath(root) {
31
- return resolve(root, ".pi", "settings.json");
32
- }
33
- function userSettingsPath() {
34
- return resolve(homedir(), ".pi", "agent", "settings.json");
35
- }
36
- function readJson(path, fallback) {
37
- if (!existsSync(path))
38
- return fallback;
39
- try {
40
- return JSON.parse(readFileSync(path, "utf-8"));
41
- } catch {
42
- return fallback;
43
- }
44
- }
45
- function packageKey(entry) {
46
- if (typeof entry === "string")
47
- return entry;
48
- if (entry && typeof entry === "object" && typeof entry.source === "string") {
49
- return entry.source;
50
- }
51
- return JSON.stringify(entry);
52
- }
53
- function writeSettings(path, settings) {
54
- mkdirSync(dirname(path), { recursive: true });
55
- writeFileSync(path, `${JSON.stringify(settings, null, 2)}
56
- `, "utf-8");
57
- }
58
- async function searchNpmForPiExtensions(term) {
59
- const query = encodeURIComponent(term ? `${term} pi extension` : "pi extension");
60
- const url = `https://registry.npmjs.org/-/v1/search?text=${query}&size=20`;
61
- const response = await fetch(url);
62
- if (!response.ok) {
63
- throw new CliError(`npm registry search failed (${response.status}).`, 2, { hint: "Check network access to registry.npmjs.org, then retry `rig pi search <term>`." });
64
- }
65
- const payload = await response.json();
66
- const results = [];
67
- for (const entry of payload.objects ?? []) {
68
- const pkg = entry.package;
69
- if (!pkg?.name)
70
- continue;
71
- const keywords = (pkg.keywords ?? []).map((k) => k.toLowerCase());
72
- 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");
73
- if (!piLike)
74
- continue;
75
- results.push({ name: pkg.name, version: pkg.version ?? "", description: pkg.description ?? "" });
76
- }
77
- return results;
78
- }
79
- async function executePi(context, args) {
80
- const [command = "list", ...rest] = args;
81
- const projectSettingsPath = settingsPath(context.projectRoot);
82
- const managedRecordPath = resolve(context.projectRoot, ".rig", "state", "pi-managed-packages.json");
83
- switch (command) {
84
- case "list": {
85
- requireNoExtraArgs(rest, "rig pi list");
86
- const project = readJson(projectSettingsPath, {});
87
- const managed = new Set(readJson(managedRecordPath, []));
88
- const user = readJson(userSettingsPath(), {});
89
- const projectPackages = (Array.isArray(project.packages) ? project.packages : []).map((entry) => ({
90
- source: packageKey(entry),
91
- managedByRigConfig: managed.has(packageKey(entry))
92
- }));
93
- const userPackages = (Array.isArray(user.packages) ? user.packages : []).map(packageKey);
94
- if (context.outputMode === "text") {
95
- console.log("Project Pi packages (.pi/settings.json):");
96
- if (projectPackages.length === 0)
97
- console.log(" (none)");
98
- for (const pkg of projectPackages) {
99
- console.log(` ${pkg.source}${pkg.managedByRigConfig ? " [from rig.config runtime.pi.packages]" : ""}`);
100
- }
101
- console.log("User Pi packages (~/.pi/agent/settings.json):");
102
- if (userPackages.length === 0)
103
- console.log(" (none)");
104
- for (const pkg of userPackages)
105
- console.log(` ${pkg}`);
106
- console.log("Add more: `rig pi add <npm-package>` \xB7 discover: `rig pi search <term>`");
107
- }
108
- return { ok: true, group: "pi", command, details: { projectPackages, userPackages } };
109
- }
110
- case "add": {
111
- const [source, ...extra] = rest;
112
- requireNoExtraArgs(extra, "rig pi add <package-source>");
113
- if (!source) {
114
- throw new CliError("Usage: rig pi add <package-source> (npm name, name@version, or git URL)", 2);
115
- }
116
- const settings = readJson(projectSettingsPath, {});
117
- const packages = Array.isArray(settings.packages) ? settings.packages : [];
118
- if (packages.some((entry) => packageKey(entry) === source)) {
119
- throw new CliError(`"${source}" is already in ${projectSettingsPath}.`, 2, { hint: "Run `rig pi list` to see installed extensions." });
120
- }
121
- writeSettings(projectSettingsPath, { ...settings, packages: [...packages, source] });
122
- if (context.outputMode === "text") {
123
- console.log(`Added ${source} to ${projectSettingsPath}.`);
124
- console.log("Pi installs missing packages automatically at the next session start (local and worker).");
125
- }
126
- return { ok: true, group: "pi", command, details: { source, settingsPath: projectSettingsPath } };
127
- }
128
- case "remove": {
129
- const [source, ...extra] = rest;
130
- requireNoExtraArgs(extra, "rig pi remove <package-source>");
131
- if (!source) {
132
- throw new CliError("Usage: rig pi remove <package-source>", 2);
133
- }
134
- const managed = new Set(readJson(managedRecordPath, []));
135
- if (managed.has(source)) {
136
- throw new CliError(`"${source}" is managed by rig.config.ts (runtime.pi.packages); remove it there instead.`, 2);
137
- }
138
- const settings = readJson(projectSettingsPath, {});
139
- const packages = Array.isArray(settings.packages) ? settings.packages : [];
140
- const next = packages.filter((entry) => packageKey(entry) !== source);
141
- if (next.length === packages.length) {
142
- 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." });
143
- }
144
- const nextSettings = { ...settings };
145
- if (next.length > 0)
146
- nextSettings.packages = next;
147
- else
148
- delete nextSettings.packages;
149
- writeSettings(projectSettingsPath, nextSettings);
150
- if (context.outputMode === "text") {
151
- console.log(`Removed ${source} from ${projectSettingsPath}.`);
152
- }
153
- return { ok: true, group: "pi", command, details: { source } };
154
- }
155
- case "search": {
156
- const term = rest.join(" ").trim();
157
- const results = await searchNpmForPiExtensions(term);
158
- if (context.outputMode === "text") {
159
- if (results.length === 0) {
160
- console.log(`No Pi extension packages found on npm${term ? ` for "${term}"` : ""}.`);
161
- } else {
162
- console.log(`Pi extension packages on npm${term ? ` matching "${term}"` : ""}:`);
163
- for (const pkg of results) {
164
- console.log(` ${pkg.name}@${pkg.version} ${pkg.description.slice(0, 80)}`);
165
- }
166
- console.log("Install one: `rig pi add <name>`");
167
- }
168
- }
169
- return { ok: true, group: "pi", command, details: { term, results } };
170
- }
171
- default:
172
- throw new CliError(`Unknown pi command: ${command}. Use list|add|remove|search.`, 1, { hint: "Run `rig pi --help` for usage." });
173
- }
174
- }
175
- export {
176
- executePi
177
- };
@@ -1,16 +0,0 @@
1
- import { type RunnerContext } from "../runner";
2
- import type { CommandOutcome } from "@rig/runtime";
3
- export declare function executePlugin(context: RunnerContext, args: string[]): Promise<CommandOutcome>;
4
- /**
5
- * Resolve a plugin CLI command by exact id ("my-plugin:deploy") or by the
6
- * unambiguous local part after the namespace colon ("deploy").
7
- */
8
- export declare function resolvePluginCliCommand(commands: readonly {
9
- id: string;
10
- command: string;
11
- description?: string;
12
- }[], requested: string): {
13
- id: string;
14
- command: string;
15
- description?: string;
16
- } | undefined;