@h-rig/cli 0.0.6-alpha.77 → 0.0.6-alpha.79

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 (91) hide show
  1. package/dist/bin/build-rig-binaries.d.ts +2 -0
  2. package/dist/bin/rig.d.ts +2 -0
  3. package/dist/bin/rig.js +10214 -9309
  4. package/dist/src/app/board.d.ts +23 -0
  5. package/dist/src/app/board.js +1786 -0
  6. package/dist/src/app/drone-ui.d.ts +37 -0
  7. package/dist/src/app/drone-ui.js +294 -0
  8. package/dist/src/app/theme.d.ts +47 -0
  9. package/dist/src/{commands/_tui-theme.js → app/theme.js} +16 -1
  10. package/dist/src/commands/_async-ui.d.ts +13 -0
  11. package/dist/src/commands/_async-ui.js +74 -3
  12. package/dist/src/commands/_authority-runs.d.ts +22 -0
  13. package/dist/src/commands/_cli-format.d.ts +49 -0
  14. package/dist/src/commands/_cli-format.js +26 -8
  15. package/dist/src/commands/_connection-state.d.ts +44 -0
  16. package/dist/src/commands/_doctor-checks.d.ts +52 -0
  17. package/dist/src/commands/_doctor-checks.js +3 -1
  18. package/dist/src/commands/_help-catalog.d.ts +51 -0
  19. package/dist/src/commands/_help-catalog.js +9 -70
  20. package/dist/src/commands/_json-output.d.ts +11 -0
  21. package/dist/src/commands/_operator-surface.d.ts +34 -0
  22. package/dist/src/commands/_operator-view.d.ts +30 -0
  23. package/dist/src/commands/_operator-view.js +184 -7
  24. package/dist/src/commands/_parsers.d.ts +15 -0
  25. package/dist/src/commands/_paths.d.ts +11 -0
  26. package/dist/src/commands/_pi-frontend.d.ts +27 -0
  27. package/dist/src/commands/_pi-frontend.js +184 -7
  28. package/dist/src/commands/_pi-install.d.ts +42 -0
  29. package/dist/src/commands/_pi-install.js +1 -1
  30. package/dist/src/commands/_policy.d.ts +8 -0
  31. package/dist/src/commands/_preflight.d.ts +22 -0
  32. package/dist/src/commands/_preflight.js +3 -1
  33. package/dist/src/commands/_probes.d.ts +1 -0
  34. package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
  35. package/dist/src/commands/_run-replay.d.ts +24 -0
  36. package/dist/src/commands/_server-client.d.ts +186 -0
  37. package/dist/src/commands/_server-client.js +3 -1
  38. package/dist/src/commands/_snapshot-upload.d.ts +39 -0
  39. package/dist/src/commands/_snapshot-upload.js +3 -1
  40. package/dist/src/commands/_spinner.d.ts +25 -0
  41. package/dist/src/commands/_task-picker.d.ts +9 -0
  42. package/dist/src/commands/_task-picker.js +132 -7
  43. package/dist/src/commands/agent.d.ts +3 -0
  44. package/dist/src/commands/browser.d.ts +65 -0
  45. package/dist/src/commands/browser.js +306 -30
  46. package/dist/src/commands/connect.d.ts +7 -0
  47. package/dist/src/commands/connect.js +130 -64
  48. package/dist/src/commands/dist.d.ts +28 -0
  49. package/dist/src/commands/doctor.d.ts +3 -0
  50. package/dist/src/commands/doctor.js +77 -4
  51. package/dist/src/commands/github.d.ts +3 -0
  52. package/dist/src/commands/github.js +77 -4
  53. package/dist/src/commands/inbox.d.ts +30 -0
  54. package/dist/src/commands/inbox.js +101 -78
  55. package/dist/src/commands/init.d.ts +74 -0
  56. package/dist/src/commands/init.js +350 -10
  57. package/dist/src/commands/inspect.d.ts +3 -0
  58. package/dist/src/commands/inspect.js +77 -4
  59. package/dist/src/commands/inspector.d.ts +3 -0
  60. package/dist/src/commands/pi.d.ts +3 -0
  61. package/dist/src/commands/plugin.d.ts +16 -0
  62. package/dist/src/commands/profile-and-review.d.ts +4 -0
  63. package/dist/src/commands/queue.d.ts +3 -0
  64. package/dist/src/commands/remote.d.ts +3 -0
  65. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  66. package/dist/src/commands/run.d.ts +3 -0
  67. package/dist/src/commands/run.js +195 -69
  68. package/dist/src/commands/server.d.ts +7 -0
  69. package/dist/src/commands/server.js +133 -65
  70. package/dist/src/commands/setup.d.ts +16 -0
  71. package/dist/src/commands/setup.js +77 -4
  72. package/dist/src/commands/stats.d.ts +12 -0
  73. package/dist/src/commands/stats.js +57 -113
  74. package/dist/src/commands/task-report-bug.d.ts +19 -0
  75. package/dist/src/commands/task-report-bug.js +231 -40
  76. package/dist/src/commands/task-run-driver.d.ts +132 -0
  77. package/dist/src/commands/task-run-driver.js +26 -3
  78. package/dist/src/commands/task.d.ts +14 -0
  79. package/dist/src/commands/task.js +341 -229
  80. package/dist/src/commands/test.d.ts +3 -0
  81. package/dist/src/commands/workspace.d.ts +3 -0
  82. package/dist/src/commands.d.ts +29 -0
  83. package/dist/src/commands.js +10194 -9289
  84. package/dist/src/index.d.ts +4 -0
  85. package/dist/src/index.js +10200 -9295
  86. package/dist/src/launcher.d.ts +61 -0
  87. package/dist/src/report-bug.d.ts +44 -0
  88. package/dist/src/runner.d.ts +47 -0
  89. package/dist/src/withMutedConsole.d.ts +2 -0
  90. package/package.json +10 -9
  91. package/dist/src/commands/_operator-board.js +0 -730
@@ -0,0 +1,132 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import { updateConfiguredTaskSourceTask } from "@rig/runtime/control-plane/tasks/source-lifecycle";
3
+ import { runPrAutomation, type GitCommandRunner, type GitHubCommandRunner, type PrAutomationResult, type RigAutomationConfig } from "@rig/runtime/control-plane/native/pr-automation";
4
+ import { type SourceTaskContract } from "./_run-driver-helpers";
5
+ export type TaskRunReviewState = {
6
+ approved?: boolean;
7
+ provider?: string;
8
+ mode?: string;
9
+ verdict?: string;
10
+ local_reasons?: string[];
11
+ ai_reasons?: string[];
12
+ ai_warnings?: string[];
13
+ };
14
+ declare const PI_CANONICAL_RUN_STAGES: readonly ["Connect", "GitHub/task sync", "Prepare workspace", "Launch Pi", "Plan", "Implement", "Validate", "Commit", "Open PR", "Review/CI", "Merge", "Complete"];
15
+ export declare function canonicalPiRunStages(): string[];
16
+ export declare function buildPiRigBridgeEnv(input: {
17
+ readonly projectRoot: string;
18
+ readonly runId: string;
19
+ readonly taskId: string;
20
+ readonly serverUrl?: string | null;
21
+ readonly authToken?: string | null;
22
+ readonly githubToken?: string | null;
23
+ }): Record<string, string>;
24
+ export declare function applyDirtyBaselineSnapshot(input: {
25
+ readonly sourceRoot: string;
26
+ readonly targetRoot: string;
27
+ }): {
28
+ applied: boolean;
29
+ copiedUntracked: number;
30
+ detail: string;
31
+ };
32
+ export declare function buildTaskRunReviewEnv(config?: TaskRunAutomationConfig | null): Record<string, string>;
33
+ export declare function buildDirtyBaselineHandshakeEnv(input: {
34
+ readonly projectRoot: string;
35
+ readonly runId: string;
36
+ readonly baselineMode?: "head" | "dirty-snapshot";
37
+ }): Record<string, string>;
38
+ type TaskRunAutomationConfig = RigAutomationConfig & {
39
+ readonly github?: {
40
+ readonly issueUpdates?: "lifecycle" | "minimal" | "off";
41
+ };
42
+ readonly planning?: {
43
+ readonly mode?: "auto" | "always" | "off";
44
+ readonly requireForLabels?: readonly string[];
45
+ readonly skipForLabels?: readonly string[];
46
+ };
47
+ };
48
+ export declare function resolveTaskRunAutomationLimits(config?: TaskRunAutomationConfig | null, env?: Record<string, string | undefined>): {
49
+ maxValidationAttempts: number;
50
+ maxPrFixIterations: number;
51
+ };
52
+ export type PlanningClassification = {
53
+ readonly planningRequired: boolean;
54
+ readonly size: "small" | "medium" | "large";
55
+ readonly risk: "low" | "medium" | "high";
56
+ readonly reason: string;
57
+ readonly policy: "always" | "off" | "auto";
58
+ };
59
+ export declare function classifyPlanningNeed(input: {
60
+ readonly config?: TaskRunAutomationConfig | null;
61
+ readonly sourceTask?: SourceTaskContract | null;
62
+ }): PlanningClassification;
63
+ export declare function buildPiValidationRetrySteeringPrompt(input: {
64
+ taskId: string;
65
+ attempt: number;
66
+ maxAttempts: number;
67
+ failureDetail: string;
68
+ validationOutput?: string | null;
69
+ }): string;
70
+ export declare function classifyValidationRetryOutcome(input: {
71
+ attempt: number;
72
+ maxAttempts: number;
73
+ failureDetail: string;
74
+ }): {
75
+ stage: "Validate failed";
76
+ status: "retry" | "needs_attention";
77
+ failureDetail: string;
78
+ };
79
+ export type TaskRunStageName = typeof PI_CANONICAL_RUN_STAGES[number] | "Needs attention" | "Failed";
80
+ export declare function taskRunStageLogId(runId: string, stage: TaskRunStageName): string;
81
+ export type TaskRunPostValidationLifecycleResult = {
82
+ readonly status: "completed" | "skipped" | "needs_attention";
83
+ readonly pr?: PrAutomationResult;
84
+ };
85
+ export declare function runTaskRunPostValidationLifecycle(input: {
86
+ readonly projectRoot: string;
87
+ readonly runId: string;
88
+ readonly taskId?: string;
89
+ readonly runtimeTaskId: string;
90
+ readonly runtimeWorkspace?: string | null;
91
+ readonly branch?: string | null;
92
+ readonly config?: TaskRunAutomationConfig | null;
93
+ readonly sourceTask: SourceTaskContract | null;
94
+ readonly uploadedSnapshot?: boolean;
95
+ readonly appendStage?: (stage: TaskRunStageName, detail?: string | null, status?: string, tone?: "info" | "tool" | "error") => void;
96
+ readonly ghCommand?: GitHubCommandRunner;
97
+ readonly gitCommand?: GitCommandRunner;
98
+ readonly prAutomation?: typeof runPrAutomation;
99
+ readonly steerPi?: (message: string) => Promise<void>;
100
+ readonly updateTaskSource?: typeof updateConfiguredTaskSourceTask;
101
+ }): Promise<TaskRunPostValidationLifecycleResult>;
102
+ export declare function classifyCompletionVerificationLine(line: string): {
103
+ isCompletionLine: boolean;
104
+ isVerifierReview: boolean;
105
+ };
106
+ export declare function createRunLogIdFactory(runId: string): () => string;
107
+ export declare function summarizeTaskRunProcessFailure(input: {
108
+ exitCode: number | null;
109
+ signal: string | null;
110
+ stderrLines?: readonly string[];
111
+ }): string;
112
+ export declare function readTaskRunAcceptedArtifactState(input: {
113
+ taskId: string | null;
114
+ workspaceDir: string | null;
115
+ artifactNotBeforeMs?: number;
116
+ }): {
117
+ accepted: boolean;
118
+ reason: string | null;
119
+ };
120
+ export declare function executeRigOwnedTaskRun(context: RunnerContext, input: {
121
+ runId: string;
122
+ taskId?: string;
123
+ title?: string;
124
+ runtimeAdapter: "claude-code" | "codex" | "pi";
125
+ model?: string;
126
+ runtimeMode: string;
127
+ interactionMode: string;
128
+ initialPrompt?: string;
129
+ baselineMode?: "head" | "dirty-snapshot";
130
+ prMode?: "auto" | "ask" | "off";
131
+ }): Promise<void>;
132
+ export {};
@@ -728,7 +728,9 @@ ${failure.contextLine}`, 1, { hint: failure.hint });
728
728
  })() : null;
729
729
  if (!response.ok) {
730
730
  const diagnostics = diagnosticMessage(payload);
731
- const detail = diagnostics ?? (text || response.statusText);
731
+ const rawDetail = diagnostics ?? (text || response.statusText);
732
+ const detail = diagnostics ? rawDetail : rawDetail.split(`
733
+ `).map((line) => line.trim()).find((line) => line.length > 0)?.slice(0, 200) ?? response.statusText;
732
734
  const failure = await buildServerFailureContext(context.projectRoot, server);
733
735
  throw new CliError(`Rig server request failed (${response.status}): ${detail}
734
736
  ${failure.contextLine}`, 1, { hint: failure.hint });
@@ -779,6 +781,19 @@ function looksLikeGitHubToken(value) {
779
781
  return false;
780
782
  return /^(gh[opusr]_|github_pat_)/.test(token);
781
783
  }
784
+ function isSensitivePayloadKey(key) {
785
+ return /token|secret|password|authorization|credential/i.test(key);
786
+ }
787
+ function redactSensitivePayload(value) {
788
+ if (Array.isArray(value))
789
+ return value.map(redactSensitivePayload);
790
+ if (!value || typeof value !== "object")
791
+ return value;
792
+ return Object.fromEntries(Object.entries(value).map(([key, child]) => [
793
+ key,
794
+ isSensitivePayloadKey(key) && typeof child === "string" && child.trim() ? "[redacted]" : redactSensitivePayload(child)
795
+ ]));
796
+ }
782
797
  function githubBridgeEnv(token) {
783
798
  const clean = token?.trim();
784
799
  if (!clean)
@@ -1476,7 +1491,7 @@ function appendPiToolTimelineFromRecord(input) {
1476
1491
  }
1477
1492
  function isNonRenderablePiProtocolRecord(record) {
1478
1493
  const type = typeof record.type === "string" ? record.type : "";
1479
- return type === "agent_start" || type === "agent_end" || type === "message_start" || type === "message_end" || type === "turn_start" || type === "turn_end" || type === "tool_result" || type === "message_update" && (!record.assistantMessageEvent || typeof record.assistantMessageEvent !== "object" || Array.isArray(record.assistantMessageEvent) || record.assistantMessageEvent.type !== "text_delta");
1494
+ return type === "pi.event" || type === "status.update" || type === "activity.update" || type === "ready" || type === "agent_start" || type === "agent_end" || type === "message_start" || type === "message_end" || type === "turn_start" || type === "turn_end" || type === "tool_result" || type === "message_update" && (!record.assistantMessageEvent || typeof record.assistantMessageEvent !== "object" || Array.isArray(record.assistantMessageEvent) || record.assistantMessageEvent.type !== "text_delta");
1480
1495
  }
1481
1496
  function appendToolTimelineFromLog(input) {
1482
1497
  const title = typeof input.log.title === "string" ? input.log.title : "";
@@ -2036,7 +2051,15 @@ ${planningClassification.planningRequired ? `Before implementing, write a concis
2036
2051
  emitServerRunEvent({ type: "log", runId: input.runId, title });
2037
2052
  return true;
2038
2053
  }
2039
- return false;
2054
+ appendRunTimeline(context.projectRoot, input.runId, {
2055
+ id: `timeline:${input.runId}:${Date.now()}:wrapper:${event.type}`,
2056
+ type: "wrapper-event",
2057
+ eventType: event.type,
2058
+ payload: redactSensitivePayload(payload),
2059
+ createdAt: new Date().toISOString()
2060
+ });
2061
+ emitServerRunEvent({ type: "timeline", runId: input.runId });
2062
+ return true;
2040
2063
  };
2041
2064
  const handleAgentStdoutLine = (line) => {
2042
2065
  const trimmed = line.trim();
@@ -0,0 +1,14 @@
1
+ import { type RunnerContext } from "../runner";
2
+ import type { CommandOutcome } from "@rig/runtime/control-plane/runtime/types";
3
+ /** Project-config dispatch defaults — exported so the board's `n` (new run)
4
+ * flow dispatches with exactly the same defaults as `rig task run`. */
5
+ export declare function loadTaskRunProjectDefaults(projectRoot: string): Promise<{
6
+ runtimeAdapter?: "claude-code" | "codex" | "pi";
7
+ model?: string;
8
+ runtimeMode?: string;
9
+ prMode?: "auto" | "ask" | "off";
10
+ }>;
11
+ export type ReportBugFn = (context: RunnerContext, args: string[]) => Promise<CommandOutcome>;
12
+ export declare function executeTask(context: RunnerContext, args: string[], options: {
13
+ executeTaskReportBug: ReportBugFn;
14
+ }): Promise<CommandOutcome>;