fix: detectBranch handles cd && git pattern + docs update#28
Merged
George-iam merged 2 commits intomainfrom Apr 7, 2026
Merged
fix: detectBranch handles cd && git pattern + docs update#28George-iam merged 2 commits intomainfrom
George-iam merged 2 commits intomainfrom
Conversation
Safety hook detectBranch now parses cd target from "cd /path && git ..." commands and runs git branch --show-current in the correct directory. Also uses .includes() instead of .startsWith() for merged PR check so chained commands (cd && git commit) are caught. Docs: remove axme_search_memory, add axme_memories, update axme_context description in README and ARCHITECTURE.
Replace fragile cd-only regex with extractGitCwd that handles: - cd /path && ..., cd /path; ... - pushd /path && ... - git -C /path (including multiple -C flags) Remove subdirectory scan fallback (returned random repo branch).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
detectBranchnow parsescd /path &&prefix from Bash commands and runsgit branch --show-currentin the correct directory. Previously, chained commands likecd /path && git commitbypassed merged-PR detection because the hook ran in workspace root.startsWith("git push")toincludes("git push")so chained commands are caughtaxme_search_memory(removed in PR#25), addaxme_memories(added in PR#24), updateaxme_contextdescriptionRoot cause
Agent pushed commits to
fix/compact-kb-stricter-20260407after PR#27 was merged. Safety hook didn't block because:cd /home/.../axme-code && git commit ...checkGitusedstartsWith("git commit")which didn't match (starts withcd)detectBranchrangit branch --show-currentin workspace root (not axme-code), got wrong branchTest plan
cd /path && git commiton a merged branch should be blocked