Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/check-policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"


Expand Down
16 changes: 14 additions & 2 deletions tests/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'), [])
Expand All @@ -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')
Expand Down
Loading