Elffuss BraidHub

kikocis/VibeCodeViewer public

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