Merge quick/build-ldflags-guard: build.sh ldflags + pre-commit anti-stale + uses_functions

This commit is contained in:
2026-06-16 20:27:46 +02:00
5 changed files with 44 additions and 1 deletions
+4
View File
@@ -60,6 +60,10 @@ uses_functions:
- cdp_type_ref_go_browser - cdp_type_ref_go_browser
- cdp_hover_ref_go_browser - cdp_hover_ref_go_browser
- cdp_click_xy_human_go_browser - cdp_click_xy_human_go_browser
- cdp_collect_console_go_browser
- cdp_print_pdf_go_browser
- cdp_select_option_go_browser
- cdp_set_file_input_go_browser
uses_types: [] uses_types: []
framework: "" framework: ""
entry_point: "main.go" entry_point: "main.go"
Executable
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Compila browser_mcp inyectando la versión declarada en app.md como única fuente
# de verdad. Evita el drift entre la constante del binario y app.md (bug 16/06/2026:
# serverInfo reportaba 0.7.0 mientras app.md ya iba por 0.8.0).
#
# Uso: ./build.sh
set -euo pipefail
cd "$(dirname "$0")"
version="$(grep -m1 '^version:' app.md | awk '{print $2}')"
if [ -z "${version}" ]; then
echo "build.sh: no pude leer 'version:' de app.md" >&2
exit 1
fi
CGO_ENABLED=0 go build -ldflags "-X main.version=${version}" -o browser_mcp .
echo "built browser_mcp version=${version}"
+5 -1
View File
@@ -15,7 +15,11 @@ import (
"fn-registry/functions/browser" "fn-registry/functions/browser"
) )
const version = "0.8.0" // version is the server version reported in serverInfo. The literal here is a
// fallback for `go build` with no flags; build.sh overrides it via
// -ldflags "-X main.version=<app.md version>" so app.md stays the single source
// of truth and the binary can never drift behind it (see build.sh).
var version = "0.8.0"
type config struct { type config struct {
httpAddr string httpAddr string
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Instala los git hooks versionados de este repo en .git/hooks.
set -euo pipefail
cd "$(dirname "$0")/.."
ln -sf ../../scripts/pre-commit .git/hooks/pre-commit
echo "instalado .git/hooks/pre-commit -> scripts/pre-commit"
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Anti-stale binary guard. El .mcp.json ejecuta el binario ./browser_mcp; si se
# commitea un cambio en los .go sin recompilar, la sesión sirve código viejo
# (bug 16/06/2026). Este hook recompila en cada commit. Instálalo con
# scripts/install-hooks.sh.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
if ! ./build.sh >/tmp/browser_mcp_build.log 2>&1; then
echo "pre-commit: build.sh falló — commit abortado. Log:" >&2
cat /tmp/browser_mcp_build.log >&2
exit 1
fi