diff --git a/README.md b/README.md index 2f2ef4c..39356ea 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ and [Signing](https://github.com/computer-mcp/.github/blob/master/MAINTENANCE.md | PR titles, added content and added/modified paths; verified default-branch commits | PR diffs use the merge base; pushes check their supplied range; removed lines are outside the added-content check | Local task state is any path under `.agent/` except the agents CLI's tracked -instruction units in `.agent/instructions/`, its `.agent/agents.json` +instruction units in `.agent/instructions/`, its `.agent/agents.yaml` declaration and its `.agent/agents.resolved` lock at the repository root. An `.agent/` directory nested under the units or elsewhere remains task state; references to the whole root directory, such as an ignore rule for `.agent/*`, diff --git a/scripts/check-policy.py b/scripts/check-policy.py index 017d0ed..2570815 100644 --- a/scripts/check-policy.py +++ b/scripts/check-policy.py @@ -21,7 +21,7 @@ TASK_REFERENCE = re.compile(r"(?]+") # The agents CLI's instruction units, declaration and lock at the repository root # are tracked repository guidance; everything else under .agent/ is local task state. -AGENT_FILES = {".agent/agents.json", ".agent/agents.resolved"} +AGENT_FILES = {".agent/agents.yaml", ".agent/agents.resolved"} AGENT_INSTRUCTIONS = ".agent/instructions/" # Ignore rules for the whole directory name no task file. AGENT_PATTERNS = {".agent/*", ".agent/**"} diff --git a/tests/test_policy.py b/tests/test_policy.py index 4d066e7..19c2157 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -1,6 +1,7 @@ import copy import importlib.util import io +import os import json import re from contextlib import redirect_stdout @@ -117,22 +118,22 @@ def test_private_paths_and_task_references(self): self.assertEqual(policy.content_findings("file", text, path=True), []) def test_agent_instruction_files_are_repository_guidance(self): - for text in (".agent/agents.json", ".agent/agents.resolved", ".agent/instructions/guide.md", + for text in (".agent/agents.yaml", ".agent/agents.resolved", ".agent/instructions/guide.md", ".agent/instructions/shared/plugin-rules.md", "`.agent/instructions/shared/`", "/.agent/*", "`/.agent/*`", "!/.agent/instructions/", - '"path" : ".agent/instructions/guide.md",', "Edit .agent/agents.json."): + '"path" : ".agent/instructions/guide.md",', "Edit .agent/agents.yaml."): with self.subTest(text=text): self.assertEqual(policy.content_findings("file", text), []) - for path in (".agent/agents.json", ".agent/agents.resolved", ".agent/instructions/guide.md"): + for path in (".agent/agents.yaml", ".agent/agents.resolved", ".agent/instructions/guide.md"): with self.subTest(path=path): self.assertEqual(policy.content_findings(path, path, path=True), []) - for text in (f"{AGENT}/.agents.lock", f"{AGENT}/cache/source", f"{AGENT}/agents.json.bak", + for text in (f"{AGENT}/.agents.lock", f"{AGENT}/cache/source", f"{AGENT}/agents.yaml.bak", f"{AGENT}/instructions/../plans/task.md", "/.agent/* and " + TASK, - f"{AGENT}/instructions/shared/{AGENT}/cache/state", f"plugin/{AGENT}/agents.json", + f"{AGENT}/instructions/shared/{AGENT}/cache/state", f"plugin/{AGENT}/agents.yaml", f"../{AGENT}/instructions/guide.md", "https://example.org/r/blob/master/" + TASK): with self.subTest(text=text): self.assertTrue(policy.content_findings("file", text)) - for path in (f"plugin/{AGENT}/agents.json", f"{AGENT}/transaction.json", f"{AGENT}/instructions.md", + for path in (f"plugin/{AGENT}/agents.yaml", f"{AGENT}/transaction.json", f"{AGENT}/instructions.md", f"{AGENT}/instructions/shared/{AGENT}/cache/state", ".agent/*"): with self.subTest(path=path): self.assertTrue(policy.content_findings(path, path, path=True)) @@ -176,7 +177,13 @@ def test_unverified_wrong_identity_sha_and_owner_signature_fail(self): class GitRangeTests(unittest.TestCase): def setUp(self): - temporary = tempfile.TemporaryDirectory() + 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 = patch.dict(os.environ, environment, clear=True) + isolation.start() + self.addCleanup(isolation.stop) + (ROOT / ".build").mkdir(exist_ok=True) + temporary = tempfile.TemporaryDirectory(dir=ROOT / ".build") self.addCleanup(temporary.cleanup) self.root = Path(temporary.name) self.git("init", "-q", "-b", "master") @@ -216,10 +223,17 @@ def test_pr_checks_title_messages_content_and_paths_without_signature_api(self): self.api.get.assert_not_called() def test_committed_agent_instruction_files_pass_while_task_state_fails(self): - rules = ("/.agent/*", "!/.agent/instructions/", "!/.agent/agents.json", "!/.agent/agents.resolved") + rules = ("/.agent/*", "!/.agent/instructions/", "!/.agent/agents.yaml", "!/.agent/agents.resolved") self.write(".gitignore", "\n".join(rules) + "\n") self.write(".agent/instructions/guide.md", "# Guide\n") - self.write(".agent/agents.json", '{"instructions": {"agents": ["claude-code", "codex"], "sections": ["guide"]}}\n') + self.write(".agent/agents.yaml", + 'version: 1\n' + 'components:\n' + ' - kind: instructions\n' + ' sections:\n' + ' - name: guide\n' + ' agents: [claude-code, codex, cursor]\n' + ) self.write(".agent/agents.resolved", '{"path" : ".agent/instructions/guide.md"}\n') head = self.commit("docs: generate AGENTS.md from instruction units") self.assertEqual(policy.check(self.root, self.event(head), "pull_request", RULES, self.api), [])