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

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

2

3 from __future__ import annotations

4

5 import argparse

6 import os

7 from pathlib import Path

8

9 from little_loops.cli.output import configure_output

10 from little_loops.cli_args import (

11 add_common_auto_args,

12 parse_issue_ids,

13 parse_issue_ids_ordered,

14 parse_issue_types,

15)

16 from little_loops.config import BRConfig

17 from little_loops.issue_manager import AutoManager

18

19

20 def main_auto() -> int:

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

22

23 Process all backlog issues sequentially in priority order.

24

25 Returns:

26 Exit code (0 = success)

27 """

28 parser = argparse.ArgumentParser(

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

30 formatter_class=argparse.RawDescriptionHelpFormatter,

31 epilog="""

32 Examples:

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

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

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

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

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

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

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

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

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

42""",

43 )

44

45 # Add common arguments from shared module

46 add_common_auto_args(parser)

47

48 # Add tool-specific arguments

49 parser.add_argument(

50 "--category",

51 "-c",

52 type=str,

53 default=None,

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

55 )

56

57 args = parser.parse_args()

58

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

60 config = BRConfig(project_root)

61 configure_output(config.cli)

62

63 if args.idle_timeout is not None:

64 config.automation.idle_timeout_seconds = args.idle_timeout

65

66 if args.handoff_threshold is not None:

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

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

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

70

71 # Parse issue ID filters

72 only_ids = parse_issue_ids_ordered(args.only)

73 skip_ids = parse_issue_ids(args.skip)

74 type_prefixes = parse_issue_types(args.type)

75

76 manager = AutoManager(

77 config=config,

78 dry_run=args.dry_run,

79 max_issues=args.max_issues,

80 resume=args.resume,

81 category=args.category,

82 only_ids=only_ids,

83 skip_ids=skip_ids,

84 type_prefixes=type_prefixes,

85 verbose=not args.quiet,

86 )

87

88 return manager.run()