Skip to content
Merged
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
9 changes: 6 additions & 3 deletions .devagent/plugins/ralph/tools/verify-hooks-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
# E2E verification for --on-iteration and --on-complete: run ralph with both hooks
# (same script appends all payloads to one file) and verify iteration + completion payloads.
#
# Requires (run from repo root):
# Requires:
# - Git repo with .git and branch feature/ralph-iteration-hooks
# - Beads DB with epic devagent-iteration-hooks and at least one ready task
# - RALPH_MAX_ITERATIONS=1 is used (env override) so one iteration + completion run
# Usage: from repo root: .devagent/plugins/ralph/tools/verify-hooks-e2e.sh
# Usage: .devagent/plugins/ralph/tools/verify-hooks-e2e.sh

set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../../.." && pwd)"
if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}/../../../../.." rev-parse --show-toplevel 2>/dev/null)"; then
echo "Error: Unable to resolve repo root from ${SCRIPT_DIR}" >&2
exit 1
fi
Comment on lines +13 to +16
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Redundant path traversal undermines the git-based approach.

git rev-parse --show-toplevel resolves the repository root from any location within the repo. The manual ../../../../.. navigation is unnecessary and reintroduces the brittleness you're trying to eliminate—if the script ever moves, this path breaks.

♻️ Proposed fix: use SCRIPT_DIR directly
-if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}/../../../../.." rev-parse --show-toplevel 2>/dev/null)"; then
+if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}" rev-parse --show-toplevel 2>/dev/null)"; then
   echo "Error: Unable to resolve repo root from ${SCRIPT_DIR}" >&2
   exit 1
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}/../../../../.." rev-parse --show-toplevel 2>/dev/null)"; then
echo "Error: Unable to resolve repo root from ${SCRIPT_DIR}" >&2
exit 1
fi
if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}" rev-parse --show-toplevel 2>/dev/null)"; then
echo "Error: Unable to resolve repo root from ${SCRIPT_DIR}" >&2
exit 1
fi
🤖 Prompt for AI Agents
In @.devagent/plugins/ralph/tools/verify-hooks-e2e.sh around lines 13 - 16, The
git invocation that computes REPO_ROOT should use SCRIPT_DIR directly instead of
the hard-coded "../../../../.." traversal; change the command that sets
REPO_ROOT (the line using git -C and rev-parse) to run git -C "${SCRIPT_DIR}"
rev-parse --show-toplevel so it reliably resolves the repo root from the script
location, keeping the existing error check and processLogger-style echo/exit
behavior intact.

cd "$REPO_ROOT"

OUT_FILE="$(mktemp)"
Expand Down