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

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,94 +0,0 @@
1
- export type TaskRunReviewState = Record<string, unknown>;
2
- export type TaskRunStageName = "Connect" | "Prepare" | "Execute" | "Validate" | "Review" | "Publish" | "Complete" | "Needs attention" | "Failed";
3
- export type SubmitTaskRunInput = {
4
- runId: string;
5
- taskId?: string;
6
- title?: string;
7
- runtimeAdapter: "claude-code" | "codex" | "pi";
8
- model?: string;
9
- runtimeMode: string;
10
- interactionMode: string;
11
- initialPrompt?: string;
12
- baselineMode?: "head" | "dirty-snapshot";
13
- prMode?: "auto" | "ask" | "off";
14
- };
15
- type TaskRunAutomationConfig = {
16
- review?: {
17
- mode?: string;
18
- provider?: string;
19
- };
20
- automation?: {
21
- maxValidationAttempts?: number;
22
- maxPrFixIterations?: number;
23
- };
24
- };
25
- export declare function canonicalPiRunStages(): string[];
26
- export declare function buildPiRigBridgeEnv(input: {
27
- projectRoot: string;
28
- runId: string;
29
- taskId?: string | null;
30
- runtimeMode?: string | null;
31
- model?: string | null;
32
- }): Record<string, string>;
33
- export declare function applyDirtyBaselineSnapshot(input: {
34
- sourceRoot: string;
35
- targetRoot: string;
36
- }): {
37
- applied: boolean;
38
- copiedUntracked: number;
39
- detail: string;
40
- };
41
- export declare function buildTaskRunReviewEnv(config?: TaskRunAutomationConfig | null): Record<string, string>;
42
- export declare function buildDirtyBaselineHandshakeEnv(input: {
43
- projectRoot: string;
44
- runId: string;
45
- baselineMode: "head" | "dirty-snapshot";
46
- }): Record<string, string>;
47
- export declare function resolveTaskRunAutomationLimits(config?: TaskRunAutomationConfig | null, env?: Record<string, string | undefined>): {
48
- maxValidationAttempts: number;
49
- maxPrFixIterations: number;
50
- };
51
- export type PlanningClassification = {
52
- needsPlanning: boolean;
53
- reason: string;
54
- };
55
- export declare function classifyPlanningNeed(input: {
56
- prompt: string;
57
- acceptanceCriteria?: string | null;
58
- }): PlanningClassification;
59
- export declare function buildPiValidationRetrySteeringPrompt(input: {
60
- taskId?: string | null;
61
- attempt: number;
62
- failureDetail: string;
63
- }): string;
64
- export declare function classifyValidationRetryOutcome(input: {
65
- attempt: number;
66
- maxAttempts: number;
67
- failureDetail: string;
68
- }): {
69
- stage: "Validate failed";
70
- status: "retry" | "needs_attention";
71
- failureDetail: string;
72
- };
73
- export declare function taskRunStageLogId(runId: string, stage: TaskRunStageName): string;
74
- export declare function createRunLogIdFactory(runId: string): () => string;
75
- export declare function summarizeTaskRunProcessFailure(input: {
76
- stage: string;
77
- exitCode?: number | null;
78
- stderr?: string | null;
79
- stdout?: string | null;
80
- fallback?: string | null;
81
- }): string;
82
- export declare function classifyCompletionVerificationLine(line: string): {
83
- isCompletionLine: boolean;
84
- stage: string | null;
85
- status: "started" | "passed" | "failed" | null;
86
- };
87
- export declare function readTaskRunAcceptedArtifactState(input: {
88
- artifactPath: string;
89
- }): {
90
- accepted: boolean;
91
- reason: string | null;
92
- };
93
- export declare function runTaskRunPostValidationLifecycle(input: Record<string, unknown>): Promise<Record<string, unknown>>;
94
- export {};
@@ -1,203 +0,0 @@
1
- // @bun
2
- // packages/cli/src/commands/task-run-driver.ts
3
- import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync } from "fs";
4
- import { resolve } from "path";
5
- import { createEnvCloseoutRunners } from "@rig/runtime/control-plane/native/closeout-runners";
6
- import {
7
- runInProcessCloseout
8
- } from "@rig/runtime/control-plane/native/in-process-closeout";
9
- import { updateRunTaskSourceLifecycle } from "@rig/runtime/control-plane/tasks/source-lifecycle";
10
- var PI_CANONICAL_RUN_STAGES = ["Connect", "Prepare", "Execute", "Validate", "Review", "Publish", "Complete"];
11
- function canonicalPiRunStages() {
12
- return [...PI_CANONICAL_RUN_STAGES];
13
- }
14
- function buildPiRigBridgeEnv(input) {
15
- return {
16
- PROJECT_RIG_ROOT: input.projectRoot,
17
- RIG_RUN_ID: input.runId,
18
- ...input.taskId ? { RIG_TASK_ID: input.taskId } : {},
19
- ...input.runtimeMode ? { RIG_RUNTIME_MODE: input.runtimeMode } : {},
20
- ...input.model ? { RIG_MODEL: input.model } : {}
21
- };
22
- }
23
- function copyTree(sourceRoot, targetRoot) {
24
- if (!existsSync(sourceRoot))
25
- return 0;
26
- let copied = 0;
27
- for (const entry of readdirSync(sourceRoot, { withFileTypes: true })) {
28
- const sourcePath = resolve(sourceRoot, entry.name);
29
- const targetPath = resolve(targetRoot, entry.name);
30
- if (entry.isDirectory()) {
31
- mkdirSync(targetPath, { recursive: true });
32
- copied += copyTree(sourcePath, targetPath);
33
- continue;
34
- }
35
- mkdirSync(resolve(targetPath, ".."), { recursive: true });
36
- copyFileSync(sourcePath, targetPath);
37
- copied += 1;
38
- }
39
- return copied;
40
- }
41
- function applyDirtyBaselineSnapshot(input) {
42
- mkdirSync(input.targetRoot, { recursive: true });
43
- const copied = copyTree(input.sourceRoot, input.targetRoot);
44
- return {
45
- applied: copied > 0,
46
- copiedUntracked: copied,
47
- detail: copied > 0 ? `Copied ${copied} file(s) into the runtime workspace.` : "No files copied."
48
- };
49
- }
50
- function buildTaskRunReviewEnv(config) {
51
- return {
52
- ...config?.review?.mode ? { AI_REVIEW_MODE: config.review.mode } : {},
53
- ...config?.review?.provider ? { AI_REVIEW_PROVIDER: config.review.provider } : {}
54
- };
55
- }
56
- function buildDirtyBaselineHandshakeEnv(input) {
57
- return {
58
- RIG_DIRTY_BASELINE_MODE: input.baselineMode,
59
- RIG_DIRTY_BASELINE_READY_FILE: resolve(input.projectRoot, ".rig", "state", `${input.runId}.dirty-ready`)
60
- };
61
- }
62
- function resolveTaskRunAutomationLimits(config, env = process.env) {
63
- const maxValidationAttempts = Number.parseInt(env.RIG_MAX_VALIDATION_ATTEMPTS ?? "", 10);
64
- const maxPrFixIterations = Number.parseInt(env.RIG_MAX_PR_FIX_ITERATIONS ?? "", 10);
65
- return {
66
- maxValidationAttempts: Number.isFinite(maxValidationAttempts) && maxValidationAttempts > 0 ? maxValidationAttempts : config?.automation?.maxValidationAttempts ?? 30,
67
- maxPrFixIterations: Number.isFinite(maxPrFixIterations) && maxPrFixIterations > 0 ? maxPrFixIterations : config?.automation?.maxPrFixIterations ?? 100500
68
- };
69
- }
70
- function classifyPlanningNeed(input) {
71
- const text = `${input.prompt}
72
- ${input.acceptanceCriteria ?? ""}`.toLowerCase();
73
- const needsPlanning = /plan|design|approach|architecture|multi-step/.test(text);
74
- return { needsPlanning, reason: needsPlanning ? "operator requested a planning pass" : "no planning trigger detected" };
75
- }
76
- function buildPiValidationRetrySteeringPrompt(input) {
77
- return [
78
- `Validation failed on attempt ${input.attempt}${input.taskId ? ` for task ${input.taskId}` : ""}.`,
79
- input.failureDetail.trim(),
80
- "Fix the issue, rerun validation, and continue only after it passes."
81
- ].join(`
82
-
83
- `);
84
- }
85
- function classifyValidationRetryOutcome(input) {
86
- return {
87
- stage: "Validate failed",
88
- status: input.attempt < input.maxAttempts ? "retry" : "needs_attention",
89
- failureDetail: input.failureDetail
90
- };
91
- }
92
- function taskRunStageLogId(runId, stage) {
93
- return `log:${runId}:stage:${stage.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
94
- }
95
- function createRunLogIdFactory(runId) {
96
- let next = 0;
97
- return () => `${runId}:log:${++next}`;
98
- }
99
- function summarizeTaskRunProcessFailure(input) {
100
- const detail = [input.stderr?.trim(), input.stdout?.trim()].filter(Boolean)[0];
101
- return `${input.stage} failed${input.exitCode !== null && input.exitCode !== undefined ? ` (exit ${input.exitCode})` : ""}${detail ? `: ${detail}` : input.fallback ? `: ${input.fallback}` : ""}`;
102
- }
103
- function classifyCompletionVerificationLine(line) {
104
- if (line.startsWith("=== Completion Verification:")) {
105
- return { isCompletionLine: true, stage: line.replace(/^=== Completion Verification:\s*/, "").replace(/\s*=+$/, "").trim(), status: "started" };
106
- }
107
- if (/^PASS\b/.test(line))
108
- return { isCompletionLine: true, stage: null, status: "passed" };
109
- if (/^FAIL\b/.test(line))
110
- return { isCompletionLine: true, stage: null, status: "failed" };
111
- return { isCompletionLine: false, stage: null, status: null };
112
- }
113
- function readTaskRunAcceptedArtifactState(input) {
114
- if (!existsSync(input.artifactPath))
115
- return { accepted: false, reason: null };
116
- try {
117
- const parsed = JSON.parse(readFileSync(input.artifactPath, "utf8"));
118
- return {
119
- accepted: parsed.accepted === true,
120
- reason: typeof parsed.reason === "string" ? parsed.reason : null
121
- };
122
- } catch {
123
- return { accepted: false, reason: null };
124
- }
125
- }
126
- async function runTaskRunPostValidationLifecycle(input) {
127
- const projectRoot = cleanString(input.projectRoot) ?? process.cwd();
128
- const runId = cleanString(input.runId) ?? "run";
129
- const taskId = cleanString(input.runtimeTaskId) ?? cleanString(input.taskId);
130
- if (!taskId)
131
- throw new Error("Task run post-validation lifecycle requires a task id.");
132
- const workspace = cleanString(input.runtimeWorkspace) ?? cleanString(input.workspace) ?? projectRoot;
133
- const branch = cleanString(input.branch) ?? `rig/${taskId}-${runId}`;
134
- const config = input.config && typeof input.config === "object" && !Array.isArray(input.config) ? input.config : {};
135
- const sourceTask = input.sourceTask && typeof input.sourceTask === "object" && !Array.isArray(input.sourceTask) ? input.sourceTask : null;
136
- const runners = createEnvCloseoutRunners(process.env);
137
- const appendStage = typeof input.appendStage === "function" ? input.appendStage : null;
138
- const result = await runInProcessCloseout({
139
- projectRoot,
140
- runId,
141
- taskId,
142
- branch,
143
- workspace,
144
- artifactRoot: cleanString(input.artifactRoot),
145
- config,
146
- sourceTask,
147
- command: typeof input.command === "function" ? input.command : runners.command,
148
- gitCommand: typeof input.gitCommand === "function" ? input.gitCommand : runners.gitCommand,
149
- steerPi: async (message) => {
150
- appendStage?.("Review/CI", message, "running");
151
- if (typeof input.steerPi === "function") {
152
- await input.steerPi(message);
153
- }
154
- },
155
- journalPhase: (phase, outcome, detail) => {
156
- const status = outcome === "completed" ? "completed" : outcome === "failed" ? "needs_attention" : "running";
157
- appendStage?.(phase, detail ?? null, status);
158
- },
159
- reflect: async (status, summary, options) => {
160
- const github = config.github && typeof config.github === "object" && !Array.isArray(config.github) ? config.github : null;
161
- if (github?.issueUpdates === "off")
162
- return;
163
- await updateRunTaskSourceLifecycle(projectRoot, {
164
- runId,
165
- taskId,
166
- sourceTask,
167
- worktreePath: workspace,
168
- logRoot: cleanString(input.logRoot),
169
- sessionPath: cleanString(input.sessionPath)
170
- }, status, summary, options);
171
- }
172
- });
173
- return {
174
- ok: true,
175
- runId,
176
- taskId,
177
- branch,
178
- merged: result.status === "merged",
179
- closedIssue: result.status === "merged",
180
- prUrl: result.prUrl,
181
- status: result.status
182
- };
183
- }
184
- function cleanString(value) {
185
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
186
- }
187
- export {
188
- taskRunStageLogId,
189
- summarizeTaskRunProcessFailure,
190
- runTaskRunPostValidationLifecycle,
191
- resolveTaskRunAutomationLimits,
192
- readTaskRunAcceptedArtifactState,
193
- createRunLogIdFactory,
194
- classifyValidationRetryOutcome,
195
- classifyPlanningNeed,
196
- classifyCompletionVerificationLine,
197
- canonicalPiRunStages,
198
- buildTaskRunReviewEnv,
199
- buildPiValidationRetrySteeringPrompt,
200
- buildPiRigBridgeEnv,
201
- buildDirtyBaselineHandshakeEnv,
202
- applyDirtyBaselineSnapshot
203
- };
@@ -1,35 +0,0 @@
1
- import type { RegisteredTaskSource } from "@rig/contracts";
2
- import type { CommandOutcome } from "@rig/runtime/control-plane/runtime/types";
3
- import { type RunnerContext } from "../runner";
4
- import { type RigExtensionTask } from "./_run-bridge";
5
- export type TaskLike = RigExtensionTask & Record<string, unknown>;
6
- export type TaskCommandDeps = {
7
- readonly listTasks?: (projectRoot: string) => Promise<readonly TaskLike[]>;
8
- readonly getTask?: (projectRoot: string, taskId: string) => Promise<TaskLike | null>;
9
- readonly spawnRun?: (input: {
10
- readonly projectRoot: string;
11
- readonly taskId: string;
12
- readonly title?: string | null;
13
- }) => Promise<{
14
- readonly runId: string;
15
- }>;
16
- readonly taskReady?: (projectRoot: string) => Promise<void> | void;
17
- readonly taskValidate?: (projectRoot: string, taskId?: string) => Promise<boolean>;
18
- readonly taskVerify?: (projectRoot: string, taskId?: string) => Promise<boolean>;
19
- readonly taskReopen?: (projectRoot: string, options: {
20
- all: boolean;
21
- taskId?: string;
22
- dryRun?: boolean;
23
- }) => {
24
- reopened?: readonly string[];
25
- [key: string]: unknown;
26
- };
27
- readonly taskArtifacts?: (projectRoot: string, taskId?: string) => void;
28
- readonly taskArtifactDir?: (projectRoot: string, taskId?: string) => string;
29
- readonly taskArtifactWrite?: (projectRoot: string, filename: string, content: string, taskId?: string) => void;
30
- readonly loadTaskSource?: (projectRoot: string) => Promise<{
31
- readonly kind: string;
32
- readonly source: RegisteredTaskSource;
33
- }>;
34
- };
35
- export declare function executeTask(context: RunnerContext, args: string[], deps?: TaskCommandDeps): Promise<CommandOutcome>;