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

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 (120) hide show
  1. package/README.md +18 -19
  2. package/dist/bin/build-rig-binaries.d.ts +2 -0
  3. package/dist/bin/build-rig-binaries.js +22 -10
  4. package/dist/bin/rig.d.ts +72 -0
  5. package/dist/bin/rig.js +15742 -7203
  6. package/dist/config/rig-default-config.yml +5 -0
  7. package/dist/src/app/drone-ui.d.ts +34 -0
  8. package/dist/src/app/drone-ui.js +278 -0
  9. package/dist/src/commands/_async-ui.d.ts +10 -0
  10. package/dist/src/commands/_async-ui.js +121 -0
  11. package/dist/src/commands/_cli-format.d.ts +56 -0
  12. package/dist/src/commands/_cli-format.js +319 -0
  13. package/dist/src/commands/_config-env.d.ts +18 -0
  14. package/dist/src/commands/_config-env.js +22 -0
  15. package/dist/src/commands/_connection-state.d.ts +54 -0
  16. package/dist/src/commands/_connection-state.js +75 -11
  17. package/dist/src/commands/_doctor-checks.d.ts +46 -0
  18. package/dist/src/commands/_doctor-checks.js +95 -244
  19. package/dist/src/commands/_help-catalog.d.ts +29 -0
  20. package/dist/src/commands/_help-catalog.js +146 -0
  21. package/dist/src/commands/_inprocess-services.d.ts +33 -0
  22. package/dist/src/commands/_inprocess-services.js +102 -0
  23. package/dist/src/commands/_json-output.d.ts +11 -0
  24. package/dist/src/commands/_json-output.js +60 -0
  25. package/dist/src/commands/_lazy-reconcile.d.ts +34 -0
  26. package/dist/src/commands/_lazy-reconcile.js +102 -0
  27. package/dist/src/commands/_parsers.d.ts +15 -0
  28. package/dist/src/commands/_parsers.js +18 -11
  29. package/dist/src/commands/_paths.d.ts +11 -0
  30. package/dist/src/commands/_paths.js +1 -1
  31. package/dist/src/commands/_pi-frontend.d.ts +35 -0
  32. package/dist/src/commands/_pi-frontend.js +64 -0
  33. package/dist/src/commands/_pi-install.d.ts +42 -0
  34. package/dist/src/commands/_pi-install.js +19 -36
  35. package/dist/src/commands/_policy.d.ts +8 -0
  36. package/dist/src/commands/_policy.js +67 -19
  37. package/dist/src/commands/_probes.d.ts +1 -0
  38. package/dist/src/commands/_run-bridge.d.ts +114 -0
  39. package/dist/src/commands/_run-bridge.js +387 -0
  40. package/dist/src/commands/_run-diagnostics.d.ts +9 -0
  41. package/dist/src/commands/_run-diagnostics.js +51 -0
  42. package/dist/src/commands/_run-driver-helpers.d.ts +26 -0
  43. package/dist/src/commands/_run-driver-helpers.js +79 -230
  44. package/dist/src/commands/_run-projection.d.ts +50 -0
  45. package/dist/src/commands/_run-projection.js +349 -0
  46. package/dist/src/commands/_run-subcommands.d.ts +3 -0
  47. package/dist/src/commands/_run-subcommands.js +31 -0
  48. package/dist/src/commands/_spinner.d.ts +25 -0
  49. package/dist/src/commands/_spinner.js +65 -0
  50. package/dist/src/commands/agent.d.ts +3 -0
  51. package/dist/src/commands/agent.js +8690 -235
  52. package/dist/src/commands/config.d.ts +3 -0
  53. package/dist/src/commands/config.js +181 -0
  54. package/dist/src/commands/dist.d.ts +28 -0
  55. package/dist/src/commands/dist.js +44 -29
  56. package/dist/src/commands/doctor.d.ts +3 -0
  57. package/dist/src/commands/doctor.js +214 -245
  58. package/dist/src/commands/github.d.ts +3 -0
  59. package/dist/src/commands/github.js +237 -171
  60. package/dist/src/commands/inbox.d.ts +28 -0
  61. package/dist/src/commands/inbox.js +530 -111
  62. package/dist/src/commands/init.d.ts +64 -0
  63. package/dist/src/commands/init.js +941 -654
  64. package/dist/src/commands/inspect.d.ts +20 -0
  65. package/dist/src/commands/inspect.js +709 -119
  66. package/dist/src/commands/pi.d.ts +3 -0
  67. package/dist/src/commands/pi.js +177 -0
  68. package/dist/src/commands/plugin.d.ts +16 -0
  69. package/dist/src/commands/plugin.js +576 -29
  70. package/dist/src/commands/profile-and-review.d.ts +4 -0
  71. package/dist/src/commands/profile-and-review.js +112 -67
  72. package/dist/src/commands/queue.d.ts +3 -0
  73. package/dist/src/commands/queue.js +20 -20
  74. package/dist/src/commands/remote.d.ts +3 -0
  75. package/dist/src/commands/remote.js +883 -50
  76. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  77. package/dist/src/commands/repo-git-harness.js +78 -28
  78. package/dist/src/commands/run.d.ts +21 -0
  79. package/dist/src/commands/run.js +17732 -618
  80. package/dist/src/commands/server.d.ts +3 -0
  81. package/dist/src/commands/server.js +166 -285
  82. package/dist/src/commands/setup.d.ts +16 -0
  83. package/dist/src/commands/setup.js +230 -267
  84. package/dist/src/commands/stats.d.ts +15 -0
  85. package/dist/src/commands/stats.js +632 -0
  86. package/dist/src/commands/task-run-driver.d.ts +94 -0
  87. package/dist/src/commands/task-run-driver.js +120 -1856
  88. package/dist/src/commands/task.d.ts +35 -0
  89. package/dist/src/commands/task.js +676 -1183
  90. package/dist/src/commands/test.d.ts +3 -0
  91. package/dist/src/commands/test.js +15 -8
  92. package/dist/src/commands/triage.d.ts +11 -0
  93. package/dist/src/commands/triage.js +227 -0
  94. package/dist/src/commands/workspace.d.ts +3 -0
  95. package/dist/src/commands/workspace.js +18 -11
  96. package/dist/src/commands.d.ts +13 -0
  97. package/dist/src/commands.js +16760 -7779
  98. package/dist/src/index.d.ts +4 -0
  99. package/dist/src/index.js +16880 -8223
  100. package/dist/src/launcher.d.ts +61 -0
  101. package/dist/src/launcher.js +81 -13
  102. package/dist/src/operator-cli.d.ts +2 -0
  103. package/dist/src/operator-cli.js +17867 -0
  104. package/dist/src/operator-entry.d.ts +1 -0
  105. package/dist/src/operator-entry.js +3 -0
  106. package/dist/src/runner.d.ts +47 -0
  107. package/dist/src/runner.js +19 -24
  108. package/dist/src/withMutedConsole.d.ts +2 -0
  109. package/package.json +21 -7
  110. package/dist/src/commands/_authority-runs.js +0 -110
  111. package/dist/src/commands/_operator-view.js +0 -322
  112. package/dist/src/commands/_preflight.js +0 -460
  113. package/dist/src/commands/_server-client.js +0 -364
  114. package/dist/src/commands/_snapshot-upload.js +0 -313
  115. package/dist/src/commands/_task-picker.js +0 -48
  116. package/dist/src/commands/browser.js +0 -890
  117. package/dist/src/commands/connect.js +0 -180
  118. package/dist/src/commands/inspector.js +0 -256
  119. package/dist/src/commands/task-report-bug.js +0 -1083
  120. package/dist/src/report-bug.js +0 -260
@@ -1,260 +0,0 @@
1
- // @bun
2
- // packages/cli/src/report-bug.ts
3
- import { copyFileSync, existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
4
- import { basename, extname, join, resolve } from "path";
5
- function slugifyBugTitle(value) {
6
- const slug = value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80).replace(/-+$/g, "");
7
- return slug || "bug-report";
8
- }
9
- function defaultBrowserBugProfile(title) {
10
- return `hp-next-${slugifyBugTitle(title)}`;
11
- }
12
- function defaultBrowserBugOptions(environment) {
13
- if (environment === "shared-dev") {
14
- return {
15
- preset: "hp-next-shared",
16
- attachUrl: "http://127.0.0.1:9341",
17
- stateDir: ".tmp/rig-browser/hp-next-shared"
18
- };
19
- }
20
- return {
21
- preset: "hp-next-local",
22
- attachUrl: "http://127.0.0.1:9333",
23
- stateDir: ".tmp/rig-browser/hp-next"
24
- };
25
- }
26
- function createBugReportFiles(input) {
27
- const slug = slugifyBugTitle(input.slug || input.title);
28
- const outputDir = resolve(input.projectRoot, input.outputRoot);
29
- const reportDir = resolve(outputDir, slug);
30
- const assetDir = join(reportDir, "assets");
31
- const screenshotDir = join(reportDir, "screenshots");
32
- const taskPath = join(reportDir, "task.md");
33
- const browserRequired = input.browserRequired ?? true;
34
- const browserPath = browserRequired ? join(reportDir, "browser.json") : null;
35
- const manifestPath = join(reportDir, "manifest.json");
36
- if (existsSync(reportDir)) {
37
- if (!input.overwrite) {
38
- throw new Error(`Bug report directory already exists: ${reportDir}`);
39
- }
40
- rmSync(reportDir, { recursive: true, force: true });
41
- }
42
- mkdirSync(assetDir, { recursive: true });
43
- mkdirSync(screenshotDir, { recursive: true });
44
- const copiedScreenshots = copyEvidenceFiles(input.projectRoot, screenshotDir, input.screenshots ?? [], "screenshot");
45
- const copiedAssets = copyEvidenceFiles(input.projectRoot, assetDir, input.assets ?? [], "asset");
46
- const manifestAssets = [
47
- ...copiedScreenshots.map((name) => ({
48
- path: `screenshots/${name}`,
49
- type: mediaTypeForFileName(name)
50
- })),
51
- ...copiedAssets.map((name) => ({
52
- path: `assets/${name}`,
53
- type: mediaTypeForFileName(name)
54
- }))
55
- ];
56
- const browser = browserRequired ? buildBrowserBlock(input) : null;
57
- const manifest = {
58
- schema_version: 1,
59
- slug,
60
- issue_id: input.issueId ?? null,
61
- title: input.title,
62
- environment: input.environment,
63
- url: input.url,
64
- viewport: input.viewport,
65
- task_file: "task.md",
66
- browser_file: browserRequired ? "browser.json" : null,
67
- screenshots: copiedScreenshots.map((name) => `screenshots/${name}`),
68
- assets: manifestAssets,
69
- created_at: new Date().toISOString(),
70
- platform: process.platform,
71
- arch: process.arch
72
- };
73
- writeFileSync(join(assetDir, "README.md"), buildAssetReadme(input.title), "utf8");
74
- writeFileSync(join(screenshotDir, "README.md"), buildScreenshotReadme(input.title), "utf8");
75
- if (browserPath && browser) {
76
- writeFileSync(browserPath, `${JSON.stringify(browser, null, 2)}
77
- `, "utf8");
78
- }
79
- writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
80
- `, "utf8");
81
- writeFileSync(taskPath, buildBugReportMarkdown(input, browser, copiedScreenshots, copiedAssets), "utf8");
82
- return {
83
- slug,
84
- reportDir,
85
- taskPath,
86
- browserPath,
87
- manifestPath,
88
- assetDir,
89
- screenshotDir,
90
- copiedAssets,
91
- copiedScreenshots
92
- };
93
- }
94
- function buildBrowserBlock(input) {
95
- return {
96
- browser: {
97
- required: true,
98
- preset: input.preset,
99
- profile: input.profile,
100
- attach_url: input.attachUrl,
101
- state_dir: input.stateDir,
102
- dev_command: "bun run app:dev:browser:hp-next",
103
- launch_command: "bun run app:start:browser:hp-next",
104
- check_command: "bun run app:check:browser:hp-next",
105
- e2e_command: "bun run app:e2e:browser:hp-next",
106
- mode: input.mode
107
- }
108
- };
109
- }
110
- function buildBugReportMarkdown(input, browser, screenshots, assets) {
111
- const browserRequired = input.browserRequired ?? true;
112
- const assetEntries = [
113
- ...screenshots.map((name) => ({ name, path: `screenshots/${name}` })),
114
- ...assets.map((name) => ({ name, path: `assets/${name}` }))
115
- ];
116
- const assetLines = assetEntries.length > 0 ? assetEntries.map(({ name, path }) => formatAssetMarkdown(name, path)) : ["- No assets attached yet. Drag screenshots or videos into `assets/` and link them here."];
117
- const evidenceLines = input.evidence.length > 0 ? input.evidence.map((item) => `- ${item}`) : ["- Console errors: not captured yet.", "- Failed network requests: not captured yet."];
118
- return [
119
- `# ${input.title}`,
120
- "",
121
- ...input.issueId ? ["## Task", "", `Task ID: \`${input.issueId}\``, ""] : [],
122
- "## Summary",
123
- "",
124
- input.summary || "TODO: describe the user-visible bug.",
125
- "",
126
- ...browser ? [
127
- "## Browser Block",
128
- "",
129
- "```json",
130
- JSON.stringify(browser, null, 2),
131
- "```",
132
- ""
133
- ] : [],
134
- "## Environment",
135
- "",
136
- `- URL: \`${input.url}\``,
137
- `- Environment: \`${input.environment}\``,
138
- ...browserRequired ? [
139
- `- Preset: \`${input.preset}\``,
140
- `- Profile: \`${input.profile}\``,
141
- `- Viewport: \`${input.viewport}\``
142
- ] : ["- Browser: not required for this report."],
143
- "",
144
- "## Reproduction",
145
- "",
146
- ...numberedLines(input.steps.length > 0 ? input.steps : ["TODO: add reproduction step."]),
147
- "",
148
- "## Expected",
149
- "",
150
- input.expected || "TODO: expected behavior.",
151
- "",
152
- "## Actual",
153
- "",
154
- input.actual || "TODO: actual behavior.",
155
- "",
156
- "## Assets",
157
- "",
158
- ...assetLines,
159
- "",
160
- "## Evidence",
161
- "",
162
- ...evidenceLines,
163
- "",
164
- "## Agent Handoff",
165
- "",
166
- ...input.issueId ? [
167
- `- Canonical task assets live under \`artifacts/${input.issueId}/bug-report/\`.`,
168
- `- Start with \`artifacts/${input.issueId}/bug-report/task.md\` and the files in \`artifacts/${input.issueId}/bug-report/assets/\`.`,
169
- browserRequired ? `- Run \`bun run rig task info --task ${input.issueId}\` to confirm browser wiring before debugging.` : `- Run \`bun run rig task info --task ${input.issueId}\` to confirm scope and artifact links before debugging.`
170
- ] : [
171
- "- Draft-only report: convert this into a beads task before assigning it to an agent run."
172
- ],
173
- "",
174
- "## Validation",
175
- "",
176
- "```bash",
177
- ...input.issueId ? [`bun run rig task validate --task ${input.issueId}`] : [],
178
- ...browserRequired ? [
179
- "bun run app:check:browser:hp-next",
180
- "bun run app:e2e:browser:hp-next"
181
- ] : [],
182
- "```",
183
- ""
184
- ].join(`
185
- `);
186
- }
187
- function numberedLines(items) {
188
- return items.map((item, index) => `${index + 1}. ${item}`);
189
- }
190
- function buildAssetReadme(title) {
191
- return [
192
- `# Evidence Assets For ${title}`,
193
- "",
194
- "Drag and drop screenshots or videos for this bug report into this directory.",
195
- "Use stable, descriptive file names such as `login-loading.png`, `chunk-404-network.png`, or `otp-flow.webm`.",
196
- "Reference images from `../task.md` with Markdown image links and videos with normal file links.",
197
- ""
198
- ].join(`
199
- `);
200
- }
201
- function buildScreenshotReadme(title) {
202
- return [
203
- `# Screenshots For ${title}`,
204
- "",
205
- "Drop legacy screenshot files for this bug report into this directory.",
206
- "Use `assets/` for new screenshot, video, and mixed evidence attachments.",
207
- "Reference screenshots from `../task.md` with Markdown image links.",
208
- ""
209
- ].join(`
210
- `);
211
- }
212
- function copyEvidenceFiles(projectRoot, targetDir, paths, label) {
213
- const copied = [];
214
- const used = new Set;
215
- for (const rawPath of paths.map((path) => path.trim()).filter(Boolean)) {
216
- const source = resolve(projectRoot, rawPath);
217
- if (!existsSync(source)) {
218
- throw new Error(`${label} does not exist: ${source}`);
219
- }
220
- const targetName = uniqueEvidenceName(rawPath, used, label);
221
- copyFileSync(source, join(targetDir, targetName));
222
- copied.push(targetName);
223
- }
224
- return copied;
225
- }
226
- function uniqueEvidenceName(path, used, fallback) {
227
- const original = sanitizeFileName(basename(path)) || fallback;
228
- const extension = extname(original);
229
- const stem = extension ? original.slice(0, -extension.length) : original;
230
- let candidate = original;
231
- let index = 2;
232
- while (used.has(candidate)) {
233
- candidate = `${stem}-${index}${extension}`;
234
- index += 1;
235
- }
236
- used.add(candidate);
237
- return candidate;
238
- }
239
- function sanitizeFileName(value) {
240
- return value.trim().replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
241
- }
242
- function mediaTypeForFileName(fileName) {
243
- const extension = extname(fileName).toLowerCase();
244
- if ([".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg"].includes(extension)) {
245
- return "image";
246
- }
247
- if ([".mp4", ".mov", ".m4v", ".webm", ".avi", ".mkv"].includes(extension)) {
248
- return "video";
249
- }
250
- return "file";
251
- }
252
- function formatAssetMarkdown(name, path) {
253
- return mediaTypeForFileName(name) === "image" ? `- ![${name}](${path})` : `- [${name}](${path})`;
254
- }
255
- export {
256
- slugifyBugTitle,
257
- defaultBrowserBugProfile,
258
- defaultBrowserBugOptions,
259
- createBugReportFiles
260
- };