diff --git a/scripts/check-policy.py b/scripts/check-policy.py index 17b0ad8..b2e24d4 100755 --- a/scripts/check-policy.py +++ b/scripts/check-policy.py @@ -25,7 +25,7 @@ TOOL_ATTRIBUTION = re.compile(r"Generated" r" with|cursor\.com|anthropic\.com|claude\.ai|openai\.com", re.I) # The agents CLI's committed declaration and lock name agent IDs such as codex; # instruction units under .agent/instructions/ are tracked repository guidance. -AGENT_STATE_FILES = {".agent/agents.json", ".agent/agents.resolved"} +AGENT_STATE_FILES = {".agent/agents.yaml", ".agent/agents.resolved"} AGENT_INSTRUCTIONS = ".agent/instructions/" diff --git a/tests/test_policy.py b/tests/test_policy.py index ceaa313..e8f1c05 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -55,6 +55,11 @@ def test_dispatch_requires_a_full_nonzero_github_sha(self): class GitRangeTests(unittest.TestCase): def setUp(self): + environment = {key: value for key, value in os.environ.items() if not key.startswith("GIT_")} + environment.update(GIT_CONFIG_NOSYSTEM="1", GIT_CONFIG_GLOBAL=os.devnull) + isolation = mock.patch.dict(os.environ, environment, clear=True) + isolation.start() + self.addCleanup(isolation.stop) self.root = ROOT / '.build/test-policy' self.root.mkdir(parents=True) self.addCleanup(shutil.rmtree, self.root) @@ -319,7 +324,14 @@ def test_attributes_cannot_hide_text_or_disable_whitespace_policy(self): def test_agents_instruction_files_are_tracked_and_other_agent_files_stay_private(self): (self.root / '.agent/instructions/shared').mkdir(parents=True) (self.root / '.agent/instructions/shared/route.md').write_text('---\ndescription: Route changes.\n---\n## Route\n') - (self.root / '.agent/agents.json').write_text('{"instructions": {"agents": ["claude-code", "codex"]}}\n') + (self.root / '.agent/agents.yaml').write_text( + 'version: 1\n' + 'components:\n' + ' - kind: instructions\n' + ' sections:\n' + ' - name: shared/route\n' + ' agents: [claude-code, codex, cursor]\n' + ) (self.root / '.agent/agents.resolved').write_text('{"instructions": {"chatgpt": {}}}\n') head = self.commit('docs: declare agent instructions') self.assertEqual(policy.check(self.event(head, 'docs: declare agent instructions'), 'pull_request'), []) @@ -328,7 +340,7 @@ def test_agents_instruction_files_are_tracked_and_other_agent_files_stay_private (self.root / '.agent/cache').mkdir() (self.root / '.agent/cache/state').write_text('state\n') private = ('.agent/instructions/shared/.agent/cache/state', '.agent/instructions/.work' + 'space/notes.md', - '.agent/instructions/PLANS.md', 'plugin/.agent/agents.json', '.agent/agents.json.bak') + '.agent/instructions/PLANS.md', 'plugin/.agent/agents.yaml', '.agent/agents.yaml.bak') for path in private: (self.root / path).parent.mkdir(parents=True, exist_ok=True) (self.root / path).write_text('state\n')