Coverage for little_loops / cli / issues / next_issue.py: 0%

19 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2026-04-02 13:03 -0500

1"""ll-issues next-issue: Print the highest-confidence active issue.""" 

2 

3from __future__ import annotations 

4 

5import argparse 

6from typing import TYPE_CHECKING 

7 

8if TYPE_CHECKING: 

9 from little_loops.config import BRConfig 

10 

11 

12def cmd_next_issue(config: BRConfig, args: argparse.Namespace) -> int: 

13 """Print the highest-confidence active issue. 

14 

15 Sort key: (-(outcome_confidence or -1), -(confidence_score or -1), priority_int) 

16 

17 Args: 

18 config: Project configuration 

19 args: Parsed arguments with optional .json and .path flags 

20 

21 Returns: 

22 Exit code (0 = found, 1 = no issues) 

23 """ 

24 from little_loops.cli.output import print_json 

25 from little_loops.issue_parser import find_issues 

26 

27 issues = find_issues(config) 

28 if not issues: 

29 return 1 

30 

31 issues.sort( 

32 key=lambda i: ( 

33 -(i.outcome_confidence if i.outcome_confidence is not None else -1), 

34 -(i.confidence_score if i.confidence_score is not None else -1), 

35 i.priority_int, 

36 ) 

37 ) 

38 

39 top = issues[0] 

40 

41 if getattr(args, "json", False): 

42 print_json( 

43 { 

44 "id": top.issue_id, 

45 "path": str(top.path), 

46 "outcome_confidence": top.outcome_confidence, 

47 "confidence_score": top.confidence_score, 

48 "priority": top.priority, 

49 } 

50 ) 

51 return 0 

52 

53 if getattr(args, "path", False): 

54 print(str(top.path)) 

55 return 0 

56 

57 print(top.issue_id) 

58 return 0