- Fix jq syntax: bd show --json returns array, use .[0].notes - Add grep command to extract PR number from URL - Correct Gitea workflow: tea pr view lists all PRs, use tea pr list --state=closed instead
89 lines
2.4 KiB
Markdown
89 lines
2.4 KiB
Markdown
---
|
|
description: Reconcile beads with merged PRs and close completed beads
|
|
---
|
|
|
|
# Reconcile Beads Workflow
|
|
|
|
This skill reconciles beads that are in `in_review` status with their corresponding PRs. If a PR has been merged, the bead is closed.
|
|
|
|
## Prerequisites
|
|
|
|
- Custom status `in_review` must be configured: `bd config set status.custom "in_review"`
|
|
- Beads in `in_review` status should have a PR URL in their notes
|
|
|
|
## Workflow
|
|
|
|
### Step 1: Find beads in review
|
|
|
|
```bash
|
|
bd list --status=in_review
|
|
```
|
|
|
|
### Step 2: For each bead, check PR status
|
|
|
|
1. **Get the PR URL from bead notes**:
|
|
```bash
|
|
bd show [BEAD_ID] --json | jq -r '.[0].notes'
|
|
```
|
|
Note: `bd show --json` returns an array, so use `.[0]` to access the first element.
|
|
Extract the PR URL (look for lines starting with "PR:" or containing pull request URLs).
|
|
Extract the PR number: `echo "$NOTES" | grep -oP '/pulls/\K\d+'`
|
|
|
|
2. **Detect hosting provider**:
|
|
- Run `git remote get-url origin`
|
|
- If URL contains `github.com`, use `gh`; otherwise use `tea` (Gitea/Forgejo)
|
|
|
|
3. **Check PR status**:
|
|
- For GitHub:
|
|
```bash
|
|
gh pr view [PR_NUMBER] --json state,merged
|
|
```
|
|
- For Gitea:
|
|
```bash
|
|
tea pr list --state=closed
|
|
```
|
|
Look for the PR number in the INDEX column with STATE "merged".
|
|
Note: `tea pr view [PR_NUMBER]` lists all PRs, not a specific one. Use `tea pr list --state=closed` and look for your PR number in the results.
|
|
|
|
### Step 3: Close merged beads
|
|
|
|
If the PR is merged:
|
|
```bash
|
|
bd close [BEAD_ID] --reason="PR merged: [PR_URL]"
|
|
```
|
|
|
|
### Step 4: Report summary
|
|
|
|
Present results:
|
|
|
|
```
|
|
## Beads Reconciliation Summary
|
|
|
|
### Closed (PR Merged)
|
|
| Bead | PR | Title |
|
|
|------|-----|-------|
|
|
| beads-abc | #123 | Feature X |
|
|
| beads-xyz | #456 | Bug fix Y |
|
|
|
|
### Still in Review
|
|
| Bead | PR | Status | Title |
|
|
|------|-----|--------|-------|
|
|
| beads-def | #789 | Open | Feature Z |
|
|
|
|
### Issues Found
|
|
- beads-ghi: No PR URL found in notes
|
|
- beads-jkl: PR #999 not found (may have been deleted)
|
|
```
|
|
|
|
## Error Handling
|
|
|
|
- **Missing PR URL**: Skip the bead and report it
|
|
- **PR not found**: Report the error but continue with other beads
|
|
- **API errors**: Report and continue
|
|
|
|
## Notes
|
|
|
|
- This skill complements `/parallel_beads` which sets beads to `in_review` status
|
|
- Run this skill periodically or after merging PRs to keep beads in sync
|
|
- Beads with closed (but not merged) PRs are not automatically closed - they may need rework
|