@link-assistant/hive-mind 0.51.7 ā 0.51.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 +8 -0
- package/package.json +1 -1
- package/src/solve.results.lib.mjs +62 -51
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @link-assistant/hive-mind
|
|
2
2
|
|
|
3
|
+
## 0.51.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- de72c12: fix: ensure log attachment works when PR is merged during session
|
|
8
|
+
|
|
9
|
+
Fixes issue where log files would not be attached to pull requests when the PR was merged during the AI solving session. The `gh pr list` command only returns OPEN PRs by default, causing merged PRs to not be found. Added `--state all` flag to find PRs regardless of their state (OPEN, MERGED, or CLOSED), and added handling to skip operations that don't work on merged PRs (like `gh pr edit` and `gh pr ready`) while still allowing log attachment.
|
|
10
|
+
|
|
3
11
|
## 0.51.7
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -417,7 +417,9 @@ export const verifyResults = async (owner, repo, branchName, issueNumber, prNumb
|
|
|
417
417
|
await log('\nš Checking for pull requests from branch ' + branchName + '...');
|
|
418
418
|
|
|
419
419
|
// First, get all PRs from our branch
|
|
420
|
-
|
|
420
|
+
// IMPORTANT: Use --state all to find PRs that may have been merged during the session (Issue #1008)
|
|
421
|
+
// Without --state all, gh pr list only returns OPEN PRs, missing merged ones
|
|
422
|
+
const allBranchPrsResult = await $`gh pr list --repo ${owner}/${repo} --head ${branchName} --state all --json number,url,createdAt,headRefName,title,state,updatedAt,isDraft`;
|
|
421
423
|
|
|
422
424
|
if (allBranchPrsResult.code !== 0) {
|
|
423
425
|
await log(' ā ļø Failed to check pull requests');
|
|
@@ -438,63 +440,72 @@ export const verifyResults = async (owner, repo, branchName, issueNumber, prNumb
|
|
|
438
440
|
if (isPrFromSession) {
|
|
439
441
|
await log(` ā
Found pull request #${pr.number}: "${pr.title}"`);
|
|
440
442
|
|
|
441
|
-
// Check if PR
|
|
442
|
-
const
|
|
443
|
-
if (
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
// Use the new GitHub linking detection library to check for valid keywords
|
|
448
|
-
// This ensures we only detect actual GitHub-recognized linking keywords
|
|
449
|
-
// (fixes, closes, resolves and their variants) in proper format
|
|
450
|
-
// See: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
|
|
451
|
-
const hasLinkingKeyword = hasGitHubLinkingKeyword(prBody, issueNumber, argv.fork ? owner : null, argv.fork ? repo : null);
|
|
452
|
-
|
|
453
|
-
if (!hasLinkingKeyword) {
|
|
454
|
-
await log(` š Updating PR body to link issue #${issueNumber}...`);
|
|
455
|
-
|
|
456
|
-
// Add proper issue reference to the PR body
|
|
457
|
-
const linkingText = `\n\nFixes ${issueRef}`;
|
|
458
|
-
const updatedBody = prBody + linkingText;
|
|
459
|
-
|
|
460
|
-
// Use --body-file instead of --body to avoid command-line length limits
|
|
461
|
-
// and special character escaping issues that can cause hangs/timeouts
|
|
462
|
-
const fs = (await use('fs')).promises;
|
|
463
|
-
const tempBodyFile = `/tmp/pr-body-update-${pr.number}-${Date.now()}.md`;
|
|
464
|
-
await fs.writeFile(tempBodyFile, updatedBody);
|
|
465
|
-
|
|
466
|
-
try {
|
|
467
|
-
const updateResult = await $`gh pr edit ${pr.number} --repo ${owner}/${repo} --body-file "${tempBodyFile}"`;
|
|
468
|
-
|
|
469
|
-
// Clean up temp file
|
|
470
|
-
await fs.unlink(tempBodyFile).catch(() => {});
|
|
443
|
+
// Check if PR was merged during the session (Issue #1008)
|
|
444
|
+
const isPrMerged = pr.state === 'MERGED';
|
|
445
|
+
if (isPrMerged) {
|
|
446
|
+
await log(` ā¹ļø PR #${pr.number} was merged during the session`);
|
|
447
|
+
}
|
|
471
448
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
449
|
+
// Skip PR body update and ready conversion for merged PRs (they can't be edited)
|
|
450
|
+
if (!isPrMerged) {
|
|
451
|
+
// Check if PR body has proper issue linking keywords
|
|
452
|
+
const prBodyResult = await $`gh pr view ${pr.number} --repo ${owner}/${repo} --json body --jq .body`;
|
|
453
|
+
if (prBodyResult.code === 0) {
|
|
454
|
+
const prBody = prBodyResult.stdout.toString();
|
|
455
|
+
const issueRef = argv.fork ? `${owner}/${repo}#${issueNumber}` : `#${issueNumber}`;
|
|
456
|
+
|
|
457
|
+
// Use the new GitHub linking detection library to check for valid keywords
|
|
458
|
+
// This ensures we only detect actual GitHub-recognized linking keywords
|
|
459
|
+
// (fixes, closes, resolves and their variants) in proper format
|
|
460
|
+
// See: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
|
|
461
|
+
const hasLinkingKeyword = hasGitHubLinkingKeyword(prBody, issueNumber, argv.fork ? owner : null, argv.fork ? repo : null);
|
|
462
|
+
|
|
463
|
+
if (!hasLinkingKeyword) {
|
|
464
|
+
await log(` š Updating PR body to link issue #${issueNumber}...`);
|
|
465
|
+
|
|
466
|
+
// Add proper issue reference to the PR body
|
|
467
|
+
const linkingText = `\n\nFixes ${issueRef}`;
|
|
468
|
+
const updatedBody = prBody + linkingText;
|
|
469
|
+
|
|
470
|
+
// Use --body-file instead of --body to avoid command-line length limits
|
|
471
|
+
// and special character escaping issues that can cause hangs/timeouts
|
|
472
|
+
const fs = (await use('fs')).promises;
|
|
473
|
+
const tempBodyFile = `/tmp/pr-body-update-${pr.number}-${Date.now()}.md`;
|
|
474
|
+
await fs.writeFile(tempBodyFile, updatedBody);
|
|
475
|
+
|
|
476
|
+
try {
|
|
477
|
+
const updateResult = await $`gh pr edit ${pr.number} --repo ${owner}/${repo} --body-file "${tempBodyFile}"`;
|
|
478
|
+
|
|
479
|
+
// Clean up temp file
|
|
480
|
+
await fs.unlink(tempBodyFile).catch(() => {});
|
|
481
|
+
|
|
482
|
+
if (updateResult.code === 0) {
|
|
483
|
+
await log(` ā
Updated PR body to include "Fixes ${issueRef}"`);
|
|
484
|
+
} else {
|
|
485
|
+
await log(` ā ļø Could not update PR body: ${updateResult.stderr ? updateResult.stderr.toString().trim() : 'Unknown error'}`);
|
|
486
|
+
}
|
|
487
|
+
} catch (updateError) {
|
|
488
|
+
// Clean up temp file on error
|
|
489
|
+
await fs.unlink(tempBodyFile).catch(() => {});
|
|
490
|
+
throw updateError;
|
|
476
491
|
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
await fs.unlink(tempBodyFile).catch(() => {});
|
|
480
|
-
throw updateError;
|
|
492
|
+
} else {
|
|
493
|
+
await log(' ā
PR body already contains issue reference');
|
|
481
494
|
}
|
|
482
|
-
} else {
|
|
483
|
-
await log(' ā
PR body already contains issue reference');
|
|
484
495
|
}
|
|
485
|
-
}
|
|
486
496
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
497
|
+
// Check if PR is ready for review (convert from draft if necessary)
|
|
498
|
+
if (pr.isDraft) {
|
|
499
|
+
await log(' š Converting PR from draft to ready for review...');
|
|
500
|
+
const readyResult = await $`gh pr ready ${pr.number} --repo ${owner}/${repo}`;
|
|
501
|
+
if (readyResult.code === 0) {
|
|
502
|
+
await log(' ā
PR converted to ready for review');
|
|
503
|
+
} else {
|
|
504
|
+
await log(` ā ļø Could not convert PR to ready (${readyResult.stderr ? readyResult.stderr.toString().trim() : 'unknown error'})`);
|
|
505
|
+
}
|
|
493
506
|
} else {
|
|
494
|
-
await log(
|
|
507
|
+
await log(' ā
PR is already ready for review', { verbose: true });
|
|
495
508
|
}
|
|
496
|
-
} else {
|
|
497
|
-
await log(' ā
PR is already ready for review', { verbose: true });
|
|
498
509
|
}
|
|
499
510
|
|
|
500
511
|
// Upload log file to PR if requested
|