Files
ai-workflow-course/modules/04-getting-the-ai-out-of-the-browser/lab/verify.sh
T
claude 896c4606c6 fix(M1-6): apply AI-drives-git reframe, lesson=theory, de-slop, + issue fixes
Phase 1 of the reframe. M1-3 stay manual-by-hand (browser chat); M4 is the pivot
to the AI agent (Claude Code as example); M5-6 are agent-driven.

- M1: de-slop (em-dashes), relocate the build-note out of the lab. Seam devices kept.
- M2: #78 tell learner how to paste cli.py into chat; #79 commit the delete so the
  tree ends clean. restore/cold-session devices kept.
- M3: #80 define ADR; #81 create-file-before-add; #82 ls before/after merge to prove
  branch isolation; #83 drop "prose"; M3 now owns the branch-basics intro.
- M4: #84 Claude Code as the worked example; #85 AI drives git (arithmetic->calculator);
  #86 /path/to -> ~/ai-workflow-course; #87 agent does the revert+verify.
- M5: #88 ask the agent which config files to commit, then let it stage/commit
  (CLAUDE.md example; repo still uses AGENTS.md).
- M6: #90 stop re-teaching branch basics; rescope to the AI experimenting on a branch;
  the engineered conflict is now AI-resolved, learner-verified.

Closes #78
Closes #79
Closes #80
Closes #81
Closes #82
Closes #84
Closes #85
Closes #87
Closes #88
Closes #90

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TfzV5QvtPDz8LJS3Pu5VLT
2026-06-22 21:41:14 -04:00

93 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# verify.sh — Module 4 lab check.
#
# Exercises the `delete <index>` command the AI implemented across tasks.py and cli.py.
# It adds three tasks, deletes the middle one by index, and confirms the right task is gone
# and the other two remain. This is a behavior check on the multi-file change — it does not
# care HOW the AI implemented it, only that `delete` works end to end.
#
# Copy this into your tasks-app project directory, then run it from there:
# cp ~/ai-workflow-course/modules/04-getting-the-ai-out-of-the-browser/lab/verify.sh .
# bash verify.sh
#
# (It self-locates cli.py, so it also still works if you run it in place as `bash lab/verify.sh`.)
# It saves and restores your real tasks.json, so your actual task list is left untouched.
set -euo pipefail
# Find the project root: the directory containing cli.py. Works whether you run this from the
# project root or from the lab/ subfolder.
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$here/cli.py" ]; then
root="$here"
elif [ -f "$here/../cli.py" ]; then
root="$(cd "$here/.." && pwd)"
else
root="$(pwd)"
fi
if [ ! -f "$root/cli.py" ]; then
echo "FAIL: couldn't find cli.py. Run this from your tasks-app project directory." >&2
exit 1
fi
# Pick a Python interpreter.
if command -v python3 >/dev/null 2>&1; then
PY=python3
elif command -v python >/dev/null 2>&1; then
PY=python
else
echo "FAIL: no python found on PATH." >&2
exit 1
fi
cd "$root"
# Preserve any real task state, and always restore it on exit (even on failure).
state="tasks.json"
backup=""
if [ -f "$state" ]; then
backup="$(mktemp)"
cp "$state" "$backup"
fi
cleanup() {
if [ -n "$backup" ]; then
mv "$backup" "$state"
else
rm -f "$state"
fi
}
trap cleanup EXIT
# Start from an empty list.
rm -f "$state"
echo "Running delete-command check with: $PY"
"$PY" cli.py add "alpha" >/dev/null
"$PY" cli.py add "beta" >/dev/null
"$PY" cli.py add "gamma" >/dev/null
# Delete the middle task (index 1 = "beta").
if ! "$PY" cli.py delete 1 >/dev/null 2>&1; then
echo "FAIL: 'python cli.py delete 1' errored. Is the delete command wired up in cli.py?" >&2
exit 1
fi
out="$("$PY" cli.py list)"
ok=1
echo "$out" | grep -q "beta" && { echo "FAIL: 'beta' should have been deleted but is still listed." >&2; ok=0; }
echo "$out" | grep -q "alpha" || { echo "FAIL: 'alpha' should still be present but is missing." >&2; ok=0; }
echo "$out" | grep -q "gamma" || { echo "FAIL: 'gamma' should still be present but is missing." >&2; ok=0; }
if [ "$ok" -ne 1 ]; then
echo "--- current list ---" >&2
echo "$out" >&2
exit 1
fi
echo "PASS: delete removed the right task; alpha and gamma remain."
echo "The multi-file change works. Review it with 'git diff', then commit."