feat: interactive setup — collects tasks and project rules in terminal

setup.sh now walks the user through entering their tasks and project
context interactively. Writes plan.md and prompt.md from their input.
Offers to launch the loop immediately at the end.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-04 08:41:36 +00:00
co-authored by Claude Opus 4.6
parent eda9e48965
commit 75e9274582
+152 -81
View File
@@ -201,56 +201,7 @@ LOOPEOF
ok "Created loop/loop.sh"
fi
# ── prompt.md (embedded) ────────────────────────────────────────────────────
if [[ -f "$LOOP_DIR/prompt.md" ]]; then
warn "loop/prompt.md exists — skipping"
else
cat > "$LOOP_DIR/prompt.md" << 'PROMPTEOF'
You are executing a project roadmap autonomously. Read these files first:
1. `loop/plan.md` — Your task checklist (mark items `- [x]` as you complete them)
2. Read any project documentation (README, CLAUDE.md, etc.) for conventions
## For each task in loop/plan.md:
1. Find the first unchecked `- [ ]` item
2. Understand what needs to be done
3. Implement it following the project's existing patterns and conventions
4. Run the project's type checker / linter / tests — fix all errors
5. Commit with a conventional message: `type(scope): description`
6. Mark the task `- [x]` in `loop/plan.md`
7. Move to the next unchecked task immediately
## Rules
- If tests fail, fix them before moving on
- If a task is difficult, make at least 30 genuine attempts before skipping
- Always run linter + type checker after code changes
- Do not stop until all tasks are checked or you are rate limited
PROMPTEOF
ok "Created loop/prompt.md"
fi
# ── plan.md (embedded) ──────────────────────────────────────────────────────
if [[ -f "$LOOP_DIR/plan.md" ]]; then
warn "loop/plan.md exists — skipping"
else
cat > "$LOOP_DIR/plan.md" << 'PLANEOF'
# Task Plan
## Phase 1
- [ ] **1.1** — First task description
- [ ] **1.2** — Second task description
## Phase 2
- [ ] **2.1** — Third task description
- [ ] **2.2** — Fourth task description
## Final
- [ ] **FINAL** — Run full test suite, fix failures, tag release
PLANEOF
ok "Created loop/plan.md"
fi
# ── prompt.md and plan.md are created later after interactive input ────────
echo ""
@@ -379,47 +330,167 @@ fi
echo ""
# ── Done ─────────────────────────────────────────────────────────────────────
echo -e " ${BOLD}${GREEN}Setup complete!${NC}"
echo ""
# ══════════════════════════════════════════════════════════════════════════════
# INTERACTIVE SETUP — collect tasks and project context
# ══════════════════════════════════════════════════════════════════════════════
echo -e " ${DIM}════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e " ${BOLD}You need to do two things:${NC}"
echo ""
echo -e " ${CYAN}1.${NC} ${BOLD}Edit your task list${NC} — add your actual tasks:"
echo ""
echo -e " ${DIM}$LOOP_DIR/plan.md${NC}"
echo ""
echo -e " Format: one ${BOLD}- [ ]${NC} per task. Claude checks them off as it goes."
echo -e " Example:"
echo -e " ${DIM}- [ ] Add user authentication with JWT${NC}"
echo -e " ${DIM}- [ ] Create REST API for CRUD operations${NC}"
echo -e " ${DIM}- [ ] Add unit tests for auth module${NC}"
echo ""
echo -e " ${CYAN}2.${NC} ${BOLD}Edit your prompt${NC} — add project-specific rules:"
echo ""
echo -e " ${DIM}$LOOP_DIR/prompt.md${NC}"
echo ""
echo -e " Tell Claude about your stack, coding style, test commands,"
echo -e " and anything else it should know about your project."
echo -e " ${BOLD}Now let's set up your tasks and project context.${NC}"
echo ""
# ── Collect tasks ────────────────────────────────────────────────────────────
if [[ -f "$LOOP_DIR/plan.md" ]]; then
echo -e " ${YELLOW}loop/plan.md already exists.${NC}"
echo -ne " Overwrite with new tasks? [y/N] "
read -r OVERWRITE_PLAN
[[ "$OVERWRITE_PLAN" =~ ^[Yy] ]] || SKIP_PLAN=1
fi
if [[ "${SKIP_PLAN:-0}" != "1" ]]; then
echo -e " ${BOLD}Enter your tasks${NC} — one per line."
echo -e " ${DIM}Be specific. Claude will execute these literally.${NC}"
echo -e " ${DIM}Example: \"Add JWT authentication with refresh tokens\"${NC}"
echo -e " ${DIM}Press Enter on an empty line when done.${NC}"
echo ""
TASKS=()
TASK_NUM=1
while true; do
echo -ne " ${CYAN}Task $TASK_NUM:${NC} "
read -r TASK_LINE
[[ -z "$TASK_LINE" ]] && break
TASKS+=("$TASK_LINE")
TASK_NUM=$((TASK_NUM + 1))
done
if [[ ${#TASKS[@]} -eq 0 ]]; then
warn "No tasks entered — writing example plan"
cat > "$LOOP_DIR/plan.md" << 'PLANEOF'
# Task Plan
## Phase 1
- [ ] **1.1** — First task description
- [ ] **1.2** — Second task description
## Final
- [ ] **FINAL** — Run full test suite, fix failures, tag release
PLANEOF
else
echo "# Task Plan" > "$LOOP_DIR/plan.md"
echo "" >> "$LOOP_DIR/plan.md"
i=1
for task in "${TASKS[@]}"; do
echo "- [ ] **$i** — $task" >> "$LOOP_DIR/plan.md"
i=$((i + 1))
done
echo "" >> "$LOOP_DIR/plan.md"
echo "- [ ] **FINAL** — Run full test suite, fix any failures" >> "$LOOP_DIR/plan.md"
ok "Wrote ${#TASKS[@]} tasks to loop/plan.md"
fi
echo ""
fi
# ── Collect project context ──────────────────────────────────────────────────
if [[ -f "$LOOP_DIR/prompt.md" ]] && [[ "${SKIP_PLAN:-0}" == "1" ]]; then
SKIP_PROMPT=1
fi
if [[ "${SKIP_PROMPT:-0}" != "1" ]]; then
echo -e " ${BOLD}Project context${NC} — tell Claude about your project."
echo -e " ${DIM}Stack, test commands, coding style, anything important.${NC}"
echo -e " ${DIM}Example: \"TypeScript + React, run 'npm test', use Prettier formatting\"${NC}"
echo -e " ${DIM}Press Enter on an empty line when done (or just Enter to skip).${NC}"
echo ""
RULES=()
while true; do
echo -ne " ${CYAN}>${NC} "
read -r RULE_LINE
[[ -z "$RULE_LINE" ]] && break
RULES+=("$RULE_LINE")
done
# Build prompt.md
cat > "$LOOP_DIR/prompt.md" << 'PROMPTEOF'
You are executing a project roadmap autonomously. Read these files first:
1. `loop/plan.md` — Your task checklist (mark items `- [x]` as you complete them)
2. Read any project documentation (README, CLAUDE.md, etc.) for conventions
PROMPTEOF
if [[ ${#RULES[@]} -gt 0 ]]; then
echo "## Project Rules" >> "$LOOP_DIR/prompt.md"
echo "" >> "$LOOP_DIR/prompt.md"
for rule in "${RULES[@]}"; do
echo "- $rule" >> "$LOOP_DIR/prompt.md"
done
echo "" >> "$LOOP_DIR/prompt.md"
ok "Added ${#RULES[@]} project rules to prompt"
fi
cat >> "$LOOP_DIR/prompt.md" << 'PROMPTEOF'
## For each task in loop/plan.md:
1. Find the first unchecked `- [ ]` item
2. Understand what needs to be done
3. Implement it following the project's existing patterns and conventions
4. Run the project's type checker / linter / tests — fix all errors
5. Commit with a conventional message: `type(scope): description`
6. Mark the task `- [x]` in `loop/plan.md`
7. Move to the next unchecked task immediately
## Rules
- If tests fail, fix them before moving on
- If a task is difficult, make at least 30 genuine attempts before skipping
- Always run linter + type checker after code changes
- Do not stop until all tasks are checked or you are rate limited
PROMPTEOF
ok "Created loop/prompt.md"
echo ""
fi
# ── Summary & launch ─────────────────────────────────────────────────────────
TASK_COUNT=$(grep -c '^\- \[ \]' "$LOOP_DIR/plan.md" 2>/dev/null || echo "0")
echo -e " ${DIM}════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e " ${BOLD}Then run:${NC}"
echo -e " ${BOLD}${GREEN}Ready to go!${NC}"
echo ""
echo -e " ${BOLD}Tasks:${NC} $TASK_COUNT in loop/plan.md"
echo -e " ${BOLD}Prompt:${NC} loop/prompt.md"
echo -e " ${BOLD}Log:${NC} loop/loop.log (created on first run)"
echo ""
echo -e " ${DIM}────────────────────────────────────────────────────────────${NC}"
echo ""
echo -e " ${BOLD}To start:${NC}"
echo -e " ${GREEN}./loop/loop.sh${NC}"
echo ""
echo -e " Or for guaranteed no-sleep (macOS):"
echo -e " ${BOLD}To start with sleep prevention (macOS):${NC}"
echo -e " ${GREEN}caffeinate -i ./loop/loop.sh${NC}"
echo ""
echo -e " ${BOLD}Monitor:${NC} ${DIM}tail -f loop/loop.log${NC}"
echo -e " ${BOLD}Progress:${NC} ${DIM}grep -c '\\[x\\]' loop/plan.md${NC}"
echo -e " ${BOLD}Monitor:${NC}"
echo -e " ${DIM}tail -f loop/loop.log${NC}"
echo ""
echo -e " ${BOLD}Config (env vars):${NC}"
echo -e " ${DIM}CLAUDE_AUTONOMOUS=0${NC} Let Claude stop freely (for testing)"
echo -e " ${DIM}ITERATION_COUNT=20${NC} More iterations"
echo -e " ${DIM}ITERATION_DELAY=60${NC} Longer pause between iterations"
echo -e " ${BOLD}Config:${NC}"
echo -e " ${DIM}CLAUDE_AUTONOMOUS=0${NC} — let Claude stop freely (testing)"
echo -e " ${DIM}ITERATION_COUNT=20${NC} — more iterations"
echo -e " ${DIM}ITERATION_DELAY=60${NC} — longer pause between rounds"
echo ""
echo -e " ${BOLD}Test run:${NC}"
echo -e " ${DIM}CLAUDE_AUTONOMOUS=0 ITERATION_COUNT=1 ./loop/loop.sh${NC}"
echo -e " ${DIM}────────────────────────────────────────────────────────────${NC}"
echo ""
echo -ne " ${BOLD}Start the loop now?${NC} [y/N] "
read -r START_NOW
if [[ "$START_NOW" =~ ^[Yy] ]]; then
echo ""
echo -e " ${GREEN}Launching...${NC}"
echo ""
exec ./loop/loop.sh
fi
echo ""
echo -e " ${DIM}Run ./loop/loop.sh whenever you're ready.${NC}"
echo ""