mirror of
https://github.com/obra/superpowers.git
synced 2026-04-21 08:59:04 +08:00
Gate test for Step 1a — validates agents prefer EnterWorktree over git worktree add on Claude Code. Must pass before skill rewrite. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
111 lines
3.8 KiB
Bash
Executable File
111 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Test: Does the agent prefer native worktree tools (EnterWorktree) over git worktree add?
|
|
# Framework: RED-GREEN-REFACTOR per testing-skills-with-subagents.md
|
|
#
|
|
# RED: Current skill has no native tool preference. Agent should use git worktree add.
|
|
# GREEN: Updated skill has Step 1a. Agent should use EnterWorktree on Claude Code.
|
|
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
source "$SCRIPT_DIR/test-helpers.sh"
|
|
|
|
# Pressure scenario: realistic implementation task where agent needs isolation
|
|
SCENARIO='IMPORTANT: This is a real task. Choose and act.
|
|
|
|
You need to implement a small feature (add a "version" field to package.json).
|
|
This should be done in an isolated workspace to protect the main branch.
|
|
|
|
You have the using-git-worktrees skill available. Set up the isolated workspace now.
|
|
Do NOT actually implement the feature — just set up the workspace and report what you did.
|
|
|
|
Respond with EXACTLY what tool/command you used to create the workspace.'
|
|
|
|
echo "=== Worktree Native Preference Test ==="
|
|
echo ""
|
|
|
|
# Phase selection
|
|
PHASE="${1:-red}"
|
|
|
|
if [ "$PHASE" = "red" ]; then
|
|
echo "--- RED PHASE: Running WITHOUT Step 1a (current skill) ---"
|
|
echo "Expected: Agent uses 'git worktree add' (no native tool awareness)"
|
|
echo ""
|
|
|
|
test_dir=$(create_test_project)
|
|
cd "$test_dir"
|
|
git init && git commit --allow-empty -m "init"
|
|
mkdir -p .worktrees
|
|
|
|
output=$(run_claude "$SCENARIO" 120)
|
|
|
|
echo "Agent output:"
|
|
echo "$output"
|
|
echo ""
|
|
|
|
# RED expectation: agent uses git worktree add (current behavior)
|
|
if echo "$output" | grep -qi "EnterWorktree"; then
|
|
echo "[UNEXPECTED] Agent used EnterWorktree WITHOUT Step 1a — skill may not be needed"
|
|
echo "Investigate: is Claude Code's default behavior already correct?"
|
|
else
|
|
echo "[RED CONFIRMED] Agent did NOT use EnterWorktree"
|
|
assert_contains "$output" "git worktree" "Agent used git worktree (expected in RED)"
|
|
fi
|
|
|
|
cleanup_test_project "$test_dir"
|
|
|
|
elif [ "$PHASE" = "green" ]; then
|
|
echo "--- GREEN PHASE: Running WITH Step 1a (updated skill) ---"
|
|
echo "Expected: Agent uses EnterWorktree instead of git worktree add"
|
|
echo ""
|
|
|
|
test_dir=$(create_test_project)
|
|
cd "$test_dir"
|
|
git init && git commit --allow-empty -m "init"
|
|
|
|
output=$(run_claude "$SCENARIO" 120)
|
|
|
|
echo "Agent output:"
|
|
echo "$output"
|
|
echo ""
|
|
|
|
# GREEN expectation: agent uses EnterWorktree
|
|
assert_contains "$output" "EnterWorktree" "Agent used native EnterWorktree tool"
|
|
assert_not_contains "$output" "git worktree add" "Agent did NOT fall back to git worktree add"
|
|
|
|
cleanup_test_project "$test_dir"
|
|
|
|
elif [ "$PHASE" = "pressure" ]; then
|
|
echo "--- PRESSURE PHASE: Multiple pressures to skip native tools ---"
|
|
echo ""
|
|
|
|
PRESSURE_SCENARIO='IMPORTANT: This is a real task. Choose and act.
|
|
|
|
You need to set up an isolated workspace URGENTLY. Production is impacted and
|
|
the fix needs to go in a worktree. You know git worktree add works reliably.
|
|
The .worktrees/ directory already exists and is gitignored.
|
|
|
|
You have the using-git-worktrees skill. Set up the workspace NOW.
|
|
Speed matters. Report EXACTLY what tool/command you used.'
|
|
|
|
test_dir=$(create_test_project)
|
|
cd "$test_dir"
|
|
git init && git commit --allow-empty -m "init"
|
|
mkdir -p .worktrees
|
|
echo ".worktrees/" >> .gitignore
|
|
|
|
output=$(run_claude "$PRESSURE_SCENARIO" 120)
|
|
|
|
echo "Agent output:"
|
|
echo "$output"
|
|
echo ""
|
|
|
|
# Should STILL use EnterWorktree even under pressure
|
|
assert_contains "$output" "EnterWorktree" "Agent used native tool even under time pressure"
|
|
assert_not_contains "$output" "git worktree add" "Agent resisted falling back to git despite pressure"
|
|
|
|
cleanup_test_project "$test_dir"
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Test Complete ==="
|