feat(close): Add --suggest-next flag to show newly unblocked issues (GH#679)

When closing an issue, the new --suggest-next flag returns a list of
issues that became unblocked (ready to work on) as a result of the close.

This helps agents and users quickly identify what work is now available
after completing a blocker.

Example:
  $ bd close bd-5 --suggest-next
  ✓ Closed bd-5: Completed

  Newly unblocked:
    • bd-7 "Implement feature X" (P1)
    • bd-8 "Write tests for X" (P2)

Implementation:
- Added GetNewlyUnblockedByClose to storage interface
- Implemented efficient single-query for SQLite using blocked_issues_cache
- Added SuggestNext field to CloseArgs in RPC protocol
- Added CloseResult type for structured response
- CLI handles both daemon and direct modes

Thanks to @kraitsura for the detailed feature request and design.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-25 20:05:04 -08:00
parent 35ab0d7a7f
commit f3a5e02a35
16 changed files with 306 additions and 140 deletions

View File

@@ -50,18 +50,14 @@ function getPlatformInfo() {
return { platformName, archName, binaryName };
}
// Small delay helper for Windows file handle release
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Download file from URL
function downloadFile(url, dest) {
return new Promise((resolve, reject) => {
console.log(`Downloading from: ${url}`);
const file = fs.createWriteStream(dest);
const request = https.get(url, (response) => {
// Handle redirects - must happen BEFORE creating write stream
// Handle redirects
if (response.statusCode === 301 || response.statusCode === 302) {
const redirectUrl = response.headers.location;
console.log(`Following redirect to: ${redirectUrl}`);
@@ -74,37 +70,27 @@ function downloadFile(url, dest) {
return;
}
// Only create write stream after we know we have the final URL
const file = fs.createWriteStream(dest);
response.pipe(file);
file.on('finish', () => {
// Wait for file.close() to complete before resolving
// This is critical on Windows where the file may still be locked
file.close(async (err) => {
if (err) {
reject(err);
return;
}
// On Windows, add a small delay to ensure file handle is fully released
if (os.platform() === 'win32') {
await delay(100);
}
resolve();
file.close((err) => {
if (err) reject(err);
else resolve();
});
});
file.on('error', (err) => {
fs.unlink(dest, () => {});
reject(err);
});
});
request.on('error', (err) => {
fs.unlink(dest, () => {});
reject(err);
});
file.on('error', (err) => {
fs.unlink(dest, () => {});
reject(err);
});
});
}