@h-rig/runtime 0.0.6-alpha.35 → 0.0.6-alpha.37

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.
@@ -3616,7 +3616,7 @@ class GeneralCliEventBus {
3616
3616
  }
3617
3617
 
3618
3618
  // packages/runtime/src/control-plane/native/git-ops.ts
3619
- import { existsSync as existsSync25, lstatSync, mkdirSync as mkdirSync12, readFileSync as readFileSync15, writeFileSync as writeFileSync12 } from "fs";
3619
+ import { existsSync as existsSync25, lstatSync, mkdirSync as mkdirSync12, readFileSync as readFileSync15, unlinkSync, writeFileSync as writeFileSync12 } from "fs";
3620
3620
  import { dirname as dirname15, isAbsolute as isAbsolute2, resolve as resolve28 } from "path";
3621
3621
  import { fileURLToPath as fileURLToPath2 } from "url";
3622
3622
 
@@ -6693,14 +6693,19 @@ function resolveTaskMonorepoRoot(projectRoot) {
6693
6693
  return resolveHarnessPaths(projectRoot).monorepoRoot;
6694
6694
  }
6695
6695
  function collectCommittedMonorepoFiles(projectRoot, repo) {
6696
- const defaultRef = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
6697
- if (defaultRef.exitCode === 0 && defaultRef.stdout.trim()) {
6698
- const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", defaultRef.stdout.trim()], projectRoot);
6699
- if (mergeBase.exitCode === 0 && mergeBase.stdout.trim()) {
6700
- const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
6701
- if (result.exitCode === 0) {
6702
- return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6703
- }
6696
+ const baseRefCandidates = [];
6697
+ const originHead = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
6698
+ if (originHead.exitCode === 0 && originHead.stdout.trim()) {
6699
+ baseRefCandidates.push(originHead.stdout.trim());
6700
+ }
6701
+ baseRefCandidates.push("origin/main", "origin/dev", "origin/master", "main", "dev", "master");
6702
+ for (const baseRef of baseRefCandidates) {
6703
+ const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", baseRef], projectRoot);
6704
+ if (mergeBase.exitCode !== 0 || !mergeBase.stdout.trim())
6705
+ continue;
6706
+ const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
6707
+ if (result.exitCode === 0) {
6708
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6704
6709
  }
6705
6710
  }
6706
6711
  const initialHeadCommit = resolveRuntimeInitialHeadCommit(projectRoot, repo);
@@ -7826,9 +7831,23 @@ function commitRepo(projectRoot, repo, label, message, allowEmpty, scoped, files
7826
7831
  console.log(`Skipping ${label}: no changes to commit.`);
7827
7832
  return;
7828
7833
  }
7829
- const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
7830
- if (addArgs) {
7831
- runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
7834
+ if (scopedFiles.length > 0) {
7835
+ const pathspecFile = resolve28(repo, ".git", `rig-stage-${process.pid}-${Date.now()}.txt`);
7836
+ writeFileSync12(pathspecFile, `${scopedFiles.join(`
7837
+ `)}
7838
+ `, "utf-8");
7839
+ try {
7840
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, "add", `--pathspec-from-file=${pathspecFile}`), `Failed to stage changes for ${label}`);
7841
+ } finally {
7842
+ try {
7843
+ unlinkSync(pathspecFile);
7844
+ } catch {}
7845
+ }
7846
+ } else {
7847
+ const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
7848
+ if (addArgs) {
7849
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
7850
+ }
7832
7851
  }
7833
7852
  const stagedChanges = stagedChangeCount(projectRoot, repo);
7834
7853
  if (stagedChanges === 0) {
@@ -9,7 +9,7 @@ import { existsSync as existsSync31 } from "fs";
9
9
  import { resolve as resolve31 } from "path";
10
10
 
11
11
  // packages/runtime/src/control-plane/native/git-ops.ts
12
- import { existsSync as existsSync24, lstatSync, mkdirSync as mkdirSync12, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "fs";
12
+ import { existsSync as existsSync24, lstatSync, mkdirSync as mkdirSync12, readFileSync as readFileSync13, unlinkSync, writeFileSync as writeFileSync12 } from "fs";
13
13
  import { dirname as dirname12, isAbsolute as isAbsolute2, resolve as resolve26 } from "path";
14
14
  import { fileURLToPath as fileURLToPath2 } from "url";
15
15
 
@@ -6228,17 +6228,28 @@ function loadGithubPullRequestCheckRollup(projectRoot, repoName, prNumber) {
6228
6228
  return response.statusCheckRollup || [];
6229
6229
  }
6230
6230
  function evaluatePullRequestCiChecks(checks, repoName, prNumber, options = {}) {
6231
- const nonGreptileChecks = checks.filter((check) => {
6232
- const label = (check.name || check.context || "").toLowerCase();
6233
- return label.length > 0 && !label.includes("greptile");
6234
- });
6235
- const pending = nonGreptileChecks.filter((check) => {
6231
+ const isPendingCheck2 = (check) => {
6236
6232
  if ((check.__typename || "") === "CheckRun") {
6237
6233
  return (check.status || "").toUpperCase() !== "COMPLETED";
6238
6234
  }
6239
6235
  const state = (check.state || check.status || "").toUpperCase();
6240
6236
  return state === "PENDING" || state === "EXPECTED" || state === "QUEUED" || state === "IN_PROGRESS";
6237
+ };
6238
+ const pendingGreptile = checks.filter((check) => {
6239
+ const label = (check.name || check.context || "").toLowerCase();
6240
+ return label.includes("greptile") && isPendingCheck2(check);
6241
+ });
6242
+ if (pendingGreptile.length > 0) {
6243
+ return {
6244
+ verdict: "SKIP",
6245
+ reasons: pendingGreptile.map((check) => `[CI] ${repoName}#${prNumber} mandatory Greptile check is still pending: ${check.name || check.context || "unknown"}.`)
6246
+ };
6247
+ }
6248
+ const nonGreptileChecks = checks.filter((check) => {
6249
+ const label = (check.name || check.context || "").toLowerCase();
6250
+ return label.length > 0 && !label.includes("greptile");
6241
6251
  });
6252
+ const pending = nonGreptileChecks.filter(isPendingCheck2);
6242
6253
  const mergeClean = (options.mergeStateStatus || "").toUpperCase() === "CLEAN";
6243
6254
  if (pending.length > 0 && !mergeClean) {
6244
6255
  return {
@@ -6964,14 +6975,19 @@ function resolveTaskMonorepoRoot(projectRoot) {
6964
6975
  return resolveHarnessPaths(projectRoot).monorepoRoot;
6965
6976
  }
6966
6977
  function collectCommittedMonorepoFiles(projectRoot, repo) {
6967
- const defaultRef = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
6968
- if (defaultRef.exitCode === 0 && defaultRef.stdout.trim()) {
6969
- const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", defaultRef.stdout.trim()], projectRoot);
6970
- if (mergeBase.exitCode === 0 && mergeBase.stdout.trim()) {
6971
- const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
6972
- if (result.exitCode === 0) {
6973
- return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6974
- }
6978
+ const baseRefCandidates = [];
6979
+ const originHead = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
6980
+ if (originHead.exitCode === 0 && originHead.stdout.trim()) {
6981
+ baseRefCandidates.push(originHead.stdout.trim());
6982
+ }
6983
+ baseRefCandidates.push("origin/main", "origin/dev", "origin/master", "main", "dev", "master");
6984
+ for (const baseRef of baseRefCandidates) {
6985
+ const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", baseRef], projectRoot);
6986
+ if (mergeBase.exitCode !== 0 || !mergeBase.stdout.trim())
6987
+ continue;
6988
+ const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
6989
+ if (result.exitCode === 0) {
6990
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6975
6991
  }
6976
6992
  }
6977
6993
  const initialHeadCommit = resolveRuntimeInitialHeadCommit(projectRoot, repo);
@@ -8122,9 +8138,23 @@ function commitRepo(projectRoot, repo, label, message, allowEmpty, scoped, files
8122
8138
  console.log(`Skipping ${label}: no changes to commit.`);
8123
8139
  return;
8124
8140
  }
8125
- const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
8126
- if (addArgs) {
8127
- runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
8141
+ if (scopedFiles.length > 0) {
8142
+ const pathspecFile = resolve26(repo, ".git", `rig-stage-${process.pid}-${Date.now()}.txt`);
8143
+ writeFileSync12(pathspecFile, `${scopedFiles.join(`
8144
+ `)}
8145
+ `, "utf-8");
8146
+ try {
8147
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, "add", `--pathspec-from-file=${pathspecFile}`), `Failed to stage changes for ${label}`);
8148
+ } finally {
8149
+ try {
8150
+ unlinkSync(pathspecFile);
8151
+ } catch {}
8152
+ }
8153
+ } else {
8154
+ const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
8155
+ if (addArgs) {
8156
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
8157
+ }
8128
8158
  }
8129
8159
  const stagedChanges = stagedChangeCount(projectRoot, repo);
8130
8160
  if (stagedChanges === 0) {
@@ -1073,7 +1073,7 @@ function primeGuardHotPaths() {
1073
1073
  primeGuardHotPaths();
1074
1074
 
1075
1075
  // packages/runtime/src/control-plane/native/git-ops.ts
1076
- import { existsSync as existsSync22, lstatSync, mkdirSync as mkdirSync13, readFileSync as readFileSync13, writeFileSync as writeFileSync13 } from "fs";
1076
+ import { existsSync as existsSync22, lstatSync, mkdirSync as mkdirSync13, readFileSync as readFileSync13, unlinkSync, writeFileSync as writeFileSync13 } from "fs";
1077
1077
  import { dirname as dirname11, isAbsolute as isAbsolute2, resolve as resolve24 } from "path";
1078
1078
  import { fileURLToPath as fileURLToPath2 } from "url";
1079
1079
 
@@ -6661,17 +6661,28 @@ function loadGithubPullRequestCheckRollup(projectRoot, repoName, prNumber) {
6661
6661
  return response.statusCheckRollup || [];
6662
6662
  }
6663
6663
  function evaluatePullRequestCiChecks(checks, repoName, prNumber, options = {}) {
6664
- const nonGreptileChecks = checks.filter((check) => {
6665
- const label = (check.name || check.context || "").toLowerCase();
6666
- return label.length > 0 && !label.includes("greptile");
6667
- });
6668
- const pending = nonGreptileChecks.filter((check) => {
6664
+ const isPendingCheck2 = (check) => {
6669
6665
  if ((check.__typename || "") === "CheckRun") {
6670
6666
  return (check.status || "").toUpperCase() !== "COMPLETED";
6671
6667
  }
6672
6668
  const state = (check.state || check.status || "").toUpperCase();
6673
6669
  return state === "PENDING" || state === "EXPECTED" || state === "QUEUED" || state === "IN_PROGRESS";
6670
+ };
6671
+ const pendingGreptile = checks.filter((check) => {
6672
+ const label = (check.name || check.context || "").toLowerCase();
6673
+ return label.includes("greptile") && isPendingCheck2(check);
6674
+ });
6675
+ if (pendingGreptile.length > 0) {
6676
+ return {
6677
+ verdict: "SKIP",
6678
+ reasons: pendingGreptile.map((check) => `[CI] ${repoName}#${prNumber} mandatory Greptile check is still pending: ${check.name || check.context || "unknown"}.`)
6679
+ };
6680
+ }
6681
+ const nonGreptileChecks = checks.filter((check) => {
6682
+ const label = (check.name || check.context || "").toLowerCase();
6683
+ return label.length > 0 && !label.includes("greptile");
6674
6684
  });
6685
+ const pending = nonGreptileChecks.filter(isPendingCheck2);
6675
6686
  const mergeClean = (options.mergeStateStatus || "").toUpperCase() === "CLEAN";
6676
6687
  if (pending.length > 0 && !mergeClean) {
6677
6688
  return {
@@ -6975,14 +6986,19 @@ function resolveTaskMonorepoRoot(projectRoot) {
6975
6986
  return resolveHarnessPaths(projectRoot).monorepoRoot;
6976
6987
  }
6977
6988
  function collectCommittedMonorepoFiles(projectRoot, repo) {
6978
- const defaultRef = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
6979
- if (defaultRef.exitCode === 0 && defaultRef.stdout.trim()) {
6980
- const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", defaultRef.stdout.trim()], projectRoot);
6981
- if (mergeBase.exitCode === 0 && mergeBase.stdout.trim()) {
6982
- const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
6983
- if (result.exitCode === 0) {
6984
- return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6985
- }
6989
+ const baseRefCandidates = [];
6990
+ const originHead = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
6991
+ if (originHead.exitCode === 0 && originHead.stdout.trim()) {
6992
+ baseRefCandidates.push(originHead.stdout.trim());
6993
+ }
6994
+ baseRefCandidates.push("origin/main", "origin/dev", "origin/master", "main", "dev", "master");
6995
+ for (const baseRef of baseRefCandidates) {
6996
+ const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", baseRef], projectRoot);
6997
+ if (mergeBase.exitCode !== 0 || !mergeBase.stdout.trim())
6998
+ continue;
6999
+ const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
7000
+ if (result.exitCode === 0) {
7001
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6986
7002
  }
6987
7003
  }
6988
7004
  const initialHeadCommit = resolveRuntimeInitialHeadCommit(projectRoot, repo);
@@ -7896,9 +7912,23 @@ function commitRepo(projectRoot, repo, label, message, allowEmpty, scoped, files
7896
7912
  console.log(`Skipping ${label}: no changes to commit.`);
7897
7913
  return;
7898
7914
  }
7899
- const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
7900
- if (addArgs) {
7901
- runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
7915
+ if (scopedFiles.length > 0) {
7916
+ const pathspecFile = resolve24(repo, ".git", `rig-stage-${process.pid}-${Date.now()}.txt`);
7917
+ writeFileSync13(pathspecFile, `${scopedFiles.join(`
7918
+ `)}
7919
+ `, "utf-8");
7920
+ try {
7921
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, "add", `--pathspec-from-file=${pathspecFile}`), `Failed to stage changes for ${label}`);
7922
+ } finally {
7923
+ try {
7924
+ unlinkSync(pathspecFile);
7925
+ } catch {}
7926
+ }
7927
+ } else {
7928
+ const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
7929
+ if (addArgs) {
7930
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
7931
+ }
7902
7932
  }
7903
7933
  const stagedChanges = stagedChangeCount(projectRoot, repo);
7904
7934
  if (stagedChanges === 0) {
@@ -8401,7 +8431,7 @@ async function main() {
8401
8431
  target: "monorepo",
8402
8432
  message: `rig: ${taskId} task completion`,
8403
8433
  allowEmpty: false,
8404
- scoped: true
8434
+ scoped: false
8405
8435
  });
8406
8436
  console.log("OK: Task changes committed");
8407
8437
  } else {
@@ -126,7 +126,7 @@ import { resolve as resolve38 } from "path";
126
126
  import { resolveProjectRoot } from "@rig/hook-kit";
127
127
 
128
128
  // packages/runtime/src/control-plane/native/git-ops.ts
129
- import { existsSync as existsSync25, lstatSync, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
129
+ import { existsSync as existsSync25, lstatSync, mkdirSync as mkdirSync11, readFileSync as readFileSync13, unlinkSync, writeFileSync as writeFileSync10 } from "fs";
130
130
  import { dirname as dirname11, isAbsolute as isAbsolute2, resolve as resolve25 } from "path";
131
131
 
132
132
  // packages/runtime/src/control-plane/runtime/baked-secrets.ts
@@ -126,7 +126,7 @@ import { resolve as resolve38 } from "path";
126
126
  import { resolveProjectRoot } from "@rig/hook-kit";
127
127
 
128
128
  // packages/runtime/src/control-plane/native/git-ops.ts
129
- import { existsSync as existsSync25, lstatSync, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "fs";
129
+ import { existsSync as existsSync25, lstatSync, mkdirSync as mkdirSync11, readFileSync as readFileSync13, unlinkSync, writeFileSync as writeFileSync10 } from "fs";
130
130
  import { dirname as dirname11, isAbsolute as isAbsolute2, resolve as resolve25 } from "path";
131
131
 
132
132
  // packages/runtime/src/control-plane/runtime/baked-secrets.ts
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  // packages/runtime/src/control-plane/native/git-ops.ts
3
- import { existsSync as existsSync9, lstatSync, mkdirSync as mkdirSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "fs";
3
+ import { existsSync as existsSync9, lstatSync, mkdirSync as mkdirSync5, readFileSync as readFileSync7, unlinkSync, writeFileSync as writeFileSync5 } from "fs";
4
4
  import { dirname as dirname7, isAbsolute as isAbsolute2, resolve as resolve11 } from "path";
5
5
  import { fileURLToPath } from "url";
6
6
 
@@ -1404,14 +1404,19 @@ function resolveTaskMonorepoRoot(projectRoot) {
1404
1404
  return resolveHarnessPaths(projectRoot).monorepoRoot;
1405
1405
  }
1406
1406
  function collectCommittedMonorepoFiles(projectRoot, repo) {
1407
- const defaultRef = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
1408
- if (defaultRef.exitCode === 0 && defaultRef.stdout.trim()) {
1409
- const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", defaultRef.stdout.trim()], projectRoot);
1410
- if (mergeBase.exitCode === 0 && mergeBase.stdout.trim()) {
1411
- const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
1412
- if (result.exitCode === 0) {
1413
- return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
1414
- }
1407
+ const baseRefCandidates = [];
1408
+ const originHead = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
1409
+ if (originHead.exitCode === 0 && originHead.stdout.trim()) {
1410
+ baseRefCandidates.push(originHead.stdout.trim());
1411
+ }
1412
+ baseRefCandidates.push("origin/main", "origin/dev", "origin/master", "main", "dev", "master");
1413
+ for (const baseRef of baseRefCandidates) {
1414
+ const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", baseRef], projectRoot);
1415
+ if (mergeBase.exitCode !== 0 || !mergeBase.stdout.trim())
1416
+ continue;
1417
+ const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
1418
+ if (result.exitCode === 0) {
1419
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
1415
1420
  }
1416
1421
  }
1417
1422
  const initialHeadCommit = resolveRuntimeInitialHeadCommit(projectRoot, repo);
@@ -2439,9 +2444,23 @@ function commitRepo(projectRoot, repo, label, message, allowEmpty, scoped, files
2439
2444
  console.log(`Skipping ${label}: no changes to commit.`);
2440
2445
  return;
2441
2446
  }
2442
- const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
2443
- if (addArgs) {
2444
- runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
2447
+ if (scopedFiles.length > 0) {
2448
+ const pathspecFile = resolve11(repo, ".git", `rig-stage-${process.pid}-${Date.now()}.txt`);
2449
+ writeFileSync5(pathspecFile, `${scopedFiles.join(`
2450
+ `)}
2451
+ `, "utf-8");
2452
+ try {
2453
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, "add", `--pathspec-from-file=${pathspecFile}`), `Failed to stage changes for ${label}`);
2454
+ } finally {
2455
+ try {
2456
+ unlinkSync(pathspecFile);
2457
+ } catch {}
2458
+ }
2459
+ } else {
2460
+ const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
2461
+ if (addArgs) {
2462
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
2463
+ }
2445
2464
  }
2446
2465
  const stagedChanges = stagedChangeCount(projectRoot, repo);
2447
2466
  if (stagedChanges === 0) {
@@ -4,7 +4,7 @@ import { existsSync as existsSync31 } from "fs";
4
4
  import { resolve as resolve31 } from "path";
5
5
 
6
6
  // packages/runtime/src/control-plane/native/git-ops.ts
7
- import { existsSync as existsSync24, lstatSync, mkdirSync as mkdirSync12, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "fs";
7
+ import { existsSync as existsSync24, lstatSync, mkdirSync as mkdirSync12, readFileSync as readFileSync13, unlinkSync, writeFileSync as writeFileSync12 } from "fs";
8
8
  import { dirname as dirname12, isAbsolute as isAbsolute2, resolve as resolve26 } from "path";
9
9
  import { fileURLToPath as fileURLToPath2 } from "url";
10
10
 
@@ -6222,17 +6222,28 @@ function loadGithubPullRequestCheckRollup(projectRoot, repoName, prNumber) {
6222
6222
  return response.statusCheckRollup || [];
6223
6223
  }
6224
6224
  function evaluatePullRequestCiChecks(checks, repoName, prNumber, options = {}) {
6225
- const nonGreptileChecks = checks.filter((check) => {
6226
- const label = (check.name || check.context || "").toLowerCase();
6227
- return label.length > 0 && !label.includes("greptile");
6228
- });
6229
- const pending = nonGreptileChecks.filter((check) => {
6225
+ const isPendingCheck2 = (check) => {
6230
6226
  if ((check.__typename || "") === "CheckRun") {
6231
6227
  return (check.status || "").toUpperCase() !== "COMPLETED";
6232
6228
  }
6233
6229
  const state = (check.state || check.status || "").toUpperCase();
6234
6230
  return state === "PENDING" || state === "EXPECTED" || state === "QUEUED" || state === "IN_PROGRESS";
6231
+ };
6232
+ const pendingGreptile = checks.filter((check) => {
6233
+ const label = (check.name || check.context || "").toLowerCase();
6234
+ return label.includes("greptile") && isPendingCheck2(check);
6235
+ });
6236
+ if (pendingGreptile.length > 0) {
6237
+ return {
6238
+ verdict: "SKIP",
6239
+ reasons: pendingGreptile.map((check) => `[CI] ${repoName}#${prNumber} mandatory Greptile check is still pending: ${check.name || check.context || "unknown"}.`)
6240
+ };
6241
+ }
6242
+ const nonGreptileChecks = checks.filter((check) => {
6243
+ const label = (check.name || check.context || "").toLowerCase();
6244
+ return label.length > 0 && !label.includes("greptile");
6235
6245
  });
6246
+ const pending = nonGreptileChecks.filter(isPendingCheck2);
6236
6247
  const mergeClean = (options.mergeStateStatus || "").toUpperCase() === "CLEAN";
6237
6248
  if (pending.length > 0 && !mergeClean) {
6238
6249
  return {
@@ -6958,14 +6969,19 @@ function resolveTaskMonorepoRoot(projectRoot) {
6958
6969
  return resolveHarnessPaths(projectRoot).monorepoRoot;
6959
6970
  }
6960
6971
  function collectCommittedMonorepoFiles(projectRoot, repo) {
6961
- const defaultRef = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
6962
- if (defaultRef.exitCode === 0 && defaultRef.stdout.trim()) {
6963
- const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", defaultRef.stdout.trim()], projectRoot);
6964
- if (mergeBase.exitCode === 0 && mergeBase.stdout.trim()) {
6965
- const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
6966
- if (result.exitCode === 0) {
6967
- return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6968
- }
6972
+ const baseRefCandidates = [];
6973
+ const originHead = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
6974
+ if (originHead.exitCode === 0 && originHead.stdout.trim()) {
6975
+ baseRefCandidates.push(originHead.stdout.trim());
6976
+ }
6977
+ baseRefCandidates.push("origin/main", "origin/dev", "origin/master", "main", "dev", "master");
6978
+ for (const baseRef of baseRefCandidates) {
6979
+ const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", baseRef], projectRoot);
6980
+ if (mergeBase.exitCode !== 0 || !mergeBase.stdout.trim())
6981
+ continue;
6982
+ const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
6983
+ if (result.exitCode === 0) {
6984
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
6969
6985
  }
6970
6986
  }
6971
6987
  const initialHeadCommit = resolveRuntimeInitialHeadCommit(projectRoot, repo);
@@ -8116,9 +8132,23 @@ function commitRepo(projectRoot, repo, label, message, allowEmpty, scoped, files
8116
8132
  console.log(`Skipping ${label}: no changes to commit.`);
8117
8133
  return;
8118
8134
  }
8119
- const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
8120
- if (addArgs) {
8121
- runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
8135
+ if (scopedFiles.length > 0) {
8136
+ const pathspecFile = resolve26(repo, ".git", `rig-stage-${process.pid}-${Date.now()}.txt`);
8137
+ writeFileSync12(pathspecFile, `${scopedFiles.join(`
8138
+ `)}
8139
+ `, "utf-8");
8140
+ try {
8141
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, "add", `--pathspec-from-file=${pathspecFile}`), `Failed to stage changes for ${label}`);
8142
+ } finally {
8143
+ try {
8144
+ unlinkSync(pathspecFile);
8145
+ } catch {}
8146
+ }
8147
+ } else {
8148
+ const addArgs = buildStageAddArgs(repo, scopedFiles, scoped);
8149
+ if (addArgs) {
8150
+ runOrThrow(projectRoot, gitCmd(projectRoot, repo, ...addArgs), `Failed to stage changes for ${label}`);
8151
+ }
8122
8152
  }
8123
8153
  const stagedChanges = stagedChangeCount(projectRoot, repo);
8124
8154
  if (stagedChanges === 0) {
@@ -3816,7 +3816,7 @@ function resolveRuntimeSecrets(env, baked = BAKED_RUNTIME_SECRETS) {
3816
3816
  }
3817
3817
 
3818
3818
  // packages/runtime/src/control-plane/native/git-ops.ts
3819
- import { existsSync as existsSync21, lstatSync, mkdirSync as mkdirSync10, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "fs";
3819
+ import { existsSync as existsSync21, lstatSync, mkdirSync as mkdirSync10, readFileSync as readFileSync11, unlinkSync, writeFileSync as writeFileSync10 } from "fs";
3820
3820
  import { dirname as dirname12, isAbsolute as isAbsolute2, resolve as resolve23 } from "path";
3821
3821
 
3822
3822
  // packages/runtime/src/control-plane/native/pr-review-gate.ts
@@ -6402,17 +6402,28 @@ function loadGithubPullRequestCheckRollup(projectRoot, repoName, prNumber) {
6402
6402
  return response.statusCheckRollup || [];
6403
6403
  }
6404
6404
  function evaluatePullRequestCiChecks(checks, repoName, prNumber, options = {}) {
6405
- const nonGreptileChecks = checks.filter((check) => {
6406
- const label = (check.name || check.context || "").toLowerCase();
6407
- return label.length > 0 && !label.includes("greptile");
6408
- });
6409
- const pending = nonGreptileChecks.filter((check) => {
6405
+ const isPendingCheck2 = (check) => {
6410
6406
  if ((check.__typename || "") === "CheckRun") {
6411
6407
  return (check.status || "").toUpperCase() !== "COMPLETED";
6412
6408
  }
6413
6409
  const state = (check.state || check.status || "").toUpperCase();
6414
6410
  return state === "PENDING" || state === "EXPECTED" || state === "QUEUED" || state === "IN_PROGRESS";
6411
+ };
6412
+ const pendingGreptile = checks.filter((check) => {
6413
+ const label = (check.name || check.context || "").toLowerCase();
6414
+ return label.includes("greptile") && isPendingCheck2(check);
6415
6415
  });
6416
+ if (pendingGreptile.length > 0) {
6417
+ return {
6418
+ verdict: "SKIP",
6419
+ reasons: pendingGreptile.map((check) => `[CI] ${repoName}#${prNumber} mandatory Greptile check is still pending: ${check.name || check.context || "unknown"}.`)
6420
+ };
6421
+ }
6422
+ const nonGreptileChecks = checks.filter((check) => {
6423
+ const label = (check.name || check.context || "").toLowerCase();
6424
+ return label.length > 0 && !label.includes("greptile");
6425
+ });
6426
+ const pending = nonGreptileChecks.filter(isPendingCheck2);
6416
6427
  const mergeClean = (options.mergeStateStatus || "").toUpperCase() === "CLEAN";
6417
6428
  if (pending.length > 0 && !mergeClean) {
6418
6429
  return {
@@ -7245,14 +7256,19 @@ function resolveTaskMonorepoRoot(projectRoot) {
7245
7256
  return resolveHarnessPaths(projectRoot).monorepoRoot;
7246
7257
  }
7247
7258
  function collectCommittedMonorepoFiles(projectRoot, repo) {
7248
- const defaultRef = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
7249
- if (defaultRef.exitCode === 0 && defaultRef.stdout.trim()) {
7250
- const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", defaultRef.stdout.trim()], projectRoot);
7251
- if (mergeBase.exitCode === 0 && mergeBase.stdout.trim()) {
7252
- const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
7253
- if (result.exitCode === 0) {
7254
- return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
7255
- }
7259
+ const baseRefCandidates = [];
7260
+ const originHead = runCapture(["git", "-C", repo, "rev-parse", "--abbrev-ref", "origin/HEAD"], projectRoot);
7261
+ if (originHead.exitCode === 0 && originHead.stdout.trim()) {
7262
+ baseRefCandidates.push(originHead.stdout.trim());
7263
+ }
7264
+ baseRefCandidates.push("origin/main", "origin/dev", "origin/master", "main", "dev", "master");
7265
+ for (const baseRef of baseRefCandidates) {
7266
+ const mergeBase = runCapture(["git", "-C", repo, "merge-base", "HEAD", baseRef], projectRoot);
7267
+ if (mergeBase.exitCode !== 0 || !mergeBase.stdout.trim())
7268
+ continue;
7269
+ const result = runCapture(["git", "-C", repo, "diff", "--name-only", `${mergeBase.stdout.trim()}..HEAD`], projectRoot);
7270
+ if (result.exitCode === 0) {
7271
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
7256
7272
  }
7257
7273
  }
7258
7274
  const initialHeadCommit = resolveRuntimeInitialHeadCommit(projectRoot, repo);
@@ -47,7 +47,7 @@ function resolveRuntimeSecrets(env, baked = BAKED_RUNTIME_SECRETS) {
47
47
  }
48
48
 
49
49
  // packages/runtime/src/control-plane/native/git-ops.ts
50
- import { existsSync as existsSync13, lstatSync, mkdirSync as mkdirSync6, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "fs";
50
+ import { existsSync as existsSync13, lstatSync, mkdirSync as mkdirSync6, readFileSync as readFileSync9, unlinkSync, writeFileSync as writeFileSync7 } from "fs";
51
51
  import { dirname as dirname9, isAbsolute as isAbsolute2, resolve as resolve14 } from "path";
52
52
 
53
53
  // packages/runtime/src/control-plane/runtime/context.ts
@@ -4452,17 +4452,28 @@ function loadGithubPullRequestCheckRollup(projectRoot, repoName, prNumber) {
4452
4452
  return response.statusCheckRollup || [];
4453
4453
  }
4454
4454
  function evaluatePullRequestCiChecks(checks, repoName, prNumber, options = {}) {
4455
- const nonGreptileChecks = checks.filter((check) => {
4456
- const label = (check.name || check.context || "").toLowerCase();
4457
- return label.length > 0 && !label.includes("greptile");
4458
- });
4459
- const pending = nonGreptileChecks.filter((check) => {
4455
+ const isPendingCheck2 = (check) => {
4460
4456
  if ((check.__typename || "") === "CheckRun") {
4461
4457
  return (check.status || "").toUpperCase() !== "COMPLETED";
4462
4458
  }
4463
4459
  const state = (check.state || check.status || "").toUpperCase();
4464
4460
  return state === "PENDING" || state === "EXPECTED" || state === "QUEUED" || state === "IN_PROGRESS";
4461
+ };
4462
+ const pendingGreptile = checks.filter((check) => {
4463
+ const label = (check.name || check.context || "").toLowerCase();
4464
+ return label.includes("greptile") && isPendingCheck2(check);
4465
+ });
4466
+ if (pendingGreptile.length > 0) {
4467
+ return {
4468
+ verdict: "SKIP",
4469
+ reasons: pendingGreptile.map((check) => `[CI] ${repoName}#${prNumber} mandatory Greptile check is still pending: ${check.name || check.context || "unknown"}.`)
4470
+ };
4471
+ }
4472
+ const nonGreptileChecks = checks.filter((check) => {
4473
+ const label = (check.name || check.context || "").toLowerCase();
4474
+ return label.length > 0 && !label.includes("greptile");
4465
4475
  });
4476
+ const pending = nonGreptileChecks.filter(isPendingCheck2);
4466
4477
  const mergeClean = (options.mergeStateStatus || "").toUpperCase() === "CLEAN";
4467
4478
  if (pending.length > 0 && !mergeClean) {
4468
4479
  return {
@@ -525,9 +525,6 @@ class RigPiSessionService {
525
525
  await this.prompt(sessionId, trimmed, active.runtime.session.isStreaming ? "steer" : undefined);
526
526
  return { type: "done", message: `Accepted ${trimmed}` };
527
527
  }
528
- respondToCommand(_sessionId, _requestId, _value) {
529
- return { type: "unsupported", message: "No pending command selection is active." };
530
- }
531
528
  respondToExtensionUi(sessionId, input) {
532
529
  const active = this.requireActive(sessionId);
533
530
  return { accepted: active.ui.respond(input) };
@@ -737,10 +734,6 @@ async function runRigPiSessionDaemon(options = {}) {
737
734
  const body = await readJson(req);
738
735
  return json(await sessions.runCommand(sessionId, requireText(body, "text")));
739
736
  }
740
- if (action === "commands/respond" && req.method === "POST") {
741
- const body = await readJson(req);
742
- return json(sessions.respondToCommand(sessionId, requireText(body, "requestId"), body.value));
743
- }
744
737
  if (action === "extension-ui/respond" && req.method === "POST") {
745
738
  const body = await readJson(req);
746
739
  return json(sessions.respondToExtensionUi(sessionId, {
@@ -523,9 +523,6 @@ class RigPiSessionService {
523
523
  await this.prompt(sessionId, trimmed, active.runtime.session.isStreaming ? "steer" : undefined);
524
524
  return { type: "done", message: `Accepted ${trimmed}` };
525
525
  }
526
- respondToCommand(_sessionId, _requestId, _value) {
527
- return { type: "unsupported", message: "No pending command selection is active." };
528
- }
529
526
  respondToExtensionUi(sessionId, input) {
530
527
  const active = this.requireActive(sessionId);
531
528
  return { accepted: active.ui.respond(input) };
@@ -735,10 +732,6 @@ async function runRigPiSessionDaemon(options = {}) {
735
732
  const body = await readJson(req);
736
733
  return json(await sessions.runCommand(sessionId, requireText(body, "text")));
737
734
  }
738
- if (action === "commands/respond" && req.method === "POST") {
739
- const body = await readJson(req);
740
- return json(sessions.respondToCommand(sessionId, requireText(body, "requestId"), body.value));
741
- }
742
735
  if (action === "extension-ui/respond" && req.method === "POST") {
743
736
  const body = await readJson(req);
744
737
  return json(sessions.respondToExtensionUi(sessionId, {
@@ -462,9 +462,6 @@ class RigPiSessionService {
462
462
  await this.prompt(sessionId, trimmed, active.runtime.session.isStreaming ? "steer" : undefined);
463
463
  return { type: "done", message: `Accepted ${trimmed}` };
464
464
  }
465
- respondToCommand(_sessionId, _requestId, _value) {
466
- return { type: "unsupported", message: "No pending command selection is active." };
467
- }
468
465
  respondToExtensionUi(sessionId, input) {
469
466
  const active = this.requireActive(sessionId);
470
467
  return { accepted: active.ui.respond(input) };
package/dist/src/index.js CHANGED
@@ -624,17 +624,25 @@ async function waitForServerHealthy(baseUrl, authToken, timeoutMs) {
624
624
  }
625
625
  return false;
626
626
  }
627
- function resolveRigServerSpawnPlan(projectRoot, host, authToken, which = (command) => Bun.which(command)) {
627
+ function resolveRigServerCommand(projectRoot, which = (command) => Bun.which(command)) {
628
628
  const binary = process.env.RIG_SERVER_BIN?.trim() || which("rig-server")?.trim();
629
- const args = ["start", "--host", host, "--port", "0", "--auth-token", authToken];
630
629
  if (binary) {
631
- return { command: binary, args, cwd: projectRoot };
630
+ return { command: binary, commandArgs: [], cwd: projectRoot };
632
631
  }
633
- return {
634
- command: "bun",
635
- args: ["run", "packages/server/src/server.ts", ...args],
636
- cwd: resolve5(import.meta.dir, "../../..")
637
- };
632
+ const workspaceEntry = resolve5(import.meta.dir, "../../..", "packages/server/src/server.ts");
633
+ if (existsSync4(workspaceEntry)) {
634
+ return { command: "bun", commandArgs: ["run", workspaceEntry], cwd: resolve5(import.meta.dir, "../../..") };
635
+ }
636
+ try {
637
+ const installedEntry = Bun.resolveSync("@rig/server/src/server.ts", projectRoot);
638
+ return { command: "bun", commandArgs: ["run", installedEntry], cwd: projectRoot };
639
+ } catch {}
640
+ return { command: "bun", commandArgs: ["run", workspaceEntry], cwd: resolve5(import.meta.dir, "../../..") };
641
+ }
642
+ function resolveRigServerSpawnPlan(projectRoot, host, authToken, which = (command) => Bun.which(command)) {
643
+ const resolved = resolveRigServerCommand(projectRoot, which);
644
+ const args = ["start", "--host", host, "--port", "0", "--auth-token", authToken];
645
+ return { command: resolved.command, args: [...resolved.commandArgs, ...args], cwd: resolved.cwd };
638
646
  }
639
647
  async function waitForPublishedServer(projectRoot, authToken, timeoutMs) {
640
648
  const deadline = Date.now() + timeoutMs;
@@ -134,17 +134,25 @@ async function waitForServerHealthy(baseUrl, authToken, timeoutMs) {
134
134
  }
135
135
  return false;
136
136
  }
137
- function resolveRigServerSpawnPlan(projectRoot, host, authToken, which = (command) => Bun.which(command)) {
137
+ function resolveRigServerCommand(projectRoot, which = (command) => Bun.which(command)) {
138
138
  const binary = process.env.RIG_SERVER_BIN?.trim() || which("rig-server")?.trim();
139
- const args = ["start", "--host", host, "--port", "0", "--auth-token", authToken];
140
139
  if (binary) {
141
- return { command: binary, args, cwd: projectRoot };
140
+ return { command: binary, commandArgs: [], cwd: projectRoot };
142
141
  }
143
- return {
144
- command: "bun",
145
- args: ["run", "packages/server/src/server.ts", ...args],
146
- cwd: resolve2(import.meta.dir, "../../..")
147
- };
142
+ const workspaceEntry = resolve2(import.meta.dir, "../../..", "packages/server/src/server.ts");
143
+ if (existsSync2(workspaceEntry)) {
144
+ return { command: "bun", commandArgs: ["run", workspaceEntry], cwd: resolve2(import.meta.dir, "../../..") };
145
+ }
146
+ try {
147
+ const installedEntry = Bun.resolveSync("@rig/server/src/server.ts", projectRoot);
148
+ return { command: "bun", commandArgs: ["run", installedEntry], cwd: projectRoot };
149
+ } catch {}
150
+ return { command: "bun", commandArgs: ["run", workspaceEntry], cwd: resolve2(import.meta.dir, "../../..") };
151
+ }
152
+ function resolveRigServerSpawnPlan(projectRoot, host, authToken, which = (command) => Bun.which(command)) {
153
+ const resolved = resolveRigServerCommand(projectRoot, which);
154
+ const args = ["start", "--host", host, "--port", "0", "--auth-token", authToken];
155
+ return { command: resolved.command, args: [...resolved.commandArgs, ...args], cwd: resolved.cwd };
148
156
  }
149
157
  async function waitForPublishedServer(projectRoot, authToken, timeoutMs) {
150
158
  const deadline = Date.now() + timeoutMs;
@@ -201,6 +209,7 @@ var __testOnly = {
201
209
  resolveRigServerSpawnPlan
202
210
  };
203
211
  export {
212
+ resolveRigServerCommand,
204
213
  readPublishedRigServerStateSync,
205
214
  readPublishedRigServerState,
206
215
  ensureLocalRigServerConnection,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/runtime",
3
- "version": "0.0.6-alpha.35",
3
+ "version": "0.0.6-alpha.37",
4
4
  "type": "module",
5
5
  "description": "Rig package",
6
6
  "license": "UNLICENSED",
@@ -63,14 +63,14 @@
63
63
  "main": "./dist/src/index.js",
64
64
  "module": "./dist/src/index.js",
65
65
  "dependencies": {
66
- "@earendil-works/pi-coding-agent": "npm:@h-rig/pi-coding-agent@0.0.6-alpha.35",
66
+ "@earendil-works/pi-coding-agent": "npm:@h-rig/pi-coding-agent@0.0.6-alpha.37",
67
67
  "@libsql/client": "^0.17.2",
68
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.35",
69
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.35",
70
- "@rig/hook-kit": "npm:@h-rig/hook-kit@0.0.6-alpha.35",
71
- "@rig/shared": "npm:@h-rig/shared@0.0.6-alpha.35",
72
- "@rig/skill-loader": "npm:@h-rig/skill-loader@0.0.6-alpha.35",
73
- "@rig/validator-kit": "npm:@h-rig/validator-kit@0.0.6-alpha.35",
68
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.37",
69
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.37",
70
+ "@rig/hook-kit": "npm:@h-rig/hook-kit@0.0.6-alpha.37",
71
+ "@rig/shared": "npm:@h-rig/shared@0.0.6-alpha.37",
72
+ "@rig/skill-loader": "npm:@h-rig/skill-loader@0.0.6-alpha.37",
73
+ "@rig/validator-kit": "npm:@h-rig/validator-kit@0.0.6-alpha.37",
74
74
  "effect": "4.0.0-beta.78",
75
75
  "smol-toml": "^1.6.0"
76
76
  }