From 5e7aa4b1374a4803441f76e02fe45f3a9c19eb37 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 --- README.md | 2 +- scripts/check-policy.py | 2 +- tests/test_policy.py | 34 +++++++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2f2ef4c..9e7232e 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.swift` 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..836e256 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.swift", ".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..b1e833d 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.swift", ".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.swift."): 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.swift", ".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.swift.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.swift", 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.swift", 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,19 @@ 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.swift", "!/.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.swift", + '// 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.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), []) From ea486f6b3b38a52bd8a7f30e9679864294d09e38 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 --- README.md | 2 +- scripts/check-policy.py | 2 +- tests/test_policy.py | 30 ++++++++++++++---------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9e7232e..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.swift` +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 836e256..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.swift", ".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 b1e833d..19c2157 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -118,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.swift", ".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.swift."): + '"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.swift", ".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.swift.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.swift", + 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.swift", 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)) @@ -223,18 +223,16 @@ 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.swift", "!/.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.swift", - '// 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.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")