import pytest from agentci.domain.commands import CommandError, parse_command, resolve_job_kind from agentci.domain.models import CommandName, JobKind def test_ignores_non_commands() -> None: assert parse_command("please run /agent plan") is None def test_parses_multiline_message() -> None: command = parse_command("/agent implement focus on API\nand add tests") assert command is not None assert command.name is CommandName.IMPLEMENT assert command.message == "focus on API\nand add tests" assert resolve_job_kind(command, is_pull_request=False) is JobKind.IMPLEMENT def test_discuss_requires_message() -> None: with pytest.raises(CommandError, match="requires a message"): parse_command("/agent discuss") def test_rejects_wrong_location() -> None: command = parse_command("/agent fix") assert command is not None with pytest.raises(CommandError, match="pull request"): resolve_job_kind(command, is_pull_request=False) def test_resolves_iterate_by_location() -> None: command = parse_command("/agent iterate refine tests") assert command is not None assert resolve_job_kind(command, is_pull_request=False) is JobKind.ITERATE_PLAN assert resolve_job_kind(command, is_pull_request=True) is JobKind.ITERATE_IMPLEMENT