53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| 
 | |
| set -euo pipefail
 | |
| 
 | |
| if [[ $# -ne 1 ]]; then
 | |
|     echo "Usage: $0 <toolbox-name>" >&2
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| RAW_NAME="$1"
 | |
| if [[ "${RAW_NAME}" == toolbox-* ]]; then
 | |
|     TOOLBOX_NAME="${RAW_NAME}"
 | |
| else
 | |
|     TOOLBOX_NAME="toolbox-${RAW_NAME}"
 | |
| fi
 | |
| 
 | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 | |
| TEMPLATE_DIR="${SCRIPT_DIR}/toolbox-template"
 | |
| TARGET_DIR="${SCRIPT_DIR}/${TOOLBOX_NAME}"
 | |
| 
 | |
| if [[ ! -d "${TEMPLATE_DIR}" ]]; then
 | |
|     echo "Error: template directory not found at ${TEMPLATE_DIR}" >&2
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| if [[ -e "${TARGET_DIR}" ]]; then
 | |
|     echo "Error: ${TARGET_DIR} already exists" >&2
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| cp -R "${TEMPLATE_DIR}" "${TARGET_DIR}"
 | |
| 
 | |
| python3 - "$TARGET_DIR" "$TOOLBOX_NAME" <<'PY'
 | |
| import sys
 | |
| from pathlib import Path
 | |
| 
 | |
| base = Path(sys.argv[1])
 | |
| toolbox_name = sys.argv[2]
 | |
| 
 | |
| for path in base.rglob("*"):
 | |
|     if not path.is_file():
 | |
|         continue
 | |
|     text = path.read_text()
 | |
|     updated = text.replace("{{toolbox_name}}", toolbox_name)
 | |
|     if updated != text:
 | |
|         path.write_text(updated)
 | |
| PY
 | |
| 
 | |
| echo "Created ${TARGET_DIR} from template."
 | |
| echo "Next steps:"
 | |
| echo "  1) Edit ${TARGET_DIR}/SEED once to describe the toolbox goals."
 | |
| echo "  2) Load ${TARGET_DIR}/PROMPT in Codex; it will instruct you to read SEED and proceed."
 |