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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/*`,
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
TASK_REFERENCE = re.compile(r"(?<![\w.-])[.]agent[/\\][^\s`\"'<>]+")
# 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/**"}
Expand Down
32 changes: 23 additions & 9 deletions tests/test_policy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import importlib.util
import io
import os
import json
import re
from contextlib import redirect_stdout
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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), [])
Expand Down
Loading