From 5d39e9ea1b6dcfff2398da5b324069f378926646 Mon Sep 17 00:00:00 2001 From: showxu <10173746+showxu@users.noreply.github.com> Date: Fri, 6 Nov 2026 17:53:15 +0800 Subject: [PATCH 1/2] fix: accept Swift agent declarations --- scripts/check-policy.py | 2 +- tests/test_policy.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/check-policy.py b/scripts/check-policy.py index 17b0ad8..5a8315d 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.swift", ".agent/agents.resolved"} AGENT_INSTRUCTIONS = ".agent/instructions/" diff --git a/tests/test_policy.py b/tests/test_policy.py index ceaa313..41ed635 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,16 @@ 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.swift').write_text( + '// agents-tools-version: 1.0\n' + 'import AgentsDescription\n' + '\n' + 'let agents = Agents(\n' + ' components: [\n' + ' .instructions(sections: ["guide"], agents: [.claudeCode, .codex, .cursor]),\n' + ' ]\n' + ')\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 +342,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.swift', '.agent/Agents.swift.bak') for path in private: (self.root / path).parent.mkdir(parents=True, exist_ok=True) (self.root / path).write_text('state\n') From ae85a926c57ab2c6e251130d345e2611fc358154 Mon Sep 17 00:00:00 2001 From: showxu <10173746+showxu@users.noreply.github.com> Date: Mon, 16 Nov 2026 01:31:43 +0800 Subject: [PATCH 2/2] fix: recognize canonical YAML declarations --- scripts/check-policy.py | 2 +- tests/test_policy.py | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/scripts/check-policy.py b/scripts/check-policy.py index 5a8315d..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.swift", ".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 41ed635..e8f1c05 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -324,15 +324,13 @@ 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.swift').write_text( - '// agents-tools-version: 1.0\n' - 'import AgentsDescription\n' - '\n' - 'let agents = Agents(\n' - ' components: [\n' - ' .instructions(sections: ["guide"], agents: [.claudeCode, .codex, .cursor]),\n' - ' ]\n' - ')\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') @@ -342,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.swift', '.agent/Agents.swift.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')