@link-assistant/hive-mind 1.69.8 → 1.69.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,11 @@
1
1
  # @link-assistant/hive-mind
2
2
 
3
+ ## 1.69.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 9d04a2f: Detect empty repositories before branch creation when Git reports an unborn branch name.
8
+
3
9
  ## 1.69.8
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/hive-mind",
3
- "version": "1.69.8",
3
+ "version": "1.69.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",
@@ -71,12 +71,10 @@ export async function verifyDefaultBranchAndStatus({ tempDir, log, formatAligned
71
71
  }
72
72
 
73
73
  let defaultBranch = defaultBranchResult.stdout.toString().trim();
74
- if (!defaultBranch) {
75
- // Repository is likely empty (no commits) - detect and handle
76
- const isEmptyRepo = await detectEmptyRepository(tempDir, $);
74
+ const isEmptyRepo = await detectEmptyRepository(tempDir, $);
77
75
 
78
- if (isEmptyRepo && argv && argv.autoInitRepository && owner && repo) {
79
- // --auto-init-repository is enabled, try to initialize
76
+ if (isEmptyRepo) {
77
+ if (argv && argv.autoInitRepository && owner && repo) {
80
78
  await log('');
81
79
  await log(`${formatAligned('⚠️', 'EMPTY REPOSITORY', 'detected')}`, { level: 'warn' });
82
80
  await log(`${formatAligned('', '', `Repository ${owner}/${repo} contains no commits`)}`);
@@ -126,7 +124,6 @@ export async function verifyDefaultBranchAndStatus({ tempDir, log, formatAligned
126
124
  await log(`${formatAligned('✅', 'Repository initialized:', `Now on branch ${defaultBranch}`)}`);
127
125
  await log(`\n${formatAligned('📌', 'Default branch:', defaultBranch)}`);
128
126
  } else {
129
- // Auto-init failed - provide helpful message with --auto-init-repository context
130
127
  await log('');
131
128
  await log(`${formatAligned('❌', 'AUTO-INIT FAILED', '')}`, { level: 'error' });
132
129
  await log('');
@@ -149,8 +146,7 @@ export async function verifyDefaultBranchAndStatus({ tempDir, log, formatAligned
149
146
 
150
147
  throw new Error('Empty repository auto-initialization failed');
151
148
  }
152
- } else if (isEmptyRepo) {
153
- // Empty repo detected but --auto-init-repository is not enabled
149
+ } else {
154
150
  await log('');
155
151
  await log(`${formatAligned('❌', 'EMPTY REPOSITORY DETECTED', '')}`, { level: 'error' });
156
152
  await log('');
@@ -170,25 +166,24 @@ export async function verifyDefaultBranchAndStatus({ tempDir, log, formatAligned
170
166
  await tryCommentOnIssueAboutEmptyRepo({ issueUrl, owner, repo, log, formatAligned, $ });
171
167
 
172
168
  throw new Error('Empty repository detected - use --auto-init-repository to initialize');
173
- } else {
174
- // Not an empty repo, some other issue with branch detection
175
- await log('');
176
- await log(`${formatAligned('❌', 'DEFAULT BRANCH DETECTION FAILED', '')}`, { level: 'error' });
177
- await log('');
178
- await log(' 🔍 What happened:');
179
- await log(" Unable to determine the repository's default branch.");
180
- await log('');
181
- await log(' 💡 This might mean:');
182
- await log(' • Unusual repository configuration');
183
- await log(' • Git command issues');
184
- await log('');
185
- await log(' 🔧 How to fix:');
186
- await log(' 1. Check repository status');
187
- await log(` 2. Verify locally: cd ${tempDir} && git branch`);
188
- await log(` 3. Check remote: cd ${tempDir} && git branch -r`);
189
- await log('');
190
- throw new Error('Default branch detection failed');
191
169
  }
170
+ } else if (!defaultBranch) {
171
+ await log('');
172
+ await log(`${formatAligned('❌', 'DEFAULT BRANCH DETECTION FAILED', '')}`, { level: 'error' });
173
+ await log('');
174
+ await log(' 🔍 What happened:');
175
+ await log(" Unable to determine the repository's default branch.");
176
+ await log('');
177
+ await log(' 💡 This might mean:');
178
+ await log(' • Unusual repository configuration');
179
+ await log(' • Git command issues');
180
+ await log('');
181
+ await log(' 🔧 How to fix:');
182
+ await log(' 1. Check repository status');
183
+ await log(` 2. Verify locally: cd ${tempDir} && git branch`);
184
+ await log(` 3. Check remote: cd ${tempDir} && git branch -r`);
185
+ await log('');
186
+ throw new Error('Default branch detection failed');
192
187
  } else {
193
188
  await log(`\n${formatAligned('📌', 'Default branch:', defaultBranch)}`);
194
189
  }
@@ -267,16 +262,19 @@ Thank you!`;
267
262
  */
268
263
  async function detectEmptyRepository(tempDir, $) {
269
264
  // Check if there are any commits in the repository
270
- const logResult = await $({ cwd: tempDir })`git rev-parse HEAD 2>&1`;
271
- if (logResult.code !== 0) {
272
- // git rev-parse HEAD fails when there are no commits
273
- const output = (logResult.stdout || logResult.stderr || '').toString();
274
- if (output.includes('unknown revision') || output.includes('bad default revision') || output.includes('does not have any commits')) {
275
- return true;
276
- }
265
+ const logResult = await $({ cwd: tempDir })`git rev-parse --verify HEAD 2>&1`;
266
+ if (logResult.code === 0) {
267
+ return false;
268
+ }
269
+
270
+ // git rev-parse HEAD fails when there are no commits
271
+ const output = (logResult.stdout || logResult.stderr || '').toString();
272
+ if (output.includes('unknown revision') || output.includes('ambiguous argument') || output.includes('bad default revision') || output.includes('does not have any commits') || output.includes('Needed a single revision')) {
273
+ return true;
277
274
  }
278
275
 
279
- // Also check if there are any remote branches
276
+ // Fall back to remote branch absence for Git versions with different
277
+ // no-commit messages, but only after HEAD lookup failed.
280
278
  const remoteBranchResult = await $({ cwd: tempDir })`git branch -r`;
281
279
  if (remoteBranchResult.code === 0) {
282
280
  const branches = remoteBranchResult.stdout.toString().trim();