66import sys
77from datetime import datetime
88
9+
910def run_gh_command (cmd ):
1011 """Run a gh CLI command and return JSON output."""
1112 try :
1213 result = subprocess .run (
13- cmd ,
14- shell = True ,
15- capture_output = True ,
16- text = True ,
17- timeout = 30
14+ cmd , shell = True , capture_output = True , text = True , timeout = 30
1815 )
1916 if result .returncode == 0 and result .stdout :
2017 return json .loads (result .stdout )
@@ -23,59 +20,67 @@ def run_gh_command(cmd):
2320 print (f"Error running command: { e } " , file = sys .stderr )
2421 return None
2522
23+
2624def fetch_issues ():
2725 """Fetch open issues from GitHub."""
28- cmd = ' gh issue list --json number,title,body,labels,reactions --limit 20'
26+ cmd = " gh issue list --json number,title,body,labels --limit 20"
2927 data = run_gh_command (cmd )
30-
28+
3129 if not data :
3230 return []
33-
31+
3432 # Parse and filter by labels
3533 issues = []
3634 for item in data :
37- labels = [l .get (' name' , '' ) for l in item .get (' labels' , [])]
38-
35+ labels = [l .get (" name" , "" ) for l in item .get (" labels" , [])]
36+
3937 # Prioritize agent-input and agent-help-wanted
4038 priority = 0
41- if ' agent-input' in labels :
39+ if " agent-input" in labels :
4240 priority = 10
43- elif ' agent-help-wanted' in labels :
41+ elif " agent-help-wanted" in labels :
4442 priority = 5
45- elif ' agent-self' in labels :
43+ elif " agent-self" in labels :
4644 priority = 1
47-
45+
4846 if priority > 0 :
49- issues .append ({
50- 'number' : item ['number' ],
51- 'title' : item ['title' ],
52- 'body' : item ['body' ] or '' ,
53- 'priority' : priority ,
54- 'labels' : labels
55- })
56-
47+ issues .append (
48+ {
49+ "number" : item ["number" ],
50+ "title" : item ["title" ],
51+ "body" : item ["body" ] or "" ,
52+ "priority" : priority ,
53+ "labels" : labels ,
54+ }
55+ )
56+
5757 # Sort by priority (descending) then by number (descending)
58- issues .sort (key = lambda x : (- x [' priority' ], - x [' number' ]))
59-
58+ issues .sort (key = lambda x : (- x [" priority" ], - x [" number" ]))
59+
6060 return issues [:10 ] # Top 10 issues
6161
62+
6263def main ():
6364 """Generate ISSUES_TODAY.md from GitHub issues."""
6465 issues = fetch_issues ()
65-
66+
6667 if not issues :
67- print ("# Issues Today\n \n No open issues labeled with agent-input or agent-help-wanted." , file = sys .stdout )
68+ print (
69+ "# Issues Today\n \n No open issues labeled with agent-input or agent-help-wanted." ,
70+ file = sys .stdout ,
71+ )
6872 return
69-
73+
7074 output = ["# Issues Today\n " ]
71-
75+
7276 for issue in issues :
7377 output .append (f"## Issue #{ issue ['number' ]} : { issue ['title' ]} \n " )
7478 output .append (f"Labels: { ', ' .join (issue ['labels' ])} \n \n " )
7579 output .append (f"{ issue ['body' ]} \n \n " )
7680 output .append ("---\n \n " )
77-
78- print ('' .join (output ), file = sys .stdout )
7981
80- if __name__ == '__main__' :
82+ print ("" .join (output ), file = sys .stdout )
83+
84+
85+ if __name__ == "__main__" :
8186 main ()
0 commit comments