-
Scope: default to all open issues in confluentinc/terraform-provider-confluent. If the user narrows it (a label, a time window, a keyword), use that instead. First obtain the total matching count without truncation:
gh api --method GET search/issues -f q='repo:confluentinc/terraform-provider-confluent is:issue is:open' --jq '.total_count'
Include any user-supplied label, time-window, or keyword filters in the search query. If the count is more than ~500, report it and ask whether to narrow the scope or explicitly approve fetching the larger result set. Only then fetch the issues, setting --limit to at least the reported count so the scan is not silently capped:
gh issue list --repo confluentinc/terraform-provider-confluent --state open \
--json number,title,body,labels,createdAt,updatedAt,comments,url --limit <reported-count>
-
Normalize: strip issue-template boilerplate (fixed headers, checkbox scaffolding) before comparing bodies — it inflates similarity between unrelated issues that just used the same template. Focus on what varies: error messages, exact resource/config blocks, provider/plugin versions, stack traces, repro steps.
-
Cluster (don't do a naive O(n²) full-text pass):
- Block by shared signals first: same error string/exit code, same resource type (e.g.
confluent_kafka_cluster, confluent_kafka_topic), overlapping title tokens, same label.
- Within a block, actually read the normalized bodies and judge whether they're the same bug/request, not just the same resource. Two issues about
confluent_kafka_topic failing for different root causes are not a duplicate pair.
-
Cross-repo check: for clusters that look like they might stem from a platform/API behavior rather than a Terraform-specific bug, do one targeted search against the sibling repo before concluding:
gh issue list --repo confluentinc/cli --state open --search "<keyword>"
If you find a match, flag it as cross-repo related rather than a same-repo duplicate — see classification below.
-
Pick a canonical issue per group: prefer most complete repro/description, then oldest by createdAt, then most comments/reactions. State which rule decided it.
-
Classify:
- Same-repo duplicate (High/Medium/Low confidence) — candidate for closing in Phase 2.
- Cross-repo related (High/Medium/Low confidence) — same underlying platform behavior surfacing in both repos. Default action is cross-linking, not closing either side.
For every group, give one or two sentences of concrete reasoning (shared error text, same resource/field, same provider version) — never just "these look similar."
-
Output: write a markdown report (default ./issue-dedup-report-<YYYY-MM-DD>.md) with one entry per group:
## Group 1 — [same-repo duplicate | cross-repo related] — confidence: High/Medium/Low
Canonical: #123 <title> (<url>)
Duplicates:
- #456 <title> (<url>)
Reasoning: <concrete, specific>
Then summarize in chat: issues scanned, groups found, top few by confidence. Stop here unless the user asks you to resolve.
Only enter this phase against a scan you (or a prior run) just produced, or a group the user hands you directly. Never invent duplicate judgments from scratch here.
-
Re-verify each issue in each group before trusting the report — reports go stale:
gh issue view <number> --repo confluentinc/terraform-provider-confluent --json state,title,labels,comments,body
Drop/flag a group if an issue is already closed, has picked up substantial new discussion diverging from the canonical thread (treat as "needs manual review"), or its body has changed enough to undercut the original judgment.
-
Show the exact plan before acting — literal comment text and commands, not a summary:
Canonical: #123 <title>
Will close as duplicate: #456 <title>
Comment: "Closing as a duplicate of #123. If this doesn't fully capture your issue, please reopen or comment on the original with details."
Label: duplicate
Close reason: not planned
For cross-repo related groups, default to cross-linking only (a comment on each issue pointing at the other) — do not close either side unless the user explicitly says to.
-
Wait for explicit confirmation. Confirm per group unless the user explicitly approves the whole batch — and even then, show every group's plan first.
-
Execute only confirmed groups:
gh issue comment <dup> --repo confluentinc/terraform-provider-confluent --body "<comment>"
gh issue edit <dup> --repo confluentinc/terraform-provider-confluent --add-label duplicate
gh issue close <dup> --repo confluentinc/terraform-provider-confluent --reason "not planned"
For a cross-repo cross-link, the corresponding comment goes on the confluentinc/cli issue via the same gh issue comment pattern with that repo. If gh reports a permissions error, stop and tell the user — don't retry or route around it.
-
Log and summarize: append each executed action (issue, action, timestamp) to ./issue-dedup-actions-<YYYY-MM-DD>.md, then report groups resolved, groups skipped (why), and groups left for manual review.