Coverage for little_loops / cli / issues / next_issue.py: 19%
21 statements
« prev ^ index » next coverage.py v7.12.0, created at 2026-04-11 23:20 -0500
« prev ^ index » next coverage.py v7.12.0, created at 2026-04-11 23:20 -0500
1"""ll-issues next-issue: Print the highest-confidence active issue."""
3from __future__ import annotations
5import argparse
6from typing import TYPE_CHECKING
8if TYPE_CHECKING:
9 from little_loops.config import BRConfig
12def cmd_next_issue(config: BRConfig, args: argparse.Namespace) -> int:
13 """Print the highest-confidence active issue.
15 Sort key: (-(outcome_confidence or -1), -(confidence_score or -1), priority_int)
17 Args:
18 config: Project configuration
19 args: Parsed arguments with optional .json and .path flags
21 Returns:
22 Exit code (0 = found, 1 = no issues)
23 """
24 from little_loops.cli.output import print_json
25 from little_loops.cli_args import parse_issue_ids
26 from little_loops.issue_parser import find_issues
28 skip_ids = parse_issue_ids(getattr(args, "skip", None))
29 issues = find_issues(config, skip_ids=skip_ids or None)
30 if not issues:
31 return 1
33 issues.sort(
34 key=lambda i: (
35 -(i.outcome_confidence if i.outcome_confidence is not None else -1),
36 -(i.confidence_score if i.confidence_score is not None else -1),
37 i.priority_int,
38 )
39 )
41 top = issues[0]
43 if getattr(args, "json", False):
44 print_json(
45 {
46 "id": top.issue_id,
47 "path": str(top.path),
48 "outcome_confidence": top.outcome_confidence,
49 "confidence_score": top.confidence_score,
50 "priority": top.priority,
51 }
52 )
53 return 0
55 if getattr(args, "path", False):
56 print(str(top.path))
57 return 0
59 print(top.issue_id)
60 return 0