fix(scripts): discover agents when the checkout is a Claude worktree
check-apm-agents-valid.sh filtered find output with `-not -path '*/.claude/worktrees/*'`, matched against absolute paths. When the checkout itself lives at <repo>/.claude/worktrees/<name>/, every path contains that segment, so every agent file was excluded and the gate reported "N of N tracked agent files were not discovered". The walk starts at $REPO_ROOT/plugins, so a nested worktree is unreachable and the filter is dropped. The test suite gains a case that runs the gate from a fixture under .claude/worktrees/, and now unsets inherited GIT_* variables so its git fixtures never resolve to the caller's repository. Fixes #199 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
bf86679d42
commit
bc7673d4f0
2 files changed
+40
-3
No files matched your search
@@ -58,15 +58,18 @@ if ! command -v python3 >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
# --- Discover the agent files ---
|
||||
# `-not -path` mirrors tests/run-bats.sh: worktrees under .claude/ are other
|
||||
# checkouts of this same repo, not additional content.
|
||||
# No `.claude/worktrees` exclusion, unlike tests/run-bats.sh: the walk starts at
|
||||
# $REPO_ROOT/plugins, so a worktree nested at $REPO_ROOT/.claude/worktrees/ is
|
||||
# unreachable and there is nothing to exclude. A `-not -path` glob here would
|
||||
# match against ABSOLUTE paths, and when this checkout is itself a Claude
|
||||
# worktree (<repo>/.claude/worktrees/<name>/) every path contains that segment,
|
||||
# so it excluded every agent file and failed the derived check below (#199).
|
||||
AGENT_FILES=()
|
||||
while IFS= read -r f; do
|
||||
[[ -n "$f" ]] && AGENT_FILES+=("$f")
|
||||
done < <(
|
||||
find "$REPO_ROOT/plugins" -type f -name '*.agent.md' \
|
||||
-path '*/.apm/agents/*' \
|
||||
-not -path '*/.claude/worktrees/*' \
|
||||
2>/dev/null | sort
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user