@link-assistant/hive-mind 1.2.8 → 1.2.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @link-assistant/hive-mind
2
2
 
3
+ ## 1.2.9
4
+
5
+ ### Patch Changes
6
+
7
+ - b5e047a: Fix branch checkout error showing null/null instead of actual repository URL
8
+ - Pass owner/repo/prNumber to branch error handlers for accurate error messages
9
+ - Add upstream remote fallback when PR branch not found in origin (handles bot PRs)
10
+ - Add case study documentation for issue #1120
11
+
3
12
  ## 1.2.8
4
13
 
5
14
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/hive-mind",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "AI-powered issue solver and hive mind for collaborative problem solving",
5
5
  "main": "src/hive.mjs",
6
6
  "type": "module",
@@ -100,7 +100,7 @@ export function detectBranchFormat(branchName) {
100
100
  return null;
101
101
  }
102
102
 
103
- export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNumber, tempDir, defaultBranch, argv, log, formatAligned, $, crypto }) {
103
+ export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNumber, tempDir, defaultBranch, argv, log, formatAligned, $, crypto, owner, repo, prNumber }) {
104
104
  // Create a branch for the issue or checkout existing PR branch
105
105
  let branchName;
106
106
  let checkoutResult;
@@ -136,11 +136,11 @@ export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNu
136
136
  const { handleBranchCheckoutError } = branchErrors;
137
137
  await handleBranchCheckoutError({
138
138
  branchName,
139
- prNumber: null, // Will be set later
139
+ prNumber,
140
140
  errorOutput,
141
141
  issueUrl: argv['issue-url'] || argv._[0],
142
- owner: null, // Will be set later
143
- repo: null, // Will be set later
142
+ owner,
143
+ repo,
144
144
  tempDir,
145
145
  argv,
146
146
  formatAligned,
@@ -154,8 +154,8 @@ export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNu
154
154
  branchName,
155
155
  errorOutput,
156
156
  tempDir,
157
- owner: null, // Will be set later
158
- repo: null, // Will be set later
157
+ owner,
158
+ repo,
159
159
  formatAligned,
160
160
  log,
161
161
  });
@@ -193,9 +193,9 @@ export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNu
193
193
  isContinueMode,
194
194
  branchName,
195
195
  actualBranch,
196
- prNumber: null, // Will be set later
197
- owner: null, // Will be set later
198
- repo: null, // Will be set later
196
+ prNumber,
197
+ owner,
198
+ repo,
199
199
  tempDir,
200
200
  formatAligned,
201
201
  log,
package/src/solve.mjs CHANGED
@@ -553,6 +553,9 @@ try {
553
553
  formatAligned,
554
554
  $,
555
555
  crypto,
556
+ owner,
557
+ repo,
558
+ prNumber,
556
559
  });
557
560
 
558
561
  // Auto-merge default branch to pull request branch if enabled
@@ -1208,6 +1208,41 @@ export const checkoutPrBranch = async (tempDir, branchName, prForkRemote, prFork
1208
1208
  } else {
1209
1209
  // Branch doesn't exist locally, try to checkout from remote
1210
1210
  checkoutResult = await $({ cwd: tempDir })`git checkout -b ${branchName} ${remoteName}/${branchName}`;
1211
+
1212
+ // If checkout from origin failed, try upstream remote as fallback
1213
+ // This handles the case where we're in fork mode but the PR branch exists in upstream
1214
+ // (e.g., a bot created PR in the upstream repo, not a fork PR)
1215
+ if (checkoutResult.code !== 0 && remoteName === 'origin') {
1216
+ await log(`${formatAligned('🔄', 'Branch not in origin:', 'Checking upstream remote...')}`);
1217
+
1218
+ // Check if upstream remote exists
1219
+ const upstreamCheckResult = await $({ cwd: tempDir })`git remote get-url upstream 2>/dev/null`;
1220
+ if (upstreamCheckResult.code === 0) {
1221
+ // Fetch from upstream to ensure we have the latest branches
1222
+ await log(`${formatAligned('đŸ“Ĩ', 'Fetching from upstream:', 'Looking for PR branch...')}`);
1223
+ const fetchUpstreamResult = await $({ cwd: tempDir })`git fetch upstream`;
1224
+
1225
+ if (fetchUpstreamResult.code === 0) {
1226
+ // Check if branch exists in upstream
1227
+ const upstreamBranchCheckResult = await $({ cwd: tempDir })`git show-ref --verify --quiet refs/remotes/upstream/${branchName}`;
1228
+
1229
+ if (upstreamBranchCheckResult.code === 0) {
1230
+ await log(`${formatAligned('✅', 'Found branch in upstream:', `upstream/${branchName}`)}`);
1231
+ // Try to checkout from upstream instead
1232
+ checkoutResult = await $({ cwd: tempDir })`git checkout -b ${branchName} upstream/${branchName}`;
1233
+
1234
+ if (checkoutResult.code === 0) {
1235
+ await log(`${formatAligned('â„šī¸', 'Note:', 'PR branch was in upstream repository, not your fork')}`);
1236
+ await log(`${formatAligned('', '', 'This can happen when a bot creates a PR directly in the main repository')}`);
1237
+ }
1238
+ } else {
1239
+ await log(`${formatAligned('âš ī¸', 'Branch not found:', `Not in origin or upstream remotes`)}`, { level: 'warning' });
1240
+ }
1241
+ } else {
1242
+ await log(`${formatAligned('âš ī¸', 'Warning:', 'Failed to fetch from upstream')}`, { level: 'warning' });
1243
+ }
1244
+ }
1245
+ }
1211
1246
  }
1212
1247
 
1213
1248
  return checkoutResult;