Elffuss BraidHub

kikocis/VibeCodeViewer public

main · 2.4 KiB · executableRawPermalink
1#!/usr/bin/env bash
2# Sirve VibeCodeViewer en localhost por defecto.
3# Para exponerlo a la LAN de forma explícita: VCC_HOST=0.0.0.0 ./serve.sh
4set -euo pipefail
5cd "$(dirname "$0")"
6
7usage() {
8 cat <<'EOF'
9Uso: ./serve.sh [puerto]
10 ./serve.sh [puerto] --test N M [K]
11 ./serve.sh --help
12
13 puerto puerto HTTP (por defecto 8137)
14 VCC_HOST interfaz de escucha (por defecto 127.0.0.1). Usa
15 VCC_HOST=0.0.0.0 solo si quieres exponerlo a la LAN.
16 --test N M genera un src/data.js sintético (tools/gentest.mjs) con N
17 ficheros, cada uno al fondo de su propia cadena de M carpetas
18 anidadas, y luego sirve. Para depurar el renderizado.
19 --test N M K modo urbanización: cada distrito folder_g contiene un bloque
20 urb_g que crea K carpetas en el nivel de urbanización; cada
21 carpeta continúa la cadena hasta profundidad M. urb_g se
22 convierte en urbanización si K > 2000, o si K > 200 y M ≥ 8
23 (umbrales de src/model.js).
24
25Ejemplos:
26 ./serve.sh --test 2 3 # 2 cadenas de 3 carpetas con 1 fichero
27 ./serve.sh --test 500 8 # 500 edificios de interior profundo
28 ./serve.sh --test 1000 8 250 # 4 urbanizaciones de 250 edificios
29 ./serve.sh --test 1000 4 250 # mismos grupos, poco profundos → sin urbanización
30 ./serve.sh --test 2500 3 2500 # urbanización por población (>2000)
31 ./serve.sh 8200 --test 100 10 # puerto alternativo + test
32
33Restaurar el data.js real: git checkout -- src/data.js, o relanzar scan.mjs.
34EOF
35}
36
37PORT=8137
38HOST=${VCC_HOST:-127.0.0.1}
39if [[ $# -gt 0 && "$1" =~ ^(--help|-h)$ ]]; then usage; exit 0; fi
40if [[ $# -gt 0 && "$1" != --test ]]; then PORT="$1"; shift; fi
41
42if [[ $# -gt 0 ]]; then
43 case "$1" in
44 --test)
45 shift
46 [[ $# -ge 2 ]] || { usage >&2; exit 1; }
47 node tools/gentest.mjs "$@"
48 ;;
49 --help|-h) usage; exit 0 ;;
50 *) usage >&2; exit 1 ;;
51 esac
52fi
53
54echo "VibeCodeViewer — sirviendo en:"
55echo " http://localhost:${PORT}/ (usa esta URL para analizar carpetas locales)"
56if [[ "$HOST" != "127.0.0.1" && "$HOST" != "localhost" ]]; then
57 echo ""
58 echo "Aviso: VCC_HOST=${HOST} expone el servidor a otras interfaces."
59 echo "Para Abrir Carpeta… desde otro origen necesitarás HTTPS o un túnel seguro."
60 for ip in $(hostname -I 2>/dev/null); do
61 echo " http://${ip}:${PORT}/ (solo visualización/LAN)"
62 done
63fi
64exec python3 -m http.server "$PORT" --bind "$HOST"