From ffebdc658483fd0dd1ad9ffcb1a79fce11c99221 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Tue, 11 Aug 2026 18:34:27 +0000 Subject: [PATCH] fix(kyberforge): stop dotfiles-repo $HOME from shadowing user scope in validate.sh detect_scope() had the same bug class fixed in new-agent.sh (099bdec): it checked for a .git directory before checking whether it had reached $HOME, so a dotfiles-managed home directory (yadm, chezmoi bare-repo, etc.) made validate.sh misresolve to project scope, deriving the counterpart as ~/.github/agents/.agent.md instead of the correct ~/.copilot/agents/.agent.md and failing with a false "counterpart file not found". Check the $HOME boundary before the .git check, same fix shape as 099bdec. Found via post-implementation review of issue #89. --- .../skills/agent-audit/scripts/validate.sh | 8 ++++++- .../skills/agent-audit/tests/validate.bats | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/kyberforge/skills/agent-audit/scripts/validate.sh b/plugins/kyberforge/skills/agent-audit/scripts/validate.sh index 0339939..5ebe829 100755 --- a/plugins/kyberforge/skills/agent-audit/scripts/validate.sh +++ b/plugins/kyberforge/skills/agent-audit/scripts/validate.sh @@ -147,16 +147,22 @@ def find_apm_package_root(apm_yml_path): return False def detect_scope(start_dir): + home = os.path.expanduser('~') current = os.path.abspath(start_dir) while True: apm_yml = os.path.join(current, 'apm.yml') if os.path.isfile(apm_yml) and find_apm_package_root(apm_yml): return 'plugin', current + # $HOME is the user-scope boundary — checked before the .git test + # below, so a dotfiles-managed $HOME (yadm, chezmoi bare-repo, etc.) + # can't shadow user scope by being its own .git repo. + if current == home: + return 'user', home if os.path.isdir(os.path.join(current, '.git')): return 'project', current parent = os.path.dirname(current) if parent == current: - return 'user', os.path.expanduser('~') + return 'user', home current = parent agent_dir = os.path.dirname(agent_file) diff --git a/plugins/kyberforge/skills/agent-audit/tests/validate.bats b/plugins/kyberforge/skills/agent-audit/tests/validate.bats index 4bb1a93..7ed3568 100644 --- a/plugins/kyberforge/skills/agent-audit/tests/validate.bats +++ b/plugins/kyberforge/skills/agent-audit/tests/validate.bats @@ -68,6 +68,30 @@ EOF refute_output --partial "FAIL" } +@test "user scope: \$HOME being a dotfiles .git repo does not shadow user scope" { + local fake_home="$TMPDIR/fakehome" + mkdir -p "$fake_home/.git" "$fake_home/.claude/agents" "$fake_home/.copilot/agents" + cat > "$fake_home/.claude/agents/my-agent.md" < "$fake_home/.copilot/agents/my-agent.agent.md" <