@h-rig/bundle-default-lifecycle 0.0.6-alpha.156 → 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.
- package/dist/src/cli.d.ts +1 -7
- package/dist/src/cli.js +5 -2
- package/dist/src/control-plane/completion-verification.js +1591 -118
- package/dist/src/control-plane/hooks/inject-context.d.ts +2 -0
- package/dist/src/control-plane/hooks/inject-context.js +175 -0
- package/dist/src/control-plane/hooks/shared.d.ts +11 -0
- package/dist/src/control-plane/hooks/shared.js +44 -0
- package/dist/src/control-plane/hooks/submodule-branch.d.ts +2 -0
- package/dist/src/control-plane/hooks/submodule-branch.js +432 -0
- package/dist/src/control-plane/hooks/task-runtime-start.d.ts +2 -0
- package/dist/src/control-plane/hooks/task-runtime-start.js +429 -0
- package/dist/src/control-plane/materialize-task-config.d.ts +29 -0
- package/dist/src/control-plane/materialize-task-config.js +95 -0
- package/dist/src/control-plane/native/git-ops.d.ts +67 -0
- package/dist/src/control-plane/native/git-ops.js +1390 -0
- package/dist/src/control-plane/policy.d.ts +3 -0
- package/dist/src/control-plane/policy.js +226 -0
- package/dist/src/control-plane/pr-automation.d.ts +2 -0
- package/dist/src/control-plane/pr-automation.js +26 -16
- package/dist/src/control-plane/pr-merge-gate-cap.d.ts +10 -0
- package/dist/src/control-plane/pr-merge-gate-cap.js +13 -0
- package/dist/src/control-plane/task-data.d.ts +13 -0
- package/dist/src/control-plane/task-data.js +12 -0
- package/dist/src/control-plane/task-verify.js +131 -59
- package/dist/src/control-plane/verifier.d.ts +1 -3
- package/dist/src/control-plane/verifier.js +133 -57
- package/dist/src/defaultPipeline.d.ts +1 -1
- package/dist/src/defaultPipeline.js +5 -2
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +1908 -290
- package/dist/src/native/closeout-runners.js +22 -2
- package/dist/src/native/github-auth-env.d.ts +2 -0
- package/dist/src/native/github-auth-env.js +25 -0
- package/dist/src/native/host-git.d.ts +6 -0
- package/dist/src/native/host-git.js +62 -0
- package/dist/src/native/in-process-closeout.d.ts +1 -3
- package/dist/src/native/in-process-closeout.js +0 -794
- package/dist/src/pipelineCloseout.js +1905 -185
- package/dist/src/plugin.js +2843 -145
- package/dist/src/stages/auto-merge.js +28 -16
- package/dist/src/stages/commit.js +28 -16
- package/dist/src/stages/isolation.d.ts +1 -1
- package/dist/src/stages/isolation.js +5 -3
- package/dist/src/stages/merge-gate.js +35 -3
- package/dist/src/stages/open-pr.js +28 -16
- package/dist/src/stages/push.js +28 -16
- package/dist/src/stages/source-closeout.js +28 -16
- package/package.json +29 -16
- package/dist/src/branch-naming.d.ts +0 -15
- package/dist/src/branch-naming.js +0 -33
- package/dist/src/closeoutEquivalence.d.ts +0 -37
- package/dist/src/closeoutEquivalence.js +0 -78
- package/dist/src/closeoutShadowHarness.d.ts +0 -27
- package/dist/src/closeoutShadowHarness.js +0 -29
|
@@ -15,6 +15,19 @@ var __export = (target, all) => {
|
|
|
15
15
|
};
|
|
16
16
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
17
|
|
|
18
|
+
// packages/bundle-default-lifecycle/src/control-plane/pr-merge-gate-cap.ts
|
|
19
|
+
import { PR_MERGE_GATE } from "@rig/contracts";
|
|
20
|
+
import { defineCapability } from "@rig/core/capability";
|
|
21
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
22
|
+
async function resolvePrMergeGateService(projectRoot) {
|
|
23
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
24
|
+
return PrMergeGateCap.require(host);
|
|
25
|
+
}
|
|
26
|
+
var PrMergeGateCap;
|
|
27
|
+
var init_pr_merge_gate_cap = __esm(() => {
|
|
28
|
+
PrMergeGateCap = defineCapability(PR_MERGE_GATE);
|
|
29
|
+
});
|
|
30
|
+
|
|
18
31
|
// packages/bundle-default-lifecycle/src/control-plane/pr-automation.ts
|
|
19
32
|
var exports_pr_automation = {};
|
|
20
33
|
__export(exports_pr_automation, {
|
|
@@ -32,11 +45,7 @@ __export(exports_pr_automation, {
|
|
|
32
45
|
buildPrAutomationBody: () => buildPrAutomationBody,
|
|
33
46
|
UPLOADED_SNAPSHOT_PR_MARKER: () => UPLOADED_SNAPSHOT_PR_MARKER
|
|
34
47
|
});
|
|
35
|
-
import { assertSafeGitBranchName } from "@rig/
|
|
36
|
-
import { runStrictPrMergeGate } from "@rig/pr-review-plugin";
|
|
37
|
-
import {
|
|
38
|
-
strictMergeHeadShaFromGate
|
|
39
|
-
} from "@rig/contracts";
|
|
48
|
+
import { assertSafeGitBranchName } from "@rig/core/safe-identifiers";
|
|
40
49
|
function positiveInt(value, fallback) {
|
|
41
50
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
42
51
|
}
|
|
@@ -339,7 +348,7 @@ async function commitRunChanges(input) {
|
|
|
339
348
|
async function closeIssueAfterMergedPr(input) {
|
|
340
349
|
await input.updateTaskSource(input.projectRoot, {
|
|
341
350
|
taskId: input.taskId,
|
|
342
|
-
sourceTask: input.sourceTask,
|
|
351
|
+
...input.sourceTask !== undefined ? { sourceTask: input.sourceTask } : {},
|
|
343
352
|
update: {
|
|
344
353
|
status: "closed",
|
|
345
354
|
comment: [
|
|
@@ -385,11 +394,12 @@ async function runRepoDefaultMerge(input) {
|
|
|
385
394
|
if (merge.mode === "off")
|
|
386
395
|
return;
|
|
387
396
|
const requireGreptile = (input.config?.review?.provider ?? "greptile") === "greptile";
|
|
388
|
-
const
|
|
397
|
+
const mergeGate = await resolvePrMergeGateService(input.projectRoot ?? input.cwd ?? process.cwd());
|
|
398
|
+
const matchHeadSha = mergeGate.resolveHeadSha({ result: input.strictGate, prUrl: input.prUrl, requireGreptile });
|
|
389
399
|
const method = merge.method ?? "repo-default";
|
|
390
400
|
const args = ["pr", "merge", input.prUrl];
|
|
391
401
|
if (method === "repo-default") {
|
|
392
|
-
args.push(await resolveRepoDefaultMergeFlag({ prUrl: input.prUrl, command: input.command, cwd: input.cwd }));
|
|
402
|
+
args.push(await resolveRepoDefaultMergeFlag({ prUrl: input.prUrl, command: input.command, ...input.cwd !== undefined ? { cwd: input.cwd } : {} }));
|
|
393
403
|
} else {
|
|
394
404
|
args.push(`--${method}`);
|
|
395
405
|
}
|
|
@@ -466,6 +476,7 @@ async function syncBranchAfterPrFeedback(input) {
|
|
|
466
476
|
}
|
|
467
477
|
async function runPrAutomation(input) {
|
|
468
478
|
const branch = assertSafeGitBranchName(input.branch, "PR branch");
|
|
479
|
+
const mergeGate = await resolvePrMergeGateService(input.projectRoot);
|
|
469
480
|
const prConfig = input.config?.pr ?? {};
|
|
470
481
|
const requireGreptile = (input.config?.review?.provider ?? "greptile") === "greptile";
|
|
471
482
|
if (prConfig.mode === "off" || prConfig.mode === "ask") {
|
|
@@ -475,7 +486,7 @@ async function runPrAutomation(input) {
|
|
|
475
486
|
taskId: input.taskId,
|
|
476
487
|
runId: input.runId,
|
|
477
488
|
summary: input.sourceTask?.title ? `Rig completed: ${input.sourceTask.title}` : null,
|
|
478
|
-
uploadedSnapshot: input.uploadedSnapshot
|
|
489
|
+
...input.uploadedSnapshot !== undefined ? { uploadedSnapshot: input.uploadedSnapshot } : {}
|
|
479
490
|
});
|
|
480
491
|
if (input.gitCommand) {
|
|
481
492
|
await pushBranchSyncedWithOrigin({ projectRoot: input.projectRoot, branch, gitCommand: input.gitCommand });
|
|
@@ -547,16 +558,16 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
547
558
|
await syncBranchAfterPrFeedback({ projectRoot: input.projectRoot, taskId: input.taskId, branch, gitCommand: input.gitCommand });
|
|
548
559
|
continue;
|
|
549
560
|
}
|
|
550
|
-
const gate = await
|
|
561
|
+
const gate = await mergeGate.runGate({
|
|
551
562
|
projectRoot: input.projectRoot,
|
|
552
563
|
prUrl,
|
|
553
564
|
taskId: input.taskId,
|
|
554
565
|
runId: input.runId,
|
|
555
566
|
cycle: iteration,
|
|
556
567
|
command: input.command,
|
|
557
|
-
artifactRoot: input.artifactRoot,
|
|
568
|
+
...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
|
|
558
569
|
allowedFailures: input.config?.merge?.allowedFailures ?? [],
|
|
559
|
-
greptileApi
|
|
570
|
+
...requireGreptile && input.greptileApi ? { greptileApi: input.greptileApi } : {},
|
|
560
571
|
requireGreptile
|
|
561
572
|
});
|
|
562
573
|
latestFeedback = [...gate.actionableFeedback];
|
|
@@ -586,22 +597,22 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
586
597
|
}
|
|
587
598
|
if (gate.approved) {
|
|
588
599
|
pendingElapsedMs = 0;
|
|
589
|
-
const finalGate = await
|
|
600
|
+
const finalGate = await mergeGate.runGate({
|
|
590
601
|
projectRoot: input.projectRoot,
|
|
591
602
|
prUrl,
|
|
592
603
|
taskId: input.taskId,
|
|
593
604
|
runId: input.runId,
|
|
594
605
|
cycle: iteration,
|
|
595
606
|
command: input.command,
|
|
596
|
-
artifactRoot: input.artifactRoot,
|
|
607
|
+
...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
|
|
597
608
|
allowedFailures: input.config?.merge?.allowedFailures ?? [],
|
|
598
|
-
greptileApi
|
|
609
|
+
...requireGreptile && input.greptileApi ? { greptileApi: input.greptileApi } : {},
|
|
599
610
|
requireGreptile,
|
|
600
611
|
final: true
|
|
601
612
|
});
|
|
602
613
|
if (finalGate.approved) {
|
|
603
614
|
await input.lifecycle?.onMergeStarted?.({ prUrl });
|
|
604
|
-
await runRepoDefaultMerge({ prUrl, config: input.config, command: input.command, cwd: input.projectRoot, strictGate: finalGate });
|
|
615
|
+
await runRepoDefaultMerge({ prUrl, ...input.config !== undefined ? { config: input.config } : {}, command: input.command, cwd: input.projectRoot, strictGate: finalGate });
|
|
605
616
|
await input.lifecycle?.onMerged?.({ prUrl });
|
|
606
617
|
return { status: "merged", prUrl, iterations: iteration, actionableFeedback: [], merged: true };
|
|
607
618
|
}
|
|
@@ -648,6 +659,7 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
648
659
|
}
|
|
649
660
|
var UPLOADED_SNAPSHOT_PR_MARKER = "<!-- rig:uploaded-snapshot -->", RIG_RUNTIME_COMMIT_EXCLUDES, GREPTILE_REREVIEW_MARKER_PREFIX = "rig:greptile-rereview";
|
|
650
661
|
var init_pr_automation = __esm(() => {
|
|
662
|
+
init_pr_merge_gate_cap();
|
|
651
663
|
RIG_RUNTIME_COMMIT_EXCLUDES = [
|
|
652
664
|
".rig",
|
|
653
665
|
"artifacts",
|
|
@@ -15,6 +15,19 @@ var __export = (target, all) => {
|
|
|
15
15
|
};
|
|
16
16
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
17
|
|
|
18
|
+
// packages/bundle-default-lifecycle/src/control-plane/pr-merge-gate-cap.ts
|
|
19
|
+
import { PR_MERGE_GATE } from "@rig/contracts";
|
|
20
|
+
import { defineCapability } from "@rig/core/capability";
|
|
21
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
22
|
+
async function resolvePrMergeGateService(projectRoot) {
|
|
23
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
24
|
+
return PrMergeGateCap.require(host);
|
|
25
|
+
}
|
|
26
|
+
var PrMergeGateCap;
|
|
27
|
+
var init_pr_merge_gate_cap = __esm(() => {
|
|
28
|
+
PrMergeGateCap = defineCapability(PR_MERGE_GATE);
|
|
29
|
+
});
|
|
30
|
+
|
|
18
31
|
// packages/bundle-default-lifecycle/src/control-plane/pr-automation.ts
|
|
19
32
|
var exports_pr_automation = {};
|
|
20
33
|
__export(exports_pr_automation, {
|
|
@@ -32,11 +45,7 @@ __export(exports_pr_automation, {
|
|
|
32
45
|
buildPrAutomationBody: () => buildPrAutomationBody,
|
|
33
46
|
UPLOADED_SNAPSHOT_PR_MARKER: () => UPLOADED_SNAPSHOT_PR_MARKER
|
|
34
47
|
});
|
|
35
|
-
import { assertSafeGitBranchName } from "@rig/
|
|
36
|
-
import { runStrictPrMergeGate } from "@rig/pr-review-plugin";
|
|
37
|
-
import {
|
|
38
|
-
strictMergeHeadShaFromGate
|
|
39
|
-
} from "@rig/contracts";
|
|
48
|
+
import { assertSafeGitBranchName } from "@rig/core/safe-identifiers";
|
|
40
49
|
function positiveInt(value, fallback) {
|
|
41
50
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
42
51
|
}
|
|
@@ -339,7 +348,7 @@ async function commitRunChanges(input) {
|
|
|
339
348
|
async function closeIssueAfterMergedPr(input) {
|
|
340
349
|
await input.updateTaskSource(input.projectRoot, {
|
|
341
350
|
taskId: input.taskId,
|
|
342
|
-
sourceTask: input.sourceTask,
|
|
351
|
+
...input.sourceTask !== undefined ? { sourceTask: input.sourceTask } : {},
|
|
343
352
|
update: {
|
|
344
353
|
status: "closed",
|
|
345
354
|
comment: [
|
|
@@ -385,11 +394,12 @@ async function runRepoDefaultMerge(input) {
|
|
|
385
394
|
if (merge.mode === "off")
|
|
386
395
|
return;
|
|
387
396
|
const requireGreptile = (input.config?.review?.provider ?? "greptile") === "greptile";
|
|
388
|
-
const
|
|
397
|
+
const mergeGate = await resolvePrMergeGateService(input.projectRoot ?? input.cwd ?? process.cwd());
|
|
398
|
+
const matchHeadSha = mergeGate.resolveHeadSha({ result: input.strictGate, prUrl: input.prUrl, requireGreptile });
|
|
389
399
|
const method = merge.method ?? "repo-default";
|
|
390
400
|
const args = ["pr", "merge", input.prUrl];
|
|
391
401
|
if (method === "repo-default") {
|
|
392
|
-
args.push(await resolveRepoDefaultMergeFlag({ prUrl: input.prUrl, command: input.command, cwd: input.cwd }));
|
|
402
|
+
args.push(await resolveRepoDefaultMergeFlag({ prUrl: input.prUrl, command: input.command, ...input.cwd !== undefined ? { cwd: input.cwd } : {} }));
|
|
393
403
|
} else {
|
|
394
404
|
args.push(`--${method}`);
|
|
395
405
|
}
|
|
@@ -466,6 +476,7 @@ async function syncBranchAfterPrFeedback(input) {
|
|
|
466
476
|
}
|
|
467
477
|
async function runPrAutomation(input) {
|
|
468
478
|
const branch = assertSafeGitBranchName(input.branch, "PR branch");
|
|
479
|
+
const mergeGate = await resolvePrMergeGateService(input.projectRoot);
|
|
469
480
|
const prConfig = input.config?.pr ?? {};
|
|
470
481
|
const requireGreptile = (input.config?.review?.provider ?? "greptile") === "greptile";
|
|
471
482
|
if (prConfig.mode === "off" || prConfig.mode === "ask") {
|
|
@@ -475,7 +486,7 @@ async function runPrAutomation(input) {
|
|
|
475
486
|
taskId: input.taskId,
|
|
476
487
|
runId: input.runId,
|
|
477
488
|
summary: input.sourceTask?.title ? `Rig completed: ${input.sourceTask.title}` : null,
|
|
478
|
-
uploadedSnapshot: input.uploadedSnapshot
|
|
489
|
+
...input.uploadedSnapshot !== undefined ? { uploadedSnapshot: input.uploadedSnapshot } : {}
|
|
479
490
|
});
|
|
480
491
|
if (input.gitCommand) {
|
|
481
492
|
await pushBranchSyncedWithOrigin({ projectRoot: input.projectRoot, branch, gitCommand: input.gitCommand });
|
|
@@ -547,16 +558,16 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
547
558
|
await syncBranchAfterPrFeedback({ projectRoot: input.projectRoot, taskId: input.taskId, branch, gitCommand: input.gitCommand });
|
|
548
559
|
continue;
|
|
549
560
|
}
|
|
550
|
-
const gate = await
|
|
561
|
+
const gate = await mergeGate.runGate({
|
|
551
562
|
projectRoot: input.projectRoot,
|
|
552
563
|
prUrl,
|
|
553
564
|
taskId: input.taskId,
|
|
554
565
|
runId: input.runId,
|
|
555
566
|
cycle: iteration,
|
|
556
567
|
command: input.command,
|
|
557
|
-
artifactRoot: input.artifactRoot,
|
|
568
|
+
...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
|
|
558
569
|
allowedFailures: input.config?.merge?.allowedFailures ?? [],
|
|
559
|
-
greptileApi
|
|
570
|
+
...requireGreptile && input.greptileApi ? { greptileApi: input.greptileApi } : {},
|
|
560
571
|
requireGreptile
|
|
561
572
|
});
|
|
562
573
|
latestFeedback = [...gate.actionableFeedback];
|
|
@@ -586,22 +597,22 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
586
597
|
}
|
|
587
598
|
if (gate.approved) {
|
|
588
599
|
pendingElapsedMs = 0;
|
|
589
|
-
const finalGate = await
|
|
600
|
+
const finalGate = await mergeGate.runGate({
|
|
590
601
|
projectRoot: input.projectRoot,
|
|
591
602
|
prUrl,
|
|
592
603
|
taskId: input.taskId,
|
|
593
604
|
runId: input.runId,
|
|
594
605
|
cycle: iteration,
|
|
595
606
|
command: input.command,
|
|
596
|
-
artifactRoot: input.artifactRoot,
|
|
607
|
+
...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
|
|
597
608
|
allowedFailures: input.config?.merge?.allowedFailures ?? [],
|
|
598
|
-
greptileApi
|
|
609
|
+
...requireGreptile && input.greptileApi ? { greptileApi: input.greptileApi } : {},
|
|
599
610
|
requireGreptile,
|
|
600
611
|
final: true
|
|
601
612
|
});
|
|
602
613
|
if (finalGate.approved) {
|
|
603
614
|
await input.lifecycle?.onMergeStarted?.({ prUrl });
|
|
604
|
-
await runRepoDefaultMerge({ prUrl, config: input.config, command: input.command, cwd: input.projectRoot, strictGate: finalGate });
|
|
615
|
+
await runRepoDefaultMerge({ prUrl, ...input.config !== undefined ? { config: input.config } : {}, command: input.command, cwd: input.projectRoot, strictGate: finalGate });
|
|
605
616
|
await input.lifecycle?.onMerged?.({ prUrl });
|
|
606
617
|
return { status: "merged", prUrl, iterations: iteration, actionableFeedback: [], merged: true };
|
|
607
618
|
}
|
|
@@ -648,6 +659,7 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
648
659
|
}
|
|
649
660
|
var UPLOADED_SNAPSHOT_PR_MARKER = "<!-- rig:uploaded-snapshot -->", RIG_RUNTIME_COMMIT_EXCLUDES, GREPTILE_REREVIEW_MARKER_PREFIX = "rig:greptile-rereview";
|
|
650
661
|
var init_pr_automation = __esm(() => {
|
|
662
|
+
init_pr_merge_gate_cap();
|
|
651
663
|
RIG_RUNTIME_COMMIT_EXCLUDES = [
|
|
652
664
|
".rig",
|
|
653
665
|
"artifacts",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
2
|
+
// packages/bundle-default-lifecycle/src/stages/isolation.ts
|
|
3
|
+
import { ISOLATION_BACKEND } from "@rig/contracts";
|
|
4
|
+
import { defineCapability } from "@rig/core/capability";
|
|
5
|
+
import { requireCapabilityForRoot } from "@rig/core/capability-loaders";
|
|
3
6
|
|
|
4
7
|
// packages/bundle-default-lifecycle/src/stages/types.ts
|
|
5
8
|
function defineDefaultLifecycleStage(input) {
|
|
@@ -18,8 +21,7 @@ var isolationStage = defineDefaultLifecycleStage({
|
|
|
18
21
|
calls: ["ensureAgentRuntime"]
|
|
19
22
|
});
|
|
20
23
|
async function runIsolationStage(input) {
|
|
21
|
-
const
|
|
22
|
-
const backend = await requireIsolationBackend(input.projectRoot);
|
|
24
|
+
const backend = await requireCapabilityForRoot(input.projectRoot, defineCapability(ISOLATION_BACKEND), `No ISOLATION_BACKEND capability is registered for project root "${input.projectRoot}". ` + "Install @rig/isolation-plugin (it ships in the default bundle) so runtime provisioning can resolve a backend.");
|
|
23
25
|
return await backend.ensureAgentRuntime(input);
|
|
24
26
|
}
|
|
25
27
|
export {
|
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
+
|
|
18
|
+
// packages/bundle-default-lifecycle/src/control-plane/pr-merge-gate-cap.ts
|
|
19
|
+
var exports_pr_merge_gate_cap = {};
|
|
20
|
+
__export(exports_pr_merge_gate_cap, {
|
|
21
|
+
resolvePrMergeGateService: () => resolvePrMergeGateService
|
|
22
|
+
});
|
|
23
|
+
import { PR_MERGE_GATE } from "@rig/contracts";
|
|
24
|
+
import { defineCapability } from "@rig/core/capability";
|
|
25
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
26
|
+
async function resolvePrMergeGateService(projectRoot) {
|
|
27
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
28
|
+
return PrMergeGateCap.require(host);
|
|
29
|
+
}
|
|
30
|
+
var PrMergeGateCap;
|
|
31
|
+
var init_pr_merge_gate_cap = __esm(() => {
|
|
32
|
+
PrMergeGateCap = defineCapability(PR_MERGE_GATE);
|
|
33
|
+
});
|
|
3
34
|
|
|
4
35
|
// packages/bundle-default-lifecycle/src/stages/types.ts
|
|
5
36
|
function defineDefaultLifecycleStage(input) {
|
|
@@ -18,8 +49,9 @@ var mergeGateStage = defineDefaultLifecycleStage({
|
|
|
18
49
|
calls: ["runStrictPrMergeGate"]
|
|
19
50
|
});
|
|
20
51
|
async function runMergeGateStage(input) {
|
|
21
|
-
const {
|
|
22
|
-
|
|
52
|
+
const { resolvePrMergeGateService: resolvePrMergeGateService2 } = await Promise.resolve().then(() => (init_pr_merge_gate_cap(), exports_pr_merge_gate_cap));
|
|
53
|
+
const mergeGate = await resolvePrMergeGateService2(input.projectRoot);
|
|
54
|
+
return await mergeGate.runGate({
|
|
23
55
|
projectRoot: input.projectRoot,
|
|
24
56
|
prUrl: input.prUrl,
|
|
25
57
|
taskId: input.taskId,
|
|
@@ -15,6 +15,19 @@ var __export = (target, all) => {
|
|
|
15
15
|
};
|
|
16
16
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
17
|
|
|
18
|
+
// packages/bundle-default-lifecycle/src/control-plane/pr-merge-gate-cap.ts
|
|
19
|
+
import { PR_MERGE_GATE } from "@rig/contracts";
|
|
20
|
+
import { defineCapability } from "@rig/core/capability";
|
|
21
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
22
|
+
async function resolvePrMergeGateService(projectRoot) {
|
|
23
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
24
|
+
return PrMergeGateCap.require(host);
|
|
25
|
+
}
|
|
26
|
+
var PrMergeGateCap;
|
|
27
|
+
var init_pr_merge_gate_cap = __esm(() => {
|
|
28
|
+
PrMergeGateCap = defineCapability(PR_MERGE_GATE);
|
|
29
|
+
});
|
|
30
|
+
|
|
18
31
|
// packages/bundle-default-lifecycle/src/control-plane/pr-automation.ts
|
|
19
32
|
var exports_pr_automation = {};
|
|
20
33
|
__export(exports_pr_automation, {
|
|
@@ -32,11 +45,7 @@ __export(exports_pr_automation, {
|
|
|
32
45
|
buildPrAutomationBody: () => buildPrAutomationBody,
|
|
33
46
|
UPLOADED_SNAPSHOT_PR_MARKER: () => UPLOADED_SNAPSHOT_PR_MARKER
|
|
34
47
|
});
|
|
35
|
-
import { assertSafeGitBranchName } from "@rig/
|
|
36
|
-
import { runStrictPrMergeGate } from "@rig/pr-review-plugin";
|
|
37
|
-
import {
|
|
38
|
-
strictMergeHeadShaFromGate
|
|
39
|
-
} from "@rig/contracts";
|
|
48
|
+
import { assertSafeGitBranchName } from "@rig/core/safe-identifiers";
|
|
40
49
|
function positiveInt(value, fallback) {
|
|
41
50
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
42
51
|
}
|
|
@@ -339,7 +348,7 @@ async function commitRunChanges(input) {
|
|
|
339
348
|
async function closeIssueAfterMergedPr(input) {
|
|
340
349
|
await input.updateTaskSource(input.projectRoot, {
|
|
341
350
|
taskId: input.taskId,
|
|
342
|
-
sourceTask: input.sourceTask,
|
|
351
|
+
...input.sourceTask !== undefined ? { sourceTask: input.sourceTask } : {},
|
|
343
352
|
update: {
|
|
344
353
|
status: "closed",
|
|
345
354
|
comment: [
|
|
@@ -385,11 +394,12 @@ async function runRepoDefaultMerge(input) {
|
|
|
385
394
|
if (merge.mode === "off")
|
|
386
395
|
return;
|
|
387
396
|
const requireGreptile = (input.config?.review?.provider ?? "greptile") === "greptile";
|
|
388
|
-
const
|
|
397
|
+
const mergeGate = await resolvePrMergeGateService(input.projectRoot ?? input.cwd ?? process.cwd());
|
|
398
|
+
const matchHeadSha = mergeGate.resolveHeadSha({ result: input.strictGate, prUrl: input.prUrl, requireGreptile });
|
|
389
399
|
const method = merge.method ?? "repo-default";
|
|
390
400
|
const args = ["pr", "merge", input.prUrl];
|
|
391
401
|
if (method === "repo-default") {
|
|
392
|
-
args.push(await resolveRepoDefaultMergeFlag({ prUrl: input.prUrl, command: input.command, cwd: input.cwd }));
|
|
402
|
+
args.push(await resolveRepoDefaultMergeFlag({ prUrl: input.prUrl, command: input.command, ...input.cwd !== undefined ? { cwd: input.cwd } : {} }));
|
|
393
403
|
} else {
|
|
394
404
|
args.push(`--${method}`);
|
|
395
405
|
}
|
|
@@ -466,6 +476,7 @@ async function syncBranchAfterPrFeedback(input) {
|
|
|
466
476
|
}
|
|
467
477
|
async function runPrAutomation(input) {
|
|
468
478
|
const branch = assertSafeGitBranchName(input.branch, "PR branch");
|
|
479
|
+
const mergeGate = await resolvePrMergeGateService(input.projectRoot);
|
|
469
480
|
const prConfig = input.config?.pr ?? {};
|
|
470
481
|
const requireGreptile = (input.config?.review?.provider ?? "greptile") === "greptile";
|
|
471
482
|
if (prConfig.mode === "off" || prConfig.mode === "ask") {
|
|
@@ -475,7 +486,7 @@ async function runPrAutomation(input) {
|
|
|
475
486
|
taskId: input.taskId,
|
|
476
487
|
runId: input.runId,
|
|
477
488
|
summary: input.sourceTask?.title ? `Rig completed: ${input.sourceTask.title}` : null,
|
|
478
|
-
uploadedSnapshot: input.uploadedSnapshot
|
|
489
|
+
...input.uploadedSnapshot !== undefined ? { uploadedSnapshot: input.uploadedSnapshot } : {}
|
|
479
490
|
});
|
|
480
491
|
if (input.gitCommand) {
|
|
481
492
|
await pushBranchSyncedWithOrigin({ projectRoot: input.projectRoot, branch, gitCommand: input.gitCommand });
|
|
@@ -547,16 +558,16 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
547
558
|
await syncBranchAfterPrFeedback({ projectRoot: input.projectRoot, taskId: input.taskId, branch, gitCommand: input.gitCommand });
|
|
548
559
|
continue;
|
|
549
560
|
}
|
|
550
|
-
const gate = await
|
|
561
|
+
const gate = await mergeGate.runGate({
|
|
551
562
|
projectRoot: input.projectRoot,
|
|
552
563
|
prUrl,
|
|
553
564
|
taskId: input.taskId,
|
|
554
565
|
runId: input.runId,
|
|
555
566
|
cycle: iteration,
|
|
556
567
|
command: input.command,
|
|
557
|
-
artifactRoot: input.artifactRoot,
|
|
568
|
+
...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
|
|
558
569
|
allowedFailures: input.config?.merge?.allowedFailures ?? [],
|
|
559
|
-
greptileApi
|
|
570
|
+
...requireGreptile && input.greptileApi ? { greptileApi: input.greptileApi } : {},
|
|
560
571
|
requireGreptile
|
|
561
572
|
});
|
|
562
573
|
latestFeedback = [...gate.actionableFeedback];
|
|
@@ -586,22 +597,22 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
586
597
|
}
|
|
587
598
|
if (gate.approved) {
|
|
588
599
|
pendingElapsedMs = 0;
|
|
589
|
-
const finalGate = await
|
|
600
|
+
const finalGate = await mergeGate.runGate({
|
|
590
601
|
projectRoot: input.projectRoot,
|
|
591
602
|
prUrl,
|
|
592
603
|
taskId: input.taskId,
|
|
593
604
|
runId: input.runId,
|
|
594
605
|
cycle: iteration,
|
|
595
606
|
command: input.command,
|
|
596
|
-
artifactRoot: input.artifactRoot,
|
|
607
|
+
...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
|
|
597
608
|
allowedFailures: input.config?.merge?.allowedFailures ?? [],
|
|
598
|
-
greptileApi
|
|
609
|
+
...requireGreptile && input.greptileApi ? { greptileApi: input.greptileApi } : {},
|
|
599
610
|
requireGreptile,
|
|
600
611
|
final: true
|
|
601
612
|
});
|
|
602
613
|
if (finalGate.approved) {
|
|
603
614
|
await input.lifecycle?.onMergeStarted?.({ prUrl });
|
|
604
|
-
await runRepoDefaultMerge({ prUrl, config: input.config, command: input.command, cwd: input.projectRoot, strictGate: finalGate });
|
|
615
|
+
await runRepoDefaultMerge({ prUrl, ...input.config !== undefined ? { config: input.config } : {}, command: input.command, cwd: input.projectRoot, strictGate: finalGate });
|
|
605
616
|
await input.lifecycle?.onMerged?.({ prUrl });
|
|
606
617
|
return { status: "merged", prUrl, iterations: iteration, actionableFeedback: [], merged: true };
|
|
607
618
|
}
|
|
@@ -648,6 +659,7 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
648
659
|
}
|
|
649
660
|
var UPLOADED_SNAPSHOT_PR_MARKER = "<!-- rig:uploaded-snapshot -->", RIG_RUNTIME_COMMIT_EXCLUDES, GREPTILE_REREVIEW_MARKER_PREFIX = "rig:greptile-rereview";
|
|
650
661
|
var init_pr_automation = __esm(() => {
|
|
662
|
+
init_pr_merge_gate_cap();
|
|
651
663
|
RIG_RUNTIME_COMMIT_EXCLUDES = [
|
|
652
664
|
".rig",
|
|
653
665
|
"artifacts",
|
package/dist/src/stages/push.js
CHANGED
|
@@ -15,6 +15,19 @@ var __export = (target, all) => {
|
|
|
15
15
|
};
|
|
16
16
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
17
|
|
|
18
|
+
// packages/bundle-default-lifecycle/src/control-plane/pr-merge-gate-cap.ts
|
|
19
|
+
import { PR_MERGE_GATE } from "@rig/contracts";
|
|
20
|
+
import { defineCapability } from "@rig/core/capability";
|
|
21
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
22
|
+
async function resolvePrMergeGateService(projectRoot) {
|
|
23
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
24
|
+
return PrMergeGateCap.require(host);
|
|
25
|
+
}
|
|
26
|
+
var PrMergeGateCap;
|
|
27
|
+
var init_pr_merge_gate_cap = __esm(() => {
|
|
28
|
+
PrMergeGateCap = defineCapability(PR_MERGE_GATE);
|
|
29
|
+
});
|
|
30
|
+
|
|
18
31
|
// packages/bundle-default-lifecycle/src/control-plane/pr-automation.ts
|
|
19
32
|
var exports_pr_automation = {};
|
|
20
33
|
__export(exports_pr_automation, {
|
|
@@ -32,11 +45,7 @@ __export(exports_pr_automation, {
|
|
|
32
45
|
buildPrAutomationBody: () => buildPrAutomationBody,
|
|
33
46
|
UPLOADED_SNAPSHOT_PR_MARKER: () => UPLOADED_SNAPSHOT_PR_MARKER
|
|
34
47
|
});
|
|
35
|
-
import { assertSafeGitBranchName } from "@rig/
|
|
36
|
-
import { runStrictPrMergeGate } from "@rig/pr-review-plugin";
|
|
37
|
-
import {
|
|
38
|
-
strictMergeHeadShaFromGate
|
|
39
|
-
} from "@rig/contracts";
|
|
48
|
+
import { assertSafeGitBranchName } from "@rig/core/safe-identifiers";
|
|
40
49
|
function positiveInt(value, fallback) {
|
|
41
50
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
42
51
|
}
|
|
@@ -339,7 +348,7 @@ async function commitRunChanges(input) {
|
|
|
339
348
|
async function closeIssueAfterMergedPr(input) {
|
|
340
349
|
await input.updateTaskSource(input.projectRoot, {
|
|
341
350
|
taskId: input.taskId,
|
|
342
|
-
sourceTask: input.sourceTask,
|
|
351
|
+
...input.sourceTask !== undefined ? { sourceTask: input.sourceTask } : {},
|
|
343
352
|
update: {
|
|
344
353
|
status: "closed",
|
|
345
354
|
comment: [
|
|
@@ -385,11 +394,12 @@ async function runRepoDefaultMerge(input) {
|
|
|
385
394
|
if (merge.mode === "off")
|
|
386
395
|
return;
|
|
387
396
|
const requireGreptile = (input.config?.review?.provider ?? "greptile") === "greptile";
|
|
388
|
-
const
|
|
397
|
+
const mergeGate = await resolvePrMergeGateService(input.projectRoot ?? input.cwd ?? process.cwd());
|
|
398
|
+
const matchHeadSha = mergeGate.resolveHeadSha({ result: input.strictGate, prUrl: input.prUrl, requireGreptile });
|
|
389
399
|
const method = merge.method ?? "repo-default";
|
|
390
400
|
const args = ["pr", "merge", input.prUrl];
|
|
391
401
|
if (method === "repo-default") {
|
|
392
|
-
args.push(await resolveRepoDefaultMergeFlag({ prUrl: input.prUrl, command: input.command, cwd: input.cwd }));
|
|
402
|
+
args.push(await resolveRepoDefaultMergeFlag({ prUrl: input.prUrl, command: input.command, ...input.cwd !== undefined ? { cwd: input.cwd } : {} }));
|
|
393
403
|
} else {
|
|
394
404
|
args.push(`--${method}`);
|
|
395
405
|
}
|
|
@@ -466,6 +476,7 @@ async function syncBranchAfterPrFeedback(input) {
|
|
|
466
476
|
}
|
|
467
477
|
async function runPrAutomation(input) {
|
|
468
478
|
const branch = assertSafeGitBranchName(input.branch, "PR branch");
|
|
479
|
+
const mergeGate = await resolvePrMergeGateService(input.projectRoot);
|
|
469
480
|
const prConfig = input.config?.pr ?? {};
|
|
470
481
|
const requireGreptile = (input.config?.review?.provider ?? "greptile") === "greptile";
|
|
471
482
|
if (prConfig.mode === "off" || prConfig.mode === "ask") {
|
|
@@ -475,7 +486,7 @@ async function runPrAutomation(input) {
|
|
|
475
486
|
taskId: input.taskId,
|
|
476
487
|
runId: input.runId,
|
|
477
488
|
summary: input.sourceTask?.title ? `Rig completed: ${input.sourceTask.title}` : null,
|
|
478
|
-
uploadedSnapshot: input.uploadedSnapshot
|
|
489
|
+
...input.uploadedSnapshot !== undefined ? { uploadedSnapshot: input.uploadedSnapshot } : {}
|
|
479
490
|
});
|
|
480
491
|
if (input.gitCommand) {
|
|
481
492
|
await pushBranchSyncedWithOrigin({ projectRoot: input.projectRoot, branch, gitCommand: input.gitCommand });
|
|
@@ -547,16 +558,16 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
547
558
|
await syncBranchAfterPrFeedback({ projectRoot: input.projectRoot, taskId: input.taskId, branch, gitCommand: input.gitCommand });
|
|
548
559
|
continue;
|
|
549
560
|
}
|
|
550
|
-
const gate = await
|
|
561
|
+
const gate = await mergeGate.runGate({
|
|
551
562
|
projectRoot: input.projectRoot,
|
|
552
563
|
prUrl,
|
|
553
564
|
taskId: input.taskId,
|
|
554
565
|
runId: input.runId,
|
|
555
566
|
cycle: iteration,
|
|
556
567
|
command: input.command,
|
|
557
|
-
artifactRoot: input.artifactRoot,
|
|
568
|
+
...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
|
|
558
569
|
allowedFailures: input.config?.merge?.allowedFailures ?? [],
|
|
559
|
-
greptileApi
|
|
570
|
+
...requireGreptile && input.greptileApi ? { greptileApi: input.greptileApi } : {},
|
|
560
571
|
requireGreptile
|
|
561
572
|
});
|
|
562
573
|
latestFeedback = [...gate.actionableFeedback];
|
|
@@ -586,22 +597,22 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
586
597
|
}
|
|
587
598
|
if (gate.approved) {
|
|
588
599
|
pendingElapsedMs = 0;
|
|
589
|
-
const finalGate = await
|
|
600
|
+
const finalGate = await mergeGate.runGate({
|
|
590
601
|
projectRoot: input.projectRoot,
|
|
591
602
|
prUrl,
|
|
592
603
|
taskId: input.taskId,
|
|
593
604
|
runId: input.runId,
|
|
594
605
|
cycle: iteration,
|
|
595
606
|
command: input.command,
|
|
596
|
-
artifactRoot: input.artifactRoot,
|
|
607
|
+
...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
|
|
597
608
|
allowedFailures: input.config?.merge?.allowedFailures ?? [],
|
|
598
|
-
greptileApi
|
|
609
|
+
...requireGreptile && input.greptileApi ? { greptileApi: input.greptileApi } : {},
|
|
599
610
|
requireGreptile,
|
|
600
611
|
final: true
|
|
601
612
|
});
|
|
602
613
|
if (finalGate.approved) {
|
|
603
614
|
await input.lifecycle?.onMergeStarted?.({ prUrl });
|
|
604
|
-
await runRepoDefaultMerge({ prUrl, config: input.config, command: input.command, cwd: input.projectRoot, strictGate: finalGate });
|
|
615
|
+
await runRepoDefaultMerge({ prUrl, ...input.config !== undefined ? { config: input.config } : {}, command: input.command, cwd: input.projectRoot, strictGate: finalGate });
|
|
605
616
|
await input.lifecycle?.onMerged?.({ prUrl });
|
|
606
617
|
return { status: "merged", prUrl, iterations: iteration, actionableFeedback: [], merged: true };
|
|
607
618
|
}
|
|
@@ -648,6 +659,7 @@ ${createResult.stdout ?? ""}`) : null;
|
|
|
648
659
|
}
|
|
649
660
|
var UPLOADED_SNAPSHOT_PR_MARKER = "<!-- rig:uploaded-snapshot -->", RIG_RUNTIME_COMMIT_EXCLUDES, GREPTILE_REREVIEW_MARKER_PREFIX = "rig:greptile-rereview";
|
|
650
661
|
var init_pr_automation = __esm(() => {
|
|
662
|
+
init_pr_merge_gate_cap();
|
|
651
663
|
RIG_RUNTIME_COMMIT_EXCLUDES = [
|
|
652
664
|
".rig",
|
|
653
665
|
"artifacts",
|