@h-rig/cli 0.0.6-alpha.27 → 0.0.6-alpha.280
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.
- package/README.md +6 -28
- package/package.json +11 -28
- package/dist/bin/build-rig-binaries.js +0 -107
- package/dist/bin/rig.js +0 -11321
- package/dist/src/commands/_authority-runs.js +0 -111
- package/dist/src/commands/_cli-format.js +0 -164
- package/dist/src/commands/_connection-state.js +0 -123
- package/dist/src/commands/_doctor-checks.js +0 -507
- package/dist/src/commands/_help-catalog.js +0 -203
- package/dist/src/commands/_operator-surface.js +0 -204
- package/dist/src/commands/_operator-view.js +0 -1147
- package/dist/src/commands/_parsers.js +0 -107
- package/dist/src/commands/_paths.js +0 -50
- package/dist/src/commands/_pi-frontend.js +0 -843
- package/dist/src/commands/_pi-install.js +0 -185
- package/dist/src/commands/_pi-worker-bridge-extension.js +0 -761
- package/dist/src/commands/_policy.js +0 -79
- package/dist/src/commands/_preflight.js +0 -403
- package/dist/src/commands/_probes.js +0 -13
- package/dist/src/commands/_run-driver-helpers.js +0 -289
- package/dist/src/commands/_server-client.js +0 -514
- package/dist/src/commands/_snapshot-upload.js +0 -318
- package/dist/src/commands/_task-picker.js +0 -76
- package/dist/src/commands/agent.js +0 -499
- package/dist/src/commands/browser.js +0 -890
- package/dist/src/commands/connect.js +0 -288
- package/dist/src/commands/dist.js +0 -402
- package/dist/src/commands/doctor.js +0 -517
- package/dist/src/commands/github.js +0 -281
- package/dist/src/commands/inbox.js +0 -160
- package/dist/src/commands/init.js +0 -1563
- package/dist/src/commands/inspect.js +0 -174
- package/dist/src/commands/inspector.js +0 -256
- package/dist/src/commands/plugin.js +0 -167
- package/dist/src/commands/profile-and-review.js +0 -178
- package/dist/src/commands/queue.js +0 -198
- package/dist/src/commands/remote.js +0 -507
- package/dist/src/commands/repo-git-harness.js +0 -221
- package/dist/src/commands/run.js +0 -1688
- package/dist/src/commands/server.js +0 -571
- package/dist/src/commands/setup.js +0 -687
- package/dist/src/commands/task-report-bug.js +0 -1083
- package/dist/src/commands/task-run-driver.js +0 -2600
- package/dist/src/commands/task.js +0 -2200
- package/dist/src/commands/test.js +0 -39
- package/dist/src/commands/workspace.js +0 -123
- package/dist/src/commands.js +0 -11000
- package/dist/src/index.js +0 -11339
- package/dist/src/launcher.js +0 -133
- package/dist/src/report-bug.js +0 -260
- package/dist/src/runner.js +0 -273
- package/dist/src/withMutedConsole.js +0 -42
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/commands/_run-driver-helpers.ts
|
|
3
|
-
import { readFileSync } from "fs";
|
|
4
|
-
import { resolve as resolve3 } from "path";
|
|
5
|
-
|
|
6
|
-
// packages/cli/src/runner.ts
|
|
7
|
-
import { EventBus } from "@rig/runtime/control-plane/runtime/events";
|
|
8
|
-
import { CliError } from "@rig/runtime/control-plane/errors";
|
|
9
|
-
import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
|
|
10
|
-
import { PluginManager } from "@rig/runtime/control-plane/runtime/plugins";
|
|
11
|
-
import { loadRuntimeContextFromEnv } from "@rig/runtime/control-plane/runtime/context";
|
|
12
|
-
import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
|
|
13
|
-
import { CliError as CliError2 } from "@rig/runtime/control-plane/errors";
|
|
14
|
-
|
|
15
|
-
// packages/cli/src/commands/_run-driver-helpers.ts
|
|
16
|
-
import {
|
|
17
|
-
appendJsonlRecord,
|
|
18
|
-
readAuthorityRun as readAuthorityRun2,
|
|
19
|
-
resolveAuthorityRunDir as resolveAuthorityRunDir2,
|
|
20
|
-
writeJsonFile as writeJsonFile2
|
|
21
|
-
} from "@rig/runtime/control-plane/authority-files";
|
|
22
|
-
import { taskLookup } from "@rig/runtime/control-plane/native/task-ops";
|
|
23
|
-
import { buildProviderTaskRunInstructionLines } from "@rig/runtime/control-plane/provider/runtime-instructions";
|
|
24
|
-
import { loadRigTaskRunSkillBody } from "@rig/runtime/control-plane/provider/rig-task-run-skill";
|
|
25
|
-
|
|
26
|
-
// packages/cli/src/commands/_authority-runs.ts
|
|
27
|
-
import { existsSync } from "fs";
|
|
28
|
-
import { resolve as resolve2 } from "path";
|
|
29
|
-
import {
|
|
30
|
-
readAuthorityRun,
|
|
31
|
-
readJsonlFile,
|
|
32
|
-
resolveAuthorityRunDir,
|
|
33
|
-
writeJsonFile
|
|
34
|
-
} from "@rig/runtime/control-plane/authority-files";
|
|
35
|
-
|
|
36
|
-
// packages/cli/src/commands/_paths.ts
|
|
37
|
-
import { resolve } from "path";
|
|
38
|
-
import { resolveMonorepoRoot } from "@rig/runtime/control-plane/native/utils";
|
|
39
|
-
function resolveControlPlaneMonorepoRoot(projectRoot) {
|
|
40
|
-
return resolveMonorepoRoot(projectRoot);
|
|
41
|
-
}
|
|
42
|
-
function resolveControlPlaneTaskConfigPath(projectRoot) {
|
|
43
|
-
return resolve(resolveControlPlaneMonorepoRoot(projectRoot), ".rig", "task-config.json");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// packages/cli/src/commands/_authority-runs.ts
|
|
47
|
-
function readLatestBeadRecord(projectRoot, taskId) {
|
|
48
|
-
const issuesPath = resolve2(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
|
|
49
|
-
if (!existsSync(issuesPath)) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
let latest = null;
|
|
53
|
-
for (const issue of readJsonlFile(issuesPath)) {
|
|
54
|
-
if (!issue || typeof issue !== "object") {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const record = issue;
|
|
58
|
-
if (record.id === taskId) {
|
|
59
|
-
latest = record;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return latest;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// packages/cli/src/commands/_run-driver-helpers.ts
|
|
66
|
-
function patchAuthorityRun(projectRoot, runId, patch) {
|
|
67
|
-
const current = readAuthorityRun2(projectRoot, runId);
|
|
68
|
-
if (!current) {
|
|
69
|
-
throw new CliError2(`Run not found: ${runId}`, 2);
|
|
70
|
-
}
|
|
71
|
-
const next = {
|
|
72
|
-
...current,
|
|
73
|
-
...patch,
|
|
74
|
-
updatedAt: new Date().toISOString()
|
|
75
|
-
};
|
|
76
|
-
writeJsonFile2(resolve3(resolveAuthorityRunDir2(projectRoot, runId), "run.json"), next);
|
|
77
|
-
return next;
|
|
78
|
-
}
|
|
79
|
-
function touchAuthorityRun(projectRoot, runId) {
|
|
80
|
-
const current = readAuthorityRun2(projectRoot, runId);
|
|
81
|
-
if (!current) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
writeJsonFile2(resolve3(resolveAuthorityRunDir2(projectRoot, runId), "run.json"), {
|
|
85
|
-
...current,
|
|
86
|
-
updatedAt: new Date().toISOString()
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function appendRunTimeline(projectRoot, runId, value) {
|
|
90
|
-
appendJsonlRecord(resolve3(resolveAuthorityRunDir2(projectRoot, runId), "timeline.jsonl"), value);
|
|
91
|
-
touchAuthorityRun(projectRoot, runId);
|
|
92
|
-
}
|
|
93
|
-
function appendRunLog(projectRoot, runId, value) {
|
|
94
|
-
appendJsonlRecord(resolve3(resolveAuthorityRunDir2(projectRoot, runId), "logs.jsonl"), value);
|
|
95
|
-
touchAuthorityRun(projectRoot, runId);
|
|
96
|
-
}
|
|
97
|
-
function appendRunAction(projectRoot, runId, value) {
|
|
98
|
-
appendJsonlRecord(resolve3(resolveAuthorityRunDir2(projectRoot, runId), "timeline.jsonl"), {
|
|
99
|
-
id: value.id,
|
|
100
|
-
type: "action",
|
|
101
|
-
actionType: value.actionType,
|
|
102
|
-
title: value.title,
|
|
103
|
-
detail: value.detail ?? null,
|
|
104
|
-
state: value.state,
|
|
105
|
-
createdAt: value.startedAt,
|
|
106
|
-
completedAt: value.completedAt ?? null,
|
|
107
|
-
payload: value.payload ?? {}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function startRunAction(projectRoot, runId, input) {
|
|
111
|
-
const startedAt = new Date().toISOString();
|
|
112
|
-
appendRunAction(projectRoot, runId, {
|
|
113
|
-
id: input.actionId,
|
|
114
|
-
actionType: input.actionType,
|
|
115
|
-
title: input.title,
|
|
116
|
-
detail: input.detail,
|
|
117
|
-
state: "running",
|
|
118
|
-
startedAt,
|
|
119
|
-
payload: input.payload
|
|
120
|
-
});
|
|
121
|
-
emitServerRunEvent({ type: "timeline", runId });
|
|
122
|
-
return {
|
|
123
|
-
startedAt,
|
|
124
|
-
complete: (detail, payload) => {
|
|
125
|
-
appendRunAction(projectRoot, runId, {
|
|
126
|
-
id: input.actionId,
|
|
127
|
-
actionType: input.actionType,
|
|
128
|
-
title: input.title,
|
|
129
|
-
detail: detail ?? input.detail ?? null,
|
|
130
|
-
state: "completed",
|
|
131
|
-
startedAt,
|
|
132
|
-
completedAt: new Date().toISOString(),
|
|
133
|
-
payload: payload ?? input.payload
|
|
134
|
-
});
|
|
135
|
-
emitServerRunEvent({ type: "timeline", runId });
|
|
136
|
-
},
|
|
137
|
-
fail: (detail, payload) => {
|
|
138
|
-
appendRunAction(projectRoot, runId, {
|
|
139
|
-
id: input.actionId,
|
|
140
|
-
actionType: input.actionType,
|
|
141
|
-
title: input.title,
|
|
142
|
-
detail,
|
|
143
|
-
state: "failed",
|
|
144
|
-
startedAt,
|
|
145
|
-
completedAt: new Date().toISOString(),
|
|
146
|
-
payload: payload ?? input.payload
|
|
147
|
-
});
|
|
148
|
-
emitServerRunEvent({ type: "timeline", runId });
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function emitServerRunEvent(event) {
|
|
153
|
-
console.log(`__RIG_RUN_EVENT__${JSON.stringify({ ...event, at: new Date().toISOString() })}`);
|
|
154
|
-
}
|
|
155
|
-
function buildRunPrompt(input) {
|
|
156
|
-
const initialPrompt = input.initialPrompt?.trim() || null;
|
|
157
|
-
if (!input.taskId) {
|
|
158
|
-
return initialPrompt ?? input.fallbackTitle?.trim() ?? "Continue the requested Rig run and complete the work.";
|
|
159
|
-
}
|
|
160
|
-
const issues = (() => {
|
|
161
|
-
try {
|
|
162
|
-
return taskLookup(input.projectRoot, input.taskId);
|
|
163
|
-
} catch {
|
|
164
|
-
return "";
|
|
165
|
-
}
|
|
166
|
-
})();
|
|
167
|
-
const scopeText = (() => {
|
|
168
|
-
try {
|
|
169
|
-
const parsed = JSON.parse(readFileSync(resolveControlPlaneTaskConfigPath(input.projectRoot), "utf8"));
|
|
170
|
-
const entry = parsed[input.taskId] ?? {};
|
|
171
|
-
const scope = Array.isArray(entry.scope) ? entry.scope.filter((item) => typeof item === "string") : [];
|
|
172
|
-
const validation = Array.isArray(entry.validation) ? entry.validation.filter((item) => typeof item === "string") : [];
|
|
173
|
-
const lines = [];
|
|
174
|
-
if (scope.length > 0)
|
|
175
|
-
lines.push(`Scope:
|
|
176
|
-
- ${scope.join(`
|
|
177
|
-
- `)}`);
|
|
178
|
-
if (validation.length > 0)
|
|
179
|
-
lines.push(`Validation:
|
|
180
|
-
- ${validation.join(`
|
|
181
|
-
- `)}`);
|
|
182
|
-
return lines.join(`
|
|
183
|
-
|
|
184
|
-
`);
|
|
185
|
-
} catch {
|
|
186
|
-
return "";
|
|
187
|
-
}
|
|
188
|
-
})();
|
|
189
|
-
const bead = readLatestBeadRecord(input.projectRoot, input.taskId);
|
|
190
|
-
const sourceTask = input.sourceTask ?? null;
|
|
191
|
-
const sourceDescription = firstPromptString(sourceTask?.description, sourceTask?.body);
|
|
192
|
-
const sourceAcceptance = firstPromptString(sourceTask?.acceptanceCriteria, sourceTask?.acceptance_criteria);
|
|
193
|
-
const sourceValidation = uniqueStrings([...sourceTask?.validation ?? [], ...sourceTask?.validators ?? []]);
|
|
194
|
-
const title = (bead && typeof bead === "object" && typeof bead.title === "string" ? bead.title : null) ?? firstPromptString(sourceTask?.title) ?? input.fallbackTitle ?? issues ?? input.taskId;
|
|
195
|
-
const description = (bead && typeof bead === "object" && typeof bead.description === "string" ? bead.description : null) ?? sourceDescription ?? input.fallbackDescription ?? "";
|
|
196
|
-
const acceptance = bead && typeof bead === "object" && typeof bead.acceptance_criteria === "string" ? bead.acceptance_criteria : sourceAcceptance ?? input.fallbackAcceptanceCriteria ?? "";
|
|
197
|
-
const sourceContractLines = renderSourceTaskContract(sourceTask, sourceValidation);
|
|
198
|
-
const providerLines = buildProviderTaskRunInstructionLines(input.runtimeAdapter);
|
|
199
|
-
const skillBody = loadRigTaskRunSkillBody();
|
|
200
|
-
return [
|
|
201
|
-
`You are working on task ${input.taskId}: ${title}.`,
|
|
202
|
-
description ? `Description:
|
|
203
|
-
${description}` : null,
|
|
204
|
-
acceptance ? `Acceptance criteria:
|
|
205
|
-
${acceptance}` : null,
|
|
206
|
-
sourceContractLines.length > 0 ? `Source task contract:
|
|
207
|
-
${sourceContractLines.join(`
|
|
208
|
-
`)}` : null,
|
|
209
|
-
scopeText || renderSourceScopeValidation(sourceTask, sourceValidation) || null,
|
|
210
|
-
initialPrompt ? `Additional operator guidance:
|
|
211
|
-
${initialPrompt}` : null,
|
|
212
|
-
providerLines.length > 0 ? `Provider-specific runtime tooling:
|
|
213
|
-
${providerLines.join(" ")}` : null,
|
|
214
|
-
skillBody || null
|
|
215
|
-
].filter((value) => Boolean(value)).join(`
|
|
216
|
-
|
|
217
|
-
`);
|
|
218
|
-
}
|
|
219
|
-
function firstPromptString(...values) {
|
|
220
|
-
for (const value of values) {
|
|
221
|
-
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
222
|
-
if (trimmed.length > 0) {
|
|
223
|
-
return trimmed;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return null;
|
|
227
|
-
}
|
|
228
|
-
function uniqueStrings(values) {
|
|
229
|
-
return Array.from(new Set(values.map((value) => value.trim()).filter(Boolean)));
|
|
230
|
-
}
|
|
231
|
-
function renderSourceTaskContract(task, validation) {
|
|
232
|
-
if (!task) {
|
|
233
|
-
return [];
|
|
234
|
-
}
|
|
235
|
-
const lines = [];
|
|
236
|
-
const sourceIssueId = firstPromptString(task.sourceIssueId);
|
|
237
|
-
if (sourceIssueId)
|
|
238
|
-
lines.push(`Source issue: ${sourceIssueId}`);
|
|
239
|
-
const status = firstPromptString(task.status);
|
|
240
|
-
if (status)
|
|
241
|
-
lines.push(`Source status: ${status}`);
|
|
242
|
-
const issueType = firstPromptString(task.issueType);
|
|
243
|
-
if (issueType)
|
|
244
|
-
lines.push(`Issue type: ${issueType}`);
|
|
245
|
-
const role = firstPromptString(task.role);
|
|
246
|
-
if (role)
|
|
247
|
-
lines.push(`Role: ${role}`);
|
|
248
|
-
const externalRef = firstPromptString(task.externalRef);
|
|
249
|
-
if (externalRef)
|
|
250
|
-
lines.push(`External ref: ${externalRef}`);
|
|
251
|
-
const labels = uniqueStrings(task.labels ?? []);
|
|
252
|
-
if (labels.length > 0)
|
|
253
|
-
lines.push(`Labels:
|
|
254
|
-
- ${labels.join(`
|
|
255
|
-
- `)}`);
|
|
256
|
-
if (validation.length > 0)
|
|
257
|
-
lines.push(`Validators:
|
|
258
|
-
- ${validation.join(`
|
|
259
|
-
- `)}`);
|
|
260
|
-
return lines;
|
|
261
|
-
}
|
|
262
|
-
function renderSourceScopeValidation(task, validation) {
|
|
263
|
-
if (!task) {
|
|
264
|
-
return "";
|
|
265
|
-
}
|
|
266
|
-
const lines = [];
|
|
267
|
-
const scope = uniqueStrings(task.scope ?? []);
|
|
268
|
-
if (scope.length > 0)
|
|
269
|
-
lines.push(`Scope:
|
|
270
|
-
- ${scope.join(`
|
|
271
|
-
- `)}`);
|
|
272
|
-
if (validation.length > 0)
|
|
273
|
-
lines.push(`Validation:
|
|
274
|
-
- ${validation.join(`
|
|
275
|
-
- `)}`);
|
|
276
|
-
return lines.join(`
|
|
277
|
-
|
|
278
|
-
`);
|
|
279
|
-
}
|
|
280
|
-
export {
|
|
281
|
-
touchAuthorityRun,
|
|
282
|
-
startRunAction,
|
|
283
|
-
patchAuthorityRun,
|
|
284
|
-
emitServerRunEvent,
|
|
285
|
-
buildRunPrompt,
|
|
286
|
-
appendRunTimeline,
|
|
287
|
-
appendRunLog,
|
|
288
|
-
appendRunAction
|
|
289
|
-
};
|