feat: include PR/MR URL in DEV completion notifications
Adds automatic PR/MR URL detection and inclusion in DEV completion announcements to provide better visibility into completed work. Changes: 1. TaskManager interface: - Added getMergedMRUrl() method to fetch PR/MR URL for an issue 2. GitHub/GitLab providers: - Implemented getMergedMRUrl() to find most recent merged PR/MR - Returns URL of PR/MR that references the issue number 3. task_complete tool: - Added optional prUrl parameter - Auto-detects PR/MR URL if not provided - Includes PR URL in announcement with 🔗 prefix - Format: 'PR: https://github.com/...' 4. Role templates (dev.md): - Updated to instruct workers to include prUrl in task_complete - Documents that prUrl is optional (auto-detected as fallback) Example announcement: ✅ DEV done #101 — Added PR/MR URL to notifications 🔗 PR: https://github.com/user/repo/pull/102 . Moved to QA queue. Addresses issue #101
This commit is contained in:
@@ -224,6 +224,37 @@ export class GitHubProvider implements TaskManager {
|
||||
}
|
||||
}
|
||||
|
||||
async getMergedMRUrl(issueId: number): Promise<string | null> {
|
||||
try {
|
||||
const raw = await this.gh([
|
||||
"pr", "list",
|
||||
"--state", "merged",
|
||||
"--json", "number,title,body,url,mergedAt",
|
||||
"--limit", "20",
|
||||
]);
|
||||
const prs = JSON.parse(raw) as Array<{
|
||||
number: number;
|
||||
title: string;
|
||||
body: string;
|
||||
url: string;
|
||||
mergedAt: string;
|
||||
}>;
|
||||
|
||||
const pattern = `#${issueId}`;
|
||||
|
||||
// Find the most recently merged PR that references this issue
|
||||
// PRs are returned in reverse chronological order by default
|
||||
const matchingPr = prs.find(
|
||||
(pr) =>
|
||||
pr.title.includes(pattern) || (pr.body ?? "").includes(pattern),
|
||||
);
|
||||
|
||||
return matchingPr?.url ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async addComment(issueId: number, body: string): Promise<void> {
|
||||
// Write body to temp file to preserve newlines
|
||||
const tempFile = join(tmpdir(), `devclaw-comment-${Date.now()}.md`);
|
||||
|
||||
Reference in New Issue
Block a user