@jmanuelcorral/bond-app 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +280 -23
  2. package/app/brand/TOKENS.md +5 -5
  3. package/app/layouts/bond.json +10 -14
  4. package/app/mods/bond-agents/api.js +35 -0
  5. package/app/mods/bond-agents/branch.svg +1 -0
  6. package/app/mods/bond-agents/brand.js +53 -2
  7. package/app/mods/bond-agents/config.js +4 -0
  8. package/app/mods/bond-agents/eye-off.svg +1 -0
  9. package/app/mods/bond-agents/eye.svg +1 -0
  10. package/app/mods/bond-agents/main.js +308 -327
  11. package/app/mods/bond-agents/model.js +376 -5
  12. package/app/mods/bond-board/api.js +35 -0
  13. package/app/mods/bond-board/branch.svg +1 -0
  14. package/app/mods/bond-board/brand.js +53 -2
  15. package/app/mods/bond-board/config.js +4 -0
  16. package/app/mods/bond-board/main.js +1000 -449
  17. package/app/mods/bond-board/model.js +170 -28
  18. package/app/mods/bond-pane/close.svg +1 -0
  19. package/app/mods/bond-pane/hide.svg +1 -0
  20. package/app/mods/bond-pane/main.js +103 -0
  21. package/app/mods/bond-pane/mod.json +1 -0
  22. package/app/mods/bond-pane/model.js +18 -0
  23. package/app/mods/bond-pane/split-down.svg +1 -0
  24. package/app/mods/bond-pane/split-right.svg +1 -0
  25. package/app/mods/bond-pane/unzoom.svg +1 -0
  26. package/app/mods/bond-pane/zoom.svg +1 -0
  27. package/app/mods/bond-settings/api.js +35 -0
  28. package/app/mods/bond-settings/brand.js +53 -2
  29. package/app/mods/bond-settings/config.js +4 -0
  30. package/app/mods/bond-settings/main.js +1216 -272
  31. package/app/mods/bond-settings/mod.json +1 -1
  32. package/app/mods/bond-status/api.js +35 -0
  33. package/app/mods/bond-status/brand.js +53 -2
  34. package/app/mods/bond-status/config.js +4 -0
  35. package/app/mods/bond-status/main.js +37 -15
  36. package/app/mods/bond-status/model.js +19 -1
  37. package/app/mods/bond-tabs/brand.js +53 -2
  38. package/app/mods/bond-tabs/main.js +45 -3
  39. package/app/mods/bond-titlebar/brand.js +53 -2
  40. package/app/mods/bond-titlebar/main.js +85 -29
  41. package/app/mods/bond-titlebar/version.js +3 -0
  42. package/app/themes/bond-dark.json +5 -5
  43. package/app/themes/bond-light.json +5 -5
  44. package/package.json +1 -1
  45. package/runner/Dockerfile +16 -2
  46. package/runner/SPIKE-BOND.md +6 -2
  47. package/runner/entrypoint.sh +16 -0
  48. package/runner/setup.sh +439 -8
  49. package/runner/versions.env +32 -1
  50. package/scripts/app-install.ts +322 -27
  51. package/src/cli.ts +562 -21
  52. package/src/config.ts +15 -3
  53. package/src/core/agy-login.ts +683 -0
  54. package/src/core/delivery.ts +125 -6
  55. package/src/core/doctor.ts +748 -0
  56. package/src/core/hub-session.ts +108 -91
  57. package/src/core/hub.ts +40 -8
  58. package/src/core/orchestrator.ts +1481 -187
  59. package/src/core/paths.ts +107 -0
  60. package/src/core/permissions.ts +143 -0
  61. package/src/core/pr-source.ts +147 -0
  62. package/src/core/repo-host.ts +60 -0
  63. package/src/core/service-windows.ts +180 -0
  64. package/src/core/service.ts +861 -0
  65. package/src/core/setup-install.ts +1380 -0
  66. package/src/core/setup.ts +62 -1
  67. package/src/core/watchdog.ts +6 -6
  68. package/src/db/database.ts +54 -7
  69. package/src/db/settings-repo.ts +332 -7
  70. package/src/db/ticket-repo.ts +73 -25
  71. package/src/index.ts +4 -4
  72. package/src/runner/azure-devops-client.ts +273 -0
  73. package/src/runner/docker-client.ts +93 -9
  74. package/src/runner/github-client.ts +148 -3
  75. package/src/runner/hc-client.ts +33 -5
  76. package/src/runner/image-builder.ts +123 -5
  77. package/src/runner/jira-client.ts +368 -0
  78. package/src/runner/tool-catalog.ts +84 -0
  79. package/src/server/app.ts +467 -8
  80. package/src/types.ts +140 -2
package/runner/setup.sh CHANGED
@@ -27,9 +27,12 @@
27
27
  # GEMINI_API_KEY en el entorno; sin fichero de credenciales offline
28
28
  # (antigravity.google/docs «Authenticate») → sigue con la inyección por stdin.
29
29
  # - codex: auth.json con OPENAI_API_KEY en ~/.codex; config en ~/.codex/config.toml.
30
- # - claude: settings.json en ~/.claude; token de larga duración («claude
31
- # setup-token») en ~/.claude/.credentials.json con formato claudeAiOauth
32
- # (en Linux sin keyring es el fichero que usa la propia CLI).
30
+ # - claude: settings.json en ~/.claude; token de larga duración de «claude setup-token»
31
+ # (un año, solo inferencia) en ~/.claude/oauth-token (0600). La CLI no lo lee de un
32
+ # fichero: un envoltorio sustituye a `claude` en el PATH y la arranca con
33
+ # CLAUDE_CODE_OAUTH_TOKEN solo en su proceso (decisión 2026-11-23, matiza D7). La
34
+ # sesión de «claude auth login» (~/.claude/.credentials.json) no sirve en los runs:
35
+ # su refreshToken rota y es de un solo uso (spike del plan bond-app-claude-agente).
33
36
  # - azure-cli: repo apt de packages.microsoft.com soporta bookworm
34
37
  # (learn.microsoft.com «Install the Azure CLI on Linux»).
35
38
  #
@@ -65,6 +68,7 @@ mask() { printf 'setup.sh: %s (valor no registrado)\n' "$*"; }
65
68
  usage() {
66
69
  cat <<'EOF'
67
70
  Uso: setup.sh --agents pi,copilot [--config DIR] [--credentials FICHERO] [--skip-gh] [--skip-az] [--with-bond]
71
+ [--tools esenciales,busqueda,shell] [--apt-extra paquete1,paquete2]
68
72
  --agents LISTA agentes a instalar, separados por comas (pi, claude, codex, copilot, agy)
69
73
  --config DIR config por agente (subcarpeta por agente, un fichero cada una; sin secretos)
70
74
  --credentials FICHERO fichero 0600 con GH_TOKEN/CLAUDE_TOKEN/CODEX_TOKEN (opcional; ver credentials.example.env)
@@ -72,6 +76,10 @@ Uso: setup.sh --agents pi,copilot [--config DIR] [--credentials FICHERO] [--skip
72
76
  --skip-az no instalar azure-cli + extensión azure-devops (por defecto, sí se instala)
73
77
  --with-bond instala bond (pin BOND_VERSION de versions.env) y deja su config de
74
78
  máquina hecha para el usuario runner (D-H/D-I; ver runner/SPIKE-BOND.md)
79
+ --tools LISTA grupos de herramientas de developer, separados por comas:
80
+ esenciales, busqueda, shell, python, go, rust, java, dotnet, js, db, cloud, docker
81
+ (cloud incluye azure-cli: anula --skip-az)
82
+ --apt-extra LISTA paquetes apt de Debian adicionales, separados por comas
75
83
  EOF
76
84
  }
77
85
 
@@ -94,6 +102,8 @@ CRED_FILE=""
94
102
  SKIP_GH=0
95
103
  SKIP_AZ=0
96
104
  WITH_BOND=0
105
+ TOOLS_RAW=""
106
+ APT_EXTRA_RAW=""
97
107
  while [ "$#" -gt 0 ]; do
98
108
  case "$1" in
99
109
  --agents) [ $# -ge 2 ] || die "--agents necesita un valor (p. ej. --agents pi,copilot)"
@@ -105,6 +115,10 @@ while [ "$#" -gt 0 ]; do
105
115
  --skip-gh) SKIP_GH=1; shift ;;
106
116
  --skip-az) SKIP_AZ=1; shift ;;
107
117
  --with-bond) WITH_BOND=1; shift ;;
118
+ --tools) [ $# -ge 2 ] || die "--tools necesita un valor (p. ej. --tools esenciales,shell)"
119
+ TOOLS_RAW="$2"; shift 2 ;;
120
+ --apt-extra) [ $# -ge 2 ] || die "--apt-extra necesita un valor (p. ej. --apt-extra graphviz)"
121
+ APT_EXTRA_RAW="$2"; shift 2 ;;
108
122
  -h|--help) usage; exit 0 ;;
109
123
  *) die "opción desconocida: $1 (usa --help)" ;;
110
124
  esac
@@ -125,6 +139,39 @@ for a in "${REQUESTED[@]}"; do
125
139
  done
126
140
  [ "${#AGENTS_ordered[@]}" -gt 0 ] || die "lista de agentes vacía"
127
141
 
142
+ # Grupos de herramientas (plan bond-app-ajustes-imagen P2). El catálogo de la API
143
+ # (src/runner/tool-catalog.ts) tiene la misma lista; un test las mantiene iguales.
144
+ SUPPORTED_TOOLS=(esenciales busqueda shell python go rust java dotnet js db cloud docker)
145
+ TOOLS_ordered=()
146
+ if [ -n "$TOOLS_RAW" ]; then
147
+ IFS=',' read -r -a REQ_TOOLS <<< "$TOOLS_RAW"
148
+ for t in "${REQ_TOOLS[@]}"; do
149
+ [ -n "$t" ] || die "lista de herramientas con entradas vacías: '$TOOLS_RAW'"
150
+ known=0
151
+ for s in "${SUPPORTED_TOOLS[@]}"; do [ "$t" = "$s" ] && known=1 && break; done
152
+ [ "$known" -eq 1 ] || die "grupo de herramientas no soportado: '$t' (soportados: ${SUPPORTED_TOOLS[*]})"
153
+ for p in "${TOOLS_ordered[@]}"; do [ "$p" = "$t" ] && die "grupo duplicado en --tools: '$t'"; done
154
+ TOOLS_ordered+=("$t")
155
+ done
156
+ fi
157
+ APT_EXTRA=()
158
+ if [ -n "$APT_EXTRA_RAW" ]; then
159
+ IFS=',' read -r -a REQ_APT <<< "$APT_EXTRA_RAW"
160
+ for pkg in "${REQ_APT[@]}"; do
161
+ # Nombres de paquete Debian: minúsculas, dígitos y + - . (nada de opciones ni rutas).
162
+ [[ "$pkg" =~ ^[a-z0-9][a-z0-9+.-]{1,62}$ ]] || die "paquete apt no válido en --apt-extra: '$pkg'"
163
+ APT_EXTRA+=("$pkg")
164
+ done
165
+ fi
166
+
167
+ tool_requested() {
168
+ local want="$1" t
169
+ for t in "${TOOLS_ordered[@]}"; do [ "$t" = "$want" ] && return 0; done
170
+ return 1
171
+ }
172
+ # cloud trae azure-cli: con él, --skip-az no aplica.
173
+ tool_requested cloud && SKIP_AZ=0
174
+
128
175
  agent_requested() {
129
176
  local want="$1" a
130
177
  for a in "${AGENTS_ordered[@]}"; do [ "$a" = "$want" ] && return 0; done
@@ -298,9 +345,9 @@ install_agents() {
298
345
  for a in "${AGENTS_ordered[@]}"; do
299
346
  case "$a" in
300
347
  pi) npm_install_agent pi '@earendil-works/pi-coding-agent' "$PI_VERSION" ;;
301
- claude) npm_install_agent claude '@anthropic-ai/claude-code' "$CLAUDE_VERSION" ;;
302
- codex) npm_install_agent codex '@openai/codex' "$CODEX_VERSION" ;;
303
- copilot) npm_install_agent copilot '@github/copilot' "$COPILOT_VERSION" ;;
348
+ claude) install_claude ;;
349
+ codex) install_codex ;;
350
+ copilot) install_copilot ;;
304
351
  agy) install_agy ;;
305
352
  esac
306
353
  done
@@ -350,6 +397,18 @@ install_bond() {
350
397
  }
351
398
 
352
399
  install_agy() {
400
+ # P2/P3: Hornear onboarding y trustedWorkspaces para evitar prompts interactivos iniciales
401
+ local agy_dir="$RUNNER_HOME/.gemini/antigravity-cli"
402
+ install -d -m 0700 "$agy_dir/cache"
403
+ printf '{"consumerOnboardingComplete":true,"enterpriseOnboardingComplete":true,"onboardingComplete":true}\n' > "$agy_dir/cache/onboarding.json"
404
+ chmod 0644 "$agy_dir/cache/onboarding.json"
405
+
406
+ if [ ! -f "$agy_dir/settings.json" ]; then
407
+ printf '{\n "trustedWorkspaces": [\n "/workspace",\n "/workspace/repo"\n ]\n}\n' > "$agy_dir/settings.json"
408
+ chmod 0644 "$agy_dir/settings.json"
409
+ fi
410
+ chown_if_runner "$RUNNER_HOME/.gemini" "$agy_dir" "$agy_dir/cache" "$agy_dir/cache/onboarding.json" "$agy_dir/settings.json"
411
+
353
412
  if [ "$DRY_RUN" = "1" ]; then log "dry-run: instalaría agy (instalador oficial; sin pin de versión)"; return 0; fi
354
413
  local bindir=/usr/local/bin
355
414
  if [ -x "$bindir/agy" ]; then log "agy ya presente en $bindir/agy"; return 0; fi
@@ -360,6 +419,373 @@ install_agy() {
360
419
  log "agy instalado: $(agy --version 2>/dev/null | head -n1 || echo '?')"
361
420
  }
362
421
 
422
+ # claude: la CLI por npm (versión fijada) y un envoltorio en su sitio del PATH que la arranca
423
+ # con el token de ~/.claude/oauth-token, si existe, solo en ese proceso. Nada se hornea con
424
+ # secretos: el token llega por run (stdin) o, como excepción D-A, con --credentials.
425
+ install_claude() {
426
+ npm_install_agent claude '@anthropic-ai/claude-code' "$CLAUDE_VERSION"
427
+ if [ "$DRY_RUN" = "1" ]; then log "dry-run: envolvería claude para leer ~/.claude/oauth-token"; return 0; fi
428
+ local entry real
429
+ entry="$(command -v claude)" || die "claude instalado pero no está en el PATH"
430
+ real="$(readlink -f "$entry")"
431
+ [ -n "$real" ] && [ "$real" != "$entry" ] || die "no encuentro el binario real de claude tras $entry"
432
+ rm -f "$entry"
433
+ cat > "$entry" <<WRAP
434
+ #!/bin/sh
435
+ # bond-app (runner/setup.sh): claude con el token de «claude setup-token» que bond-app
436
+ # inyecta por stdin en ~/.claude/oauth-token (0600). La variable existe solo en este
437
+ # proceso y sus hijos; nunca en docker -e, argumentos ni la imagen.
438
+ t="\${HOME}/.claude/oauth-token"
439
+ if [ -z "\${CLAUDE_CODE_OAUTH_TOKEN:-}" ] && [ -r "\$t" ]; then
440
+ CLAUDE_CODE_OAUTH_TOKEN="\$(cat "\$t")"
441
+ export CLAUDE_CODE_OAUTH_TOKEN
442
+ fi
443
+ exec "$real" "\$@"
444
+ WRAP
445
+ chmod 0755 "$entry"
446
+ log "claude envuelto: $entry → $real"
447
+ }
448
+
449
+ # claude sin preguntas al arrancar: onboarding hecho, confianza en las carpetas de los runs,
450
+ # sin la confirmación de --dangerously-skip-permissions, sin auto-update (la versión la
451
+ # fija la imagen) y sin sugerencias de prompt: claude escribe en gris una propuesta en su
452
+ # caja de entrada y quien lee la pantalla (pi al delegar, hc read) la toma por texto real. Se combina con el settings.json que traiga --config, sin pisarlo.
453
+ # hasCompletedOnboarding y projects.<dir>.hasTrustDialogAccepted no están documentados:
454
+ # verificados con claude 2.1.328 (spike del plan bond-app-claude-agente).
455
+ bake_claude() {
456
+ agent_requested claude || return 0
457
+ install -d -m 0700 "$RUNNER_HOME/.claude"
458
+ chown_if_runner "$RUNNER_HOME/.claude"
459
+ CLAUDE_STATE="$RUNNER_HOME/.claude.json" CLAUDE_SETTINGS="$RUNNER_HOME/.claude/settings.json" node -e '
460
+ const fs = require("fs");
461
+ const read = (p) => { try { return JSON.parse(fs.readFileSync(p, "utf8")); } catch { return {}; } };
462
+ const state = read(process.env.CLAUDE_STATE);
463
+ state.hasCompletedOnboarding = true;
464
+ state.projects = state.projects || {};
465
+ for (const dir of ["/workspace", "/workspace/repo", "/workspace/hub"]) {
466
+ state.projects[dir] = { ...(state.projects[dir] || {}), hasTrustDialogAccepted: true };
467
+ }
468
+ fs.writeFileSync(process.env.CLAUDE_STATE, JSON.stringify(state, null, 2) + "\n", { mode: 0o600 });
469
+ const settings = read(process.env.CLAUDE_SETTINGS);
470
+ if (!settings.theme) settings.theme = "dark";
471
+ settings.skipDangerousModePermissionPrompt = true;
472
+ // Sin pedir permisos aunque lo arranque un delegado sin --dangerously-skip-permissions.
473
+ settings.permissions = { ...(settings.permissions || {}), defaultMode: "bypassPermissions" };
474
+ settings.promptSuggestionEnabled = false;
475
+ settings.env = { ...(settings.env || {}), DISABLE_AUTOUPDATER: "1" };
476
+ fs.writeFileSync(process.env.CLAUDE_SETTINGS, JSON.stringify(settings, null, 2) + "\n", { mode: 0o644 });
477
+ ' || die "no se pudo hornear la configuración de claude"
478
+ chmod 0600 "$RUNNER_HOME/.claude.json"
479
+ chmod 0644 "$RUNNER_HOME/.claude/settings.json"
480
+ chown_if_runner "$RUNNER_HOME/.claude.json" "$RUNNER_HOME/.claude/settings.json"
481
+ log "claude horneado: onboarding, confianza en /workspace, sin confirmación de bypass, auto-update ni sugerencias"
482
+ }
483
+
484
+ # --- Herramientas de developer (--tools / --apt-extra) -------------------------------
485
+ # Paquetes apt de cada grupo (Debian bookworm). Lo que no está en apt se descarga con
486
+ # versión y sha256 fijados en versions.env.
487
+ tool_apt_packages() {
488
+ case "$1" in
489
+ esenciales) echo "ripgrep fd-find jq tree less file zip unzip xz-utils patch sqlite3 make build-essential python3 python3-venv python3-pip" ;;
490
+ busqueda) echo "shellcheck" ;;
491
+ shell) echo "zsh fzf bat git" ;;
492
+ js) echo "unzip" ;;
493
+ db) echo "postgresql-client redis-tools" ;;
494
+ cloud) echo "unzip" ;;
495
+ *) echo "" ;;
496
+ esac
497
+ }
498
+
499
+ # Descarga $1 en $2 y comprueba su sha256 ($3); nunca deja un fichero sin verificar.
500
+ fetch_verified() {
501
+ local url="$1" dest="$2" sum="$3"
502
+ curl -fsSL -o "$dest" "$url" || die "no se pudo descargar $url"
503
+ echo "$sum $dest" | sha256sum -c - >/dev/null 2>&1 || { rm -f "$dest"; die "sha256 no coincide: $url"; }
504
+ }
505
+
506
+ # Clona un repo en un commit fijado (git verifica el contenido por el hash del commit).
507
+ clone_pinned() {
508
+ local url="$1" dest="$2" commit="$3"
509
+ git init -q "$dest"
510
+ git -C "$dest" fetch -q --depth 1 "$url" "$commit" || die "no se pudo traer $url@$commit"
511
+ git -C "$dest" -c advice.detachedHead=false checkout -q FETCH_HEAD
512
+ [ "$(git -C "$dest" rev-parse HEAD)" = "$commit" ] || die "$url no está en el commit fijado $commit"
513
+ rm -rf "$dest/.git"
514
+ }
515
+
516
+ install_tool_shell() {
517
+ ln -sf /usr/bin/batcat /usr/local/bin/bat
518
+ local tmp; tmp="$(mktemp -d)"
519
+ fetch_verified "https://github.com/dandavison/delta/releases/download/${DELTA_VERSION}/git-delta_${DELTA_VERSION}_amd64.deb" "$tmp/delta.deb" "$DELTA_SHA256"
520
+ dpkg -i "$tmp/delta.deb" >/dev/null
521
+ fetch_verified "https://github.com/starship/starship/releases/download/${STARSHIP_VERSION}/starship-x86_64-unknown-linux-musl.tar.gz" "$tmp/starship.tgz" "$STARSHIP_SHA256"
522
+ tar -xzf "$tmp/starship.tgz" -C /usr/local/bin starship
523
+ rm -rf "$tmp"
524
+ # oh-my-zsh compartido y de solo lectura en /opt; cada usuario lo carga desde su .zshrc.
525
+ rm -rf /opt/oh-my-zsh
526
+ clone_pinned https://github.com/ohmyzsh/ohmyzsh.git /opt/oh-my-zsh "$OHMYZSH_COMMIT"
527
+ clone_pinned https://github.com/zsh-users/zsh-autosuggestions.git /opt/oh-my-zsh/custom/plugins/zsh-autosuggestions "$ZSH_AUTOSUGGESTIONS_COMMIT"
528
+ clone_pinned https://github.com/zsh-users/zsh-syntax-highlighting.git /opt/oh-my-zsh/custom/plugins/zsh-syntax-highlighting "$ZSH_SYNTAX_HIGHLIGHTING_COMMIT"
529
+ # zsh es solo para quien abre una shell (botón Shell): la shell de runner sigue siendo
530
+ # bash, porque los agentes ejecutan sus comandos con $SHELL y claude copia su config.
531
+ local rc="$RUNNER_HOME/.zshrc"
532
+ if [ ! -f "$rc" ]; then
533
+ cat > "$rc" <<'ZSHRC'
534
+ # bond-app (runner/setup.sh, grupo «shell»): oh-my-zsh fijado en /opt, sin autoactualizar.
535
+ export ZSH=/opt/oh-my-zsh
536
+ export ZSH_CACHE_DIR="$HOME/.cache/oh-my-zsh"
537
+ mkdir -p "$ZSH_CACHE_DIR"
538
+ ZSH_THEME=""
539
+ zstyle ':omz:update' mode disabled
540
+ DISABLE_AUTO_UPDATE=true
541
+ # Sin el plugin fzf: busca sus atajos en /usr/share/doc, que la imagen slim no trae.
542
+ plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
543
+ source "$ZSH/oh-my-zsh.sh"
544
+ command -v starship >/dev/null && eval "$(starship init zsh)"
545
+ alias cat='bat --paging=never --style=plain'
546
+ ZSHRC
547
+ chmod 0644 "$rc"
548
+ chown_if_runner "$rc"
549
+ fi
550
+ if command -v git >/dev/null && as_runner git config --global --get core.pager >/dev/null 2>&1; then :; else
551
+ as_runner git config --global core.pager delta || true
552
+ as_runner git config --global interactive.diffFilter "delta --color-only" || true
553
+ fi
554
+ }
555
+
556
+ install_tool_rust() {
557
+ local tmp; tmp="$(mktemp -d)"
558
+ fetch_verified "https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/x86_64-unknown-linux-gnu/rustup-init" "$tmp/rustup-init" "$RUSTUP_SHA256"
559
+ chmod 0755 "$tmp/rustup-init"
560
+ chown_if_runner "$tmp" "$tmp/rustup-init"
561
+ # En el home de runner (cargo install escribe ahí); los proxies van al PATH del sistema.
562
+ as_runner "$tmp/rustup-init" -y --no-modify-path --profile minimal --default-toolchain stable >/dev/null
563
+ rm -rf "$tmp"
564
+ local b
565
+ for b in "$RUNNER_HOME"/.cargo/bin/*; do ln -sf "$b" "/usr/local/bin/$(basename "$b")"; done
566
+ }
567
+
568
+ install_tool_java() {
569
+ local keyring=/etc/apt/keyrings/adoptium.gpg
570
+ mkdir -p /etc/apt/keyrings
571
+ [ -f "$keyring" ] || curl -fsSL https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor > "$keyring"
572
+ chmod go+r "$keyring"
573
+ # shellcheck disable=SC1091
574
+ . /etc/os-release
575
+ echo "deb [signed-by=$keyring] https://packages.adoptium.net/artifactory/deb ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/adoptium.list
576
+ apt-get update -qq && apt-get install -y -qq --no-install-recommends temurin-21-jdk maven >/dev/null
577
+ }
578
+
579
+ install_tool_dotnet() {
580
+ local keyring=/etc/apt/keyrings/microsoft.gpg
581
+ mkdir -p /etc/apt/keyrings
582
+ [ -f "$keyring" ] || curl -sLS https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > "$keyring"
583
+ chmod go+r "$keyring"
584
+ # shellcheck disable=SC1091
585
+ . /etc/os-release
586
+ echo "deb [arch=amd64 signed-by=$keyring] https://packages.microsoft.com/debian/${VERSION_ID}/prod ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/microsoft-prod.list
587
+ apt-get update -qq && apt-get install -y -qq --no-install-recommends dotnet-sdk-8.0 >/dev/null
588
+ }
589
+
590
+ # Docker en el run (plan bond-app-ajustes-imagen P4): el motor y sus plugins del repo apt
591
+ # oficial de Docker (firmado), la CLI de devcontainers fijada, y runner en el grupo docker.
592
+ # dockerd solo arranca en los runs que lo piden (entrypoint.sh con BOND_DIND=1, contenedor
593
+ # --privileged); en los demás el binario está pero no hay demonio ni permisos para él.
594
+ install_tool_docker() {
595
+ local keyring=/etc/apt/keyrings/docker.asc
596
+ mkdir -p /etc/apt/keyrings
597
+ [ -f "$keyring" ] || curl -fsSL https://download.docker.com/linux/debian/gpg -o "$keyring"
598
+ chmod go+r "$keyring"
599
+ # shellcheck disable=SC1091
600
+ . /etc/os-release
601
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=$keyring] https://download.docker.com/linux/debian ${VERSION_CODENAME} stable" > /etc/apt/sources.list.d/docker.list
602
+ apt-get update -qq && apt-get install -y -qq --no-install-recommends \
603
+ docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin iptables >/dev/null
604
+ command -v npm >/dev/null 2>&1 || die "la CLI de devcontainers se instala con npm y npm no está en el PATH"
605
+ npm install -g --registry=https://registry.npmjs.org "@devcontainers/cli@$DEVCONTAINERS_CLI_VERSION" >/dev/null
606
+ npm cache clean --force >/dev/null 2>&1 || true
607
+ if runner_account_exists; then usermod -aG docker "$RUNNER_USER"; fi
608
+ }
609
+
610
+ install_tool_group() {
611
+ local tmp
612
+ case "$1" in
613
+ esenciales)
614
+ ln -sf /usr/bin/fdfind /usr/local/bin/fd
615
+ fetch_verified "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" /usr/local/bin/yq "$YQ_SHA256"
616
+ chmod 0755 /usr/local/bin/yq ;;
617
+ busqueda)
618
+ command -v npm >/dev/null 2>&1 || die "ast-grep se instala con npm y npm no está en el PATH"
619
+ npm install -g --registry=https://registry.npmjs.org "@ast-grep/cli@$AST_GREP_VERSION" >/dev/null
620
+ npm cache clean --force >/dev/null 2>&1 || true ;;
621
+ shell) install_tool_shell ;;
622
+ python)
623
+ tmp="$(mktemp -d)"
624
+ fetch_verified "https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-x86_64-unknown-linux-gnu.tar.gz" "$tmp/uv.tgz" "$UV_SHA256"
625
+ tar -xzf "$tmp/uv.tgz" -C "$tmp"
626
+ install -m 0755 "$tmp"/uv-x86_64-unknown-linux-gnu/uv "$tmp"/uv-x86_64-unknown-linux-gnu/uvx /usr/local/bin/
627
+ rm -rf "$tmp" ;;
628
+ go)
629
+ tmp="$(mktemp -d)"
630
+ fetch_verified "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" "$tmp/go.tgz" "$GO_SHA256"
631
+ rm -rf /usr/local/go && tar -xzf "$tmp/go.tgz" -C /usr/local
632
+ ln -sf /usr/local/go/bin/go /usr/local/bin/go
633
+ ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt
634
+ rm -rf "$tmp" ;;
635
+ rust) install_tool_rust ;;
636
+ java) install_tool_java ;;
637
+ dotnet) install_tool_dotnet ;;
638
+ js)
639
+ corepack enable >/dev/null
640
+ # pnpm y yarn bajados ya, en versiones fijadas: si no, corepack pregunta antes de
641
+ # descargarlos la primera vez y un agente se quedaría esperando esa respuesta.
642
+ as_runner env COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack install -g "pnpm@$PNPM_VERSION" "yarn@$YARN_VERSION" >/dev/null
643
+ tmp="$(mktemp -d)"
644
+ fetch_verified "https://github.com/oven-sh/bun/releases/download/bun-v${BUN_VERSION}/bun-linux-x64.zip" "$tmp/bun.zip" "$BUN_SHA256"
645
+ unzip -q "$tmp/bun.zip" -d "$tmp"
646
+ install -m 0755 "$tmp/bun-linux-x64/bun" /usr/local/bin/bun
647
+ ln -sf /usr/local/bin/bun /usr/local/bin/bunx
648
+ rm -rf "$tmp" ;;
649
+ db) ;;
650
+ docker) install_tool_docker ;;
651
+ cloud)
652
+ fetch_verified "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" /usr/local/bin/kubectl "$KUBECTL_SHA256"
653
+ chmod 0755 /usr/local/bin/kubectl
654
+ tmp="$(mktemp -d)"
655
+ fetch_verified "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" "$tmp/tf.zip" "$TERRAFORM_SHA256"
656
+ unzip -q "$tmp/tf.zip" -d "$tmp" && install -m 0755 "$tmp/terraform" /usr/local/bin/terraform
657
+ rm -rf "$tmp" ;;
658
+ esac
659
+ }
660
+
661
+ install_tools() {
662
+ [ "${#TOOLS_ordered[@]}" -gt 0 ] || [ "${#APT_EXTRA[@]}" -gt 0 ] || return 0
663
+ local pkgs=() t
664
+ for t in "${TOOLS_ordered[@]}"; do
665
+ # shellcheck disable=SC2207
666
+ pkgs+=($(tool_apt_packages "$t"))
667
+ done
668
+ pkgs+=("${APT_EXTRA[@]}")
669
+ if [ "$DRY_RUN" = "1" ]; then
670
+ for t in "${TOOLS_ordered[@]}"; do log "dry-run: instalaría el grupo $t ($(tool_apt_packages "$t"))"; done
671
+ [ "${#APT_EXTRA[@]}" -eq 0 ] || log "dry-run: instalaría de apt: ${APT_EXTRA[*]}"
672
+ return 0
673
+ fi
674
+ am_root || die "instalar herramientas requiere root"
675
+ if [ "${#pkgs[@]}" -gt 0 ]; then
676
+ apt-get update -qq
677
+ # shellcheck disable=SC2068
678
+ apt-get install -y -qq --no-install-recommends $(printf '%s\n' "${pkgs[@]}" | sort -u) >/dev/null \
679
+ || die "apt-get no pudo instalar: ${pkgs[*]}"
680
+ fi
681
+ for t in "${TOOLS_ordered[@]}"; do
682
+ install_tool_group "$t"
683
+ log "herramientas instaladas: $t"
684
+ done
685
+ rm -rf /var/lib/apt/lists/*
686
+ }
687
+
688
+ # codex y copilot sin preguntas al arrancar (plan bond-app-codex-copilot). Se combinan con
689
+ # la config que ya haya (la de --config, o la que deja «bond setup»), sin pisarla.
690
+ bake_codex() {
691
+ agent_requested codex || return 0
692
+ install -d -m 0700 "$RUNNER_HOME/.codex"
693
+ chown_if_runner "$RUNNER_HOME/.codex"
694
+ CODEX_CONFIG="$RUNNER_HOME/.codex/config.toml" node -e '
695
+ const fs = require("fs");
696
+ const f = process.env.CODEX_CONFIG;
697
+ let t = ""; try { t = fs.readFileSync(f, "utf8"); } catch {}
698
+ // Las claves sueltas de TOML van antes de la primera tabla.
699
+ if (!/^check_for_update_on_startup\s*=/m.test(t)) t = "check_for_update_on_startup = false\n" + t;
700
+ if (!/^\[notice\]/m.test(t)) t += "\n[notice]\nhide_full_access_warning = true\n";
701
+ for (const dir of ["/workspace", "/workspace/repo", "/workspace/hub"]) {
702
+ if (!t.includes(`[projects."${dir}"]`)) t += `\n[projects."${dir}"]\ntrust_level = "trusted"\n`;
703
+ }
704
+ fs.writeFileSync(f, t, { mode: 0o644 });
705
+ ' || die "no se pudo hornear la configuración de codex"
706
+ chmod 0644 "$RUNNER_HOME/.codex/config.toml"
707
+ chown_if_runner "$RUNNER_HOME/.codex/config.toml"
708
+ log "codex horneado: confianza en /workspace, sin comprobar actualizaciones ni aviso de acceso total"
709
+ }
710
+
711
+ bake_copilot() {
712
+ agent_requested copilot || return 0
713
+ install -d -m 0700 "$RUNNER_HOME/.copilot"
714
+ chown_if_runner "$RUNNER_HOME/.copilot"
715
+ COPILOT_SETTINGS="$RUNNER_HOME/.copilot/settings.json" node -e '
716
+ const fs = require("fs");
717
+ const f = process.env.COPILOT_SETTINGS;
718
+ let s = {}; try { s = JSON.parse(fs.readFileSync(f, "utf8")); } catch {}
719
+ // Sin llavero en el contenedor: el token del login va a ~/.copilot/config.json sin preguntar.
720
+ s.storeTokenPlaintext = true;
721
+ s.trustedFolders = [...new Set([...(s.trustedFolders || []), "/workspace", "/workspace/repo", "/workspace/hub"])];
722
+ s.autoUpdate = false;
723
+ if (!s.banner) s.banner = "never";
724
+ fs.writeFileSync(f, JSON.stringify(s, null, 2) + "\n", { mode: 0o644 });
725
+ ' || die "no se pudo hornear la configuración de copilot"
726
+ chmod 0644 "$RUNNER_HOME/.copilot/settings.json"
727
+ chown_if_runner "$RUNNER_HOME/.copilot/settings.json"
728
+ log "copilot horneado: token en fichero, carpetas de confianza, sin autoactualizar ni banner"
729
+ }
730
+
731
+ # codex: la CLI por npm y un envoltorio que, en modo interactivo (sin subcomando), la arranca
732
+ # con --dangerously-bypass-hook-trust (bond le pone hooks y codex se para en «Hooks need
733
+ # review» cada vez que cambian) y --dangerously-bypass-approvals-and-sandbox, como el run
734
+ # principal; así vale también cuando lo lanza un delegado (bond-delegate lo arranca sin
735
+ # argumentos). Los subcomandos (login, exec…) van tal cual.
736
+ install_codex() {
737
+ npm_install_agent codex '@openai/codex' "$CODEX_VERSION"
738
+ if [ "$DRY_RUN" = "1" ]; then log "dry-run: envolvería codex (sin confirmar hooks)"; return 0; fi
739
+ local entry real
740
+ entry="$(command -v codex)" || die "codex instalado pero no está en el PATH"
741
+ real="$(readlink -f "$entry")"
742
+ [ -n "$real" ] && [ "$real" != "$entry" ] || die "no encuentro el binario real de codex tras $entry"
743
+ rm -f "$entry"
744
+ cat > "$entry" <<WRAP
745
+ #!/bin/sh
746
+ # bond-app (runner/setup.sh): codex interactivo sin pararse a confirmar los hooks de bond.
747
+ case "\${1:-}" in
748
+ exec|e|review|login|logout|mcp|plugin|app-server|remote-control|completion|update|doctor|sandbox|debug|apply|a|queue|archive|delete|migrate-*|unarchive|cloud|exec-server|features|help|agents|-h|--help|-V|--version)
749
+ exec "$real" "\$@" ;;
750
+ esac
751
+ # Lo mismo que lleva el run principal, también para los delegados (bond-delegate lo lanza
752
+ # sin argumentos): sin confirmar hooks ni pedir aprobaciones; el contenedor es el sandbox.
753
+ hooks=--dangerously-bypass-hook-trust
754
+ bypass=--dangerously-bypass-approvals-and-sandbox
755
+ for a in "\$@"; do
756
+ [ "\$a" = "\$hooks" ] && hooks=
757
+ [ "\$a" = "\$bypass" ] && bypass=
758
+ done
759
+ exec "$real" \$hooks \$bypass "\$@"
760
+ WRAP
761
+ chmod 0755 "$entry"
762
+ log "codex envuelto: $entry → $real"
763
+ }
764
+
765
+ # copilot: la CLI por npm y un envoltorio en su sitio del PATH que la arranca confiando en
766
+ # la carpeta del run (COPILOT_ALLOW_ALL=true exacto: su trustedFolders de settings.json no
767
+ # basta, sigue preguntando) y sin autoactualizarse. Solo en su proceso; nada secreto.
768
+ install_copilot() {
769
+ npm_install_agent copilot '@github/copilot' "$COPILOT_VERSION"
770
+ if [ "$DRY_RUN" = "1" ]; then log "dry-run: envolvería copilot (confianza en la carpeta, sin autoactualizar)"; return 0; fi
771
+ local entry real
772
+ entry="$(command -v copilot)" || die "copilot instalado pero no está en el PATH"
773
+ real="$(readlink -f "$entry")"
774
+ [ -n "$real" ] && [ "$real" != "$entry" ] || die "no encuentro el binario real de copilot tras $entry"
775
+ rm -f "$entry"
776
+ cat > "$entry" <<WRAP
777
+ #!/bin/sh
778
+ # bond-app (runner/setup.sh): copilot sin preguntar si confía en la carpeta del run y sin
779
+ # autoactualizarse (la versión la fija la imagen). Solo en este proceso y sus hijos.
780
+ : "\${COPILOT_ALLOW_ALL:=true}"
781
+ : "\${COPILOT_AUTO_UPDATE:=false}"
782
+ export COPILOT_ALLOW_ALL COPILOT_AUTO_UPDATE
783
+ exec "$real" "\$@"
784
+ WRAP
785
+ chmod 0755 "$entry"
786
+ log "copilot envuelto: $entry → $real"
787
+ }
788
+
363
789
  version_of() {
364
790
  local agent="$1" ver
365
791
  if [ "$DRY_RUN" = "1" ]; then pin_for "$agent"; return 0; fi
@@ -443,8 +869,7 @@ install_credentials() {
443
869
  fi
444
870
  if [ -n "$CLAUDE_TOKEN_V" ]; then
445
871
  mask "escribiendo credenciales de claude"
446
- write_token_file "$RUNNER_HOME/.claude/.credentials.json" \
447
- "{\"claudeAiOauth\":{\"accessToken\":\"$CLAUDE_TOKEN_V\",\"refreshToken\":\"\",\"expiresAt\":253402300799000,\"scopes\":[\"openid\",\"profile\",\"email\"]}}"
872
+ write_token_file "$RUNNER_HOME/.claude/oauth-token" "$CLAUDE_TOKEN_V"
448
873
  CRED_WRITTEN="$CRED_WRITTEN claude"
449
874
  fi
450
875
  }
@@ -474,6 +899,8 @@ write_manifest() {
474
899
  if [ -n "${BOND_DONE:-}" ]; then
475
900
  printf 'pkg=bond version=%s config_sha256=none credentials=no\n' "$(bond --version 2>/dev/null || echo "$BOND_VERSION")"
476
901
  fi
902
+ for t in "${TOOLS_ordered[@]}"; do printf 'group=%s installed=yes\n' "$t"; done
903
+ [ "${#APT_EXTRA[@]}" -eq 0 ] || printf 'apt_extra=%s\n' "$(IFS=,; echo "${APT_EXTRA[*]}")"
477
904
  printf 'tool=gh installed=%s\n' "${GH_STATE:-yes}"
478
905
  printf 'tool=az installed=%s\n' "${AZ_STATE:-yes}"
479
906
  } > "$tmp"
@@ -487,10 +914,14 @@ log "agentes pedidos: ${AGENTS_ordered[*]} (config: ${CONFIG_DIR:-ninguna}; cred
487
914
  install_system_deps
488
915
  install_gh
489
916
  install_az
917
+ install_tools
490
918
  install_agents
491
919
  install_supi
492
920
  install_bond
493
921
  install_config
922
+ bake_claude
923
+ bake_codex
924
+ bake_copilot
494
925
  install_credentials
495
926
  write_manifest
496
927
  log "listo"
@@ -22,9 +22,40 @@ SUPI_VERSION=11.0.1
22
22
  # bond (el harness que lanza el agente, D-G): instalado por setup.sh con --with-bond
23
23
  # (D-H: versión fijada; package npm con scope @jmanuelcorral/bond). El pin mínimo es
24
24
  # 1.16.4: antes de esa versión bond no tiene comando `tui` (spike runner/SPIKE-BOND.md).
25
- BOND_VERSION=1.16.4
25
+ BOND_VERSION=1.16.8
26
26
 
27
27
  # gh y azure-cli salen de los repos apt oficiales (GitHub y Microsoft); se dejan
28
28
  # en «latest» del repo. AZURE_CLI_VERSION admite el pin «2.xx.y» (sufijo ~bookworm
29
29
  # añadido por el script); vacío = última del repo.
30
30
  AZURE_CLI_VERSION=
31
+
32
+ # --- Herramientas de developer (plan bond-app-ajustes-imagen P2: setup.sh --tools) -------
33
+ # Lo que sale de apt (Debian bookworm) va sin pin: lo fija la base de la imagen. Lo que se
34
+ # descarga lleva versión y sha256 (de los ficheros de checksums oficiales de cada proyecto,
35
+ # salvo delta, que no los publica: sha256 tomado al fijar la versión). Cambiar una versión
36
+ # exige su checksum. oh-my-zsh y sus plugins se clonan en un commit fijado (git lo verifica).
37
+ YQ_VERSION=v4.54.3
38
+ YQ_SHA256=129534601871538efe0ba4c5e62a34fb1d5f469bcb975c4fddeb467d82974973
39
+ AST_GREP_VERSION=0.51.3
40
+ DELTA_VERSION=0.22.0
41
+ DELTA_SHA256=109eac8927a80a7801e025901dcee8d56aa50a8de1805a111d98b5d6dbe5d647
42
+ STARSHIP_VERSION=v1.27.0
43
+ STARSHIP_SHA256=10c8eb4cb3b761d9bf59ea828444c2dab36c900b7d69a69e08814b286969df89
44
+ OHMYZSH_COMMIT=6c31a91a3e82b4055b36cc088c2f27f81119ba60
45
+ ZSH_AUTOSUGGESTIONS_COMMIT=e52ee8ca55bcc56a17c828767a3f98f22a68d4eb
46
+ ZSH_SYNTAX_HIGHLIGHTING_COMMIT=db085e4661f6aafd24e5acb5b2e17e4dd5dddf3e
47
+ UV_VERSION=0.13.9
48
+ UV_SHA256=a7fbaff2b9a271d85c1bdb540941090fd1ce011797b4abeb48e4dcd39c2471d5
49
+ GO_VERSION=1.27.4
50
+ GO_SHA256=7226736c2339719cda28fbf3a54d71aa63bcefe376e98cef00034268dab24840
51
+ RUSTUP_VERSION=1.29.3
52
+ RUSTUP_SHA256=b1c8cb14e30889e7e2999e6b69e62d9e9b9ffc0f4df8180564d306d9680e6c55
53
+ PNPM_VERSION=12.23.0
54
+ YARN_VERSION=4.19.0
55
+ BUN_VERSION=1.4.5
56
+ BUN_SHA256=94559b3b528995a49452f9f2404cec74f2efd7d06e0a000a8cd214b02c3666eb
57
+ KUBECTL_VERSION=v1.37.2
58
+ KUBECTL_SHA256=c04487523e7aa7d1493f7808174c899db93d7a9cf57531420cd76b9bd415f8f4
59
+ DEVCONTAINERS_CLI_VERSION=0.91.0
60
+ TERRAFORM_VERSION=1.17.2
61
+ TERRAFORM_SHA256=e6f16b2f0b137ee5729caa8c4e79a3bae4ee261acd198a1fcfa8584a6296605b