Coverage for little_loops / cli / auto.py: 79%

34 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2026-05-22 16:19 -0500

1"""ll-auto: Process all backlog issues sequentially in priority order.""" 

2 

3from __future__ import annotations 

4 

5import argparse 

6import os 

7from pathlib import Path 

8 

9from little_loops.cli.output import configure_output 

10from little_loops.cli_args import ( 

11 add_common_auto_args, 

12 parse_issue_ids, 

13 parse_issue_ids_ordered, 

14 parse_issue_types, 

15 parse_labels, 

16 parse_priorities, 

17) 

18from little_loops.config import BRConfig 

19from little_loops.issue_manager import AutoManager 

20 

21 

22def main_auto() -> int: 

23 """Entry point for ll-auto command. 

24 

25 Process all backlog issues sequentially in priority order. 

26 

27 Returns: 

28 Exit code (0 = success) 

29 """ 

30 parser = argparse.ArgumentParser( 

31 description="Process all backlog issues sequentially in priority order", 

32 formatter_class=argparse.RawDescriptionHelpFormatter, 

33 epilog=""" 

34Examples: 

35 %(prog)s # Process all issues in priority order 

36 %(prog)s --max-issues 5 # Process at most 5 issues 

37 %(prog)s --resume # Resume from previous state 

38 %(prog)s --dry-run # Preview what would be processed 

39 %(prog)s --category bugs # Only process bugs 

40 %(prog)s --only BUG-001,BUG-002 # Process only specific issues 

41 %(prog)s --skip BUG-003 # Skip specific issues 

42 %(prog)s --type BUG # Process only bugs 

43 %(prog)s --type BUG,ENH # Process bugs and enhancements 

44 %(prog)s --priority P1,P2 # Only process P1 and P2 issues 

45""", 

46 ) 

47 

48 # Add common arguments from shared module 

49 add_common_auto_args(parser) 

50 

51 # Add tool-specific arguments 

52 parser.add_argument( 

53 "--category", 

54 "-c", 

55 type=str, 

56 default=None, 

57 help="Filter to specific category (bugs, features, enhancements)", 

58 ) 

59 parser.add_argument( 

60 "--verbose", 

61 "-v", 

62 action="store_true", 

63 help="Enable verbose output (default when --quiet is not set)", 

64 ) 

65 

66 args = parser.parse_args() 

67 

68 project_root = args.config or Path.cwd() 

69 config = BRConfig(project_root) 

70 configure_output(config.cli) 

71 

72 if args.idle_timeout is not None: 

73 config.automation.idle_timeout_seconds = args.idle_timeout 

74 

75 if args.handoff_threshold is not None: 

76 if not (1 <= args.handoff_threshold <= 100): 

77 parser.error("--handoff-threshold must be between 1 and 100") 

78 os.environ["LL_HANDOFF_THRESHOLD"] = str(args.handoff_threshold) 

79 

80 if args.context_limit is not None: 

81 if args.context_limit < 50000: 

82 parser.error("--context-limit must be at least 50000") 

83 os.environ["LL_CONTEXT_LIMIT"] = str(args.context_limit) 

84 

85 # Parse issue ID filters 

86 only_ids = parse_issue_ids_ordered(args.only) 

87 skip_ids = parse_issue_ids(args.skip) 

88 type_prefixes = parse_issue_types(args.type) 

89 priority_filter = parse_priorities(args.priority) 

90 label_filter = parse_labels(args.label) 

91 

92 manager = AutoManager( 

93 config=config, 

94 dry_run=args.dry_run, 

95 max_issues=args.max_issues, 

96 resume=args.resume, 

97 category=args.category, 

98 only_ids=only_ids, 

99 skip_ids=skip_ids, 

100 type_prefixes=type_prefixes, 

101 priority_filter=priority_filter, 

102 label_filter=label_filter, 

103 verbose=args.verbose or not args.quiet, 

104 preview_full=args.verbose, 

105 ) 

106 

107 return manager.run()