Skip to content

Commit 5a572a4

Browse files
committed
refactor: rename [agent_config] to [agent]
Every other section is one word: commit, branch, push, tag, files. The flags become --agent-enabled, --agent-allow-mcp-servers and --agent-allow-api-endpoints, and the env vars CCHK_AGENT_ENABLED, CCHK_AGENT_ALLOW_MCP_SERVERS and CCHK_AGENT_ALLOW_API_ENDPOINTS.
1 parent 8130326 commit 5a572a4

8 files changed

Lines changed: 48 additions & 53 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ Priority: CLI > env > TOML > default. Booleans accept `true/false`, `yes/no`,
153153
| `files.max_size` | `""` (off) | `--files-max-size` | `CCHK_FILES_MAX_SIZE` | Largest committed file, in bytes or with `KB`/`MB`/`GB` (CC302) |
154154
| `files.prohibited_patterns` | `[]` | `--files-prohibited-patterns` | `CCHK_FILES_PROHIBITED_PATTERNS` | fnmatch patterns committed paths must not match (CC303) |
155155
| `files.max_path_length` | `0` (off) | `--files-max-path-length` | `CCHK_FILES_MAX_PATH_LENGTH` | Longest allowed committed path, in characters (CC304) |
156-
| `agent_config.enabled` | `false` | `--agent-config-enabled` | `CCHK_AGENT_CONFIG_ENABLED` | Report risky settings in the agent config files a commit touches, with `--files`: MCP servers approved without asking (CC601), API requests sent to another endpoint (CC602), commands run without asking or outside the sandbox (CC603), and agent workflows anyone can start (CC604). Covers Claude Code, Codex, Gemini CLI, Cursor CLI, GitHub Copilot in VS Code and the Claude Code GitHub Action; the list is [`agent_configs.toml`](https://github.com/commit-check/commit-check/blob/main/commit_check/agent_configs.toml) |
157-
| `agent_config.allow_mcp_servers` | `[]` | `--agent-config-allow-mcp-servers` | `CCHK_AGENT_CONFIG_ALLOW_MCP_SERVERS` | MCP servers, by name, that the agent config may approve (CC601) |
158-
| `agent_config.allow_api_endpoints` | `[]` | `--agent-config-allow-api-endpoints` | `CCHK_AGENT_CONFIG_ALLOW_API_ENDPOINTS` | API endpoint URLs the agent config may send requests to (CC602), such as your company's LLM gateway |
156+
| `agent.enabled` | `false` | `--agent-enabled` | `CCHK_AGENT_ENABLED` | Report risky settings in the agent config files a commit touches, with `--files`: MCP servers approved without asking (CC601), API requests sent to another endpoint (CC602), commands run without asking or outside the sandbox (CC603), and agent workflows anyone can start (CC604). Covers Claude Code, Codex, Gemini CLI, Cursor CLI, GitHub Copilot in VS Code and the Claude Code GitHub Action; the list is [`agent_configs.toml`](https://github.com/commit-check/commit-check/blob/main/commit_check/agent_configs.toml) |
157+
| `agent.allow_mcp_servers` | `[]` | `--agent-allow-mcp-servers` | `CCHK_AGENT_ALLOW_MCP_SERVERS` | MCP servers, by name, that the agent config may approve (CC601) |
158+
| `agent.allow_api_endpoints` | `[]` | `--agent-allow-api-endpoints` | `CCHK_AGENT_ALLOW_API_ENDPOINTS` | API endpoint URLs the agent config may send requests to (CC602), such as your company's LLM gateway |
159159
| `pull_request.ai_declaration_checkboxes` | `[]` (off) | — | — | The AI declaration checkboxes of your pull request template (often headed "AI disclosure"), e.g. `["No AI tools were used", "AI tools were used"]`. A description checked with `--ai-attribution-only` must tick exactly one of them (CC501). Each entry matches a box whose text starts with it, ignoring case and bold; boxes in HTML comments and code blocks do not count |
160160

161161
Output and appearance are per-run flags, not configuration: `--format json`,

‎commit_check/agent_config.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"agent-unrestricted-trigger": "agent_unrestricted_trigger",
3737
}
3838

39-
#: The ``[agent_config]`` list that lets a finding of each check through,
39+
#: The ``[agent]`` list that lets a finding of each check through,
4040
#: for the checks that have one. A server is let through by its name, an
4141
#: endpoint by its URL.
4242
ALLOWLISTS = {
@@ -509,7 +509,7 @@ def find_settings(
509509

510510

511511
def is_allowed(finding: Finding, allowed: Iterable[str]) -> bool:
512-
"""Whether an ``[agent_config]`` allowlist lets *finding* through.
512+
"""Whether an ``[agent]`` allowlist lets *finding* through.
513513
514514
An endpoint matches with or without a trailing slash; anything else
515515
must match exactly. A URL is never matched by its start, which

‎commit_check/ci.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
"author-name": "check the author name of every commit",
5050
"author-email": "check the author email of every commit",
5151
"files": (
52-
"check the files every commit changes against the [files] and "
53-
"[agent_config] rules"
52+
"check the files every commit changes against the [files] and [agent] rules"
5453
),
5554
"pr-title": "check the title against the commit message rules",
5655
"pr-body-ai-attribution": (

‎commit_check/config_merger.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get_default_config() -> dict[str, Any]:
109109
"prohibited_patterns": [],
110110
"max_path_length": 0,
111111
},
112-
"agent_config": {
112+
"agent": {
113113
"enabled": False,
114114
"allow_mcp_servers": [],
115115
"allow_api_endpoints": [],
@@ -228,15 +228,15 @@ class ConfigMerger:
228228
"CCHK_FILES_MAX_SIZE": ("files", "max_size", str),
229229
"CCHK_FILES_PROHIBITED_PATTERNS": ("files", "prohibited_patterns", parse_list),
230230
"CCHK_FILES_MAX_PATH_LENGTH": ("files", "max_path_length", parse_int),
231-
# Agent config section
232-
"CCHK_AGENT_CONFIG_ENABLED": ("agent_config", "enabled", parse_bool),
233-
"CCHK_AGENT_CONFIG_ALLOW_MCP_SERVERS": (
234-
"agent_config",
231+
# Agent section
232+
"CCHK_AGENT_ENABLED": ("agent", "enabled", parse_bool),
233+
"CCHK_AGENT_ALLOW_MCP_SERVERS": (
234+
"agent",
235235
"allow_mcp_servers",
236236
parse_list,
237237
),
238-
"CCHK_AGENT_CONFIG_ALLOW_API_ENDPOINTS": (
239-
"agent_config",
238+
"CCHK_AGENT_ALLOW_API_ENDPOINTS": (
239+
"agent",
240240
"allow_api_endpoints",
241241
parse_list,
242242
),
@@ -280,11 +280,11 @@ class ConfigMerger:
280280
"files_max_size": ("files", "max_size"),
281281
"files_prohibited_patterns": ("files", "prohibited_patterns"),
282282
"files_max_path_length": ("files", "max_path_length"),
283-
# Agent config section
284-
"agent_config_enabled": ("agent_config", "enabled"),
285-
"agent_config_allow_mcp_servers": ("agent_config", "allow_mcp_servers"),
286-
"agent_config_allow_api_endpoints": (
287-
"agent_config",
283+
# Agent section
284+
"agent_enabled": ("agent", "enabled"),
285+
"agent_allow_mcp_servers": ("agent", "allow_mcp_servers"),
286+
"agent_allow_api_endpoints": (
287+
"agent",
288288
"allow_api_endpoints",
289289
),
290290
}
@@ -303,7 +303,7 @@ def parse_env_vars(notices: list[dict[str, str]] | None = None) -> dict[str, Any
303303
"push": {},
304304
"tag": {},
305305
"files": {},
306-
"agent_config": {},
306+
"agent": {},
307307
}
308308

309309
for env_var, (section, key, parser) in ConfigMerger.ENV_VAR_MAPPING.items():
@@ -335,7 +335,7 @@ def parse_cli_args(args: argparse.Namespace) -> dict[str, Any]:
335335
"push": {},
336336
"tag": {},
337337
"files": {},
338-
"agent_config": {},
338+
"agent": {},
339339
}
340340

341341
for arg_name, (section, key) in ConfigMerger.CLI_ARG_MAPPING.items():

‎commit_check/main.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def _get_parser() -> argparse.ArgumentParser:
302302
help="check the files the commit at HEAD (or --rev) touches: size "
303303
"limit, prohibited path patterns, path length, and risky settings in "
304304
"agent config files (all off until configured in the [files] and "
305-
"[agent_config] config sections)",
305+
"[agent] config sections)",
306306
action="store_true",
307307
required=False,
308308
)
@@ -644,12 +644,12 @@ def _get_parser() -> argparse.ArgumentParser:
644644

645645
# Agent config options
646646
agent_group = parser.add_argument_group(
647-
"agent config options",
647+
"agent options",
648648
"Configuration options for the agent config rules, run by --files",
649649
)
650650

651651
agent_group.add_argument(
652-
"--agent-config-enabled",
652+
"--agent-enabled",
653653
type=parse_bool,
654654
default=None,
655655
metavar="BOOL",
@@ -658,7 +658,7 @@ def _get_parser() -> argparse.ArgumentParser:
658658
)
659659

660660
agent_group.add_argument(
661-
"--agent-config-allow-mcp-servers",
661+
"--agent-allow-mcp-servers",
662662
type=parse_list,
663663
default=None,
664664
metavar="LIST",
@@ -667,7 +667,7 @@ def _get_parser() -> argparse.ArgumentParser:
667667
)
668668

669669
agent_group.add_argument(
670-
"--agent-config-allow-api-endpoints",
670+
"--agent-allow-api-endpoints",
671671
type=parse_list,
672672
default=None,
673673
metavar="LIST",
@@ -844,7 +844,7 @@ def _get_requested_checks(args: argparse.Namespace) -> set[str]:
844844
tuple(sorted(FILES_CHECKS)),
845845
(
846846
"--files requested but nothing is configured in the [files] or "
847-
"[agent_config] section"
847+
"[agent] section"
848848
),
849849
),
850850
(

‎commit_check/rule_builder.py‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,17 +492,17 @@ def _build_path_length_rule(
492492
def _build_agent_config_rules(self) -> list[ValidationRule]:
493493
"""Build the agent config rules, CC601 to CC604.
494494
495-
Off by default, all four at once: ``[agent_config] enabled = true``
495+
Off by default, all four at once: ``[agent] enabled = true``
496496
turns them on. Each rule that has an allowlist carries it as
497497
``allowed``. ``warn`` can demote any of them on its own.
498498
"""
499-
section = self.config.get("agent_config", {})
499+
section = self.config.get("agent", {})
500500
if not isinstance(section, dict):
501501
if section:
502502
report_notice(
503503
self.notices,
504-
"[agent_config]",
505-
f"[agent_config] must be a table, got {section!r}; "
504+
"[agent]",
505+
f"[agent] must be a table, got {section!r}; "
506506
"the agent config rules are disabled",
507507
)
508508
return []
@@ -511,9 +511,7 @@ def _build_agent_config_rules(self) -> list[ValidationRule]:
511511
rules = []
512512
for catalog_entry in AGENT_CONFIG_RULES:
513513
key = ALLOWLISTS.get(catalog_entry.check)
514-
allowed = (
515-
_string_list(section, key, [], f"[agent_config] {key}") if key else None
516-
)
514+
allowed = _string_list(section, key, [], f"[agent] {key}") if key else None
517515
rules.append(
518516
ValidationRule(
519517
check=catalog_entry.check,

‎tests/agent_config_test.py‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def test_off_by_default(self):
552552

553553
def test_enabled_builds_all_four_with_their_allowlists(self):
554554
config = {
555-
"agent_config": {
555+
"agent": {
556556
"enabled": True,
557557
"allow_mcp_servers": ["github"],
558558
"allow_api_endpoints": "https://a.example.com, https://b.example.com",
@@ -573,27 +573,27 @@ def test_enabled_builds_all_four_with_their_allowlists(self):
573573
assert rules["agent_mcp_auto_approve"].rule_id == "CC601"
574574

575575
def test_enabled_must_be_a_boolean(self):
576-
with pytest.raises(ConfigError, match=r"\[agent_config\] enabled"):
577-
RuleBuilder({"agent_config": {"enabled": "false"}})
576+
with pytest.raises(ConfigError, match=r"\[agent\] enabled"):
577+
RuleBuilder({"agent": {"enabled": "false"}})
578578

579579
def test_an_allowlist_must_be_strings(self):
580-
config = {"agent_config": {"enabled": True, "allow_mcp_servers": [1]}}
580+
config = {"agent": {"enabled": True, "allow_mcp_servers": [1]}}
581581
with pytest.raises(ConfigError, match="allow_mcp_servers"):
582582
RuleBuilder(config).build_all_rules()
583583

584584
def test_a_scalar_section_is_a_notice(self):
585585
notices = []
586-
rules = RuleBuilder({"agent_config": True}, notices).build_all_rules()
586+
rules = RuleBuilder({"agent": True}, notices).build_all_rules()
587587
assert not {r.check for r in rules} & AGENT_CONFIG_CHECKS
588-
assert notices[0]["setting"] == "[agent_config]"
588+
assert notices[0]["setting"] == "[agent]"
589589

590590
def test_an_empty_scalar_section_is_no_notice(self):
591591
notices = []
592-
RuleBuilder({"agent_config": ""}, notices).build_all_rules()
592+
RuleBuilder({"agent": ""}, notices).build_all_rules()
593593
assert notices == []
594594

595595
def test_warn_demotes_one_rule(self):
596-
config = {"agent_config": {"enabled": True}, "warn": ["CC602"]}
596+
config = {"agent": {"enabled": True}, "warn": ["CC602"]}
597597
severity = {r.check: r.severity for r in RuleBuilder(config).build_all_rules()}
598598
assert severity["agent_api_endpoint"] == "warn"
599599
assert severity["agent_mcp_auto_approve"] == "error"
@@ -607,12 +607,10 @@ def _no_args():
607607

608608
class TestConfigSources:
609609
def test_env_vars(self, monkeypatch):
610-
monkeypatch.setenv("CCHK_AGENT_CONFIG_ENABLED", "true")
611-
monkeypatch.setenv("CCHK_AGENT_CONFIG_ALLOW_MCP_SERVERS", "github,notes")
612-
monkeypatch.setenv(
613-
"CCHK_AGENT_CONFIG_ALLOW_API_ENDPOINTS", "https://llm.example.com"
614-
)
615-
assert ConfigMerger.parse_env_vars()["agent_config"] == {
610+
monkeypatch.setenv("CCHK_AGENT_ENABLED", "true")
611+
monkeypatch.setenv("CCHK_AGENT_ALLOW_MCP_SERVERS", "github,notes")
612+
monkeypatch.setenv("CCHK_AGENT_ALLOW_API_ENDPOINTS", "https://llm.example.com")
613+
assert ConfigMerger.parse_env_vars()["agent"] == {
616614
"enabled": True,
617615
"allow_mcp_servers": ["github", "notes"],
618616
"allow_api_endpoints": ["https://llm.example.com"],
@@ -621,9 +619,9 @@ def test_env_vars(self, monkeypatch):
621619
def test_a_misspelt_key_is_named(self):
622620
from commit_check.config_merger import unknown_setting_warnings
623621

624-
[warning] = unknown_setting_warnings({"agent_config": {"enable": True}})
622+
[warning] = unknown_setting_warnings({"agent": {"enable": True}})
625623
assert warning.endswith(
626-
"unknown setting [agent_config] enable is ignored; did you mean enabled?"
624+
"unknown setting [agent] enable is ignored; did you mean enabled?"
627625
)
628626

629627

@@ -846,7 +844,7 @@ def test_a_commit_adding_risky_settings_is_rejected(
846844
'{"enableAllProjectMcpServers": true}', encoding="utf-8"
847845
)
848846
(tmp_path / "cchk.toml").write_text(
849-
"[agent_config]\nenabled = true\n", encoding="utf-8"
847+
"[agent]\nenabled = true\n", encoding="utf-8"
850848
)
851849
_git(tmp_path, "add", "-A")
852850
_git(tmp_path, "commit", "-q", "-m", "chore: add settings")

‎tests/main_test.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ def test_files_with_nothing_configured_is_a_notice_and_a_skip(
13901390
assert data["checks"] == []
13911391
hint = (
13921392
"--files requested but nothing is configured in the [files] or "
1393-
"[agent_config] section"
1393+
"[agent] section"
13941394
)
13951395
assert data["notices"] == [{"setting": "--files", "message": hint}]
13961396
assert f"⊘ {hint}" in err
@@ -1873,7 +1873,7 @@ def test_files_unconfigured_prints_hint(self, capfd, monkeypatch, tmp_path):
18731873
_, err = capfd.readouterr()
18741874
assert (
18751875
"⊘ --files requested but nothing is configured in the [files] or "
1876-
"[agent_config] section" in err
1876+
"[agent] section" in err
18771877
)
18781878

18791879

0 commit comments

Comments
 (0)