@h-rig/cli-surface-plugin 0.0.6-alpha.157 → 0.0.6-alpha.158

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 (112) hide show
  1. package/dist/src/app/drone-ui.d.ts +0 -11
  2. package/dist/src/app/drone-ui.js +0 -114
  3. package/dist/src/commands/_async-ui.d.ts +1 -1
  4. package/dist/src/commands/_cli-format.d.ts +0 -29
  5. package/dist/src/commands/_cli-format.js +59 -113
  6. package/dist/src/commands/_connection-state.d.ts +6 -33
  7. package/dist/src/commands/_connection-state.js +654 -138
  8. package/dist/src/commands/_doctor-checks.d.ts +2 -5
  9. package/dist/src/commands/_doctor-checks.js +10 -9
  10. package/dist/src/commands/_help-catalog.d.ts +2 -1
  11. package/dist/src/commands/_help-catalog.js +654 -7
  12. package/dist/src/commands/_inprocess-services.d.ts +5 -5
  13. package/dist/src/commands/_inprocess-services.js +1 -1
  14. package/dist/src/commands/_parsers.js +651 -12
  15. package/dist/src/commands/_paths.d.ts +0 -2
  16. package/dist/src/commands/_paths.js +2 -10
  17. package/dist/src/commands/_pi-install.d.ts +2 -12
  18. package/dist/src/commands/_pi-install.js +3 -36
  19. package/dist/src/commands/_policy.js +659 -20
  20. package/dist/src/commands/agent.d.ts +1 -1
  21. package/dist/src/commands/agent.js +675 -24
  22. package/dist/src/commands/config.d.ts +1 -1
  23. package/dist/src/commands/config.js +656 -21
  24. package/dist/src/commands/dist.d.ts +1 -1
  25. package/dist/src/commands/dist.js +828 -102
  26. package/dist/src/commands/doctor.d.ts +1 -1
  27. package/dist/src/commands/doctor.js +658 -12
  28. package/dist/src/commands/github.d.ts +1 -1
  29. package/dist/src/commands/github.js +658 -19
  30. package/dist/src/commands/inbox.d.ts +12 -8
  31. package/dist/src/commands/inbox.js +741 -22
  32. package/dist/src/commands/init.d.ts +17 -19
  33. package/dist/src/commands/init.js +836 -306
  34. package/dist/src/commands/inspect.d.ts +5 -6
  35. package/dist/src/commands/inspect.js +754 -42
  36. package/dist/src/commands/pi.d.ts +1 -1
  37. package/dist/src/commands/pi.js +655 -16
  38. package/dist/src/commands/plugin.d.ts +9 -9
  39. package/dist/src/commands/plugin.js +652 -13
  40. package/dist/src/commands/profile-and-review.d.ts +1 -1
  41. package/dist/src/commands/profile-and-review.js +655 -16
  42. package/dist/src/commands/queue.d.ts +1 -1
  43. package/dist/src/commands/queue.js +871 -12
  44. package/dist/src/commands/remote-client.d.ts +152 -0
  45. package/dist/src/commands/remote-client.js +475 -0
  46. package/dist/src/commands/remote.d.ts +1 -1
  47. package/dist/src/commands/remote.js +1100 -29
  48. package/dist/src/commands/repo-git-harness.d.ts +1 -1
  49. package/dist/src/commands/repo-git-harness.js +2321 -47
  50. package/dist/src/commands/run.d.ts +10 -6
  51. package/dist/src/commands/run.js +830 -50
  52. package/dist/src/commands/server.d.ts +1 -1
  53. package/dist/src/commands/server.js +649 -11
  54. package/dist/src/commands/setup.d.ts +2 -2
  55. package/dist/src/commands/setup.js +829 -18
  56. package/dist/src/commands/stats.d.ts +2 -4
  57. package/dist/src/commands/stats.js +1299 -20
  58. package/dist/src/commands/test.d.ts +1 -1
  59. package/dist/src/commands/test.js +648 -9
  60. package/dist/src/commands/triage.d.ts +2 -3
  61. package/dist/src/commands/triage.js +657 -11
  62. package/dist/src/commands/workspace.d.ts +1 -1
  63. package/dist/src/commands/workspace.js +1280 -15
  64. package/dist/src/control-plane/agent-binary-build.d.ts +9 -0
  65. package/dist/src/control-plane/agent-binary-build.js +88 -0
  66. package/dist/src/control-plane/embedded-native-assets.d.ts +7 -0
  67. package/dist/src/control-plane/embedded-native-assets.js +6 -0
  68. package/dist/src/control-plane/guard.d.ts +17 -0
  69. package/dist/src/control-plane/guard.js +684 -0
  70. package/dist/src/control-plane/harness-cli.d.ts +12 -0
  71. package/dist/src/control-plane/harness-cli.js +1623 -0
  72. package/dist/src/control-plane/native/git-ops.d.ts +67 -0
  73. package/dist/src/control-plane/native/git-ops.js +1381 -0
  74. package/dist/src/control-plane/native/github-auth-env.d.ts +1 -0
  75. package/dist/src/control-plane/native/github-auth-env.js +21 -0
  76. package/dist/src/control-plane/native/host-git.d.ts +4 -0
  77. package/dist/src/control-plane/native/host-git.js +51 -0
  78. package/dist/src/control-plane/priority-queue.d.ts +22 -0
  79. package/dist/src/control-plane/priority-queue.js +212 -0
  80. package/dist/src/control-plane/rigfig.d.ts +9 -0
  81. package/dist/src/control-plane/rigfig.js +70 -0
  82. package/dist/src/control-plane/scope.d.ts +3 -0
  83. package/dist/src/control-plane/scope.js +58 -0
  84. package/dist/src/control-plane/setup-status.d.ts +44 -0
  85. package/dist/src/control-plane/setup-status.js +164 -0
  86. package/dist/src/control-plane/task-data.d.ts +2 -0
  87. package/dist/src/control-plane/task-data.js +12 -0
  88. package/dist/src/control-plane/workspace-ops.d.ts +79 -0
  89. package/dist/src/control-plane/workspace-ops.js +639 -0
  90. package/dist/src/help-catalog-data.d.ts +7 -0
  91. package/dist/src/help-catalog-data.js +660 -0
  92. package/dist/src/kernel-dispatch.js +1 -3
  93. package/dist/src/plugin.js +10072 -30
  94. package/dist/src/runner.d.ts +7 -9
  95. package/dist/src/runner.js +750 -30
  96. package/package.json +12 -13
  97. package/dist/src/commands/_json-output.d.ts +0 -11
  98. package/dist/src/commands/_json-output.js +0 -54
  99. package/dist/src/commands/_pi-frontend.d.ts +0 -35
  100. package/dist/src/commands/_pi-frontend.js +0 -64
  101. package/dist/src/commands/_run-driver-helpers.d.ts +0 -26
  102. package/dist/src/commands/_run-driver-helpers.js +0 -132
  103. package/dist/src/commands/task-run-driver.d.ts +0 -93
  104. package/dist/src/commands/task-run-driver.js +0 -136
  105. package/dist/src/commands/task.d.ts +0 -46
  106. package/dist/src/commands/task.js +0 -555
  107. package/dist/src/provider-model.d.ts +0 -34
  108. package/dist/src/provider-model.js +0 -56
  109. package/dist/src/rig-config-package-deps.d.ts +0 -10
  110. package/dist/src/rig-config-package-deps.js +0 -272
  111. package/dist/src/version.d.ts +0 -8
  112. package/dist/src/version.js +0 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/cli-surface-plugin",
3
- "version": "0.0.6-alpha.157",
3
+ "version": "0.0.6-alpha.158",
4
4
  "type": "module",
5
5
  "description": "Standard executable Rig CLI surface plugin facade.",
6
6
  "license": "UNLICENSED",
@@ -16,23 +16,22 @@
16
16
  "./plugin": {
17
17
  "types": "./dist/src/plugin.d.ts",
18
18
  "import": "./dist/src/plugin.js"
19
+ },
20
+ "./help-catalog": {
21
+ "types": "./dist/src/help-catalog-data.d.ts",
22
+ "import": "./dist/src/help-catalog-data.js"
19
23
  }
20
24
  },
21
25
  "engines": {
22
26
  "bun": ">=1.3.11"
23
27
  },
24
28
  "dependencies": {
25
- "@rig/bundle-default-lifecycle": "npm:@h-rig/bundle-default-lifecycle@0.0.6-alpha.157",
26
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.157",
27
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.157",
28
- "@rig/dependency-graph-plugin": "npm:@h-rig/dependency-graph-plugin@0.0.6-alpha.157",
29
- "@rig/github-provider-plugin": "npm:@h-rig/github-provider-plugin@0.0.6-alpha.157",
30
- "@rig/init-plugin": "npm:@h-rig/init-plugin@0.0.6-alpha.157",
31
- "@rig/kernel": "npm:@h-rig/kernel@0.0.6-alpha.157",
32
- "@rig/run-worker": "npm:@h-rig/run-worker@0.0.6-alpha.157",
33
- "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.157",
34
- "@rig/shared": "npm:@h-rig/shared@0.0.6-alpha.157",
35
- "effect": "4.0.0-beta.90",
36
- "picocolors": "^1.1.1"
29
+ "@oh-my-pi/pi-tui": "16.0.4",
30
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.158",
31
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.158",
32
+ "@rig/github-lib": "npm:@h-rig/github-lib@0.0.6-alpha.158",
33
+ "@rig/kernel-seed": "npm:@h-rig/kernel-seed@0.0.6-alpha.158",
34
+ "picocolors": "^1.1.1",
35
+ "smol-toml": "^1.6.0"
37
36
  }
38
37
  }
@@ -1,11 +0,0 @@
1
- import { type RigCliOutputEnvelope } from "@rig/contracts";
2
- /**
3
- * Build the versioned `{ v: 1, command, data }` envelope for a command
4
- * outcome, or null when the command has no output schema (legacy payload)
5
- * or the details fail validation (warned on stderr, legacy payload).
6
- */
7
- export declare function buildCliJsonEnvelope(outcome: unknown, options?: {
8
- warn?: (message: string) => void;
9
- }): RigCliOutputEnvelope | null;
10
- /** Commands with a versioned --json envelope (for help/docs/tests). */
11
- export declare function listSchematizedCliCommands(): string[];
@@ -1,54 +0,0 @@
1
- // @bun
2
- // packages/cli-surface-plugin/src/commands/_json-output.ts
3
- import { Schema } from "effect";
4
- import {
5
- RigDoctorCheckOutput,
6
- RigInboxApprovalsOutput,
7
- RigInboxInputsOutput,
8
- RigRunListOutput,
9
- RigRunShowOutput,
10
- RigStatsOutput,
11
- RigTaskListOutput,
12
- RigTaskShowOutput
13
- } from "@rig/contracts";
14
- var CLI_OUTPUT_SCHEMAS = {
15
- "task list": RigTaskListOutput,
16
- "task show": RigTaskShowOutput,
17
- "run list": RigRunListOutput,
18
- "run show": RigRunShowOutput,
19
- "inbox approvals": RigInboxApprovalsOutput,
20
- "inbox inputs": RigInboxInputsOutput,
21
- "doctor check": RigDoctorCheckOutput,
22
- "stats show": RigStatsOutput
23
- };
24
- function isCommandOutcomeLike(value) {
25
- if (!value || typeof value !== "object" || Array.isArray(value))
26
- return false;
27
- const record = value;
28
- return typeof record.group === "string" && typeof record.command === "string";
29
- }
30
- function buildCliJsonEnvelope(outcome, options = {}) {
31
- if (!isCommandOutcomeLike(outcome))
32
- return null;
33
- const commandKey = `${outcome.group} ${outcome.command}`;
34
- const schema = CLI_OUTPUT_SCHEMAS[commandKey];
35
- if (!schema)
36
- return null;
37
- const warn = options.warn ?? ((message) => console.error(message));
38
- const envelope = { v: 1, command: commandKey, data: outcome.details ?? {} };
39
- try {
40
- Schema.decodeUnknownSync(schema)(JSON.parse(JSON.stringify(envelope)));
41
- return envelope;
42
- } catch (error) {
43
- warn(`[rig] --json output for "${commandKey}" failed schema validation; printing legacy payload. ` + `(${error instanceof Error ? error.message.split(`
44
- `)[0] : String(error)})`);
45
- return null;
46
- }
47
- }
48
- function listSchematizedCliCommands() {
49
- return Object.keys(CLI_OUTPUT_SCHEMAS).sort();
50
- }
51
- export {
52
- listSchematizedCliCommands,
53
- buildCliJsonEnvelope
54
- };
@@ -1,35 +0,0 @@
1
- import type { RunnerContext } from "../runner";
2
- type AttachResult = {
3
- readonly run: Record<string, unknown>;
4
- readonly logs: Record<string, unknown>[];
5
- readonly timeline: Record<string, unknown>[];
6
- readonly timelineCursor: string | null;
7
- readonly steered: boolean;
8
- readonly rendered: string;
9
- readonly detached?: boolean;
10
- };
11
- export declare function resolveOperatorDroneCwd(runId: string, homeDir?: string): string;
12
- /**
13
- * Compose the operator-session environment used by the legacy interactive
14
- * attach shim. Exported for tests that pin the env contract.
15
- */
16
- export declare function buildOperatorPiEnv(input: {
17
- readonly runId: string;
18
- readonly serverUrl: string;
19
- readonly authToken?: string | null;
20
- readonly serverProjectRoot?: string | null;
21
- readonly sessionDir: string;
22
- }): Record<string, string>;
23
- export declare function shouldRequireOperatorTranscript(status: unknown): boolean;
24
- export declare function missingOperatorTranscriptMessage(runId: string, status: unknown): string;
25
- /**
26
- * Run `body` in-process while RETURNING (instead of terminating) when it calls
27
- * `process.exit`. Exported for unit tests that pin the guard semantics.
28
- */
29
- export declare function runWithProcessExitGuard(body: () => Promise<unknown>): Promise<number>;
30
- export declare function attachRunBundledPiFrontend(context: Pick<RunnerContext, "projectRoot" | "outputMode">, input: {
31
- readonly runId: string;
32
- readonly steered?: boolean;
33
- readonly returnOnQuit?: boolean;
34
- }): Promise<AttachResult>;
35
- export {};
@@ -1,64 +0,0 @@
1
- // @bun
2
- // packages/cli-surface-plugin/src/commands/_pi-frontend.ts
3
- import { homedir } from "os";
4
- import { join } from "path";
5
- import { assertPathInsideRoot, assertSafeRunId, safePathSegment } from "@rig/shared/safe-identifiers";
6
- var TERMINAL_RUN_STATUSES = { completed: true, failed: true, stopped: true, cancelled: true, canceled: true, closed: true, merged: true, needs_attention: true, "needs-attention": true };
7
- function resolveOperatorDroneCwd(runId, homeDir = homedir()) {
8
- const safeRunId = assertSafeRunId(runId);
9
- const dronesRoot = join(homeDir, ".rig", "drones");
10
- return assertPathInsideRoot(dronesRoot, join(dronesRoot, safePathSegment(String(safeRunId).slice(0, 8), { fallback: "run", maxLength: 32 })), "operator drone cwd");
11
- }
12
- function buildOperatorPiEnv(input) {
13
- return {
14
- PI_CODING_AGENT_SESSION_DIR: input.sessionDir,
15
- PI_SKIP_VERSION_CHECK: "1",
16
- PI_HIDDEN_COMMANDS: "import,fork,clone,tree,new,resume,trust",
17
- RIG_PI_OPERATOR_SESSION: "1",
18
- RIG_RUN_ID: input.runId,
19
- RIG_SERVER_URL: input.serverUrl,
20
- ...input.authToken ? { RIG_AUTH_TOKEN: input.authToken } : {},
21
- ...input.serverProjectRoot ? { RIG_PROJECT_ROOT: input.serverProjectRoot } : {}
22
- };
23
- }
24
- function shouldRequireOperatorTranscript(status) {
25
- return typeof status === "string" && TERMINAL_RUN_STATUSES[status.trim().toLowerCase()] === true;
26
- }
27
- function missingOperatorTranscriptMessage(runId, status) {
28
- const shortRun = runId.trim().slice(0, 8) || "unknown";
29
- const statusText = typeof status === "string" && status.trim() ? status.trim() : "terminal";
30
- return `Run ${shortRun} is ${statusText}, but no worker Pi session transcript is recorded for this run. It likely failed before Pi started or predates full-session capture. Use \`rig run show ${runId}\` and \`rig run logs ${runId}\` for the lifecycle details.`;
31
- }
32
- async function runWithProcessExitGuard(body) {
33
- const realExit = process.exit;
34
- let exitCode = 0;
35
- let signalQuit = () => {};
36
- const quit = new Promise((resolve) => {
37
- signalQuit = resolve;
38
- });
39
- const guardedExit = (code) => {
40
- exitCode = typeof code === "number" ? code : 0;
41
- signalQuit();
42
- return;
43
- };
44
- process.exit = guardedExit;
45
- try {
46
- await Promise.race([Promise.resolve().then(body), quit]);
47
- } finally {
48
- process.exit = realExit;
49
- }
50
- return exitCode;
51
- }
52
- async function attachRunBundledPiFrontend(context, input) {
53
- input.steered;
54
- input.returnOnQuit;
55
- throw new Error(`Interactive Pi attach for run ${input.runId} was removed in the OMP-collab cutover. Run bare \`rig\` and use the OMP cockpit run detail for the live session; legacy automation can request a non-interactive text snapshot with --once or --json.`);
56
- }
57
- export {
58
- shouldRequireOperatorTranscript,
59
- runWithProcessExitGuard,
60
- resolveOperatorDroneCwd,
61
- missingOperatorTranscriptMessage,
62
- buildOperatorPiEnv,
63
- attachRunBundledPiFrontend
64
- };
@@ -1,26 +0,0 @@
1
- export type SourceTaskContract = {
2
- id: string;
3
- title?: string | null;
4
- description?: string | null;
5
- body?: string | null;
6
- acceptanceCriteria?: string | null;
7
- acceptance_criteria?: string | null;
8
- sourceIssueId?: string | null;
9
- status?: string | null;
10
- issueType?: string | null;
11
- role?: string | null;
12
- validation?: string[];
13
- validators?: string[];
14
- labels?: string[];
15
- scope?: string[];
16
- };
17
- export declare function buildRunPrompt(input: {
18
- projectRoot: string;
19
- taskId?: string | undefined;
20
- fallbackTitle?: string | undefined;
21
- fallbackDescription?: string | undefined;
22
- fallbackAcceptanceCriteria?: string | undefined;
23
- sourceTask?: SourceTaskContract | null;
24
- initialPrompt?: string;
25
- runtimeAdapter: "pi";
26
- }): string;
@@ -1,132 +0,0 @@
1
- // @bun
2
- // packages/cli-surface-plugin/src/commands/_run-driver-helpers.ts
3
- import { existsSync, readFileSync } from "fs";
4
- import { resolve as resolve2 } from "path";
5
-
6
- // packages/cli-surface-plugin/src/commands/_paths.ts
7
- import { resolve } from "path";
8
- import { resolveMonorepoRoot } from "@rig/runtime/layout";
9
- function resolveControlPlaneMonorepoRoot(projectRoot) {
10
- return resolveMonorepoRoot(projectRoot);
11
- }
12
- function resolveControlPlaneTaskConfigPath(projectRoot) {
13
- return resolve(resolveControlPlaneMonorepoRoot(projectRoot), ".rig", "task-config.json");
14
- }
15
-
16
- // packages/cli-surface-plugin/src/commands/_run-driver-helpers.ts
17
- function readLatestBeadRecord(projectRoot, taskId) {
18
- const issuesPath = resolve2(resolveControlPlaneMonorepoRoot(projectRoot), ".beads", "issues.jsonl");
19
- if (!existsSync(issuesPath)) {
20
- return null;
21
- }
22
- let latest = null;
23
- for (const line of readFileSync(issuesPath, "utf8").split(/\r?\n/)) {
24
- const trimmed = line.trim();
25
- if (!trimmed)
26
- continue;
27
- try {
28
- const parsed = JSON.parse(trimmed);
29
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
30
- continue;
31
- const record = parsed;
32
- if (record.id === taskId)
33
- latest = record;
34
- } catch {}
35
- }
36
- return latest;
37
- }
38
- function firstPromptString(...values) {
39
- for (const value of values) {
40
- if (typeof value === "string" && value.trim())
41
- return value.trim();
42
- }
43
- return null;
44
- }
45
- function uniqueStrings(values) {
46
- return Array.from(new Set(values.map((value) => value.trim()).filter(Boolean)));
47
- }
48
- function renderSourceTaskContract(task, validation) {
49
- if (!task)
50
- return validation.length > 0 ? [`Validation: ${validation.join(", ")}`] : [];
51
- const lines = [`id: ${task.id}`];
52
- if (task.sourceIssueId)
53
- lines.push(`source issue: ${task.sourceIssueId}`);
54
- if (task.status)
55
- lines.push(`status: ${task.status}`);
56
- if (task.issueType)
57
- lines.push(`issue type: ${task.issueType}`);
58
- if (task.role)
59
- lines.push(`role: ${task.role}`);
60
- if (validation.length > 0)
61
- lines.push(`validation: ${validation.join(", ")}`);
62
- return lines;
63
- }
64
- function renderSourceScopeValidation(task, validation) {
65
- if (task || validation.length === 0)
66
- return "";
67
- return `Validation:
68
- - ${validation.join(`
69
- - `)}`;
70
- }
71
- function readTaskScopeText(projectRoot, taskId) {
72
- try {
73
- const parsed = JSON.parse(readFileSync(resolveControlPlaneTaskConfigPath(projectRoot), "utf8"));
74
- const entry = parsed[taskId] ?? {};
75
- const scope = Array.isArray(entry.scope) ? entry.scope.filter((item) => typeof item === "string") : [];
76
- const validation = Array.isArray(entry.validation) ? entry.validation.filter((item) => typeof item === "string") : [];
77
- const lines = [];
78
- if (scope.length > 0)
79
- lines.push(`Scope:
80
- - ${scope.join(`
81
- - `)}`);
82
- if (validation.length > 0)
83
- lines.push(`Validation:
84
- - ${validation.join(`
85
- - `)}`);
86
- return lines.join(`
87
-
88
- `);
89
- } catch {
90
- return "";
91
- }
92
- }
93
- function providerInstructionLines(_runtimeAdapter) {
94
- return ["Keep file writes inside the scoped task workspace and use the bridged Pi tooling for shell and follow-up prompts."];
95
- }
96
- function buildRunPrompt(input) {
97
- const initialPrompt = input.initialPrompt?.trim() || null;
98
- if (!input.taskId) {
99
- return initialPrompt ?? input.fallbackTitle?.trim() ?? "Continue the requested run and complete the work.";
100
- }
101
- const bead = readLatestBeadRecord(input.projectRoot, input.taskId);
102
- const sourceTask = input.sourceTask ?? null;
103
- const sourceDescription = firstPromptString(sourceTask?.description, sourceTask?.body);
104
- const sourceAcceptance = firstPromptString(sourceTask?.acceptanceCriteria, sourceTask?.acceptance_criteria);
105
- const sourceValidation = uniqueStrings([...sourceTask?.validation ?? [], ...sourceTask?.validators ?? []]);
106
- const title = (bead && typeof bead.title === "string" ? bead.title : null) ?? firstPromptString(sourceTask?.title) ?? input.fallbackTitle ?? input.taskId;
107
- const description = (bead && typeof bead.description === "string" ? bead.description : null) ?? sourceDescription ?? input.fallbackDescription ?? "";
108
- const acceptance = (bead && typeof bead.acceptance_criteria === "string" ? bead.acceptance_criteria : null) ?? sourceAcceptance ?? input.fallbackAcceptanceCriteria ?? "";
109
- const scopeText = readTaskScopeText(input.projectRoot, input.taskId);
110
- const sourceContractLines = renderSourceTaskContract(sourceTask, sourceValidation);
111
- const providerLines = providerInstructionLines(input.runtimeAdapter);
112
- return [
113
- `You are working on task ${input.taskId}: ${title}.`,
114
- description ? `Description:
115
- ${description}` : null,
116
- acceptance ? `Acceptance criteria:
117
- ${acceptance}` : null,
118
- sourceContractLines.length > 0 ? `Source task contract:
119
- ${sourceContractLines.join(`
120
- `)}` : null,
121
- scopeText || renderSourceScopeValidation(sourceTask, sourceValidation) || null,
122
- initialPrompt ? `Additional operator guidance:
123
- ${initialPrompt}` : null,
124
- providerLines.length > 0 ? `Provider-specific runtime tooling:
125
- ${providerLines.join(" ")}` : null
126
- ].filter((value) => Boolean(value)).join(`
127
-
128
- `);
129
- }
130
- export {
131
- buildRunPrompt
132
- };
@@ -1,93 +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: "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 {};
@@ -1,136 +0,0 @@
1
- // @bun
2
- // packages/cli-surface-plugin/src/commands/task-run-driver.ts
3
- import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync } from "fs";
4
- import { resolve } from "path";
5
- var PI_CANONICAL_RUN_STAGES = ["Connect", "Prepare", "Execute", "Validate", "Review", "Publish", "Complete"];
6
- function canonicalPiRunStages() {
7
- return [...PI_CANONICAL_RUN_STAGES];
8
- }
9
- function buildPiRigBridgeEnv(input) {
10
- return {
11
- PROJECT_RIG_ROOT: input.projectRoot,
12
- RIG_RUN_ID: input.runId,
13
- ...input.taskId ? { RIG_TASK_ID: input.taskId } : {},
14
- ...input.runtimeMode ? { RIG_RUNTIME_MODE: input.runtimeMode } : {},
15
- ...input.model ? { RIG_MODEL: input.model } : {}
16
- };
17
- }
18
- function copyTree(sourceRoot, targetRoot) {
19
- if (!existsSync(sourceRoot))
20
- return 0;
21
- let copied = 0;
22
- for (const entry of readdirSync(sourceRoot, { withFileTypes: true })) {
23
- const sourcePath = resolve(sourceRoot, entry.name);
24
- const targetPath = resolve(targetRoot, entry.name);
25
- if (entry.isDirectory()) {
26
- mkdirSync(targetPath, { recursive: true });
27
- copied += copyTree(sourcePath, targetPath);
28
- continue;
29
- }
30
- mkdirSync(resolve(targetPath, ".."), { recursive: true });
31
- copyFileSync(sourcePath, targetPath);
32
- copied += 1;
33
- }
34
- return copied;
35
- }
36
- function applyDirtyBaselineSnapshot(input) {
37
- mkdirSync(input.targetRoot, { recursive: true });
38
- const copied = copyTree(input.sourceRoot, input.targetRoot);
39
- return {
40
- applied: copied > 0,
41
- copiedUntracked: copied,
42
- detail: copied > 0 ? `Copied ${copied} file(s) into the runtime workspace.` : "No files copied."
43
- };
44
- }
45
- function buildTaskRunReviewEnv(config) {
46
- return {
47
- ...config?.review?.mode ? { AI_REVIEW_MODE: config.review.mode } : {},
48
- ...config?.review?.provider ? { AI_REVIEW_PROVIDER: config.review.provider } : {}
49
- };
50
- }
51
- function buildDirtyBaselineHandshakeEnv(input) {
52
- return {
53
- RIG_DIRTY_BASELINE_MODE: input.baselineMode,
54
- RIG_DIRTY_BASELINE_READY_FILE: resolve(input.projectRoot, ".rig", "state", `${input.runId}.dirty-ready`)
55
- };
56
- }
57
- function resolveTaskRunAutomationLimits(config, env = process.env) {
58
- const maxValidationAttempts = Number.parseInt(env.RIG_MAX_VALIDATION_ATTEMPTS ?? "", 10);
59
- const maxPrFixIterations = Number.parseInt(env.RIG_MAX_PR_FIX_ITERATIONS ?? "", 10);
60
- return {
61
- maxValidationAttempts: Number.isFinite(maxValidationAttempts) && maxValidationAttempts > 0 ? maxValidationAttempts : config?.automation?.maxValidationAttempts ?? 30,
62
- maxPrFixIterations: Number.isFinite(maxPrFixIterations) && maxPrFixIterations > 0 ? maxPrFixIterations : config?.automation?.maxPrFixIterations ?? 100500
63
- };
64
- }
65
- function classifyPlanningNeed(input) {
66
- const text = `${input.prompt}
67
- ${input.acceptanceCriteria ?? ""}`.toLowerCase();
68
- const needsPlanning = /plan|design|approach|architecture|multi-step/.test(text);
69
- return { needsPlanning, reason: needsPlanning ? "operator requested a planning pass" : "no planning trigger detected" };
70
- }
71
- function buildPiValidationRetrySteeringPrompt(input) {
72
- return [
73
- `Validation failed on attempt ${input.attempt}${input.taskId ? ` for task ${input.taskId}` : ""}.`,
74
- input.failureDetail.trim(),
75
- "Fix the issue, rerun validation, and continue only after it passes."
76
- ].join(`
77
-
78
- `);
79
- }
80
- function classifyValidationRetryOutcome(input) {
81
- return {
82
- stage: "Validate failed",
83
- status: input.attempt < input.maxAttempts ? "retry" : "needs_attention",
84
- failureDetail: input.failureDetail
85
- };
86
- }
87
- function taskRunStageLogId(runId, stage) {
88
- return `log:${runId}:stage:${stage.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
89
- }
90
- function createRunLogIdFactory(runId) {
91
- let next = 0;
92
- return () => `${runId}:log:${++next}`;
93
- }
94
- function summarizeTaskRunProcessFailure(input) {
95
- const detail = [input.stderr?.trim(), input.stdout?.trim()].filter(Boolean)[0];
96
- return `${input.stage} failed${input.exitCode !== null && input.exitCode !== undefined ? ` (exit ${input.exitCode})` : ""}${detail ? `: ${detail}` : input.fallback ? `: ${input.fallback}` : ""}`;
97
- }
98
- function classifyCompletionVerificationLine(line) {
99
- if (line.startsWith("=== Completion Verification:")) {
100
- return { isCompletionLine: true, stage: line.replace(/^=== Completion Verification:\s*/, "").replace(/\s*=+$/, "").trim(), status: "started" };
101
- }
102
- if (/^PASS\b/.test(line))
103
- return { isCompletionLine: true, stage: null, status: "passed" };
104
- if (/^FAIL\b/.test(line))
105
- return { isCompletionLine: true, stage: null, status: "failed" };
106
- return { isCompletionLine: false, stage: null, status: null };
107
- }
108
- function readTaskRunAcceptedArtifactState(input) {
109
- if (!existsSync(input.artifactPath))
110
- return { accepted: false, reason: null };
111
- try {
112
- const parsed = JSON.parse(readFileSync(input.artifactPath, "utf8"));
113
- return {
114
- accepted: parsed.accepted === true,
115
- reason: typeof parsed.reason === "string" ? parsed.reason : null
116
- };
117
- } catch {
118
- return { accepted: false, reason: null };
119
- }
120
- }
121
- export {
122
- taskRunStageLogId,
123
- summarizeTaskRunProcessFailure,
124
- resolveTaskRunAutomationLimits,
125
- readTaskRunAcceptedArtifactState,
126
- createRunLogIdFactory,
127
- classifyValidationRetryOutcome,
128
- classifyPlanningNeed,
129
- classifyCompletionVerificationLine,
130
- canonicalPiRunStages,
131
- buildTaskRunReviewEnv,
132
- buildPiValidationRetrySteeringPrompt,
133
- buildPiRigBridgeEnv,
134
- buildDirtyBaselineHandshakeEnv,
135
- applyDirtyBaselineSnapshot
136
- };
@@ -1,46 +0,0 @@
1
- import type { RegisteredTaskSource } from "@rig/contracts";
2
- import type { CommandOutcome } from "@rig/runtime/control-plane/runtime/types";
3
- import type { TaskLike } from "@rig/core/task-io";
4
- import { type RunnerContext } from "../runner";
5
- export type { TaskLike } from "@rig/core/task-io";
6
- type TaskDispatch = (input: {
7
- readonly projectRoot: string;
8
- readonly taskId: string;
9
- readonly title?: string | null;
10
- readonly model?: string | null;
11
- readonly prompt?: string | null;
12
- }) => Promise<{
13
- readonly runId: string;
14
- }>;
15
- export type TaskCommandDeps = {
16
- readonly listTasks?: (projectRoot: string) => Promise<readonly TaskLike[]>;
17
- readonly getTask?: (projectRoot: string, taskId: string) => Promise<TaskLike | null>;
18
- readonly dispatch?: TaskDispatch;
19
- readonly spawnRun?: TaskDispatch;
20
- readonly taskReady?: (projectRoot: string) => Promise<void> | void;
21
- readonly taskValidate?: (projectRoot: string, taskId?: string) => Promise<boolean> | boolean;
22
- readonly taskVerify?: (projectRoot: string, taskId?: string) => Promise<boolean> | boolean;
23
- readonly taskReopen?: (projectRoot: string, options: {
24
- all: boolean;
25
- taskId?: string;
26
- dryRun?: boolean;
27
- }) => Promise<{
28
- reopened?: readonly string[];
29
- kept?: readonly string[];
30
- [key: string]: unknown;
31
- }>;
32
- readonly taskArtifacts?: (projectRoot: string, taskId?: string) => void;
33
- readonly taskArtifactDir?: (projectRoot: string, taskId?: string) => string;
34
- readonly taskArtifactWrite?: (projectRoot: string, filename: string, content: string, taskId?: string) => void;
35
- readonly taskInfo?: (projectRoot: string, taskId?: string) => void;
36
- readonly taskScope?: (projectRoot: string, includeFiles: boolean, taskId?: string) => void;
37
- readonly taskDeps?: (projectRoot: string, taskId?: string) => void;
38
- readonly taskStatus?: (projectRoot: string) => void;
39
- readonly taskLookup?: (projectRoot: string, taskId: string) => string;
40
- readonly taskRecord?: (projectRoot: string, type: string, text: string, taskId?: string) => void;
41
- readonly loadTaskSource?: (projectRoot: string) => Promise<{
42
- readonly kind: string;
43
- readonly source: RegisteredTaskSource;
44
- }>;
45
- };
46
- export declare function executeTask(context: RunnerContext, args: string[], deps?: TaskCommandDeps): Promise<CommandOutcome>;