#!/bin/bash # setup-plan.sh - Implementation Planning Setup Script # Usage: setup-plan.sh --json set -e # Parse arguments JSON_OUTPUT=false while [[ $# -gt 0 ]]; do case $1 in --json) JSON_OUTPUT=true shift ;; *) shift ;; esac done # Get absolute paths REPO_ROOT="$(pwd)" SPECS_DIR="$REPO_ROOT/.specify" FEATURE_SPEC="$SPECS_DIR/specs/care-api.md" IMPL_PLAN="$SPECS_DIR/plan.md" CONSTITUTION="$SPECS_DIR/memory/constitution.md" # Ensure we're in the right directory if [[ ! -d ".git" ]]; then echo "Error: Must be run from git repository root" exit 1 fi # Ensure specs directory exists mkdir -p "$SPECS_DIR"/{research,contracts,templates} # Check if feature spec exists if [[ ! -f "$FEATURE_SPEC" ]]; then echo "Error: Feature specification not found at $FEATURE_SPEC" exit 1 fi # Get current branch BRANCH=$(git branch --show-current) # Create initial plan file if it doesn't exist if [[ ! -f "$IMPL_PLAN" ]]; then cat > "$IMPL_PLAN" << 'EOF' # Implementation Plan This file will be populated with the complete implementation plan. ## Status - **Created**: $(date +%Y-%m-%d) - **Status**: Planning ## Placeholder This is a placeholder file created by setup-plan.sh The complete implementation plan will be written by the planning process. EOF fi # Output results if [[ "$JSON_OUTPUT" == "true" ]]; then cat << EOF { "status": "success", "feature_spec": "$FEATURE_SPEC", "impl_plan": "$IMPL_PLAN", "specs_dir": "$SPECS_DIR", "branch": "$BRANCH", "constitution": "$CONSTITUTION", "repo_root": "$REPO_ROOT", "created_at": "$(date -Iseconds)" } EOF else echo "✅ Planning setup complete" echo "✅ Feature spec: $FEATURE_SPEC" echo "✅ Implementation plan: $IMPL_PLAN" echo "✅ Specs directory: $SPECS_DIR" echo "✅ Current branch: $BRANCH" fi