@link-assistant/hive-mind 2.11.11 → 2.11.13
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 +80 -0
- package/package.json +1 -1
- package/src/agent.lib.mjs +119 -20
- package/src/automation-stop-reporting.lib.mjs +272 -0
- package/src/cancelled-ci-rerun.lib.mjs +3 -1
- package/src/claude.lib.mjs +3 -2
- package/src/codex.lib.mjs +13 -12
- package/src/error-text.lib.mjs +130 -0
- package/src/gemini.lib.mjs +3 -1
- package/src/github-terminal-state.lib.mjs +50 -13
- package/src/interactive-codex-events.lib.mjs +4 -1
- package/src/lib.mjs +11 -0
- package/src/qwen.lib.mjs +1 -12
- package/src/solve.auto-merge-attempt.lib.mjs +245 -0
- package/src/solve.auto-merge.lib.mjs +54 -111
- package/src/solve.pre-pr-failure-notifier.lib.mjs +10 -2
- package/src/solve.watch.lib.mjs +35 -1
- package/src/tool-comments.lib.mjs +12 -1
|
@@ -35,7 +35,7 @@ const { reportError } = sentryLib;
|
|
|
35
35
|
|
|
36
36
|
// Import GitHub merge functions
|
|
37
37
|
const githubMergeLib = await import('./github-merge.lib.mjs');
|
|
38
|
-
const {
|
|
38
|
+
const { checkMergePermissions, mergePullRequest, getRepoVisibility, BILLING_LIMIT_ERROR_PATTERN, getDetailedCIStatus, rerunWorkflowRun, getWorkflowRunsForSha, getAllActiveRepoRuns, checkCIConsensus } = githubMergeLib;
|
|
39
39
|
|
|
40
40
|
// Import GitHub functions for log attachment
|
|
41
41
|
const githubLib = await import('./github.lib.mjs');
|
|
@@ -50,6 +50,18 @@ const { checkForUncommittedChanges, getUncommittedChangesDetails, executeToolIte
|
|
|
50
50
|
const terminalStateLib = await import('./github-terminal-state.lib.mjs');
|
|
51
51
|
const { checkGitHubTerminalState } = terminalStateLib;
|
|
52
52
|
|
|
53
|
+
// Issue #2144: these probes answer with a ~33 KB pull request object and a full
|
|
54
|
+
// issue object on every iteration. Issue #2130 made the helper's own default
|
|
55
|
+
// runner quiet, but passing `$` here bypassed it and the payloads were still
|
|
56
|
+
// mirrored into the attached log. Bind the quiet options to the injected `$`.
|
|
57
|
+
const { quietProbe } = await import('./quiet-probe.lib.mjs');
|
|
58
|
+
|
|
59
|
+
// Issue #2144: a closed linked issue is NOT terminal — it only blocks the final
|
|
60
|
+
// automatic merge. Every stop of this loop is also published as a GitHub comment
|
|
61
|
+
// stating exactly why it stopped.
|
|
62
|
+
const stopReportingLib = await import('./automation-stop-reporting.lib.mjs');
|
|
63
|
+
const { reportAutomationStop } = stopReportingLib;
|
|
64
|
+
|
|
53
65
|
// Import validation functions for time parsing (used for usage limit wait)
|
|
54
66
|
const validation = await import('./solve.validation.lib.mjs');
|
|
55
67
|
const { calculateWaitTime } = validation;
|
|
@@ -184,7 +196,7 @@ export const watchUntilMergeable = async params => {
|
|
|
184
196
|
issueNumber,
|
|
185
197
|
prNumber,
|
|
186
198
|
sourceBranchName: prBranch || branchName,
|
|
187
|
-
commandRunner:
|
|
199
|
+
commandRunner: quietProbe($),
|
|
188
200
|
});
|
|
189
201
|
if (terminalState.terminal && terminalState.success) {
|
|
190
202
|
await log('');
|
|
@@ -201,9 +213,20 @@ export const watchUntilMergeable = async params => {
|
|
|
201
213
|
}
|
|
202
214
|
await log(formatAligned('', 'Action:', 'Stopping auto-restart-until-mergeable mode', 2), { level: 'error' });
|
|
203
215
|
await log('');
|
|
216
|
+
// Issue #2144: report the stop on GitHub instead of exiting silently.
|
|
217
|
+
await reportAutomationStop({ $, owner, repo, targetNumber: prNumber, reason: terminalState.reason, mode: 'auto-restart-until-mergeable', message: terminalState.message, details: terminalState.details, verbose: argv.verbose, log });
|
|
204
218
|
return { success: false, reason: terminalState.reason, latestSessionId, latestAnthropicCost };
|
|
205
219
|
}
|
|
206
220
|
|
|
221
|
+
// Issue #2144: issue-scoped problems (closed / deleted linked issue) never
|
|
222
|
+
// stop this loop. They are carried to the merge decision below.
|
|
223
|
+
const issueMergeBlockers = terminalState.mergeBlockers || [];
|
|
224
|
+
if (issueMergeBlockers.length > 0 && iteration === 1) {
|
|
225
|
+
for (const blocker of issueMergeBlockers) {
|
|
226
|
+
await log(formatAligned('⚠️', 'Linked issue:', `${blocker.message} Continuing to make the pull request mergeable.`, 2), { level: 'warning' });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
207
230
|
await log(formatAligned('🔍', `Check #${iteration}:`, currentTime.toLocaleTimeString()));
|
|
208
231
|
|
|
209
232
|
try {
|
|
@@ -243,6 +266,7 @@ export const watchUntilMergeable = async params => {
|
|
|
243
266
|
}
|
|
244
267
|
await log(formatAligned('', 'Action:', 'Stopping auto-restart-until-mergeable mode', 2), { level: 'error' });
|
|
245
268
|
await log('');
|
|
269
|
+
await reportAutomationStop({ $, owner, repo, targetNumber: prNumber, reason: 'terminal_github_entity_error', mode: 'auto-restart-until-mergeable', message: terminalGitHubBlocker.message, details: terminalGitHubBlocker.details, verbose: argv.verbose, log });
|
|
246
270
|
return { success: false, reason: 'terminal_github_entity_error', latestSessionId, latestAnthropicCost };
|
|
247
271
|
}
|
|
248
272
|
|
|
@@ -356,6 +380,15 @@ export const watchUntilMergeable = async params => {
|
|
|
356
380
|
|
|
357
381
|
await log(formatAligned('✅', 'PR IS MERGEABLE!', ''));
|
|
358
382
|
|
|
383
|
+
// Issue #2144: the pull request is ready. A closed/unavailable linked
|
|
384
|
+
// issue blocks only the *automatic* merge — the loop already did its
|
|
385
|
+
// job of making the pull request mergeable. Ask the user to reopen the
|
|
386
|
+
// issue or merge manually instead of merging behind their back.
|
|
387
|
+
if (isAutoMerge && issueMergeBlockers.length > 0) {
|
|
388
|
+
await reportAutoMergeBlockedByIssue({ owner, repo, prNumber, issueNumber, mergeBlockers: issueMergeBlockers, verbose: argv.verbose });
|
|
389
|
+
return { success: false, reason: issueMergeBlockers[0].reason, mergeBlockers: issueMergeBlockers, latestSessionId, latestAnthropicCost };
|
|
390
|
+
}
|
|
391
|
+
|
|
359
392
|
if (isAutoMerge) {
|
|
360
393
|
// Attempt to merge the PR
|
|
361
394
|
await log(formatAligned('🔀', 'Auto-merging PR...', ''));
|
|
@@ -424,7 +457,17 @@ export const watchUntilMergeable = async params => {
|
|
|
424
457
|
} else {
|
|
425
458
|
// Issue #1345: Differentiate message when no CI is configured
|
|
426
459
|
const ciLine = noCiConfigured ? '- No CI/CD checks are configured for this repository' : noCiTriggered ? (workflowRunConclusions ? `- CI workflows completed without executing (${workflowRunConclusions})` : '- CI workflows exist but were not triggered for this commit') : '- All CI checks have passed';
|
|
427
|
-
|
|
460
|
+
// Issue #2144: a closed/unavailable linked issue does not stop this
|
|
461
|
+
// mode, but it is worth stating in the comment so the reader knows
|
|
462
|
+
// why no automatic merge will follow.
|
|
463
|
+
const issueLine =
|
|
464
|
+
issueMergeBlockers.length > 0
|
|
465
|
+
? `\n\nNote: ${issueMergeBlockers.map(b => b.message).join(' ')} ${issueMergeBlockers
|
|
466
|
+
.map(b => b.resolution)
|
|
467
|
+
.filter(Boolean)
|
|
468
|
+
.join(' ')}`
|
|
469
|
+
: '';
|
|
470
|
+
const commentBody = `## ✅ ${READY_TO_MERGE_MARKER}\n\nThis pull request is now ready to be merged:\n${ciLine}\n- No merge conflicts\n- No pending changes${issueLine}\n\n---\n*Monitored by hive-mind with --auto-restart-until-mergeable flag*`;
|
|
428
471
|
// Issue #1625: Track this comment ID so it can't falsely count as an AI-authored comment
|
|
429
472
|
await postTrackedComment({ $, owner, repo, targetNumber: prNumber, body: commentBody });
|
|
430
473
|
readyToMergeCommentPosted = true;
|
|
@@ -838,6 +881,8 @@ Once the billing issue is resolved, you can re-run the CI checks or push a new c
|
|
|
838
881
|
await log(formatAligned('⚠️', 'AUTO-RESUME LIMIT REACHED', `Stopping after ${limitResumeCount} limit-reset continuation${limitResumeCount !== 1 ? 's' : ''}`));
|
|
839
882
|
await log(formatAligned('', 'Configured limit:', formatAutoIterationLimit(maxAutoResumeIterations), 2));
|
|
840
883
|
await log('');
|
|
884
|
+
// Issue #2144: publish why the automation stopped.
|
|
885
|
+
await reportAutomationStop({ $, owner, repo, targetNumber: prNumber, reason: 'auto_resume_limit_reached', mode: 'auto-restart-until-mergeable', message: `Stopped after ${limitResumeCount} usage-limit continuation${limitResumeCount !== 1 ? 's' : ''} (limit: ${formatAutoIterationLimit(maxAutoResumeIterations)}).`, verbose: argv.verbose, log });
|
|
841
886
|
return { success: false, reason: 'auto_resume_limit_reached', latestSessionId, latestAnthropicCost };
|
|
842
887
|
}
|
|
843
888
|
|
|
@@ -991,6 +1036,7 @@ Once the billing issue is resolved, you can re-run the CI checks or push a new c
|
|
|
991
1036
|
await log(formatAligned('', `⚠️ Failure log upload error: ${cleanErrorMessage(logUploadError)}`, '', 2));
|
|
992
1037
|
}
|
|
993
1038
|
}
|
|
1039
|
+
await reportAutomationStop({ $, owner, repo, targetNumber: prNumber, reason: 'tool_failure_after_resume', mode: 'auto-restart-until-mergeable', message: extractToolErrorCore({ toolResult: resumeResult }) || formatToolExecutionFailure({ tool: argv.tool, toolResult: resumeResult }), verbose: argv.verbose, log });
|
|
994
1040
|
return { success: false, reason: 'tool_failure_after_resume', latestSessionId, latestAnthropicCost };
|
|
995
1041
|
}
|
|
996
1042
|
} else {
|
|
@@ -1043,6 +1089,7 @@ Once the billing issue is resolved, you can re-run the CI checks or push a new c
|
|
|
1043
1089
|
await log(formatAligned('', `⚠️ Failure log upload error: ${cleanErrorMessage(logUploadError)}`, '', 2));
|
|
1044
1090
|
}
|
|
1045
1091
|
}
|
|
1092
|
+
await reportAutomationStop({ $, owner, repo, targetNumber: prNumber, reason: 'tool_failure', mode: 'auto-restart-until-mergeable', message: extractToolErrorCore({ toolResult }) || formatToolExecutionFailure({ tool: argv.tool, toolResult }), verbose: argv.verbose, log });
|
|
1046
1093
|
return { success: false, reason: 'tool_failure', latestSessionId, latestAnthropicCost };
|
|
1047
1094
|
} else {
|
|
1048
1095
|
// Success - capture latest session data
|
|
@@ -1279,114 +1326,10 @@ Once the billing issue is resolved, you can re-run the CI checks or push a new c
|
|
|
1279
1326
|
}
|
|
1280
1327
|
};
|
|
1281
1328
|
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
export const attemptAutoMerge = async params => {
|
|
1287
|
-
const { owner, repo, prNumber, issueNumber = null, argv } = params;
|
|
1288
|
-
|
|
1289
|
-
await log('');
|
|
1290
|
-
await log(formatAligned('🔀', 'AUTO-MERGE:', 'Checking if PR can be merged...'));
|
|
1291
|
-
|
|
1292
|
-
const terminalState = await checkGitHubTerminalState({
|
|
1293
|
-
owner,
|
|
1294
|
-
repo,
|
|
1295
|
-
issueNumber,
|
|
1296
|
-
prNumber,
|
|
1297
|
-
commandRunner: $,
|
|
1298
|
-
});
|
|
1299
|
-
if (terminalState.terminal) {
|
|
1300
|
-
if (terminalState.success) {
|
|
1301
|
-
await log(formatAligned('🎉', 'PR already merged:', `#${prNumber}`, 2));
|
|
1302
|
-
return { success: true, reason: 'merged' };
|
|
1303
|
-
}
|
|
1304
|
-
await log(formatAligned('❌', 'GITHUB TARGET UNAVAILABLE:', terminalState.message, 2), { level: 'error' });
|
|
1305
|
-
for (const detail of terminalState.details || []) {
|
|
1306
|
-
await log(formatAligned('', 'Detail:', detail, 4), { level: 'error' });
|
|
1307
|
-
}
|
|
1308
|
-
return { success: false, reason: terminalState.reason, error: terminalState.message };
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
// Issue #1226: Check merge permissions before attempting
|
|
1312
|
-
const { canMerge, permission } = await checkMergePermissions(owner, repo, argv.verbose);
|
|
1313
|
-
if (!canMerge) {
|
|
1314
|
-
await log(formatAligned('⚠️', 'Cannot merge:', `Insufficient permissions (${permission || 'unknown'})`, 2));
|
|
1315
|
-
return { success: false, reason: 'insufficient_permissions', error: `User has ${permission || 'unknown'} access, needs push/maintain/admin` };
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
// Wait for CI to complete (with timeout)
|
|
1319
|
-
const ciWaitResult = await waitForCI(
|
|
1320
|
-
owner,
|
|
1321
|
-
repo,
|
|
1322
|
-
prNumber,
|
|
1323
|
-
{
|
|
1324
|
-
timeout: argv.autoMergeCiTimeout || 30 * 60 * 1000, // 30 minutes default
|
|
1325
|
-
pollInterval: argv.autoMergeCiPollInterval || 30 * 1000, // 30 seconds default
|
|
1326
|
-
onStatusUpdate: async status => {
|
|
1327
|
-
if (argv.verbose) {
|
|
1328
|
-
await log(` CI status: ${status.status}`, { verbose: true });
|
|
1329
|
-
}
|
|
1330
|
-
},
|
|
1331
|
-
},
|
|
1332
|
-
argv.verbose
|
|
1333
|
-
);
|
|
1334
|
-
|
|
1335
|
-
if (!ciWaitResult.success) {
|
|
1336
|
-
await log(formatAligned('⚠️', 'CI check failed or timed out:', ciWaitResult.error || ciWaitResult.status, 2));
|
|
1337
|
-
return { success: false, reason: ciWaitResult.status, error: ciWaitResult.error };
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
await log(formatAligned('✅', 'CI checks passed:', 'Checking mergeability...', 2));
|
|
1341
|
-
|
|
1342
|
-
// Check if PR is mergeable
|
|
1343
|
-
const mergeStatus = await checkPRMergeable(owner, repo, prNumber, argv.verbose);
|
|
1344
|
-
if (mergeStatus.terminal) {
|
|
1345
|
-
await log(formatAligned('❌', 'GITHUB TARGET UNAVAILABLE:', mergeStatus.reason || 'GitHub repository, pull request, issue, or branch is no longer accessible', 2), { level: 'error' });
|
|
1346
|
-
return { success: false, reason: 'terminal_github_entity_error', error: mergeStatus.reason };
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
if (!mergeStatus.mergeable) {
|
|
1350
|
-
await log(formatAligned('⚠️', 'PR not mergeable:', mergeStatus.reason || 'Unknown reason', 2));
|
|
1351
|
-
return { success: false, reason: 'not_mergeable', error: mergeStatus.reason };
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
await log(formatAligned('✅', 'PR is mergeable:', 'Attempting to merge...', 2));
|
|
1355
|
-
|
|
1356
|
-
// Attempt to merge
|
|
1357
|
-
const deleteAfterMerge = shouldDeleteBranchAfterMerge(argv);
|
|
1358
|
-
if (deleteAfterMerge) {
|
|
1359
|
-
await log(formatAligned('', 'Branch cleanup:', 'will delete branch after successful merge', 2));
|
|
1360
|
-
}
|
|
1361
|
-
const mergeResult = await mergePullRequest(owner, repo, prNumber, { squash: argv.squash || false, deleteAfter: deleteAfterMerge }, argv.verbose);
|
|
1362
|
-
|
|
1363
|
-
if (mergeResult.success) {
|
|
1364
|
-
await log(formatAligned('🎉', 'PR MERGED SUCCESSFULLY!', ''));
|
|
1365
|
-
|
|
1366
|
-
// Post success comment
|
|
1367
|
-
try {
|
|
1368
|
-
const commentBody = `## 🎉 ${AUTO_MERGED_MARKER}\n\nThis pull request has been automatically merged by hive-mind after all CI checks passed and the PR became mergeable.\n\n---\n*Auto-merged by hive-mind with --auto-merge flag*`;
|
|
1369
|
-
await postTrackedComment({ $, owner, repo, targetNumber: prNumber, body: commentBody });
|
|
1370
|
-
} catch {
|
|
1371
|
-
// Don't fail if comment posting fails
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
// Issue #1895: close linked issue explicitly when GitHub will not (non-default base branch).
|
|
1375
|
-
try {
|
|
1376
|
-
const closeResult = await ensureLinkedIssueClosedAfterMerge({ $, log, owner, repo, prNumber, issueNumber, verbose: argv.verbose });
|
|
1377
|
-
if (!closeResult.closed && !closeResult.skipped) {
|
|
1378
|
-
await log(formatAligned('⚠️', 'Issue auto-close:', `could not close linked issue (${closeResult.reason})`, 2), { level: 'warning' });
|
|
1379
|
-
}
|
|
1380
|
-
} catch (closeError) {
|
|
1381
|
-
await log(formatAligned('⚠️', 'Issue auto-close:', `error: ${closeError.message}`, 2), { level: 'warning' });
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
return { success: true, reason: 'merged' };
|
|
1385
|
-
} else {
|
|
1386
|
-
await log(formatAligned('⚠️', 'Merge failed:', mergeResult.error || 'Unknown error', 2));
|
|
1387
|
-
return { success: false, reason: 'merge_failed', error: mergeResult.error };
|
|
1388
|
-
}
|
|
1389
|
-
};
|
|
1329
|
+
// Issue #2144: the one-shot `--auto-merge` attempt moved to its own module so
|
|
1330
|
+
// both files stay under the 1500-line limit. Re-exported for API compatibility.
|
|
1331
|
+
const autoMergeAttempt = await import('./solve.auto-merge-attempt.lib.mjs');
|
|
1332
|
+
export const { attemptAutoMerge, reportAutoMergeBlockedByIssue } = autoMergeAttempt;
|
|
1390
1333
|
|
|
1391
1334
|
/**
|
|
1392
1335
|
* Start auto-restart-until-mergeable mode
|
|
@@ -12,6 +12,14 @@ const truncate = (value, maxLength = 2000) => {
|
|
|
12
12
|
|
|
13
13
|
const fence = value => truncate(value || 'Unknown error').replaceAll('```', '` ` `');
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Issue #2141: the failure comment was the *only* record of the run — the reason
|
|
17
|
+
* said "Agent reported error: [object Object]", `--attach-logs` was off, and the
|
|
18
|
+
* session log was never published, so the root cause could not be recovered
|
|
19
|
+
* afterwards. Say what is missing and how to make the next run diagnosable.
|
|
20
|
+
*/
|
|
21
|
+
const buildLogLine = logAttachmentAttempted => (logAttachmentAttempted ? 'Log attachment was attempted but failed. Check the solver terminal log for the complete failure output.' : 'Logs were not attached because `--attach-logs` was not enabled, so this comment is the only surviving record of the failure. Rerun with `--attach-logs --verbose` to publish the full session log with the raw tool error records.');
|
|
22
|
+
|
|
15
23
|
const isForkDivergenceFailure = reason => {
|
|
16
24
|
const normalizedReason = String(reason || '').toLowerCase();
|
|
17
25
|
return normalizedReason.includes('fork divergence') || (normalizedReason.includes('fork') && normalizedReason.includes('non-fast-forward')) || normalizedReason.includes('force-with-lease');
|
|
@@ -124,7 +132,7 @@ export function resolvePreExitFailureNotificationTarget({ code, globalState }) {
|
|
|
124
132
|
export function buildPrePullRequestFailureComment({ reason, owner, repo, issueNumber, argv = {}, logAttachmentAttempted = false, failureActionSection = null }) {
|
|
125
133
|
const tool = argv.tool || 'claude';
|
|
126
134
|
const modelLine = argv.model ? `\n- **Requested model**: \`${argv.model}\`` : '';
|
|
127
|
-
const logLine = logAttachmentAttempted
|
|
135
|
+
const logLine = buildLogLine(logAttachmentAttempted);
|
|
128
136
|
const actionSection = failureActionSection || buildPrePullRequestFailureActionSection(reason);
|
|
129
137
|
|
|
130
138
|
return `## 🚨 ${SOLUTION_DRAFT_FAILED_MARKER}
|
|
@@ -151,7 +159,7 @@ export function buildExistingPullRequestFailureComment({ reason, owner, repo, pr
|
|
|
151
159
|
const tool = argv.tool || 'claude';
|
|
152
160
|
const modelLine = argv.model ? `\n- **Requested model**: \`${argv.model}\`` : '';
|
|
153
161
|
const issueLine = issueNumber ? `\n- **Linked issue**: #${issueNumber}` : '';
|
|
154
|
-
const logLine = logAttachmentAttempted
|
|
162
|
+
const logLine = buildLogLine(logAttachmentAttempted);
|
|
155
163
|
const actionSection = failureActionSection || buildPrePullRequestFailureActionSection(reason);
|
|
156
164
|
|
|
157
165
|
return `## 🚨 ${SOLUTION_DRAFT_FAILED_MARKER}
|
package/src/solve.watch.lib.mjs
CHANGED
|
@@ -44,6 +44,18 @@ const { checkPRMerged, checkForUncommittedChanges, getUncommittedChangesDetails,
|
|
|
44
44
|
const terminalStateLib = await import('./github-terminal-state.lib.mjs');
|
|
45
45
|
const { checkGitHubTerminalState } = terminalStateLib;
|
|
46
46
|
|
|
47
|
+
// Issue #2144: these probes answer with a ~33 KB pull request object and a full
|
|
48
|
+
// issue object on every iteration. Issue #2130 made the helper's own default
|
|
49
|
+
// runner quiet, but passing `$` here bypassed it and the payloads were still
|
|
50
|
+
// mirrored into the attached log. Bind the quiet options to the injected `$`.
|
|
51
|
+
const { quietProbe } = await import('./quiet-probe.lib.mjs');
|
|
52
|
+
|
|
53
|
+
// Issue #2144: watch mode must never exit silently — every stop is published as
|
|
54
|
+
// a GitHub comment naming the exact reason. A closed linked issue is not a stop
|
|
55
|
+
// condition here at all.
|
|
56
|
+
const stopReportingLib = await import('./automation-stop-reporting.lib.mjs');
|
|
57
|
+
const { reportAutomationStop } = stopReportingLib;
|
|
58
|
+
|
|
47
59
|
// Issue #1574: Interruptible sleep so CTRL+C is never blocked by a lingering timer
|
|
48
60
|
const { interruptibleSleep } = await import('./interruptible-sleep.lib.mjs');
|
|
49
61
|
// Issue #2119: one auto-restart budget shared with solve.auto-merge.lib.mjs, so
|
|
@@ -142,7 +154,7 @@ export const watchForFeedback = async params => {
|
|
|
142
154
|
issueNumber,
|
|
143
155
|
prNumber,
|
|
144
156
|
sourceBranchName: prBranch || branchName,
|
|
145
|
-
commandRunner:
|
|
157
|
+
commandRunner: quietProbe($),
|
|
146
158
|
});
|
|
147
159
|
if (terminalState.terminal && !terminalState.success) {
|
|
148
160
|
await log('');
|
|
@@ -152,9 +164,19 @@ export const watchForFeedback = async params => {
|
|
|
152
164
|
}
|
|
153
165
|
await log(formatAligned('', 'Action:', 'Stopping watch mode', 2), { level: 'error' });
|
|
154
166
|
await log('');
|
|
167
|
+
// Issue #2144: report the stop on GitHub instead of exiting silently.
|
|
168
|
+
await reportAutomationStop({ $, owner, repo, targetNumber: prNumber, reason: terminalState.reason, mode: 'watch', message: terminalState.message, details: terminalState.details, verbose: argv.verbose, log });
|
|
155
169
|
break;
|
|
156
170
|
}
|
|
157
171
|
|
|
172
|
+
// Issue #2144: issue-scoped problems (closed / deleted linked issue) are not
|
|
173
|
+
// watch-mode stop conditions; the loop keeps working on the pull request.
|
|
174
|
+
if ((terminalState.mergeBlockers || []).length > 0 && iteration === 1) {
|
|
175
|
+
for (const blocker of terminalState.mergeBlockers) {
|
|
176
|
+
await log(formatAligned('⚠️', 'Linked issue:', `${blocker.message} Watch mode continues.`, 2), { level: 'warning' });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
158
180
|
// Check if PR is merged
|
|
159
181
|
const isMerged = terminalState.terminal && terminalState.success ? true : await checkPRMerged(owner, repo, prNumber);
|
|
160
182
|
if (isMerged) {
|
|
@@ -472,6 +494,18 @@ export const watchForFeedback = async params => {
|
|
|
472
494
|
await log(' 2. You have proper authentication configured');
|
|
473
495
|
await log(' 3. The API endpoint is accessible');
|
|
474
496
|
await log('');
|
|
497
|
+
// Issue #2144: say on GitHub why the loop stopped.
|
|
498
|
+
await reportAutomationStop({
|
|
499
|
+
$,
|
|
500
|
+
owner,
|
|
501
|
+
repo,
|
|
502
|
+
targetNumber: prNumber,
|
|
503
|
+
reason: 'tool_failure',
|
|
504
|
+
mode: 'watch',
|
|
505
|
+
message: `${argv.tool.toUpperCase()} failed ${consecutiveApiErrors} times in a row: ${extractToolErrorCore({ toolResult }) || 'unknown API error'}`,
|
|
506
|
+
verbose: argv.verbose,
|
|
507
|
+
log,
|
|
508
|
+
});
|
|
475
509
|
break; // Exit the watch loop
|
|
476
510
|
}
|
|
477
511
|
|
|
@@ -62,6 +62,17 @@ export const BILLING_LIMIT_MARKER = 'GitHub Actions Billing Limit';
|
|
|
62
62
|
// solve.auto-merge.lib.mjs — cancelled/stale CI needs manual review
|
|
63
63
|
export const CANCELLED_CI_REVIEW_MARKER = 'Cancelled CI/CD Requires Review';
|
|
64
64
|
|
|
65
|
+
// automation-stop-reporting.lib.mjs — Issue #2144: every automation stop is
|
|
66
|
+
// announced on GitHub with the exact reason. Before this, watch mode and
|
|
67
|
+
// auto-restart-until-mergeable exited silently on terminal states and tool
|
|
68
|
+
// failures, leaving the pull request with no explanation at all.
|
|
69
|
+
export const AUTOMATION_STOPPED_MARKER = 'Automation stopped';
|
|
70
|
+
|
|
71
|
+
// automation-stop-reporting.lib.mjs — Issue #2144: the pull request is
|
|
72
|
+
// mergeable but `--auto-merge` cannot complete because the linked issue is
|
|
73
|
+
// closed or unavailable. The user is asked to reopen it or merge manually.
|
|
74
|
+
export const AUTO_MERGE_BLOCKED_MARKER = 'Auto-merge blocked';
|
|
75
|
+
|
|
65
76
|
// solve.results.lib.mjs — working session summary comments posted by
|
|
66
77
|
// --attach-solution-summary / --auto-attach-solution-summary at the end of
|
|
67
78
|
// every working session (top-level solve, auto-restart-until-mergeable
|
|
@@ -111,7 +122,7 @@ export const USAGE_LIMIT_REACHED_MARKER = 'Usage Limit Reached';
|
|
|
111
122
|
* named constants above so that adding a new marker only requires adding
|
|
112
123
|
* the constant and appending it here.
|
|
113
124
|
*/
|
|
114
|
-
export const TOOL_GENERATED_COMMENT_MARKERS = [AI_WORK_SESSION_STARTED_MARKER, AI_WORK_SESSION_COMPLETED_MARKER, AI_WORK_SESSION_RESUMED_MARKER, AUTO_RESUME_ON_LIMIT_RESET_MARKER, AUTO_RESTART_ON_LIMIT_RESET_MARKER, SOLUTION_DRAFT_LOG_MARKER, AUTO_RESTART_MARKER, AUTO_RESTART_UNTIL_MERGEABLE_LOG_MARKER, READY_TO_MERGE_MARKER, READY_FOR_REVIEW_MARKER, AUTO_MERGED_MARKER, BILLING_LIMIT_MARKER, CANCELLED_CI_REVIEW_MARKER, MAINTAINER_ACCESS_REQUEST_MARKER, LIVE_PROGRESS_SECTION_START_MARKER, SESSION_FORCE_KILLED_MARKER, REPOSITORY_INITIALIZATION_REQUIRED_MARKER, INTERACTIVE_SESSION_STARTED_MARKER, INTERACTIVE_SESSION_ENDED_MARKER, NOW_WORKING_SESSION_IS_ENDED_MARKER, SOLUTION_DRAFT_FAILED_MARKER, SOLUTION_DRAFT_FINISHED_WITH_ERRORS_MARKER, USAGE_LIMIT_REACHED_MARKER, WORKING_SESSION_SUMMARY_AUTOMATION_MARKER];
|
|
125
|
+
export const TOOL_GENERATED_COMMENT_MARKERS = [AI_WORK_SESSION_STARTED_MARKER, AI_WORK_SESSION_COMPLETED_MARKER, AI_WORK_SESSION_RESUMED_MARKER, AUTO_RESUME_ON_LIMIT_RESET_MARKER, AUTO_RESTART_ON_LIMIT_RESET_MARKER, SOLUTION_DRAFT_LOG_MARKER, AUTO_RESTART_MARKER, AUTO_RESTART_UNTIL_MERGEABLE_LOG_MARKER, READY_TO_MERGE_MARKER, READY_FOR_REVIEW_MARKER, AUTO_MERGED_MARKER, BILLING_LIMIT_MARKER, CANCELLED_CI_REVIEW_MARKER, AUTOMATION_STOPPED_MARKER, AUTO_MERGE_BLOCKED_MARKER, MAINTAINER_ACCESS_REQUEST_MARKER, LIVE_PROGRESS_SECTION_START_MARKER, SESSION_FORCE_KILLED_MARKER, REPOSITORY_INITIALIZATION_REQUIRED_MARKER, INTERACTIVE_SESSION_STARTED_MARKER, INTERACTIVE_SESSION_ENDED_MARKER, NOW_WORKING_SESSION_IS_ENDED_MARKER, SOLUTION_DRAFT_FAILED_MARKER, SOLUTION_DRAFT_FINISHED_WITH_ERRORS_MARKER, USAGE_LIMIT_REACHED_MARKER, WORKING_SESSION_SUMMARY_AUTOMATION_MARKER];
|
|
115
126
|
|
|
116
127
|
/**
|
|
117
128
|
* Markers that indicate the end of a working session. Used by
|