1"""ll-issues append-log: Append a session log entry to an issue file."""

2

3 from __future__ import annotations

4

5 import sys

6 from pathlib import Path

7 from typing import TYPE_CHECKING

8

9 if TYPE_CHECKING:

10 from little_loops.config import BRConfig

11

12

13 def cmd_append_log(config: BRConfig, args: object) -> int:

14 """Append a correctly-formatted session log entry to an issue file.

15

16 Args:

17 config: Project configuration

18 args: Parsed arguments with issue_path and command attributes

19

20 Returns:

21 Exit code (0 = success, 1 = error)

22 """

23 from little_loops.session_log import append_session_log_entry

24

25 issue_path = Path(args.issue_path) # type: ignore[attr-defined]

26 success = append_session_log_entry(issue_path, args.log_command) # type: ignore[attr-defined]

27 if not success:

28 print(

29 "Warning: could not resolve session JSONL; entry not written.",

30 file=sys.stderr,

31 )

32 return 1

33 return 0