forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaintainer_review_queue.py
More file actions
executable file
·170 lines (143 loc) · 6.1 KB
/
Copy pathmaintainer_review_queue.py
File metadata and controls
executable file
·170 lines (143 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env python3
"""Maintainer review queue — compact view of pending MCP intake issues.
Usage:
python3 scripts/maintainer_review_queue.py [--repo OWNER/REPO] [--format text|json|markdown]
python3 scripts/maintainer_review_queue.py --pending-only
python3 scripts/maintainer_review_queue.py --action-stats
Read-only. Never closes, publishes, or modifies issues.
Shows:
- Issue number, title, source, classification labels
- Dedup hash (if available)
- Suggested action: convert-to-lesson / needs-info / close-as-noise / merge-duplicate
- Separates: intake-test, lesson candidates, vague/noise
"""
import argparse
import json
import hashlib
import subprocess
import sys
from collections import Counter, defaultdict
REPO_DEFAULT = "Ikalus1988/MisakaNet"
INTAKE_LABELS = {"intake", "mcp-intake", "pending-review"}
LESSON_LABELS = {"lesson-candidate", "enhancement"}
TEST_LABELS = {"intake-test", "status:competition"}
NOISE_LABELS = {"noise", "spam", "invalid"}
def gh_issue_list(repo, state="open", labels=None, limit=100):
"""List issues via gh CLI."""
cmd = ["gh", "issue", "list", "--repo", repo, "--state", state, "--limit", str(limit),
"--json", "number,title,labels,assignees,createdAt,body"]
if labels:
cmd += ["--label", ",".join(labels)]
result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30)
if result.returncode != 0:
print(f"Error: {result.stderr}", file=sys.stderr)
return []
return json.loads(result.stdout)
def extract_labels(issue):
"""Extract label names as a set."""
return {l["name"] for l in issue.get("labels", [])}
def dedup_hash(issue):
"""Generate dedup hash from title + body."""
text = (issue.get("title", "") or "") + (issue.get("body", "") or "")
return hashlib.sha256(text.lower().strip().encode()).hexdigest()[:12]
def suggest_action(issue, labels):
"""Suggest maintainer action based on labels and content."""
if labels & NOISE_LABELS:
return "close-as-noise"
if "intake-test" in labels:
return "review-test-data"
if labels & LESSON_LABELS and "ready" in labels:
return "convert-to-lesson"
if "needs-ac" in labels:
return "needs-acceptance-criteria"
if "needs-dco" in labels:
return "request-dco-signoff"
title = (issue.get("title", "") or "").lower()
if any(kw in title for kw in ["test", "spam", "dummy", "foo", "bar"]):
return "likely-noise"
body = issue.get("body", "") or ""
if len(body) < 50:
return "needs-info"
return "review-manually"
def categorize_issue(labels, title):
"""Categorize issue into queue buckets."""
if labels & TEST_LABELS:
return "intake-test"
if labels & LESSON_LABELS:
return "lesson-candidate"
if "pool:quick" in labels:
return "quick-task"
if "pool:deep" in labels:
return "deep-task"
if any(kw in title.lower() for kw in ["bounty", "reward"]):
return "bounty"
return "unclassified"
def format_text(issues):
"""Format as human-readable text."""
by_category = defaultdict(list)
for issue in issues:
labels = extract_labels(issue)
cat = categorize_issue(labels, issue.get("title", ""))
action = suggest_action(issue, labels)
by_category[cat].append((issue, labels, action))
lines = []
for cat in ["lesson-candidate", "quick-task", "deep-task", "intake-test", "bounty", "unclassified"]:
items = by_category.get(cat, [])
if not items:
continue
lines.append(f"\n{'='*60}")
lines.append(f" {cat.upper().replace('-', ' ')} ({len(items)} issues)")
lines.append(f"{'='*60}")
for issue, labels, action in items:
num = issue["number"]
title = issue["title"][:70]
lines.append(f" #{num} {title}")
lines.append(f" -> {action}")
assigned = [a["login"] for a in issue.get("assignees", [])]
if assigned:
lines.append(f" assigned: {', '.join(assigned)}")
lines.append(f"\n{'-'*60}")
lines.append(f" Total: {len(issues)} open issues in queue")
stats = Counter(categorize_issue(extract_labels(i), i.get("title", "")) for i in issues)
for cat, count in stats.most_common():
lines.append(f" {cat}: {count}")
return "\n".join(lines)
def main():
parser = argparse.ArgumentParser(description="Maintainer review queue for MCP intake issues")
parser.add_argument("--repo", default=REPO_DEFAULT)
parser.add_argument("--format", choices=["text", "json", "markdown"], default="text")
parser.add_argument("--pending-only", action="store_true")
parser.add_argument("--action-stats", action="store_true")
args = parser.parse_args()
issues = gh_issue_list(args.repo, labels=["good first issue"], limit=50)
intake_issues = gh_issue_list(args.repo, labels=["mcp-intake"], limit=50)
seen = {i["number"] for i in issues}
for ii in intake_issues:
if ii["number"] not in seen:
issues.append(ii)
seen.add(ii["number"])
if args.pending_only:
issues = [i for i in issues if not i.get("assignees")]
if args.format == "json":
output = []
for issue in issues:
labels = extract_labels(issue)
output.append({
"number": issue["number"],
"title": issue["title"],
"category": categorize_issue(labels, issue["title"]),
"action": suggest_action(issue, labels),
"dedup_hash": dedup_hash(issue),
"labels": sorted(labels),
"assigned": [a["login"] for a in issue.get("assignees", [])],
})
print(json.dumps(output, indent=2, ensure_ascii=False))
else:
print(format_text(issues))
if args.action_stats:
actions = Counter(suggest_action(i, extract_labels(i)) for i in issues)
print(f"\nAction distribution:")
for action, count in actions.most_common():
print(f" {action}: {count}")
if __name__ == "__main__":
main()