ContextStudioWizard/wizard.sh
Karamelmar 09ff27be92 Add Context Studio Wizard — project scaffolding CLI
- wizard.sh: interactive bash wizard that scaffolds new CS projects
- lib/: utils, core install, project structure, workflow generation
- templates/: Dockerfile, devcontainer.json, agent presets (minimal/standard), system.json, roles, hook rules
- README: setup, usage, mobility workflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-09 11:49:04 +01:00

160 lines
7 KiB
Bash
Executable file

#!/usr/bin/env bash
# ╔══════════════════════════════════════════════════════════════════╗
# ║ Context Studio Wizard — Project Setup ║
# ╚══════════════════════════════════════════════════════════════════╝
set -euo pipefail
WIZARD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$WIZARD_DIR/lib/utils.sh"
source "$WIZARD_DIR/lib/core.sh"
source "$WIZARD_DIR/lib/project.sh"
source "$WIZARD_DIR/lib/workflow.sh"
# ── Prerequisites ──────────────────────────────────────────────────────────
check_prerequisites() {
header "Checking Prerequisites"
require_cmd git
if command -v docker &>/dev/null; then
CONTAINER_CMD="docker"
elif command -v podman &>/dev/null; then
CONTAINER_CMD="podman"
else
die "Neither docker nor podman found. Install one to use devcontainers."
fi
success "git: $(git --version)"
success "$CONTAINER_CMD: $($CONTAINER_CMD --version | head -1)"
}
# ── Project info ───────────────────────────────────────────────────────────
collect_project_info() {
header "Project Details"
ask PROJECT_NAME "Project name" ""
[[ -z "$PROJECT_NAME" ]] && die "Project name is required."
local default_dir="$HOME/projects/$(slugify "$PROJECT_NAME")"
ask PROJECT_DIR "Project location" "$default_dir"
[[ -z "$PROJECT_DIR" ]] && die "Project location is required."
PROJECT_DIR="${PROJECT_DIR/#\~/$HOME}"
if [[ -e "$PROJECT_DIR" ]]; then
warn "Directory already exists: $PROJECT_DIR"
ask_yn _continue "Continue anyway?" "n"
[[ "$_continue" != "y" ]] && die "Aborted."
fi
}
# ── Workflow source ────────────────────────────────────────────────────────
collect_workflow_info() {
header "Workflow Configuration"
ask_choice WORKFLOW_SOURCE "How do you want to configure your workflow?" \
"Generate from scratch" \
"Clone from existing repo"
if [[ "$WORKFLOW_SOURCE" == "Clone from existing repo" ]]; then
ask WORKFLOW_REPO "Workflow repo URL" ""
[[ -z "$WORKFLOW_REPO" ]] && die "Repo URL is required."
else
ask PROJECT_DESC "Project description" "A software project"
ask TECH_STACK "Tech stack (e.g. Node.js, Rust, Python)" "Node.js"
ask_choice AGENT_PRESET "Agent preset" \
"minimal (5 agents: coordinator, 2 coders, researcher, tester)" \
"standard (9 agents: 2 coordinators, 3 coders, 2 researchers, tester, reviewer)"
# Normalize to short key
case "$AGENT_PRESET" in
minimal*) AGENT_PRESET="minimal" ;;
*) AGENT_PRESET="standard" ;;
esac
fi
}
# ── Summary & confirm ──────────────────────────────────────────────────────
confirm_summary() {
header "Summary"
echo -e " ${BOLD}Project name${RESET} : $PROJECT_NAME"
echo -e " ${BOLD}Location${RESET} : $PROJECT_DIR"
echo -e " ${BOLD}Core${RESET} : $CS_CORE_DIR"
if [[ "${WORKFLOW_SOURCE:-}" == "Clone from existing repo" ]]; then
echo -e " ${BOLD}Workflow${RESET} : clone $WORKFLOW_REPO"
else
echo -e " ${BOLD}Workflow${RESET} : generate ($AGENT_PRESET preset)"
echo -e " ${BOLD}Description${RESET} : ${PROJECT_DESC:-}"
echo -e " ${BOLD}Tech stack${RESET} : ${TECH_STACK:-}"
fi
echo ""
ask_yn _ok "Create project?" "y"
[[ "$_ok" != "y" ]] && die "Aborted."
}
# ── Build ──────────────────────────────────────────────────────────────────
build_project() {
header "Building Project"
create_project_structure "$PROJECT_DIR" "$PROJECT_NAME"
create_devcontainer "$PROJECT_DIR" "$PROJECT_NAME"
if [[ "${WORKFLOW_SOURCE:-}" == "Clone from existing repo" ]]; then
clone_workflow "$PROJECT_DIR" "$WORKFLOW_REPO"
else
generate_workflow "$PROJECT_DIR" "$PROJECT_NAME" \
"${PROJECT_DESC:-A software project}" \
"${TECH_STACK:-Node.js}" \
"$AGENT_PRESET"
fi
# Init git repo
git -C "$PROJECT_DIR" init -q
git -C "$PROJECT_DIR" add .
git -C "$PROJECT_DIR" commit -q -m "Initial project setup via Context Studio Wizard"
success "Git repo initialized"
}
# ── Done ───────────────────────────────────────────────────────────────────
print_next_steps() {
local slug
slug="$(slugify "$PROJECT_NAME")"
header "Done!"
success "Project created at: $PROJECT_DIR"
echo ""
echo -e "${BOLD}Next steps:${RESET}"
echo ""
echo -e " ${CYAN}Option A — VS Code devcontainer:${RESET}"
echo -e " code \"$PROJECT_DIR\""
echo -e " → \"Reopen in Container\""
echo ""
echo -e " ${CYAN}Option B — CLI:${RESET}"
echo -e " cd \"$PROJECT_DIR\""
echo -e " $CONTAINER_CMD build -t $slug .devcontainer/"
echo -e " $CONTAINER_CMD run -it --rm \\"
echo -e " -v \"\$(pwd)\":/workspace \\"
echo -e " -v \"\$HOME/.context-studio/core\":/opt/context-studio/core \\"
echo -e " -e ANTHROPIC_API_KEY=\"\$ANTHROPIC_API_KEY\" \\"
echo -e " $slug bash"
echo ""
echo -e " ${CYAN}Inside container — start Context Studio:${RESET}"
echo -e " node \$CS_CORE_DIR/core/start.js"
echo -e " # or headless (no Electron):"
echo -e " node \$CS_CORE_DIR/core/start.js --ui-mode=headless"
echo ""
}
# ── Main ───────────────────────────────────────────────────────────────────
main() {
echo ""
echo -e "${BOLD}${CYAN}╔══════════════════════════════════════╗${RESET}"
echo -e "${BOLD}${CYAN}║ Context Studio Wizard v1.0 ║${RESET}"
echo -e "${BOLD}${CYAN}╚══════════════════════════════════════╝${RESET}"
check_prerequisites
setup_core
collect_project_info
collect_workflow_info
confirm_summary
build_project
print_next_steps
}
main "$@"