@neriros/ralphy 2.20.0 → 2.20.1

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 (2) hide show
  1. package/dist/cli/index.js +83 -57
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -35029,8 +35029,8 @@ import { readFileSync as readFileSync2 } from "fs";
35029
35029
  import { resolve } from "path";
35030
35030
  function getVersion() {
35031
35031
  try {
35032
- if ("2.20.0")
35033
- return "2.20.0";
35032
+ if ("2.20.1")
35033
+ return "2.20.1";
35034
35034
  } catch {}
35035
35035
  const dirsToTry = [];
35036
35036
  try {
@@ -61356,7 +61356,8 @@ function buildAgentCoordinator(input) {
61356
61356
  const branchByChange = new Map;
61357
61357
  const issueByChange = new Map;
61358
61358
  const prByChange = new Map;
61359
- const prUnavailable = new Set;
61359
+ const prUnavailable = new Map;
61360
+ const PR_UNAVAILABLE_TTL_MS = 10 * 60 * 1000;
61360
61361
  const stalePingedAt = new Map;
61361
61362
  const useWorktree = args.worktree || cfg.useWorktree;
61362
61363
  const scriptRunner = input.runners?.runScript ?? (async (cmd, cwd2) => {
@@ -61680,44 +61681,90 @@ PR: ${prUrl}` : ""
61680
61681
  }
61681
61682
  async function checkPrConflict(issue) {
61682
61683
  const changeName = changeNameForIssue(issue);
61683
- if (prUnavailable.has(changeName))
61684
+ if (isPrUnavailable(changeName))
61684
61685
  return null;
61685
- const branch = branchForChange(changeName);
61686
61686
  let prUrl = prByChange.get(changeName);
61687
61687
  if (!prUrl) {
61688
+ const found = await discoverPrUrl(issue, changeName);
61689
+ if (!found)
61690
+ return null;
61691
+ prUrl = found;
61692
+ prByChange.set(changeName, prUrl);
61693
+ }
61694
+ for (let attempt2 = 0;attempt2 < 3; attempt2++) {
61688
61695
  try {
61689
- const res = await cmdRunner.run([
61690
- "gh",
61691
- "pr",
61692
- "list",
61693
- "--head",
61694
- branch,
61695
- "--state",
61696
- "open",
61697
- "--json",
61698
- "url",
61699
- "--jq",
61700
- ".[0].url // empty"
61701
- ], projectRoot);
61702
- const found = res.stdout.trim();
61703
- if (!found) {
61704
- prUnavailable.add(changeName);
61705
- return null;
61696
+ const res = await cmdRunner.run(["gh", "pr", "view", prUrl, "--json", "mergeable", "--jq", ".mergeable"], projectRoot);
61697
+ const mergeable = res.stdout.trim();
61698
+ if (mergeable !== "UNKNOWN") {
61699
+ return { url: prUrl, conflicting: mergeable === "CONFLICTING" };
61706
61700
  }
61707
- prUrl = found;
61708
- prByChange.set(changeName, prUrl);
61709
- } catch {
61710
- prUnavailable.add(changeName);
61701
+ } catch (err) {
61702
+ onLog(`! gh pr view ${prUrl} failed (conflict scan): ${err.message}`, "yellow");
61711
61703
  return null;
61712
61704
  }
61705
+ await new Promise((r) => setTimeout(r, 2000));
61713
61706
  }
61714
- try {
61715
- const res = await cmdRunner.run(["gh", "pr", "view", prUrl, "--json", "mergeable", "--jq", ".mergeable"], projectRoot);
61716
- const mergeable = res.stdout.trim();
61717
- return { url: prUrl, conflicting: mergeable === "CONFLICTING" };
61718
- } catch {
61719
- return null;
61707
+ onLog(` ${issue.identifier}: mergeability still UNKNOWN after retries (${prUrl}) \u2014 will recheck next poll`, "gray");
61708
+ return null;
61709
+ }
61710
+ function isPrUnavailable(changeName) {
61711
+ const expiry = prUnavailable.get(changeName);
61712
+ if (expiry === undefined)
61713
+ return false;
61714
+ if (Date.now() >= expiry) {
61715
+ prUnavailable.delete(changeName);
61716
+ return false;
61720
61717
  }
61718
+ return true;
61719
+ }
61720
+ function markPrUnavailable(changeName) {
61721
+ prUnavailable.set(changeName, Date.now() + PR_UNAVAILABLE_TTL_MS);
61722
+ }
61723
+ async function discoverPrUrl(issue, changeName) {
61724
+ const branch = branchForChange(changeName);
61725
+ const tryGh = async (args2) => {
61726
+ try {
61727
+ const res = await cmdRunner.run(args2, projectRoot);
61728
+ const found = res.stdout.trim();
61729
+ return found || null;
61730
+ } catch (err) {
61731
+ onLog(`! gh ${args2[1] ?? ""} failed for ${issue.identifier}: ${err.message}`, "yellow");
61732
+ return null;
61733
+ }
61734
+ };
61735
+ const byBranch = await tryGh([
61736
+ "gh",
61737
+ "pr",
61738
+ "list",
61739
+ "--head",
61740
+ branch,
61741
+ "--state",
61742
+ "open",
61743
+ "--json",
61744
+ "url",
61745
+ "--jq",
61746
+ ".[0].url // empty"
61747
+ ]);
61748
+ if (byBranch)
61749
+ return byBranch;
61750
+ const byIdentifier = await tryGh([
61751
+ "gh",
61752
+ "pr",
61753
+ "list",
61754
+ "--search",
61755
+ `${issue.identifier} in:title state:open`,
61756
+ "--json",
61757
+ "url",
61758
+ "--jq",
61759
+ ".[0].url // empty"
61760
+ ]);
61761
+ if (byIdentifier) {
61762
+ onLog(` ${issue.identifier}: PR discovered via title search (${byIdentifier})`, "gray");
61763
+ return byIdentifier;
61764
+ }
61765
+ onLog(` ${issue.identifier}: no open PR found on head=${branch} or title-search; conflict scan skipped for ${PR_UNAVAILABLE_TTL_MS / 60000}m`, "gray");
61766
+ markPrUnavailable(changeName);
61767
+ return null;
61721
61768
  }
61722
61769
  async function fetchDoneCandidates() {
61723
61770
  if (!indicators.setDone)
@@ -61953,36 +62000,15 @@ PR: ${prUrl}` : ""
61953
62000
  }
61954
62001
  async function resolvePrUrlForIssue(issue) {
61955
62002
  const changeName = changeNameForIssue(issue);
61956
- if (prUnavailable.has(changeName))
62003
+ if (isPrUnavailable(changeName))
61957
62004
  return null;
61958
62005
  const cached = prByChange.get(changeName);
61959
62006
  if (cached)
61960
62007
  return cached;
61961
- const branch = branchForChange(changeName);
61962
- try {
61963
- const res = await cmdRunner.run([
61964
- "gh",
61965
- "pr",
61966
- "list",
61967
- "--head",
61968
- branch,
61969
- "--state",
61970
- "all",
61971
- "--json",
61972
- "url",
61973
- "--jq",
61974
- ".[0].url // empty"
61975
- ], projectRoot);
61976
- const found = res.stdout.trim();
61977
- if (!found) {
61978
- prUnavailable.add(changeName);
61979
- return null;
61980
- }
62008
+ const found = await discoverPrUrl(issue, changeName);
62009
+ if (found)
61981
62010
  prByChange.set(changeName, found);
61982
- return found;
61983
- } catch {
61984
- return null;
61985
- }
62011
+ return found;
61986
62012
  }
61987
62013
  async function fetchPrIssueComments(prUrl) {
61988
62014
  const m = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/.exec(prUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neriros/ralphy",
3
- "version": "2.20.0",
3
+ "version": "2.20.1",
4
4
  "description": "An iterative AI task execution framework. Orchestrates multi-phase autonomous work using Claude or Codex engines.",
5
5
  "keywords": [
6
6
  "agent",