diff --git a/cchk.toml b/cchk.toml index 76054f7f..a870d711 100644 --- a/cchk.toml +++ b/cchk.toml @@ -18,6 +18,7 @@ ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "code [branch] # https://conventional-branch.github.io/ conventional_branch = true -allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix", "copilot"] +# Explicit list needed until AI agent prefixes are in a released version of commit-check +allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix", "ai", "claude", "codex", "copilot", "cursor"] require_rebase_target = "main" ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "shenxianpeng"] diff --git a/commit_check/__init__.py b/commit_check/__init__.py index aeecd10a..fcab5eb4 100644 --- a/commit_check/__init__.py +++ b/commit_check/__init__.py @@ -31,7 +31,8 @@ "build", "ci", ] -# Follow conventional branch +# Follow conventional branch (https://conventionalbranch.org/) +# Includes AI agent prefixes added in spec v1.1.0 DEFAULT_BRANCH_TYPES = [ "feature", "bugfix", @@ -40,6 +41,12 @@ "chore", "feat", "fix", + # AI agent prefixes (conventional branch spec v1.1.0) + "ai", + "claude", + "codex", + "copilot", + "cursor", ] # Additional allowed branch names (e.g., develop, staging) DEFAULT_BRANCH_NAMES: list[str] = [] diff --git a/tests/rule_builder_test.py b/tests/rule_builder_test.py index 27d37128..2892de1c 100644 --- a/tests/rule_builder_test.py +++ b/tests/rule_builder_test.py @@ -215,6 +215,35 @@ def test_rule_builder_allow_branch_names_empty_list(self): assert "(HEAD)" in rule.regex assert "(PR-.+)" in rule.regex + @pytest.mark.benchmark + def test_ai_agent_branch_types_in_default(self): + """AI agent prefixes from conventional branch spec v1.1.0 are valid by default.""" + import re + from commit_check import DEFAULT_BRANCH_TYPES + + assert "ai" in DEFAULT_BRANCH_TYPES + assert "claude" in DEFAULT_BRANCH_TYPES + assert "codex" in DEFAULT_BRANCH_TYPES + assert "copilot" in DEFAULT_BRANCH_TYPES + assert "cursor" in DEFAULT_BRANCH_TYPES + + config = {"branch": {"conventional_branch": True}} + builder = RuleBuilder(config) + catalog_entry = RuleCatalogEntry(check="branch", regex="", error="", suggest="") + rule = builder._build_conventional_branch_rule(catalog_entry) + assert rule is not None + + ai_agent_branches = [ + "ai/refactor-auth-flow", + "claude/stoic-hypatia-v65p1f", + "claude/fix-login-bug", + "codex/optimize-query", + "copilot/add-login-page", + "cursor/fix-header-bug", + ] + for branch in ai_agent_branches: + assert re.match(rule.regex, branch), f"Branch '{branch}' should be valid" + @pytest.mark.benchmark def test_rule_builder_allow_branch_names_with_duplicates(self): """Test RuleBuilder with duplicate branch names in allow_branch_names."""