twg-jira-resolve-merged-work
Resolve stale Jira workitems only when merged PR evidence is strong. Plan first;
mutate only after approval.
Use exact command grammar from live twg help / twg help describe; do not
guess board, sprint, transition, workspace, repo, PR, or field syntax.
CLI launcher fallback
Run twg <command>. On shell command not found, use $HOME/.local/bin/twg
(macOS/Linux) / $env:LOCALAPPDATA\Programs\twg\bin\twg.exe (PowerShell), then
tell user to add that directory to PATH. Do not treat auth or command errors as
PATH failures.
Scope
Accept one Jira scope:
- One Jira workitem key/URL.
- A small explicit list of Jira workitem keys/URLs.
- Board or sprint ID/URL.
- Epic key.
- Jira space/project key.
Default to dry run. Ask before mutating unless the user requests reviewed
execution. Use a bounded window; otherwise inspect recent active/completed
sprint work and nearby PR merge dates.
Workflow
Load Jira candidates.
- Single/list: hydrate each provided workitem directly.
- Sprint:
jira sprint workitems query.
- Board: board/backlog/sprint commands advertised by live help.
- Epic or space: JQL-backed
jira workitem query.
- Hydrate key, title, status/category, assignee, updated time, parent,
subtasks/blockers, and URL.
Split the set.
- Candidates are not done/resolved. Peers are done in the same board, sprint,
epic, or space.
- Exclude epics/parents. Skip unresolved blockers or incomplete subtasks
unless the user explicitly allows them.
Discover shared repo context set-wise.
- Even for one item or a short list, infer context for the set together.
- Extract repos/workspaces from linked PRs, commits, branches, project links,
Compass/components, context queries, and resolved peers.
- Use completed peers to infer common repos, assignees, Jira-key title/branch
conventions, PR links, and merge-to-transition lag.
Check optional discovery signals.
- If
rovo list-apps shows Bitbucket or GitHub connected, use Rovo search
for keys, titles, PR URLs, branches, and repos. Treat it as discovery until
hydrated through TWG/provider/Jira evidence.
- If
search-code is available, search exact keys first, then distinctive
title terms in discovered repos. Strong hits are branch names, commit text,
changed files, or symbols; broad fuzzy hits stay weak.
Expand likely implementers.
- Prefer assignees from completed peer items and candidates. Treat reporters
and commenters as weak hints.
- Query merged PRs authored by these assignees in the window, scoped by
discovered repos first; if unknown, infer repos from author/date results.
Search merged PRs in batches.
- Prefer one merged-PR query per repo/window, then match locally across all
candidate keys. One PR may satisfy multiple exact keys.
- Match exact keys in PR title, description, branch, commits, and linked
issue metadata.
- Fall back to per-workitem lookup only for no evidence, priority items, or
ambiguity.
Score confidence.
- High: exact key in merged PR or linked PR metadata, plausible timing, no
open same-key PR, no blockers/subtasks, and target transition exists.
- Medium: same assignee/repo with strong title similarity, or exact key only
in commit/search-code evidence.
- Low: fuzzy similarity, same author only, unknown repo, or ambiguity.
Produce the dry-run plan.
- Table columns: workitem key/title, current status, proposed transition,
confidence, brief rationale, PR title/URL, merge date, last Jira update,
link/repo proposal, PR title-fix proposal, skipped reason, and verification.
- Include exact commands only after live-help verification. Never present
low-confidence rows as executable.
Mutations
Only mutate after explicit approval of the exact rows or plan.
- Transition: list transitions first, then use only the approved done/resolved
target.
- Link enrichment: if links are missing, offer
jira workitem link weblink
for PR/repo URLs after querying links and verifying help. Do not claim this
creates native development-panel links.
- PR title fix: for Bitbucket, update title only when
twg bitbucket can read
the PR, write access is verified, the PR is confidently tied to the item, and
the user approved it. For GitHub, update only when an authenticated write tool
is available and access is verified; otherwise skip with the reason.
- Verification: re-read each changed workitem and PR. Report changed keys,
statuses, URLs, and failed rows.
Do not transition medium-confidence items automatically. Do not transition
declined/superseded PRs or rows supported only by same author, same repo, or
fuzzy similarity.
Output
Lead with the decision summary:
- executable high-confidence rows,
- review-needed medium-confidence rows,
- skipped unsafe rows,
- missing repo/auth/permission coverage.
Then provide the dry-run table and exact approval question. Include URLs or
stable IDs for every workitem and PR used as evidence.
1---2name: twg-jira-resolve-merged-work3description: Clean up stale or unresolved Jira workitems. Dry-run single items, lists, boards, sprints, epics, or projects by matching Jira keys/titles to merged PRs, repos, Rovo/search-code hits, and assignee activity.4---56# twg-jira-resolve-merged-work78Resolve stale Jira workitems only when merged PR evidence is strong. Plan first;9mutate only after approval.1011Use exact command grammar from live `twg help` / `twg help describe`; do not12guess board, sprint, transition, workspace, repo, PR, or field syntax.1314## CLI launcher fallback1516Run `twg <command>`. On shell `command not found`, use `$HOME/.local/bin/twg`17(macOS/Linux) / `$env:LOCALAPPDATA\Programs\twg\bin\twg.exe` (PowerShell), then18tell user to add that directory to PATH. Do not treat auth or command errors as19PATH failures.2021## Scope2223Accept one Jira scope:2425- One Jira workitem key/URL.26- A small explicit list of Jira workitem keys/URLs.27- Board or sprint ID/URL.28- Epic key.29- Jira space/project key.3031Default to dry run. Ask before mutating unless the user requests reviewed32execution. Use a bounded window; otherwise inspect recent active/completed33sprint work and nearby PR merge dates.3435## Workflow36371. Load Jira candidates.38 - Single/list: hydrate each provided workitem directly.39 - Sprint: `jira sprint workitems query`.40 - Board: board/backlog/sprint commands advertised by live help.41 - Epic or space: JQL-backed `jira workitem query`.42 - Hydrate key, title, status/category, assignee, updated time, parent,43 subtasks/blockers, and URL.44452. Split the set.46 - Candidates are not done/resolved. Peers are done in the same board, sprint,47 epic, or space.48 - Exclude epics/parents. Skip unresolved blockers or incomplete subtasks49 unless the user explicitly allows them.50513. Discover shared repo context set-wise.52 - Even for one item or a short list, infer context for the set together.53 - Extract repos/workspaces from linked PRs, commits, branches, project links,54 Compass/components, context queries, and resolved peers.55 - Use completed peers to infer common repos, assignees, Jira-key title/branch56 conventions, PR links, and merge-to-transition lag.57584. Check optional discovery signals.59 - If `rovo list-apps` shows Bitbucket or GitHub connected, use Rovo search60 for keys, titles, PR URLs, branches, and repos. Treat it as discovery until61 hydrated through TWG/provider/Jira evidence.62 - If `search-code` is available, search exact keys first, then distinctive63 title terms in discovered repos. Strong hits are branch names, commit text,64 changed files, or symbols; broad fuzzy hits stay weak.65665. Expand likely implementers.67 - Prefer assignees from completed peer items and candidates. Treat reporters68 and commenters as weak hints.69 - Query merged PRs authored by these assignees in the window, scoped by70 discovered repos first; if unknown, infer repos from author/date results.71726. Search merged PRs in batches.73 - Prefer one merged-PR query per repo/window, then match locally across all74 candidate keys. One PR may satisfy multiple exact keys.75 - Match exact keys in PR title, description, branch, commits, and linked76 issue metadata.77 - Fall back to per-workitem lookup only for no evidence, priority items, or78 ambiguity.79807. Score confidence.81 - High: exact key in merged PR or linked PR metadata, plausible timing, no82 open same-key PR, no blockers/subtasks, and target transition exists.83 - Medium: same assignee/repo with strong title similarity, or exact key only84 in commit/search-code evidence.85 - Low: fuzzy similarity, same author only, unknown repo, or ambiguity.86878. Produce the dry-run plan.88 - Table columns: workitem key/title, current status, proposed transition,89 confidence, brief rationale, PR title/URL, merge date, last Jira update,90 link/repo proposal, PR title-fix proposal, skipped reason, and verification.91 - Include exact commands only after live-help verification. Never present92 low-confidence rows as executable.9394## Mutations9596Only mutate after explicit approval of the exact rows or plan.9798- Transition: list transitions first, then use only the approved done/resolved99 target.100- Link enrichment: if links are missing, offer `jira workitem link weblink`101 for PR/repo URLs after querying links and verifying help. Do not claim this102 creates native development-panel links.103- PR title fix: for Bitbucket, update title only when `twg bitbucket` can read104 the PR, write access is verified, the PR is confidently tied to the item, and105 the user approved it. For GitHub, update only when an authenticated write tool106 is available and access is verified; otherwise skip with the reason.107- Verification: re-read each changed workitem and PR. Report changed keys,108 statuses, URLs, and failed rows.109110Do not transition medium-confidence items automatically. Do not transition111declined/superseded PRs or rows supported only by same author, same repo, or112fuzzy similarity.113114## Output115116Lead with the decision summary:117118- executable high-confidence rows,119- review-needed medium-confidence rows,120- skipped unsafe rows,121- missing repo/auth/permission coverage.122123Then provide the dry-run table and exact approval question. Include URLs or124stable IDs for every workitem and PR used as evidence.