Files
ai-for-dummies/.agents/scripts/worktree.sh
T
Marcos Paulo aae4d42229 docs: add .agents workspace and the Astro refactor plan
Adds the agent-facing workspace and a 20-task plan for migrating the site
to Astro. Nothing here implements the refactor; these are briefs, rules and
templates that the task agents read.

- .agents/ holds context, rules, checklists, skills, specialist agents,
  component/page/config templates and gate scripts. It is vendor-neutral so
  MiniMax, Gemini and Codex can all read it; CLAUDE.md just points at
  AGENTS.md.
- .husky/ plus .lintstagedrc.json wire the three gate tiers. gate.sh locks on
  the shared git-common-dir so parallel worktrees serialise, and guards the
  assertion count in scripts/verify.mjs against a coverage drop.
- plans/astro-refactor/ carries the phase graph, per-task briefs and the
  model-routing recommendation.

These files must be tracked before fanning out: a worktree only checks out
tracked files, so an untracked plan is invisible to every agent working in one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 01:18:27 +00:00

51 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Spin up (or tear down) an isolated worktree for one refactor task.
#
# .agents/scripts/worktree.sh start 07 route-cards
# .agents/scripts/worktree.sh finish 07 route-cards
#
# One task, one worktree, one agent. See .agents/rules/git-worktrees.md
set -euo pipefail
action=${1:?usage: worktree.sh <start|finish> <task-number> <slug>}
number=${2:?task number, e.g. 07}
slug=${3:?slug, e.g. route-cards}
dir="../af-task-${number}"
branch="refactor/task-${number}-${slug}"
plan="plans/astro-refactor/task-${number}-${slug}.md"
case "$action" in
start)
[ -f "$plan" ] || echo "warning: no plan at $plan — check the task number" >&2
git fetch origin
git worktree add "$dir" -b "$branch" origin/main
# Not optional. `.husky/_` is generated by install and is NOT committed, so
# a fresh worktree has hooks configured but absent — every commit would pass
# unchecked. --prefer-offline keeps ten parallel spin-ups off the registry.
( cd "$dir" && npm ci --prefer-offline && .agents/scripts/verify-hooks.sh )
echo
echo "worktree : $dir"
echo "branch : $branch"
echo "brief : $plan"
echo
echo "next: cd $dir && read the brief end to end before writing anything"
;;
finish)
# Never remove a worktree with uncommitted work in it.
if [ -n "$(git -C "$dir" status --porcelain)" ]; then
echo "refusing: $dir has uncommitted changes" >&2
git -C "$dir" status --short >&2
exit 1
fi
git worktree remove "$dir"
echo "removed $dir — branch $branch kept; delete it after the merge lands"
;;
*)
echo "unknown action: $action (expected start|finish)" >&2
exit 2
;;
esac