Structure webber into three independent subprojects: - webber-api/: FastAPI backend server with all agent code - webber-cli/: Standalone CLI client (renamed from cli/ to webber_cli/) - webber-sandbox/: Test project for functional testing Key changes: - Each subproject has its own .venv (Python 3.12+) - Added sandbox.sh for managing test project templates - Created sandbox-templates/ with calculator-cli and empty starter - Updated CI/CD for prefixed tags (api/v*, cli/v*) - Added comprehensive AGENTS.md with operational instructions - Added gitignore filtering to glob and grep tools - Created pyproject.toml for each subproject Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
194 lines
5.0 KiB
Bash
Executable File
194 lines
5.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Sandbox management script for Webber testing
|
|
#
|
|
# Usage:
|
|
# ./sandbox.sh list - List available templates
|
|
# ./sandbox.sh load <template> - Load a template into sandbox
|
|
# ./sandbox.sh reset - Reset sandbox to last loaded template
|
|
# ./sandbox.sh save <name> - Save current sandbox as new template
|
|
# ./sandbox.sh status - Show current sandbox status
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SANDBOX_DIR="$SCRIPT_DIR/webber-sandbox"
|
|
TEMPLATES_DIR="$SCRIPT_DIR/sandbox-templates"
|
|
MARKER_FILE="$SANDBOX_DIR/.current_template"
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
usage() {
|
|
echo "Webber Sandbox Manager"
|
|
echo ""
|
|
echo "Usage: ./sandbox.sh <command> [template]"
|
|
echo ""
|
|
echo "Commands:"
|
|
echo " list List available templates"
|
|
echo " load <template> Load a template into sandbox (preserves .venv)"
|
|
echo " reset Reset sandbox to last loaded template"
|
|
echo " save <name> Save current sandbox as new template"
|
|
echo " status Show current sandbox status"
|
|
echo ""
|
|
echo "Available templates:"
|
|
ls -1 "$TEMPLATES_DIR" 2>/dev/null || echo " (none)"
|
|
}
|
|
|
|
list_templates() {
|
|
echo "Available templates:"
|
|
echo ""
|
|
for dir in "$TEMPLATES_DIR"/*/; do
|
|
if [ -d "$dir" ]; then
|
|
name=$(basename "$dir")
|
|
desc=""
|
|
if [ -f "$dir/TASKS.md" ]; then
|
|
desc=$(head -1 "$dir/TASKS.md" | sed 's/^#\s*//')
|
|
fi
|
|
printf " %-20s %s\n" "$name" "$desc"
|
|
fi
|
|
done
|
|
}
|
|
|
|
load_template() {
|
|
local template="$1"
|
|
|
|
if [ -z "$template" ]; then
|
|
echo -e "${RED}Error: Template name required${NC}"
|
|
echo "Usage: ./sandbox.sh load <template>"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -d "$TEMPLATES_DIR/$template" ]; then
|
|
echo -e "${RED}Error: Template '$template' not found${NC}"
|
|
echo "Available templates:"
|
|
ls -1 "$TEMPLATES_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${YELLOW}Loading template: $template${NC}"
|
|
|
|
# Create sandbox dir if needed
|
|
mkdir -p "$SANDBOX_DIR"
|
|
|
|
# Clear sandbox contents (except .venv and .git)
|
|
find "$SANDBOX_DIR" -mindepth 1 -maxdepth 1 ! -name '.venv' ! -name '.git' -exec rm -rf {} +
|
|
|
|
# Copy template contents (including hidden files)
|
|
cp -r "$TEMPLATES_DIR/$template/." "$SANDBOX_DIR/"
|
|
|
|
# Mark which template was loaded
|
|
echo "$template" > "$MARKER_FILE"
|
|
|
|
echo -e "${GREEN}Loaded template: $template${NC}"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " cd webber-sandbox"
|
|
if [ ! -d "$SANDBOX_DIR/.venv" ]; then
|
|
echo " python3.12 -m venv .venv"
|
|
fi
|
|
echo " source .venv/bin/activate"
|
|
echo " pip install -r requirements.txt"
|
|
echo ""
|
|
if [ -f "$SANDBOX_DIR/TASKS.md" ]; then
|
|
echo "Tasks available in TASKS.md"
|
|
fi
|
|
}
|
|
|
|
reset_template() {
|
|
if [ ! -f "$MARKER_FILE" ]; then
|
|
echo -e "${RED}Error: No template loaded yet${NC}"
|
|
echo "Use './sandbox.sh load <template>' first"
|
|
exit 1
|
|
fi
|
|
|
|
local template=$(cat "$MARKER_FILE")
|
|
echo "Resetting to template: $template"
|
|
load_template "$template"
|
|
}
|
|
|
|
save_template() {
|
|
local name="$1"
|
|
|
|
if [ -z "$name" ]; then
|
|
echo -e "${RED}Error: Template name required${NC}"
|
|
echo "Usage: ./sandbox.sh save <name>"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -d "$TEMPLATES_DIR/$name" ]; then
|
|
echo -e "${YELLOW}Warning: Template '$name' already exists${NC}"
|
|
read -p "Overwrite? [y/N] " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Cancelled"
|
|
exit 0
|
|
fi
|
|
rm -rf "$TEMPLATES_DIR/$name"
|
|
fi
|
|
|
|
mkdir -p "$TEMPLATES_DIR/$name"
|
|
|
|
# Copy sandbox contents (except .venv, .git, __pycache__)
|
|
rsync -a --exclude='.venv' --exclude='.git' --exclude='__pycache__' \
|
|
--exclude='*.pyc' --exclude='.pytest_cache' --exclude='.mypy_cache' \
|
|
"$SANDBOX_DIR/" "$TEMPLATES_DIR/$name/"
|
|
|
|
echo -e "${GREEN}Saved template: $name${NC}"
|
|
}
|
|
|
|
show_status() {
|
|
echo "Sandbox Status"
|
|
echo "=============="
|
|
echo ""
|
|
echo "Sandbox directory: $SANDBOX_DIR"
|
|
|
|
if [ -f "$MARKER_FILE" ]; then
|
|
echo "Current template: $(cat "$MARKER_FILE")"
|
|
else
|
|
echo "Current template: (none loaded)"
|
|
fi
|
|
|
|
if [ -d "$SANDBOX_DIR/.venv" ]; then
|
|
echo "Virtual env: exists"
|
|
else
|
|
echo "Virtual env: not created"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Contents:"
|
|
if [ -d "$SANDBOX_DIR" ]; then
|
|
ls -la "$SANDBOX_DIR" 2>/dev/null | tail -n +4
|
|
else
|
|
echo " (sandbox not initialized)"
|
|
fi
|
|
}
|
|
|
|
# Main command dispatch
|
|
case "${1:-}" in
|
|
list)
|
|
list_templates
|
|
;;
|
|
load)
|
|
load_template "$2"
|
|
;;
|
|
reset)
|
|
reset_template
|
|
;;
|
|
save)
|
|
save_template "$2"
|
|
;;
|
|
status)
|
|
show_status
|
|
;;
|
|
-h|--help|"")
|
|
usage
|
|
;;
|
|
*)
|
|
echo -e "${RED}Unknown command: $1${NC}"
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|